From 03fac831800a8b7fd34af607a0ca36ced05cb0ea Mon Sep 17 00:00:00 2001 From: Harikrishna Patnala Date: Fri, 19 Jul 2013 11:54:09 +0530 Subject: [PATCH] CLOUDSTACK-3358: create template from a volume/snapshot should also take input from User/Admin whether xstools / vmware tools installed in the VM Signed off by : Nitin Mehta --- .../api/command/user/template/CreateTemplateCmd.java | 7 +++++++ server/src/com/cloud/hypervisor/HypervisorGuruBase.java | 2 +- server/src/com/cloud/template/TemplateManagerImpl.java | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java index 271357d1ef3..6116a4e6018 100644 --- a/api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java @@ -102,6 +102,9 @@ import java.util.Map; @Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="Template details in key/value pairs.") protected Map details; + @Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE, type = CommandType.BOOLEAN, description = "true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory") + protected Boolean isDynamicallyScalable; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// @@ -169,6 +172,10 @@ import java.util.Map; return params; } + public boolean isDynamicallyScalable() { + return isDynamicallyScalable == null ? false : isDynamicallyScalable; + } + // /////////////////////////////////////////////////// // ///////////// API Implementation/////////////////// // /////////////////////////////////////////////////// diff --git a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java index 769648a002d..2ffd6821d3e 100644 --- a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java +++ b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java @@ -120,7 +120,7 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis details.putAll(detailsInVm); } if (details.get(VirtualMachine.IsDynamicScalingEnabled) == null || details.get(VirtualMachine.IsDynamicScalingEnabled).isEmpty()) { - to. setEnableDynamicallyScaleVm(false); + 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()))); diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index c6446ac1f7d..f1a56023d20 100755 --- a/server/src/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/com/cloud/template/TemplateManagerImpl.java @@ -1457,6 +1457,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, if (isPublic == null) { isPublic = Boolean.FALSE; } + boolean isDynamicScalingEnabled = cmd.isDynamicallyScalable(); // check whether template owner can create public templates boolean allowPublicUserTemplates = Boolean.parseBoolean(_configServer.getConfigValue(Config.AllowPublicUserTemplates.key(), Config.ConfigurationParameterScope.account.toString(), templateOwner.getId())); @@ -1497,6 +1498,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, } throw new CloudRuntimeException(msg); } + hyperType = this._volumeDao.getHypervisorType(volumeId); } else { // create template from snapshot snapshot = _snapshotDao.findById(snapshotId); @@ -1568,6 +1570,8 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, privateTemplate = new VMTemplateVO(nextTemplateId, uniqueName, name, ImageFormat.RAW, isPublic, featured, isExtractable, TemplateType.USER, null, null, requiresHvmValue, bitsValue, templateOwner.getId(), null, description, passwordEnabledValue, guestOS.getId(), true, hyperType, templateTag, cmd.getDetails()); + privateTemplate.setDynamicallyScalable(isDynamicScalingEnabled); + if (sourceTemplateId != null) { if (s_logger.isDebugEnabled()) { s_logger.debug("This template is getting created from other template, setting source template Id to: " + sourceTemplateId);