cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kis...@apache.org
Subject [1/2] git commit: updated refs/heads/4.3 to 4034aad
Date Thu, 19 Dec 2013 10:23:27 GMT
Updated Branches:
  refs/heads/4.3 bcedbe698 -> 4034aad25


CLOUDSTACK-5554: Custom disk offering allows to create a datadisk with size greater than custom.diskoffering.size.max
value


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1c6b146d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1c6b146d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1c6b146d

Branch: refs/heads/4.3
Commit: 1c6b146d0421ef66be1015d9f422274cea741ce3
Parents: bcedbe6
Author: Harikrishna Patnala <harikrishna.patnala@citrix.com>
Authored: Thu Dec 19 12:13:38 2013 +0530
Committer: Kishan Kavala <kishan@cloud.com>
Committed: Thu Dec 19 15:45:43 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 | 12 +++++-------
 server/src/com/cloud/vm/UserVmManagerImpl.java      | 12 ++++++++++++
 setup/db/db/schema-421to430.sql                     |  2 ++
 7 files changed, 37 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1c6b146d/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 1bba479..5ac6bb1 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;
 
     Volume allocateDuplicateVolume(Volume oldVol, Long templateId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1c6b146d/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 ebd8709..c8b475c 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -1231,7 +1231,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/1c6b146d/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 4da7e58..9cc3649 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -362,8 +362,6 @@ public enum Config {
     DefaultExternalLoadBalancerCapacity("Advanced", ManagementServer.class, String.class,
"external.lb.default.capacity", "50", "default number of networks permitted per external load
balancer device", null),
     DefaultExternalFirewallCapacity("Advanced", ManagementServer.class, String.class, "external.firewall.default.capacity",
"50", "default number of networks permitted per external load firewall device", null),
     EIPWithMultipleNetScalersEnabled("Advanced", ManagementServer.class, Boolean.class, "eip.use.multiple.netscalers",
"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, Long.class, "consoleproxy.service.offering",
null, "Uuid of the service offering used by console proxy; if NULL - system offering will
be used", null),
 	SecondaryStorageServiceOffering("Advanced", ManagementServer.class, Long.class, "secstorage.service.offering",
null, "Service offering used by secondary storage; if NULL - system offering will be used",
null),
 	HaTag("Advanced", ManagementServer.class, String.class, "ha.tag", null, "HA tag defining
that the host marked with this tag can be used for HA purposes only", null),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1c6b146d/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 8dad7ae..cd8f3fb 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -3299,7 +3299,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/1c6b146d/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 dd6358a..e8cbbfe 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -337,8 +337,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;
 
@@ -529,9 +527,11 @@ 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);
                 }
             }
 
@@ -1931,8 +1931,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/1c6b146d/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 74b3439..b4c8711 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -2657,6 +2657,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/1c6b146d/setup/db/db/schema-421to430.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-421to430.sql b/setup/db/db/schema-421to430.sql
index 9913b08..8c04515 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',


Mime
View raw message