Updated Branches: refs/heads/master f2fab9d5b -> 29b90e7a5
CLOUDSTACK-5554: Custom disk offering allows to create a datadisk with size greater than custom.diskoffering.size.max value Fixed both custom.diskoffering.size.max and custom.diskoffering.size.min to ensure input values while deploying the VM and creating volume APIs. Moved both parameters to VolumeOrchestrationService using ConfigDepot Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/707da55f Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/707da55f Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/707da55f Branch: refs/heads/master Commit: 707da55fe3f94e95ee0186fd119f78d1d3def5c7 Parents: f2fab9d Author: Harikrishna Patnala <[email protected]> Authored: Thu Dec 19 15:53:59 2013 +0530 Committer: Kishan Kavala <[email protected]> Committed: Thu Dec 19 16:03:27 2013 +0530 ---------------------------------------------------------------------- .../service/VolumeOrchestrationService.java | 16 ++++++++++++++++ .../engine/orchestration/VolumeOrchestrator.java | 2 +- server/src/com/cloud/configuration/Config.java | 2 -- .../src/com/cloud/server/ManagementServerImpl.java | 2 +- .../src/com/cloud/storage/VolumeApiServiceImpl.java | 13 ++++++------- server/src/com/cloud/vm/UserVmManagerImpl.java | 12 ++++++++++++ setup/db/db/schema-421to430.sql | 2 ++ 7 files changed, 38 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/707da55f/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java index a9ccc06..80e4f9d 100644 --- a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java +++ b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java @@ -44,6 +44,7 @@ import com.cloud.utils.fsm.NoTransitionException; import com.cloud.vm.DiskProfile; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachineProfile; +import org.apache.cloudstack.framework.config.ConfigKey; /** * VolumeOrchestrationService is a PURE orchestration service on CloudStack @@ -53,6 +54,21 @@ import com.cloud.vm.VirtualMachineProfile; * to provision volumes. */ public interface VolumeOrchestrationService { + + static final ConfigKey<Long> CustomDiskOfferingMinSize = new ConfigKey<Long>("Advanced", + Long.class, + "custom.diskoffering.size.min", + "1", + "Minimum size in GB for custom disk offering.", + true + ); + static final ConfigKey<Long> CustomDiskOfferingMaxSize = new ConfigKey<Long>("Advanced", + Long.class, + "custom.diskoffering.size.max", + "1024", + "Maximum size in GB for custom disk offering.", + true + ); VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType) throws ConcurrentOperationException, StorageUnavailableException; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/707da55f/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java ---------------------------------------------------------------------- diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java index efaa288..4243646 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java @@ -1169,7 +1169,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati @Override public ConfigKey<?>[] getConfigKeys() { - return new ConfigKey<?>[] {RecreatableSystemVmEnabled, MaxVolumeSize, StorageHAMigrationEnabled}; + return new ConfigKey<?>[] {RecreatableSystemVmEnabled, MaxVolumeSize, StorageHAMigrationEnabled, CustomDiskOfferingMaxSize, CustomDiskOfferingMinSize}; } @Override http://git-wip-us.apache.org/repos/asf/cloudstack/blob/707da55f/server/src/com/cloud/configuration/Config.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 3893c2f..73f6897 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -1705,8 +1705,6 @@ public enum Config { "false", "Should be set to true, if there will be multiple NetScaler devices providing EIP service in a zone", null), - CustomDiskOfferingMinSize("Advanced", ManagementServer.class, Long.class, "custom.diskoffering.size.min", "1", "Minimum size in GB for custom disk offering", null), - CustomDiskOfferingMaxSize("Advanced", ManagementServer.class, Long.class, "custom.diskoffering.size.max", "1024", "Maximum size in GB for custom disk offering", null), ConsoleProxyServiceOffering( "Advanced", ManagementServer.class, http://git-wip-us.apache.org/repos/asf/cloudstack/blob/707da55f/server/src/com/cloud/server/ManagementServerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 8bc095d..de07a9d 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -3270,7 +3270,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe } } - long diskOffMaxSize = Long.valueOf(_configDao.getValue(Config.CustomDiskOfferingMaxSize.key())); + long diskOffMaxSize = _volumeMgr.CustomDiskOfferingMaxSize.value(); KVMSnapshotEnabled = Boolean.parseBoolean(_configDao.getValue("KVM.snapshot.enabled")); boolean userPublicTemplateEnabled = TemplateManager.AllowPublicUserTemplates.valueIn(caller.getId()); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/707da55f/server/src/com/cloud/storage/VolumeApiServiceImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 2fa023e..ba778c6 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -340,8 +340,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic Long.class, "vm.job.check.interval", "3000", "Interval in milliseconds to check if the job is complete", false); - private int _customDiskOfferingMinSize = 1; - private final int _customDiskOfferingMaxSize = 1024; private long _maxVolumeSizeInGb; private final StateMachine2<Volume.State, Volume.Event, Volume> _volStateMachine; @@ -541,9 +539,12 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic if (size == null) { throw new InvalidParameterValueException("This disk offering requires a custom size specified"); } - if ((sizeInGB < _customDiskOfferingMinSize) || (sizeInGB > _customDiskOfferingMaxSize)) { - throw new InvalidParameterValueException("Volume size: " + sizeInGB + "GB is out of allowed range. Max: " + _customDiskOfferingMaxSize + " Min:" + - _customDiskOfferingMinSize); + Long customDiskOfferingMaxSize = _volumeMgr.CustomDiskOfferingMaxSize.value(); + Long customDiskOfferingMinSize = _volumeMgr.CustomDiskOfferingMinSize.value(); + + if ((sizeInGB < customDiskOfferingMinSize) || (sizeInGB > customDiskOfferingMaxSize)) { + throw new InvalidParameterValueException("Volume size: " + sizeInGB + "GB is out of allowed range. Max: " + customDiskOfferingMaxSize + " Min:" + + customDiskOfferingMinSize); } } @@ -1925,8 +1926,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic @Override public boolean configure(String name, Map<String, Object> params) { - String _customDiskOfferingMinSizeStr = _configDao.getValue(Config.CustomDiskOfferingMinSize.toString()); - _customDiskOfferingMinSize = NumbersUtil.parseInt(_customDiskOfferingMinSizeStr, Integer.parseInt(Config.CustomDiskOfferingMinSize.getDefaultValue())); String maxVolumeSizeInGbString = _configDao.getValue(Config.MaxVolumeSize.toString()); _maxVolumeSizeInGb = NumbersUtil.parseLong(maxVolumeSizeInGbString, 2000); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/707da55f/server/src/com/cloud/vm/UserVmManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 3ad49d8..f58a451 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2520,6 +2520,18 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (tmp != null) { size = tmp; } + DiskOfferingVO diskOffering = _diskOfferingDao.findById(diskOfferingId); + if (diskOffering.isCustomized()) { + if (diskSize == null) { + throw new InvalidParameterValueException("This disk offering requires a custom size specified"); + } + Long customDiskOfferingMaxSize = volumeMgr.CustomDiskOfferingMaxSize.value(); + Long customDiskOfferingMinSize = volumeMgr.CustomDiskOfferingMinSize.value(); + if ((diskSize < customDiskOfferingMinSize) || (diskSize > customDiskOfferingMaxSize)) { + throw new InvalidParameterValueException("VM Creation failed. Volume size: " + diskSize + "GB is out of allowed range. Max: " + customDiskOfferingMaxSize + " Min:" + + customDiskOfferingMinSize); + } + } if (diskOfferingId != null) { size += _diskOfferingDao.findById(diskOfferingId).getDiskSize(); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/707da55f/setup/db/db/schema-421to430.sql ---------------------------------------------------------------------- diff --git a/setup/db/db/schema-421to430.sql b/setup/db/db/schema-421to430.sql index ba19ae6..e3e8f1c 100644 --- a/setup/db/db/schema-421to430.sql +++ b/setup/db/db/schema-421to430.sql @@ -771,6 +771,8 @@ CREATE VIEW `cloud`.`domain_router_view` AS INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Advanced", 'DEFAULT', 'management-server', "vmware.vcenter.session.timeout", "1200", "VMware client timeout in seconds", "1200", NULL,NULL,0); INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Advanced", 'DEFAULT', 'management-server', "mgt.server.vendor", "ACS", "the vendor of management server", "ACS", NULL,NULL,0); +Update `cloud`.`configuration` set `component` = "VolumeOrchestrationService", `scope` = "Global" where `name`="custom.diskoffering.size.max"; +Update `cloud`.`configuration` set `component` = "VolumeOrchestrationService", `scope` = "Global" where `name`="custom.diskoffering.size.min"; ALTER TABLE `cloud_usage`.`usage_vm_instance` ADD COLUMN `cpu_speed` INT(10) UNSIGNED NULL COMMENT 'speed per core in Mhz', ADD COLUMN `cpu_cores` INT(10) UNSIGNED NULL COMMENT 'number of cpu cores',
