Skip to content

Commit 03fac83

Browse files
Harikrishna Patnalanitinmeh
authored andcommitted
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<nitin.mehta@citrix.com>
1 parent 5af61a8 commit 03fac83

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd {
102102
@Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="Template details in key/value pairs.")
103103
protected Map details;
104104

105+
@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")
106+
protected Boolean isDynamicallyScalable;
107+
105108
// ///////////////////////////////////////////////////
106109
// ///////////////// Accessors ///////////////////////
107110
// ///////////////////////////////////////////////////
@@ -169,6 +172,10 @@ public Map getDetails() {
169172
return params;
170173
}
171174

175+
public boolean isDynamicallyScalable() {
176+
return isDynamicallyScalable == null ? false : isDynamicallyScalable;
177+
}
178+
172179
// ///////////////////////////////////////////////////
173180
// ///////////// API Implementation///////////////////
174181
// ///////////////////////////////////////////////////

server/src/com/cloud/hypervisor/HypervisorGuruBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected <T extends VirtualMachine> VirtualMachineTO toVirtualMachineTO(Virtua
120120
details.putAll(detailsInVm);
121121
}
122122
if (details.get(VirtualMachine.IsDynamicScalingEnabled) == null || details.get(VirtualMachine.IsDynamicScalingEnabled).isEmpty()) {
123-
to. setEnableDynamicallyScaleVm(false);
123+
to.setEnableDynamicallyScaleVm(false);
124124
} else {
125125
// check if XStools/VMWare tools are present in the VM and dynamic scaling feature is enabled (per zone/global)
126126
to.setEnableDynamicallyScaleVm(details.get(VirtualMachine.IsDynamicScalingEnabled).equals("true") && Boolean.parseBoolean(_configServer.getConfigValue(Config.EnableDynamicallyScaleVm.key(), Config.ConfigurationParameterScope.zone.toString(), vm.getDataCenterId())));

server/src/com/cloud/template/TemplateManagerImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,7 @@ public VMTemplateVO createPrivateTemplateRecord(CreateTemplateCmd cmd, Account t
14571457
if (isPublic == null) {
14581458
isPublic = Boolean.FALSE;
14591459
}
1460+
boolean isDynamicScalingEnabled = cmd.isDynamicallyScalable();
14601461
// check whether template owner can create public templates
14611462
boolean allowPublicUserTemplates = Boolean.parseBoolean(_configServer.getConfigValue(Config.AllowPublicUserTemplates.key(),
14621463
Config.ConfigurationParameterScope.account.toString(), templateOwner.getId()));
@@ -1497,6 +1498,7 @@ public VMTemplateVO createPrivateTemplateRecord(CreateTemplateCmd cmd, Account t
14971498
}
14981499
throw new CloudRuntimeException(msg);
14991500
}
1501+
15001502
hyperType = this._volumeDao.getHypervisorType(volumeId);
15011503
} else { // create template from snapshot
15021504
snapshot = _snapshotDao.findById(snapshotId);
@@ -1568,6 +1570,8 @@ public VMTemplateVO createPrivateTemplateRecord(CreateTemplateCmd cmd, Account t
15681570
privateTemplate = new VMTemplateVO(nextTemplateId, uniqueName, name, ImageFormat.RAW, isPublic, featured, isExtractable, TemplateType.USER,
15691571
null, null, requiresHvmValue, bitsValue, templateOwner.getId(), null, description, passwordEnabledValue, guestOS.getId(), true,
15701572
hyperType, templateTag, cmd.getDetails());
1573+
privateTemplate.setDynamicallyScalable(isDynamicScalingEnabled);
1574+
15711575
if (sourceTemplateId != null) {
15721576
if (s_logger.isDebugEnabled()) {
15731577
s_logger.debug("This template is getting created from other template, setting source template Id to: " + sourceTemplateId);

0 commit comments

Comments
 (0)