Skip to content

Commit b60de9c

Browse files
Dynamic Scaling option granularity
1 parent ff376d8 commit b60de9c

24 files changed

Lines changed: 254 additions & 91 deletions

File tree

api/src/main/java/com/cloud/offering/ServiceOffering.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,6 @@ public enum StorageType {
116116
String getDeploymentPlanner();
117117

118118
boolean isDynamic();
119+
120+
boolean isDynamicallyScalable();
119121
}

api/src/main/java/com/cloud/vm/UserVmService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering s
218218
String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIp, Boolean displayVm, String keyboard,
219219
List<Long> affinityGroupIdList, Map<String, String> customParameter, String customId, Map<String, Map<Integer, String>> dhcpOptionMap,
220220
Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap,
221-
Map<String, String> userVmOVFProperties) throws InsufficientCapacityException,
221+
Map<String, String> userVmOVFProperties, Boolean dynamicScalingEnabled) throws InsufficientCapacityException,
222222
ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
223223

224224
/**
@@ -300,7 +300,7 @@ UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOfferin
300300
HTTPMethod httpmethod, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard,
301301
List<Long> affinityGroupIdList, Map<String, String> customParameters, String customId, Map<String, Map<Integer, String>> dhcpOptionMap,
302302
Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap,
303-
Map<String, String> userVmOVFProperties) throws InsufficientCapacityException,
303+
Map<String, String> userVmOVFProperties, Boolean dynamicScalingEnabled) throws InsufficientCapacityException,
304304
ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
305305

306306
/**
@@ -379,7 +379,7 @@ UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffe
379379
String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData,
380380
String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList,
381381
Map<String, String> customParameters, String customId, Map<String, Map<Integer, String>> dhcpOptionMap, Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap,
382-
Map<String, String> templateOvfPropertiesMap)
382+
Map<String, String> templateOvfPropertiesMap, Boolean dynamicScalingEnabled)
383383

384384
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
385385

api/src/main/java/com/cloud/vm/VirtualMachine.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,4 +339,6 @@ public boolean isUsedBySystem() {
339339
@Override
340340
boolean isDisplay();
341341

342+
Boolean isDynamicallyScalable();
343+
342344
}

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,7 @@ public class ApiConstants {
831831
public static final String CROSS_ZONES = "crossZones";
832832
public static final String TEMPLATETYPE = "templatetype";
833833
public static final String SOURCETEMPLATEID = "sourcetemplateid";
834+
public static final String DynamicScalingEnabled = "dynamicscalingenabled";
834835

835836
public enum BootType {
836837
UEFI, BIOS;

api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ public class CreateServiceOfferingCmd extends BaseCmd {
223223
@Parameter(name = ApiConstants.STORAGE_POLICY, type = CommandType.UUID, entityType = VsphereStoragePoliciesResponse.class,required = false, description = "Name of the storage policy defined at vCenter, this is applicable only for VMware", since = "4.15")
224224
private Long storagePolicy;
225225

226+
@Parameter(name = ApiConstants.DynamicScalingEnabled,
227+
type = CommandType.BOOLEAN,
228+
description = "true if virtual machine needs to be dynamically scalable of cpu or memory")
229+
protected Boolean isDynamicScalingEnabled;
230+
226231
/////////////////////////////////////////////////////
227232
/////////////////// Accessors ///////////////////////
228233
/////////////////////////////////////////////////////
@@ -433,6 +438,10 @@ public Long getStoragePolicy() {
433438
return storagePolicy;
434439
}
435440

441+
public Boolean getDynamicScalingEnabled() {
442+
return isDynamicScalingEnabled == null ? Boolean.TRUE : isDynamicScalingEnabled;
443+
}
444+
436445
/////////////////////////////////////////////////////
437446
/////////////// API Implementation///////////////////
438447
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG
235235
@LogLevel(LogLevel.Log4jLevel.Off)
236236
private Map vAppNetworks;
237237

238+
@Parameter(name = ApiConstants.DynamicScalingEnabled,
239+
type = CommandType.BOOLEAN,
240+
description = "true if virtual machine needs to be dynamically scalable")
241+
protected Boolean isDynamicScalingEnabled;
242+
238243
/////////////////////////////////////////////////////
239244
/////////////////// Accessors ///////////////////////
240245
/////////////////////////////////////////////////////
@@ -623,6 +628,10 @@ public Boolean getBootIntoSetup() {
623628
return bootIntoSetup;
624629
}
625630

631+
public Boolean getDynamicScalingEnabled() {
632+
return isDynamicScalingEnabled == null ? Boolean.TRUE : isDynamicScalingEnabled;
633+
}
634+
626635
/////////////////////////////////////////////////////
627636
/////////////// API Implementation///////////////////
628637
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/response/ServiceOfferingResponse.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ public class ServiceOfferingResponse extends BaseResponse {
204204
@Param(description = "Root disk size in GB", since = "4.15")
205205
private Long rootDiskSize;
206206

207+
@SerializedName("dynamicscalingenabled")
208+
@Param(description = "true if virtual machine needs to be dynamically scalable of cpu or memory")
209+
private Boolean dynamicscalingenabled;
210+
207211
public ServiceOfferingResponse() {
208212
}
209213

@@ -457,7 +461,6 @@ public void setDetails(Map<String, String> details) {
457461

458462
public void setIscutomized(boolean iscutomized) {
459463
this.isCustomized = iscutomized;
460-
461464
}
462465

463466
public void setCacheMode(String cacheMode) {
@@ -475,4 +478,12 @@ public void setVsphereStoragePolicy(String vsphereStoragePolicy) {
475478
public void setRootDiskSize(Long rootDiskSize) {
476479
this.rootDiskSize = rootDiskSize;
477480
}
481+
482+
public Boolean getDynamicscalingenabled() {
483+
return dynamicscalingenabled;
484+
}
485+
486+
public void setDynamicscalingenabled(Boolean dynamicscalingenabled) {
487+
this.dynamicscalingenabled = dynamicscalingenabled;
488+
}
478489
}

api/src/main/java/org/apache/cloudstack/api/response/SystemVmResponse.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ public class SystemVmResponse extends BaseResponse {
170170
@Param(description = "the systemvm agent version", since = "4.13.1")
171171
private String version;
172172

173+
@SerializedName(ApiConstants.IS_DYNAMICALLY_SCALABLE)
174+
@Param(description = "true if vm contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory.")
175+
private Boolean isDynamicallyScalable;
176+
173177
@Override
174178
public String getObjectId() {
175179
return this.getId();
@@ -442,4 +446,12 @@ public String getVersion() {
442446
public void setVersion(String version) {
443447
this.version = version;
444448
}
449+
450+
public Boolean getDynamicallyScalable() {
451+
return isDynamicallyScalable;
452+
}
453+
454+
public void setDynamicallyScalable(Boolean dynamicallyScalable) {
455+
isDynamicallyScalable = dynamicallyScalable;
456+
}
445457
}

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3685,6 +3685,8 @@ public boolean upgradeVmDb(final long vmId, final ServiceOffering newServiceOffe
36853685
if (currentServiceOffering.isDynamic() && !newServiceOffering.isDynamic()) {
36863686
removeCustomOfferingDetails(vmId);
36873687
}
3688+
Boolean dynamicScalingEnabled = vmForUpdate.isDynamicallyScalable() && newServiceOffering.isDynamicallyScalable() && UserVmManager.EnableDynamicallyScaleVm.valueIn(vmForUpdate.getDataCenterId());
3689+
vmForUpdate.setDynamicallyScalable(dynamicScalingEnabled);
36883690
return _vmDao.update(vmId, vmForUpdate);
36893691
}
36903692

engine/schema/src/main/java/com/cloud/service/ServiceOfferingVO.java

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
7575
@Column(name = "deployment_planner")
7676
private String deploymentPlanner = null;
7777

78+
@Column(name = "dynamically_scalable")
79+
private boolean dynamicallyScalable;
80+
7881
// This is a delayed load value. If the value is null,
7982
// then this field has not been loaded yet.
8083
// Call service offering dao to load it.
@@ -91,7 +94,7 @@ protected ServiceOfferingVO() {
9194
}
9295

9396
public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText,
94-
ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vmType, boolean defaultUse) {
97+
ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vmType, boolean defaultUse) {
9598
super(name, displayText, provisioningType, false, tags, recreatable, useLocalStorage, systemUse, true);
9699
this.cpu = cpu;
97100
this.ramSize = ramSize;
@@ -105,64 +108,22 @@ public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer spee
105108
this.vmType = vmType == null ? null : vmType.toString().toLowerCase();
106109
}
107110

108-
public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, boolean limitCpuUse,
109-
boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vmType) {
111+
public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA,
112+
boolean limitResourceUse, boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse,
113+
VirtualMachine.Type vmType, String hostTag, String deploymentPlanner, Boolean dynamicScalingEnabled) {
110114
super(name, displayText, provisioningType, false, tags, recreatable, useLocalStorage, systemUse, true);
111115
this.cpu = cpu;
112116
this.ramSize = ramSize;
113117
this.speed = speed;
114118
this.rateMbps = rateMbps;
115119
this.multicastRateMbps = multicastRateMbps;
116120
this.offerHA = offerHA;
117-
this.limitCpuUse = limitCpuUse;
121+
this.limitCpuUse = limitResourceUse;
118122
this.volatileVm = volatileVm;
119123
this.vmType = vmType == null ? null : vmType.toString().toLowerCase();
120-
}
121-
122-
public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA,
123-
boolean limitResourceUse, boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse,
124-
VirtualMachine.Type vmType, String hostTag) {
125-
this(name,
126-
cpu,
127-
ramSize,
128-
speed,
129-
rateMbps,
130-
multicastRateMbps,
131-
offerHA,
132-
limitResourceUse,
133-
volatileVm,
134-
displayText,
135-
provisioningType,
136-
useLocalStorage,
137-
recreatable,
138-
tags,
139-
systemUse,
140-
vmType
141-
);
142124
this.hostTag = hostTag;
143-
}
144-
145-
public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA,
146-
boolean limitResourceUse, boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse,
147-
VirtualMachine.Type vmType, String hostTag, String deploymentPlanner) {
148-
this(name,
149-
cpu,
150-
ramSize,
151-
speed,
152-
rateMbps,
153-
multicastRateMbps,
154-
offerHA,
155-
limitResourceUse,
156-
volatileVm,
157-
displayText,
158-
provisioningType,
159-
useLocalStorage,
160-
recreatable,
161-
tags,
162-
systemUse,
163-
vmType,
164-
hostTag);
165125
this.deploymentPlanner = deploymentPlanner;
126+
this.dynamicallyScalable = dynamicScalingEnabled;
166127
}
167128

168129
public ServiceOfferingVO(ServiceOfferingVO offering) {
@@ -189,6 +150,7 @@ public ServiceOfferingVO(ServiceOfferingVO offering) {
189150
volatileVm = offering.isVolatileVm();
190151
hostTag = offering.getHostTag();
191152
vmType = offering.getSystemVmType();
153+
dynamicallyScalable = offering.isDynamicallyScalable();
192154
}
193155

194156
@Override
@@ -334,4 +296,13 @@ public void setDynamicFlag(boolean isdynamic) {
334296
public boolean isCustomCpuSpeedSupported() {
335297
return isCustomized() && getDetail("minCPU") != null;
336298
}
299+
300+
@Override
301+
public boolean isDynamicallyScalable() {
302+
return dynamicallyScalable;
303+
}
304+
305+
public void setDynamicallyScalable(boolean dynamicallyScalable) {
306+
this.dynamicallyScalable = dynamicallyScalable;
307+
}
337308
}

0 commit comments

Comments
 (0)