cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject git commit: updated refs/heads/4.2 to 4d35d92
Date Mon, 29 Jul 2013 08:42:43 GMT
Updated Branches:
  refs/heads/4.2 2b42a2717 -> 4d35d9220


CLOUDSTACK-3779: Support System vm scaling on VMWare

Marked the system template new system template as dynamicallyScalable
   - handled upgrade case
   - moved "dynamicallyScalable" flag to vm_instance table from user_vm_details to support
dynamic scaling of system vm
Signed off by : Nitin Mehta<nitin.mehta@citrix.com>


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

Branch: refs/heads/4.2
Commit: 4d35d92208c9b63ca27c794508d4c534fa773078
Parents: 2b42a27
Author: Harikrishna Patnala <harikrishna.patnala@citrix.com>
Authored: Mon Jul 29 14:12:05 2013 +0530
Committer: Nitin Mehta <nitin.mehta@citrix.com>
Committed: Mon Jul 29 14:12:24 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/upgrade/dao/Upgrade410to420.java  |  9 ++++++++-
 .../schema/src/com/cloud/vm/VMInstanceVO.java   | 10 ++++++++++
 .../schema/src/com/cloud/vm/dao/UserVmDao.java  |  2 +-
 .../src/com/cloud/vm/dao/UserVmDaoImpl.java     |  3 ++-
 .../xen/resource/XenServer56FP1Resource.java    |  4 ++--
 .../cloud/hypervisor/HypervisorGuruBase.java    |  9 +++------
 .../com/cloud/server/ManagementServerImpl.java  |  4 ++++
 server/src/com/cloud/vm/UserVmManagerImpl.java  | 21 ++++++--------------
 .../cloud/vm/VirtualMachineManagerImplTest.java |  2 --
 setup/db/db/schema-410to420.sql                 |  9 ++++-----
 10 files changed, 40 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4d35d922/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
index a004a79..e8ca579 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -264,7 +264,14 @@ public class Upgrade410to420 implements DbUpgrade {
                     throw new CloudRuntimeException("Error while updating "+ hypervisorAndTemplateName.getKey()
+" systemVm template", e);
                 }
             }
-
+            try {
+                pstmt = conn.prepareStatement("UPDATE `cloud`.`vm_template` set dynamically_scalable
= 1 where name = ? and type = 'SYSTEM'");
+                pstmt.setString(1, NewTemplateNameList.get(HypervisorType.VMware));
+                pstmt.executeUpdate();
+                pstmt.close();
+            } catch (SQLException e) {
+                throw new CloudRuntimeException("Error while updating dynamically_scalable
flag to 1 for SYSTEM template systemvm-vmware-4.2");
+            }
             s_logger.debug("Updating System Vm Template IDs Complete");
         }
         finally {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4d35d922/engine/schema/src/com/cloud/vm/VMInstanceVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/VMInstanceVO.java b/engine/schema/src/com/cloud/vm/VMInstanceVO.java
index e1d2892..8cf7fd0 100644
--- a/engine/schema/src/com/cloud/vm/VMInstanceVO.java
+++ b/engine/schema/src/com/cloud/vm/VMInstanceVO.java
@@ -146,6 +146,8 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State,
Vi
     @Enumerated(value=EnumType.STRING)
     protected HypervisorType hypervisorType;
 
+    @Column(name = "dynamically_scalable")
+    protected boolean dynamicallyScalable;
 
 /*
     @Column(name="tags")
@@ -491,4 +493,12 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State,
Vi
 		return diskOfferingId;
 	}
 
+    public void setDynamicallyScalable(boolean dynamicallyScalable) {
+        this.dynamicallyScalable = dynamicallyScalable;
+    }
+
+    public Boolean isDynamicallyScalable() {
+        return this.dynamicallyScalable;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4d35d922/engine/schema/src/com/cloud/vm/dao/UserVmDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/UserVmDao.java b/engine/schema/src/com/cloud/vm/dao/UserVmDao.java
index b4f9991..fa406d3 100755
--- a/engine/schema/src/com/cloud/vm/dao/UserVmDao.java
+++ b/engine/schema/src/com/cloud/vm/dao/UserVmDao.java
@@ -40,7 +40,7 @@ public interface UserVmDao extends GenericDao<UserVmVO, Long> {
      * @param userData updates the userData of the vm
      * @param displayVm updates the displayvm attribute signifying whether it has to be displayed
to the end user or not.
      */
-    void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData,
boolean displayVm);
+    void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData,
boolean displayVm, boolean isDynamicallyScalable);
     
     List<UserVmVO> findDestroyedVms(Date date);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4d35d922/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java
index 1c11563..8afce09 100755
--- a/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java
@@ -224,13 +224,14 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long>
implements Use
     }
 
     @Override
-    public void updateVM(long id, String displayName, boolean enable, Long osTypeId, String
userData, boolean displayVm) {
+    public void updateVM(long id, String displayName, boolean enable, Long osTypeId, String
userData, boolean displayVm, boolean isDynamicallyScalable) {
         UserVmVO vo = createForUpdate();
         vo.setDisplayName(displayName);
         vo.setHaEnabled(enable);
         vo.setGuestOSId(osTypeId);
         vo.setUserData(userData);
         vo.setDisplayVm(displayVm);
+        vo.setDynamicallyScalable(isDynamicallyScalable);
         update(id, vo);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4d35d922/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
index 11a7b42..d230be1 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
@@ -178,8 +178,8 @@ public class XenServer56FP1Resource extends XenServer56Resource {
             vmr.memoryDynamicMax = vmSpec.getMaxRam();
         } else {
             //scaling disallowed, set static memory target
-            if (s_logger.isDebugEnabled()) {
-                s_logger.warn("Host "+ host.getHostname(conn) +" does not support dynamic
scaling");
+            if (vmSpec.isEnableDynamicallyScaleVm() && !isDmcEnabled(conn, host))
{
+                s_logger.warn("Host "+ host.getHostname(conn) +" does not support dynamic
scaling, so the vm " + vmSpec.getName() + " is not dynamically scalable");
             }
             vmr.memoryStaticMin = vmSpec.getMinRam();
             vmr.memoryStaticMax = vmSpec.getMaxRam();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4d35d922/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
index ec68529..478baf3 100644
--- a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
+++ b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
@@ -120,15 +120,12 @@ public abstract class HypervisorGuruBase extends AdapterBase implements
Hypervis
         if(detailsInVm != null) {
             details.putAll(detailsInVm);
         }
-        if (details.get(VirtualMachine.IsDynamicScalingEnabled) == null || details.get(VirtualMachine.IsDynamicScalingEnabled).isEmpty())
{
-            to.setEnableDynamicallyScaleVm(false);
-        } else {
-            // check if XStools/VMWare tools are present in the VM and dynamic scaling feature
is enabled (per zone/global)
-            to.setEnableDynamicallyScaleVm(details.get(VirtualMachine.IsDynamicScalingEnabled).equals("true")
&& Boolean.parseBoolean(_configServer.getConfigValue(Config.EnableDynamicallyScaleVm.key(),
Config.ConfigurationParameterScope.zone.toString(), vm.getDataCenterId())));
-        }
         to.setDetails(details);
         // Workaround to make sure the TO has the UUID we need for Niciri integration
         VMInstanceVO vmInstance = _virtualMachineDao.findById(to.getId());
+        // check if XStools/VMWare tools are present in the VM and dynamic scaling feature
is enabled (per zone/global)
+        Boolean isDynamicallyScalable = vmInstance.isDynamicallyScalable() && Boolean.parseBoolean(_configServer.getConfigValue(Config.EnableDynamicallyScaleVm.key(),
Config.ConfigurationParameterScope.zone.toString(), vm.getDataCenterId()));
+        to.setEnableDynamicallyScaleVm(isDynamicallyScalable);
         to.setUuid(vmInstance.getUuid());
 
         //

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4d35d922/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 d32441c..996c693 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -3723,6 +3723,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     @Override
     public VirtualMachine upgradeSystemVM(ScaleSystemVMCmd cmd) throws ResourceUnavailableException,
ManagementServerException, VirtualMachineMigrationException, ConcurrentOperationException
{
 
+        VMInstanceVO vmInstance = _vmInstanceDao.findById(cmd.getId());
+        if (vmInstance.getHypervisorType() == HypervisorType.XenServer && vmInstance.getState().equals(State.Running))
{
+            throw new InvalidParameterValueException("Dynamic Scaling operation is not permitted
for this hypervisor on system vm");
+        }
         boolean result = _userVmMgr.upgradeVirtualMachine(cmd.getId(), cmd.getServiceOfferingId());
         if(result){
             VirtualMachine vm = _vmInstanceDao.findById(cmd.getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4d35d922/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 36432f4..0ec296e 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1194,9 +1194,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
             if(!enableDynamicallyScaleVm){
                throw new PermissionDeniedException("Dynamically scaling virtual machines
is disabled for this zone, please contact your admin");
             }
-            UserVmDetailVO vmDetailVO = _vmDetailsDao.findDetail(vmId, VirtualMachine.IsDynamicScalingEnabled);
-            if (vmDetailVO == null || !Boolean.parseBoolean(vmDetailVO.getValue())) {
-                throw new CloudRuntimeException("Unable to Scale the vm: " + vmInstance.getUuid()
+ " as vm does not have xs tools to support dynamic scaling");
+            if (!vmInstance.isDynamicallyScalable()) {
+                throw new CloudRuntimeException("Unable to Scale the vm: " + vmInstance.getUuid()
+ " as vm does not have tools to support dynamic scaling");
             }
 
             while (retry-- != 0) { // It's != so that it can match -1.
@@ -1819,18 +1818,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
             }
         }
 
-        if (isDynamicallyScalable != null) {
-            UserVmDetailVO vmDetailVO = _vmDetailsDao.findDetail(vm.getId(), VirtualMachine.IsDynamicScalingEnabled);
-            if (vmDetailVO == null) {
-                vmDetailVO = new UserVmDetailVO(vm.getId(), VirtualMachine.IsDynamicScalingEnabled,
isDynamicallyScalable.toString());
-                _vmDetailsDao.persist(vmDetailVO);
-            } else {
-                vmDetailVO.setValue(isDynamicallyScalable.toString());
-                _vmDetailsDao.update(vmDetailVO.getId(), vmDetailVO);
-            }
+        if (isDynamicallyScalable == null) {
+            isDynamicallyScalable = vmInstance.isDynamicallyScalable();
         }
 
-        _vmDao.updateVM(id, displayName, ha, osTypeId, userData, isDisplayVmEnabled);
+        _vmDao.updateVM(id, displayName, ha, osTypeId, userData, isDisplayVmEnabled, isDynamicallyScalable);
 
         if (updateUserdata) {
             boolean result = updateUserDataInternal(_vmDao.findById(id));
@@ -2732,8 +2724,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
                 owner.getDomainId(), owner.getId(), offering.getId(), userData,
                 hostName, diskOfferingId);
         vm.setUuid(uuidName);
-        vm.setDetail(VirtualMachine.IsDynamicScalingEnabled, template.isDynamicallyScalable().toString());
-
+        vm.setDynamicallyScalable(template.isDynamicallyScalable());
         if (sshPublicKey != null) {
             vm.setDetail("SSH.PublicKey", sshPublicKey);
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4d35d922/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java b/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
index f67695d..4da33e6 100644
--- a/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
+++ b/server/test/com/cloud/vm/VirtualMachineManagerImplTest.java
@@ -239,8 +239,6 @@ public class VirtualMachineManagerImplTest {
         long l = 1L;
 
         doReturn(3L).when(_vmInstance).getId();
-        when(_vmDetailsDao.findDetail(3L, VirtualMachine.IsDynamicScalingEnabled)).thenReturn(_vmDetailVO);
-        doReturn("true").when(_vmDetailVO).getValue();
         when(_vmInstanceDao.findById(anyLong())).thenReturn(_vmInstance);
         ServiceOfferingVO newServiceOffering = getSvcoffering(512);
         doReturn(1L).when(_vmInstance).getHostId();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4d35d922/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 8446e0f..5b71ca2 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -43,7 +43,9 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT',
'manage
 ALTER TABLE `cloud`.`load_balancer_vm_map` ADD state VARCHAR(40) NULL COMMENT 'service status
updated by LB healthcheck manager';
 
 ALTER TABLE `cloud`.`vm_template` ADD COLUMN `dynamically_scalable` tinyint(1) unsigned NOT
NULL DEFAULT 0  COMMENT 'true if template contains XS/VMWare tools inorder to support dynamic
scaling of VM cpu/memory';
+ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `dynamically_scalable` tinyint(1) unsigned NOT
NULL DEFAULT 0  COMMENT 'true if VM contains XS/VMWare tools inorder to support dynamic scaling
of VM cpu/memory';
 UPDATE `cloud`.`vm_template` SET dynamically_scalable = 1 WHERE name = "CentOS 5.6(64-bit)
no GUI (XenServer)" AND type = "BUILTIN";
+UPDATE `cloud`.`vm_template` SET dynamically_scalable = 1 WHERE name = "SystemVM Template
(vSphere)" AND type = "SYSTEM";
 
 alter table storage_pool add hypervisor varchar(32);
 alter table storage_pool change storage_provider_id storage_provider_name varchar(255);
@@ -1621,7 +1623,7 @@ CREATE VIEW `cloud`.`user_vm_view` AS
         affinity_group.uuid affinity_group_uuid,
         affinity_group.name affinity_group_name,
         affinity_group.description affinity_group_description,
-        vm_details.value dynamically_scalable
+        vm_instance.dynamically_scalable dynamically_scalable
 
     from
         `cloud`.`user_vm`
@@ -1685,10 +1687,7 @@ CREATE VIEW `cloud`.`user_vm_view` AS
             left join
         `cloud`.`affinity_group_vm_map` ON vm_instance.id = affinity_group_vm_map.instance_id
             left join
-        `cloud`.`affinity_group` ON affinity_group_vm_map.affinity_group_id = affinity_group.id
-            left join
-        `cloud`.`user_vm_details` vm_details ON vm_details.vm_id = vm_instance.id
-            and vm_details.name = 'enable.dynamic.scaling';
+        `cloud`.`affinity_group` ON affinity_group_vm_map.affinity_group_id = affinity_group.id;
 
 DROP VIEW IF EXISTS `cloud`.`volume_view`;
 CREATE VIEW `cloud`.`volume_view` AS


Mime
View raw message