Skip to content

Commit 083646b

Browse files
server: VM dynamic scaling option granularity (#4643)
This PR introduces new granularity levels to configure VM dynamic scalability. Previously VM is configured to be dynamically scalable based on the template and global setting. Now we bringing this option to configure at service offering and VM level also. VM can dynamically scale only when all flags are ON at VM level, template, service offering and global setting. If any of the flags is set to false then VM cannot be scalable. This result will be persisted in DB for each VM and will be honoured for that VM till it is updated. We are introducing 'dynamicscalingallowed' parameter with permitted values of true or false for deployVM API and createServiceOffering API. Following are the API parameter changes: createServiceOffering API: dynamicscalingenabled: an optional parameter of type Boolean with default value “true”. deployVirtualMachine API: dynamicscalingenabled: an optional parameter of type Boolean with default value “true”. Following are the UI changes: Service offering creation has ON/OFF switch for dynamic scaling enabled with default value true
1 parent 1286ffd commit 083646b

File tree

41 files changed

+616
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+616
-113
lines changed

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 isDynamicScalingEnabled();
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
@@ -342,4 +342,6 @@ public boolean isUsedBySystem() {
342342
@Override
343343
boolean isDisplay();
344344

345+
boolean isDynamicallyScalable();
346+
345347
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@ public class ApiConstants {
838838
public static final String CROSS_ZONES = "crossZones";
839839
public static final String TEMPLATETYPE = "templatetype";
840840
public static final String SOURCETEMPLATEID = "sourcetemplateid";
841+
public static final String DYNAMIC_SCALING_ENABLED = "dynamicscalingenabled";
841842

842843
public static final String POOL_TYPE ="pooltype";
843844

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ 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.DYNAMIC_SCALING_ENABLED, type = CommandType.BOOLEAN, since = "4.16",
227+
description = "true if virtual machine needs to be dynamically scalable of cpu or memory")
228+
protected Boolean isDynamicScalingEnabled;
229+
226230
/////////////////////////////////////////////////////
227231
/////////////////// Accessors ///////////////////////
228232
/////////////////////////////////////////////////////
@@ -441,6 +445,10 @@ public Long getStoragePolicy() {
441445
return storagePolicy;
442446
}
443447

448+
public boolean getDynamicScalingEnabled() {
449+
return isDynamicScalingEnabled == null ? true : isDynamicScalingEnabled;
450+
}
451+
444452
/////////////////////////////////////////////////////
445453
/////////////// API Implementation///////////////////
446454
/////////////////////////////////////////////////////

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

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

238+
@Parameter(name = ApiConstants.DYNAMIC_SCALING_ENABLED, type = CommandType.BOOLEAN, since = "4.16",
239+
description = "true if virtual machine needs to be dynamically scalable")
240+
protected Boolean dynamicScalingEnabled;
241+
238242
/////////////////////////////////////////////////////
239243
/////////////////// Accessors ///////////////////////
240244
/////////////////////////////////////////////////////
@@ -623,6 +627,10 @@ public Boolean getBootIntoSetup() {
623627
return bootIntoSetup;
624628
}
625629

630+
public boolean isDynamicScalingEnabled() {
631+
return dynamicScalingEnabled == null ? true : dynamicScalingEnabled;
632+
}
633+
626634
/////////////////////////////////////////////////////
627635
/////////////// API Implementation///////////////////
628636
/////////////////////////////////////////////////////

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public class UpdateVMCmd extends BaseCustomIdCmd implements SecurityGroupAction,
8989

9090
@Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE,
9191
type = CommandType.BOOLEAN,
92-
description = "true if VM contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory")
92+
description = "true if VM contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory. This can be updated only when dynamic scaling is enabled on template, service offering and the corresponding global setting")
9393
protected Boolean isDynamicallyScalable;
9494

9595
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "new host name of the vm. The VM has to be stopped/started for this update to take affect", since = "4.4")

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(ApiConstants.DYNAMIC_SCALING_ENABLED)
208+
@Param(description = "true if virtual machine needs to be dynamically scalable of cpu or memory", since = "4.16")
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3917,6 +3917,9 @@ public boolean upgradeVmDb(final long vmId, final ServiceOffering newServiceOffe
39173917
if (currentServiceOffering.isDynamic() && !newServiceOffering.isDynamic()) {
39183918
removeCustomOfferingDetails(vmId);
39193919
}
3920+
VMTemplateVO template = _templateDao.findById(vmForUpdate.getTemplateId());
3921+
boolean dynamicScalingEnabled = _userVmMgr.checkIfDynamicScalingCanBeEnabled(vmForUpdate, newServiceOffering, template, vmForUpdate.getDataCenterId());
3922+
vmForUpdate.setDynamicallyScalable(dynamicScalingEnabled);
39203923
return _vmDao.update(vmId, vmForUpdate);
39213924
}
39223925

0 commit comments

Comments
 (0)