Eli Mesika has uploaded a new change for review. Change subject: core: cannot lower the compatibility version of... ......................................................................
core: cannot lower the compatibility version of... can't lower the compatibility version of the default cluster This patch enables to decrease a DC if it has no clusters or have empty clusters. It also enables to decrease a Cluster if it is empty (has no Hosts) Validation messages were updated to fit both DC & Cluster. Change-Id: I32b089f27c286aca1857a03c75840d8cd978f1e8 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1076555 Signed-off-by: Eli Mesika <emes...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommand.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommandTest.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommandTest.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 7 files changed, 38 insertions(+), 14 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/11/25911/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java index 587245a..b533f2c 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java @@ -173,8 +173,9 @@ addCanDoActionMessage(VersionSupport.getUnsupportedVersionMessage()); result = false; } - // decreasing of compatibility version is not allowed - if (result && getVdsGroup().getcompatibility_version().compareTo(oldGroup.getcompatibility_version()) < 0) { + // decreasing of compatibility version is not allowed if there are Hosts in storage pool + if (result && getVdsGroup().getcompatibility_version().compareTo(oldGroup.getcompatibility_version()) < 0 && + getVdsDAO().getAllForStoragePool(getVdsGroup().getStoragePoolId()).size() > 0) { result = false; getReturnValue() .getCanDoActionMessages() diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommand.java index f01de63..6b0bf87 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommand.java @@ -182,8 +182,8 @@ } // decreasing of compatibility version is not allowed else if (getStoragePool().getcompatibility_version().compareTo(_oldStoragePool.getcompatibility_version()) < 0) { - // Enable to reduce compatibility version if DC has no clusters - if (getVdsGroupDAO().getAllForStoragePool(getStoragePoolId()).size() > 0) { + // Enable to reduce compatibility version if DC has no clusters or have clusters but no hosts + if (getVdsGroupDAO().getAllForStoragePool(getStoragePoolId()).size() > 0 && getVdsDAO().getAllForStoragePool(getStoragePoolId()).size() > 0) { returnValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CANNOT_DECREASE_COMPATIBILITY_VERSION); } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommandTest.java index d061f82..a6b10d3 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommandTest.java @@ -143,6 +143,7 @@ @Test public void versionDecrease() { + when(vdsDAO.getAllForStoragePool(any(Guid.class))).thenReturn(createHostList()); createCommandWithOlderVersion(); cpuExists(); cpuManufacturersMatch(); @@ -530,4 +531,12 @@ assertFalse(cmd.canDoAction()); assertTrue(cmd.getReturnValue().getCanDoActionMessages().contains(message.toString())); } + + private static List<VDS> createHostList() { + List<VDS> hosts = new ArrayList<VDS>(); + VDS vds = new VDS(); + vds.setVdsGroupId(DEFAULT_VDS_GROUP_ID); + hosts.add(vds); + return hosts; + } } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommandTest.java index 3c9d873..26e89b5 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStoragePoolCommandTest.java @@ -3,8 +3,8 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; @@ -24,6 +24,7 @@ import org.ovirt.engine.core.common.action.StoragePoolManagementParameter; import org.ovirt.engine.core.common.businessentities.StorageDomainStatic; import org.ovirt.engine.core.common.businessentities.StoragePool; +import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.config.ConfigValues; import org.ovirt.engine.core.common.errors.VdcBllMessages; @@ -31,6 +32,7 @@ import org.ovirt.engine.core.compat.Version; import org.ovirt.engine.core.dao.StorageDomainStaticDAO; import org.ovirt.engine.core.dao.StoragePoolDAO; +import org.ovirt.engine.core.dao.VdsDAO; import org.ovirt.engine.core.dao.VdsGroupDAO; import org.ovirt.engine.core.utils.MockConfigRule; @@ -55,13 +57,16 @@ @Mock private List<StorageDomainStatic> sdList; @Mock - private VdsGroupDAO vdsDao; + private VdsGroupDAO vdsGroupDao; + @Mock + private VdsDAO vdsDao; @Before public void setUp() { when(spDao.get(any(Guid.class))).thenReturn(createDefaultStoragePool()); when(sdDao.getAllForStoragePool(any(Guid.class))).thenReturn(sdList); - when(vdsDao.getAllForStoragePool(any(Guid.class))).thenReturn(createClusterList()); + when(vdsGroupDao.getAllForStoragePool(any(Guid.class))).thenReturn(createClusterList()); + when(vdsDao.getAllForStoragePool(any(Guid.class))).thenReturn(createHostList()); spyCommand(new StoragePoolManagementParameter(createNewStoragePool())); } @@ -71,7 +76,7 @@ new UpdateStoragePoolCommand<StoragePoolManagementParameter>(params); StoragePoolValidator validator = spy(realCommand.createStoragePoolValidator()); - doReturn(vdsDao).when(validator).getVdsGroupDao(); + doReturn(vdsGroupDao).when(validator).getVdsGroupDao(); cmd = spy(realCommand); doReturn(10).when(cmd).getStoragePoolNameSizeLimit(); @@ -79,7 +84,8 @@ .isStoragePoolVersionSupported(); doReturn(spDao).when(cmd).getStoragePoolDAO(); doReturn(sdDao).when(cmd).getStorageDomainStaticDAO(); - doReturn(vdsDao).when(cmd).getVdsGroupDAO(); + doReturn(vdsGroupDao).when(cmd).getVdsGroupDAO(); + doReturn(vdsDao).when(cmd).getVdsDAO(); doReturn(validator).when(cmd).createStoragePoolValidator(); } @@ -135,7 +141,7 @@ clusterList.add(thirdCluster); // Test upgrade - when(vdsDao.getAllForStoragePool(any(Guid.class))).thenReturn(clusterList); + when(vdsGroupDao.getAllForStoragePool(any(Guid.class))).thenReturn(clusterList); assertFalse(cmd.checkAllClustersLevel()); List<String> messages = cmd.getReturnValue().getCanDoActionMessages(); assertTrue(messages.contains(VdcBllMessages.ERROR_CANNOT_UPDATE_STORAGE_POOL_COMPATIBILITY_VERSION_BIGGER_THAN_CLUSTERS.toString())); @@ -238,13 +244,21 @@ return clusters; } + private static List<VDS> createHostList() { + List<VDS> hosts = new ArrayList<VDS>(); + VDS vds = new VDS(); + vds.setVdsGroupId(DEFAULT_VDS_GROUP_ID); + hosts.add(vds); + return hosts; + } + private void addDefaultClusterToPool() { VDSGroup defaultCluster = new VDSGroup(); defaultCluster.setcompatibility_version(VERSION_1_1); defaultCluster.setId(DEFAULT_VDS_GROUP_ID); List<VDSGroup> clusters = new ArrayList<VDSGroup>(); clusters.add(defaultCluster); - when(vdsDao.getAllForStoragePool(any(Guid.class))).thenReturn(clusters); + when(vdsGroupDao.getAllForStoragePool(any(Guid.class))).thenReturn(clusters); } private void canDoActionFailed(final String reason) { diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index fe18d4a..c65ee71 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -632,7 +632,7 @@ ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_INCOMPATIBLE_VERSION=Cannot ${action} ${type}. Cluster does not support Single Qxl Pci devices. ACTION_TYPE_FAILED_ILLEGAL_DOMAIN_NAME=Cannot ${action} ${type}. Illegal Domain name: ${Domain}. Domain name has unsupported special character ${Char}. ACTION_TYPE_FAILED_ILLEGAL_ARCHITECTURE_TYPE_INCOMPATIBLE=Cannot ${action} ${type}. Architecture does not match the expected value. -ACTION_TYPE_FAILED_CANNOT_DECREASE_COMPATIBILITY_VERSION=Cannot decrease data center compatibility version. +ACTION_TYPE_FAILED_CANNOT_DECREASE_COMPATIBILITY_VERSION=Cannot decrease compatibility version if Clusters are not empty. ACTION_TYPE_FAILED_GIVEN_VERSION_NOT_SUPPORTED=Cannot ${action} ${type}. Selected Compatibility Version is not supported. ACTION_TYPE_FAILED_DATA_CENTER_VERSION_DOESNT_SUPPORT_LIVE_SNAPSHOT=Cannot ${action} ${type}. Selected data center compatibility version does not support live snapshot. NETWORK_ADDR_MANDATORY_IN_STATIC_IP=Network address must be specified when using static IP diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 4eca60b..7b3bcfc 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -612,7 +612,7 @@ ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_INCOMPATIBLE_VERSION=Cannot ${action} ${type}. Cluster does not support Single Qxl Pci devices. ACTION_TYPE_FAILED_ILLEGAL_DOMAIN_NAME=Cannot ${action} ${type}. Illegal Domain name: ${Domain}. Domain name has unsupported special character ${Char}. ACTION_TYPE_FAILED_ILLEGAL_ARCHITECTURE_TYPE_INCOMPATIBLE=Cannot ${action} ${type}. Architecture does not match the expected value. -ACTION_TYPE_FAILED_CANNOT_DECREASE_COMPATIBILITY_VERSION=Cannot decrease data center compatibility version. +ACTION_TYPE_FAILED_CANNOT_DECREASE_COMPATIBILITY_VERSION=Cannot decrease compatibility version if Clusters are not empty. ACTION_TYPE_FAILED_GIVEN_VERSION_NOT_SUPPORTED=Cannot ${action} ${type}. Selected Compatibility Version is not supported. ACTION_TYPE_FAILED_DATA_CENTER_VERSION_DOESNT_SUPPORT_LIVE_SNAPSHOT=Cannot ${action} ${type}. Selected data center compatibility version does not support live snapshot. NETWORK_ADDR_MANDATORY_IN_STATIC_IP=Network address must be specified when using static ip diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 310e7ea..d27cea8 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -633,7 +633,7 @@ ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_INCOMPATIBLE_VERSION=Cannot ${action} ${type}. Cluster does not support Single Qxl Pci devices. ACTION_TYPE_FAILED_ILLEGAL_DOMAIN_NAME=Cannot ${action} ${type}. Illegal Domain name: ${Domain}. Domain name has unsupported special character ${Char}. ACTION_TYPE_FAILED_ILLEGAL_ARCHITECTURE_TYPE_INCOMPATIBLE=Cannot ${action} ${type}. Architecture does not match the expected value. -ACTION_TYPE_FAILED_CANNOT_DECREASE_COMPATIBILITY_VERSION=Cannot decrease data center compatibility version. +ACTION_TYPE_FAILED_CANNOT_DECREASE_COMPATIBILITY_VERSION=Cannot decrease compatibility version if Clusters are not empty. ACTION_TYPE_FAILED_GIVEN_VERSION_NOT_SUPPORTED=Cannot ${action} ${type}. Selected Compatibility Version is not supported. ACTION_TYPE_FAILED_DATA_CENTER_VERSION_DOESNT_SUPPORT_LIVE_SNAPSHOT=Cannot ${action} ${type}. Selected data center compatibility version does not support live snapshot. NETWORK_ADDR_MANDATORY_IN_STATIC_IP=Network address must be specified when using static ip -- To view, visit http://gerrit.ovirt.org/25911 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I32b089f27c286aca1857a03c75840d8cd978f1e8 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eli Mesika <emes...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches