Skip to content

Commit 12c711c

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 c032968 commit 12c711c

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
@@ -100,6 +100,9 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd {
100100
@Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="Template details in key/value pairs.")
101101
protected Map details;
102102

103+
@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")
104+
protected Boolean isDynamicallyScalable;
105+
103106
// ///////////////////////////////////////////////////
104107
// ///////////////// Accessors ///////////////////////
105108
// ///////////////////////////////////////////////////
@@ -167,6 +170,10 @@ public Map getDetails() {
167170
return params;
168171
}
169172

173+
public boolean isDynamicallyScalable() {
174+
return isDynamicallyScalable == null ? false : isDynamicallyScalable;
175+
}
176+
170177
// ///////////////////////////////////////////////////
171178
// ///////////// API Implementation///////////////////
172179
// ///////////////////////////////////////////////////

‎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
@@ -1460,6 +1460,7 @@ public VMTemplateVO createPrivateTemplateRecord(CreateTemplateCmd cmd, Account t
14601460
if (isPublic == null) {
14611461
isPublic = Boolean.FALSE;
14621462
}
1463+
boolean isDynamicScalingEnabled = cmd.isDynamicallyScalable();
14631464
// check whether template owner can create public templates
14641465
boolean allowPublicUserTemplates = Boolean.parseBoolean(_configServer.getConfigValue(Config.AllowPublicUserTemplates.key(),
14651466
Config.ConfigurationParameterScope.account.toString(), templateOwner.getId()));
@@ -1500,6 +1501,7 @@ public VMTemplateVO createPrivateTemplateRecord(CreateTemplateCmd cmd, Account t
15001501
}
15011502
throw new CloudRuntimeException(msg);
15021503
}
1504+
15031505
hyperType = this._volumeDao.getHypervisorType(volumeId);
15041506
} else { // create template from snapshot
15051507
snapshot = _snapshotDao.findById(snapshotId);
@@ -1571,6 +1573,8 @@ public VMTemplateVO createPrivateTemplateRecord(CreateTemplateCmd cmd, Account t
15711573
privateTemplate = new VMTemplateVO(nextTemplateId, uniqueName, name, ImageFormat.RAW, isPublic, featured, isExtractable, TemplateType.USER,
15721574
null, null, requiresHvmValue, bitsValue, templateOwner.getId(), null, description, passwordEnabledValue, guestOS.getId(), true,
15731575
hyperType, templateTag, cmd.getDetails());
1576+
privateTemplate.setDynamicallyScalable(isDynamicScalingEnabled);
1577+
15741578
if (sourceTemplateId != null) {
15751579
if (s_logger.isDebugEnabled()) {
15761580
s_logger.debug("This template is getting created from other template, setting source template Id to: " + sourceTemplateId);

0 commit comments

Comments
 (0)