You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/08/02 04:08:33 UTC

[32/44] git commit: CS-15631 : Support for up to 16 VDIs per VM on XS 6.0 and above

CS-15631 : Support for up to 16 VDIs per VM on XS 6.0 and above

Support for up to 16 VDIs per VM on XS 6.0 and above (16 VDIs => root + cd + 14 data volumes). Currently in CS number of data disk that can be attached to VM is hard-coded to 6. Made this setting configurable by moving it to hypervisor capabilities. Although XS 6.0 and above supports upto 16 VDIs but while testing on XS 6.0.2 found that only 13 data volumes can be attached to a VM. So for XS 6.0 and 6.0.2 max_data_volumes_limit is set to 13 currently.

Signed-off-by: Koushik Das <Ko...@citrix.com>


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

Branch: refs/heads/vpc
Commit: 3f571684aa3e0309f70e1a193298d28d20126d81
Parents: 3cbc0e3
Author: Koushik Das <Ko...@citrix.com>
Authored: Wed Aug 1 14:57:53 2012 +0530
Committer: Nitin Mehta <ni...@citrix.com>
Committed: Wed Aug 1 19:39:30 2012 +0530

----------------------------------------------------------------------
 .../cloud/hypervisor/HypervisorCapabilities.java   |    5 ++-
 .../cloud/hypervisor/HypervisorCapabilitiesVO.java |   12 ++++
 .../hypervisor/dao/HypervisorCapabilitiesDao.java  |    5 +-
 .../dao/HypervisorCapabilitiesDaoImpl.java         |   41 ++++++++++++++-
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   25 ++++++++-
 setup/db/create-schema.sql                         |    5 +-
 setup/db/db/schema-303to40.sql                     |    5 ++
 7 files changed, 88 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f571684/api/src/com/cloud/hypervisor/HypervisorCapabilities.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/hypervisor/HypervisorCapabilities.java b/api/src/com/cloud/hypervisor/HypervisorCapabilities.java
index d0fcf01..f91da35 100644
--- a/api/src/com/cloud/hypervisor/HypervisorCapabilities.java
+++ b/api/src/com/cloud/hypervisor/HypervisorCapabilities.java
@@ -43,5 +43,8 @@ public interface HypervisorCapabilities {
      */
     Long getMaxGuestsLimit();
 
-
+    /**
+     * @return the max. data volumes per VM supported by hypervisor
+     */
+    Integer getMaxDataVolumesLimit();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f571684/core/src/com/cloud/hypervisor/HypervisorCapabilitiesVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/hypervisor/HypervisorCapabilitiesVO.java b/core/src/com/cloud/hypervisor/HypervisorCapabilitiesVO.java
index 33cafbc..75eebeb 100644
--- a/core/src/com/cloud/hypervisor/HypervisorCapabilitiesVO.java
+++ b/core/src/com/cloud/hypervisor/HypervisorCapabilitiesVO.java
@@ -55,6 +55,9 @@ public class HypervisorCapabilitiesVO implements HypervisorCapabilities, Identit
     @Column(name="uuid")
     private String uuid;
 
+    @Column(name="max_data_volumes_limit")
+    private Integer maxDataVolumesLimit;
+
     protected HypervisorCapabilitiesVO() {
     	this.uuid = UUID.randomUUID().toString();
     }
@@ -145,6 +148,15 @@ public class HypervisorCapabilitiesVO implements HypervisorCapabilities, Identit
     }
 
     @Override
+    public Integer getMaxDataVolumesLimit() {
+        return maxDataVolumesLimit;
+    }
+
+    public void setMaxDataVolumesLimit(Integer maxDataVolumesLimit) {
+        this.maxDataVolumesLimit = maxDataVolumesLimit;
+    }
+
+    @Override
     public boolean equals(Object obj) {
         if (obj instanceof HypervisorCapabilitiesVO) {
             return ((HypervisorCapabilitiesVO)obj).getId() == this.getId();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f571684/server/src/com/cloud/hypervisor/dao/HypervisorCapabilitiesDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/dao/HypervisorCapabilitiesDao.java b/server/src/com/cloud/hypervisor/dao/HypervisorCapabilitiesDao.java
index c7fb969..8f4a475 100644
--- a/server/src/com/cloud/hypervisor/dao/HypervisorCapabilitiesDao.java
+++ b/server/src/com/cloud/hypervisor/dao/HypervisorCapabilitiesDao.java
@@ -28,6 +28,7 @@ public interface HypervisorCapabilitiesDao extends GenericDao<HypervisorCapabili
     
     HypervisorCapabilitiesVO findByHypervisorTypeAndVersion(HypervisorType hypervisorType, String hypervisorVersion);
     
-    Long getMaxGuestsLimit(HypervisorType hypervisorType, String hypervisorVersion); 
-    
+    Long getMaxGuestsLimit(HypervisorType hypervisorType, String hypervisorVersion);
+
+    Integer getMaxDataVolumesLimit(HypervisorType hypervisorType, String hypervisorVersion);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f571684/server/src/com/cloud/hypervisor/dao/HypervisorCapabilitiesDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/dao/HypervisorCapabilitiesDaoImpl.java b/server/src/com/cloud/hypervisor/dao/HypervisorCapabilitiesDaoImpl.java
index 8feeba5..1a6fb72 100644
--- a/server/src/com/cloud/hypervisor/dao/HypervisorCapabilitiesDaoImpl.java
+++ b/server/src/com/cloud/hypervisor/dao/HypervisorCapabilitiesDaoImpl.java
@@ -37,7 +37,8 @@ public class HypervisorCapabilitiesDaoImpl extends GenericDaoBase<HypervisorCapa
     protected final SearchBuilder<HypervisorCapabilitiesVO> HypervisorTypeSearch;
     protected final SearchBuilder<HypervisorCapabilitiesVO> HypervisorTypeAndVersionSearch;
     protected final GenericSearchBuilder<HypervisorCapabilitiesVO, Long> MaxGuestLimitByHypervisorSearch;
-    
+    protected final GenericSearchBuilder<HypervisorCapabilitiesVO, Integer> MaxDataVolumesLimitByHypervisorSearch;
+
     private static final String DEFAULT_VERSION = "default";
     
     protected HypervisorCapabilitiesDaoImpl() {
@@ -54,7 +55,13 @@ public class HypervisorCapabilitiesDaoImpl extends GenericDaoBase<HypervisorCapa
         MaxGuestLimitByHypervisorSearch.selectField(MaxGuestLimitByHypervisorSearch.entity().getMaxGuestsLimit());
         MaxGuestLimitByHypervisorSearch.and("hypervisorType", MaxGuestLimitByHypervisorSearch.entity().getHypervisorType(), SearchCriteria.Op.EQ);
         MaxGuestLimitByHypervisorSearch.and("hypervisorVersion", MaxGuestLimitByHypervisorSearch.entity().getHypervisorVersion(), SearchCriteria.Op.EQ);
-        MaxGuestLimitByHypervisorSearch.done();        
+        MaxGuestLimitByHypervisorSearch.done();
+
+        MaxDataVolumesLimitByHypervisorSearch = createSearchBuilder(Integer.class);
+        MaxDataVolumesLimitByHypervisorSearch.selectField(MaxDataVolumesLimitByHypervisorSearch.entity().getMaxDataVolumesLimit());
+        MaxDataVolumesLimitByHypervisorSearch.and("hypervisorType", MaxDataVolumesLimitByHypervisorSearch.entity().getHypervisorType(), SearchCriteria.Op.EQ);
+        MaxDataVolumesLimitByHypervisorSearch.and("hypervisorVersion", MaxDataVolumesLimitByHypervisorSearch.entity().getHypervisorVersion(), SearchCriteria.Op.EQ);
+        MaxDataVolumesLimitByHypervisorSearch.done();
     }
 
     @Override
@@ -104,4 +111,34 @@ public class HypervisorCapabilitiesDaoImpl extends GenericDaoBase<HypervisorCapa
         }
         return result;
     }
+
+    @Override
+    public Integer getMaxDataVolumesLimit(HypervisorType hypervisorType, String hypervisorVersion) {
+        Integer result = null;
+        boolean useDefault = false;
+        if (hypervisorVersion != null) {
+            SearchCriteria<Integer> sc = MaxDataVolumesLimitByHypervisorSearch.create();
+            sc.setParameters("hypervisorType", hypervisorType);
+            sc.setParameters("hypervisorVersion", hypervisorVersion);
+            List<Integer> limitList = customSearch(sc, null);
+            if (!limitList.isEmpty()) {
+                result = limitList.get(0);
+            } else {
+                useDefault = true;
+            }
+        } else {
+            useDefault = true;
+        }
+        // If data is not available for a specific hypervisor version then use 'default' as the version
+        if (useDefault) {
+            SearchCriteria<Integer> sc = MaxDataVolumesLimitByHypervisorSearch.create();
+            sc.setParameters("hypervisorType", hypervisorType);
+            sc.setParameters("hypervisorVersion", DEFAULT_VERSION);
+            List<Integer> limitList = customSearch(sc, null);
+            if (!limitList.isEmpty()) {
+                result = limitList.get(0);
+            }
+        }
+        return result;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f571684/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 ab92c6b..fa988af 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -505,6 +505,24 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
         }
     }
 
+    private int getMaxDataVolumesSupported(UserVmVO vm) {
+        Long hostId = vm.getHostId();
+        if (hostId == null) {
+            hostId = vm.getLastHostId();
+        }
+        HostVO host = _hostDao.findById(hostId);
+        Integer maxDataVolumesSupported = null;
+        if (host != null) {
+            _hostDao.loadDetails(host);
+            maxDataVolumesSupported = _hypervisorCapabilitiesDao.getMaxDataVolumesLimit(host.getHypervisorType(), host.getDetail("product_version"));
+        }
+        if (maxDataVolumesSupported == null) {
+            maxDataVolumesSupported = 6;  // 6 data disks by default if nothing is specified in 'hypervisor_capabilities' table
+        }
+
+        return maxDataVolumesSupported.intValue();
+    }
+
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_VOLUME_ATTACH, eventDescription = "attaching volume", async = true)
     public Volume attachVolumeToVM(AttachVolumeCmd command) {
@@ -548,10 +566,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
             }
         }
 
-        // Check that the VM has less than 6 data volumes attached
+        // Check that the number of data volumes attached to VM is less than that supported by hypervisor
         List<VolumeVO> existingDataVolumes = _volsDao.findByInstanceAndType(vmId, Volume.Type.DATADISK);
-        if (existingDataVolumes.size() >= 6) {
-            throw new InvalidParameterValueException("The specified VM already has the maximum number of data disks (6). Please specify another VM.");
+        int maxDataVolumesSupported = getMaxDataVolumesSupported(vm);
+        if (existingDataVolumes.size() >= maxDataVolumesSupported) {
+            throw new InvalidParameterValueException("The specified VM already has the maximum number of data disks (" + maxDataVolumesSupported + "). Please specify another VM.");
         }
 
         // Check that the VM and the volume are in the same zone

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f571684/setup/db/create-schema.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index 64c81a3..b327106 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -1565,6 +1565,7 @@ CREATE TABLE `cloud`.`hypervisor_capabilities` (
   `hypervisor_version` varchar(32),
   `max_guests_limit` bigint unsigned DEFAULT 50,
   `security_group_enabled` int(1) unsigned DEFAULT 1 COMMENT 'Is security group supported',
+  `max_data_volumes_limit` int unsigned DEFAULT 6 COMMENT 'Max. data volumes per VM supported by hypervisor',
   PRIMARY KEY  (`id`),
   CONSTRAINT `uc_hypervisor_capabilities__uuid` UNIQUE (`uuid`)
 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
@@ -1574,8 +1575,8 @@ INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor
 INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('XenServer', '5.6', 50, 1);
 INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('XenServer', '5.6 FP1', 50, 1);
 INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('XenServer', '5.6 SP2', 50, 1);
-INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('XenServer', '6.0', 50, 1);
-INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('XenServer', '6.0.2', 50, 1);
+INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit) VALUES ('XenServer', '6.0', 50, 1, 13);
+INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit) VALUES ('XenServer', '6.0.2', 50, 1, 13);
 INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('VMware', 'default', 128, 0);
 INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('VMware', '4.0', 128, 0);
 INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('VMware', '4.1', 128, 0);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3f571684/setup/db/db/schema-303to40.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-303to40.sql b/setup/db/db/schema-303to40.sql
index c90d73b..4ce8e65 100644
--- a/setup/db/db/schema-303to40.sql
+++ b/setup/db/db/schema-303to40.sql
@@ -80,5 +80,10 @@ DEALLOCATE PREPARE stmt1;
 AlTER TABLE physical_network_service_providers ADD CONSTRAINT `fk_pnetwork_service_providers__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE;
 UPDATE `cloud`.`configuration` SET description='In second, timeout for creating volume from snapshot' WHERE name='create.volume.from.snapshot.wait';
 
+ALTER TABLE `cloud`.`hypervisor_capabilities` ADD COLUMN `max_data_volumes_limit` int unsigned DEFAULT 6 COMMENT 'Max. data volumes per VM supported by hypervisor';
+SET SQL_SAFE_UPDATES=0;
+UPDATE `cloud`.`hypervisor_capabilities` SET `max_data_volumes_limit`=13 WHERE `hypervisor_type`='XenServer' AND (`hypervisor_version`='6.0' OR `hypervisor_version`='6.0.2');
+SET SQL_SAFE_UPDATES=1;
+