Daniel Erez has uploaded a new change for review. Change subject: core: removing deprecated GetDiskConfigurationListQuery ......................................................................
core: removing deprecated GetDiskConfigurationListQuery GetDiskConfigurationListQuery is not used anymore by client: Therefore, removing the following: * GetDiskConfigurationListQuery * GetDiskConfigurationListQueryTest * DiskConfigurationList ConfigValue. Change-Id: I8d750e63454096e4da0f7c4efdf229f7f06ac169 Signed-off-by: Daniel Erez <[email protected]> --- M backend/manager/dbscripts/upgrade/pre_upgrade/0000_config.sql D backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetDiskConfigurationListQuery.java D backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetDiskConfigurationListQueryTest.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java 5 files changed, 1 insertion(+), 175 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/80/12580/1 diff --git a/backend/manager/dbscripts/upgrade/pre_upgrade/0000_config.sql b/backend/manager/dbscripts/upgrade/pre_upgrade/0000_config.sql index 607de0b..a1a0f10 100644 --- a/backend/manager/dbscripts/upgrade/pre_upgrade/0000_config.sql +++ b/backend/manager/dbscripts/upgrade/pre_upgrade/0000_config.sql @@ -82,7 +82,6 @@ select fn_db_add_config_value('DesktopAudioDeviceType','WindowsXP,ac97,RHEL4,ac97,RHEL3,ac97,Windows2003x64,ac97,RHEL4x64,ac97,RHEL3x64,ac97,OtherLinux,ac97,Other,ac97,default,ich6','3.1'); select fn_db_add_config_value('DesktopAudioDeviceType','WindowsXP,ac97,RHEL4,ac97,RHEL3,ac97,Windows2003x64,ac97,RHEL4x64,ac97,RHEL3x64,ac97,OtherLinux,ac97,Other,ac97,default,ich6','3.2'); select fn_db_add_config_value('DisableFenceAtStartupInSec','300','general'); -select fn_db_add_config_value('DiskConfigurationList','System,Sparse,COW,true;Data,Preallocated,RAW,false;Shared,Preallocated,RAW,false;Swap,Preallocated,RAW,false;Temp,Sparse,COW,false','general'); select fn_db_add_config_value('DirectLUNDiskEnabled','false','3.0'); select fn_db_add_config_value('DirectLUNDiskEnabled','true','3.1'); select fn_db_add_config_value('DirectLUNDiskEnabled','true','3.2'); @@ -672,6 +671,7 @@ select fn_db_delete_config_value('LiveStorageMigrationEnabled','3.0'); select fn_db_delete_config_value('LiveStorageMigrationEnabled','3.1'); select fn_db_delete_config_value('LiveStorageMigrationEnabled','3.2'); +select fn_db_delete_config_value('DiskConfigurationList','general'); ------------------------------------------------------------------------------------ -- Split config section -- The purpose of this section is to treat config option that was once diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetDiskConfigurationListQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetDiskConfigurationListQuery.java deleted file mode 100644 index c7a5b87..0000000 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetDiskConfigurationListQuery.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.ovirt.engine.core.bll; - -import java.util.ArrayList; -import java.util.List; - -import org.ovirt.engine.core.common.businessentities.DiskImageBase; -import org.ovirt.engine.core.common.businessentities.VolumeFormat; -import org.ovirt.engine.core.common.businessentities.VolumeType; -import org.ovirt.engine.core.common.config.Config; -import org.ovirt.engine.core.common.config.ConfigValues; -import org.ovirt.engine.core.common.queries.VdcQueryParametersBase; -import org.ovirt.engine.core.common.utils.EnumUtils; - -public class GetDiskConfigurationListQuery<P extends VdcQueryParametersBase> extends QueriesCommandBase<P> { - /** - * The disk configuration is represented by a comma delimited string as follows: - * <code>label,VolumeType(from the enum),VolumeFormat(from the enum),wipeAfterDelete(true/false)<code>. - * E.g.: <code>System,Sparse,COW,true</code> - */ - private static final int DISK_CONFIGURATION_ELEMENTS_NUM = 4; - - public GetDiskConfigurationListQuery(P parameters) { - super(parameters); - } - - @Override - protected void executeQueryCommand() { - // Disk Config is a list of enum values of: - // diskType,volType,volFormat,wipeAfterDelete;... - List<DiskImageBase> result = new ArrayList<DiskImageBase>(); - String[] imageBasesList = Config.<String> GetValue(ConfigValues.DiskConfigurationList).split("[;]", -1); - for (String imageBase : imageBasesList) { - String[] configs = imageBase.split("[,]", -1); - if (configs.length == DISK_CONFIGURATION_ELEMENTS_NUM) { - try { - DiskImageBase tempVar = new DiskImageBase(); - tempVar.setVolumeType(EnumUtils.valueOf(VolumeType.class, configs[1], true)); - tempVar.setvolumeFormat(EnumUtils.valueOf(VolumeFormat.class, configs[2], true)); - tempVar.setWipeAfterDelete(Boolean.parseBoolean(configs[3])); - DiskImageBase dib = tempVar; - result.add(dib); - } catch (RuntimeException exp) { - log.errorFormat("Could not parse disk configuration: {0} - ex: {1}", configs, exp.getMessage()); - } - } else { - log.errorFormat("Wrong configuration value format: {0} - skipping parsing.", configs); - } - } - getQueryReturnValue().setReturnValue(result); - } -} diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetDiskConfigurationListQueryTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetDiskConfigurationListQueryTest.java deleted file mode 100644 index 4a55b97..0000000 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetDiskConfigurationListQueryTest.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.ovirt.engine.core.bll; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.commons.lang.StringUtils; -import org.junit.Rule; -import org.junit.Test; -import org.ovirt.engine.core.common.businessentities.DiskImageBase; -import org.ovirt.engine.core.common.businessentities.VolumeFormat; -import org.ovirt.engine.core.common.businessentities.VolumeType; -import org.ovirt.engine.core.common.config.ConfigValues; -import org.ovirt.engine.core.common.queries.VdcQueryParametersBase; -import org.ovirt.engine.core.utils.MockConfigRule; -import org.ovirt.engine.core.utils.RandomUtils; - -/** A test case for the {@link GetDiskConfigurationListQuery} class. */ -@SuppressWarnings("unchecked") -public class GetDiskConfigurationListQueryTest extends AbstractUserQueryTest<VdcQueryParametersBase, GetDiskConfigurationListQuery<VdcQueryParametersBase>> { - - @Rule - public MockConfigRule mcr = new MockConfigRule(); - - @Test - public void testExecuteQueryValidConfigurationMultipleDisks() { - assertValidConfig(nextDiskImageBase(), nextDiskImageBase()); - } - - @Test - public void testExecuteQueryValidConfigurationSingleDisk() { - assertValidConfig(nextDiskImageBase()); - } - - /** - * Tests the {@link GetDiskConfigurationListQuery#executeQueryCommand()} with an expected output of the given configurations. - * @param expectedDisks The expected result for the query. - */ - private void assertValidConfig(DiskImageBase... expectedDisks) { - List<String> disksConfigurtaion = new ArrayList<String>(expectedDisks.length); - - // Mock the config - for (int i = 0; i < expectedDisks.length; ++i) { - DiskImageBase expectedDisk = expectedDisks[i]; - disksConfigurtaion.add( - StringUtils.join(Arrays.asList("label" + i, - expectedDisk.getVolumeType(), - expectedDisk.getVolumeFormat(), - expectedDisk.isWipeAfterDelete()), - ',') - ); - } - String confStringValue = StringUtils.join(disksConfigurtaion, ';'); - mcr.mockConfigValue(ConfigValues.DiskConfigurationList, confStringValue); - - // Execute the query - getQuery().executeQueryCommand(); - - // Assert the results - List<DiskImageBase> result = (List<DiskImageBase>) getQuery().getQueryReturnValue().getReturnValue(); - - assertEquals("Wrong number of disk configurations", expectedDisks.length, result.size()); - for (int i = 0; i < expectedDisks.length; ++i) { - DiskImageBase expectedDisk = expectedDisks[i]; - DiskImageBase actualDisk = result.get(i); - - assertEquals("Wrong volume type", expectedDisk.getVolumeType(), actualDisk.getVolumeType()); - assertEquals("Wrong volume format", expectedDisk.getVolumeFormat(), actualDisk.getVolumeFormat()); - assertEquals("Wrong wipe after delete flag", - expectedDisk.isWipeAfterDelete(), - actualDisk.isWipeAfterDelete()); - } - } - - /** @return A randomly generate {@link DiskImageBase} */ - private static DiskImageBase nextDiskImageBase() { - DiskImageBase disk = new DiskImageBase(); - disk.setVolumeType(RandomUtils.instance().nextEnum(VolumeType.class)); - disk.setvolumeFormat(RandomUtils.instance().nextEnum(VolumeFormat.class)); - disk.setWipeAfterDelete(RandomUtils.instance().nextBoolean()); - return disk; - } - - @Test - public void testExecuteQueryInvalidMissingParameters() { - assertInvalidConfig("label,Sparse,COW"); - } - - @Test - public void testExecuteQueryInvalidExtraParameters() { - assertInvalidConfig("label,Sparse,COW,true,EasterBunny"); - } - - @Test - public void testExecuteQueryInvalidMalformedParameters() { - assertInvalidConfig("label,NOT-Sparse,COW,true"); - } - - @Test - public void testExecuteQueryInvalidConfigurationEmpty() { - assertInvalidConfig(""); - } - - private void assertInvalidConfig(String config) { - mcr.mockConfigValue(ConfigValues.DiskConfigurationList, config); - - // Execute the query - getQuery().executeQueryCommand(); - - // Assert the results - List<DiskImageBase> result = (List<DiskImageBase>) getQuery().getQueryReturnValue().getReturnValue(); - - assertTrue("No configurations should be returned", result.isEmpty()); - } -} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java index 1cec88f..abf180f 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java @@ -532,10 +532,6 @@ @DefaultValueAttribute("") ComputerADPaths(182), @Reloadable - @TypeConverterAttribute(String.class) - @DefaultValueAttribute("System,Sparse,COW,true;Data,Preallocated,RAW,false;Shared,Preallocated,RAW,false;Swap,Preallocated,RAW,false;Temp,Sparse,COW,false") - DiskConfigurationList(191), - @Reloadable @TypeConverterAttribute(Integer.class) @DefaultValueAttribute("3") SPMFailOverAttempts(192), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java index 1efaa66..5817245 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java @@ -160,7 +160,6 @@ GetConfigurationValues(VdcQueryAuthType.User), GetTimeZones(VdcQueryAuthType.User), GetDefualtTimeZone(VdcQueryAuthType.User), - GetDiskConfigurationList(VdcQueryAuthType.User), GetAvailableStoragePoolVersions(VdcQueryAuthType.User), GetAvailableClusterVersionsByStoragePool, -- To view, visit http://gerrit.ovirt.org/12580 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8d750e63454096e4da0f7c4efdf229f7f06ac169 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Daniel Erez <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
