Skip to content

Commit 10d0953

Browse files
Grey out dynamic scale VM flag on Edit VM dialog if dynamic scaling is not enabled on template, service offering and global setting.
1 parent 4b93c40 commit 10d0953

4 files changed

Lines changed: 49 additions & 6 deletions

File tree

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")

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,13 +2782,14 @@ public UserVm updateVirtualMachine(long id, String displayName, String group, Bo
27822782
if (isDynamicallyScalable == true) {
27832783
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(vm.getTemplateId());
27842784
if (!template.isDynamicallyScalable()) {
2785-
throw new InvalidParameterValueException("Dynamic Scaling cannot be enabled on the VM since template is not dynamic scaling enabled");
2785+
throw new InvalidParameterValueException("Dynamic Scaling cannot be enabled for the VM since its template does not have dynamic scaling enabled");
27862786
}
27872787
if (!offering.isDynamicScalingEnabled()) {
2788-
throw new InvalidParameterValueException("Dynamic Scaling cannot be enabled on the VM since service offering is not dynamic scaling enabled");
2788+
throw new InvalidParameterValueException("Dynamic Scaling cannot be enabled for the VM since its service offering does not have dynamic scaling enabled");
27892789
}
27902790
if (!UserVmManager.EnableDynamicallyScaleVm.valueIn(vm.getDataCenterId())) {
2791-
throw new InvalidParameterValueException("Dynamic Scaling cannot be enabled on the VM since corresponding global setting is false");
2791+
s_logger.debug(String.format("Dynamic Scaling cannot be enabled for the VM %s since the global setting enable.dynamic.scale.vm is set to false", vm.getUuid()));
2792+
throw new InvalidParameterValueException("Dynamic Scaling cannot be enabled for the VM since corresponding global setting is set to false");
27922793
}
27932794
}
27942795
}

ui/public/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@
811811
"label.driver": "Driver",
812812
"label.duration.in.sec": "Duration (in sec)",
813813
"label.dynamicscalingenabled": "Dynamic Scaling Enabled",
814-
"label.dynamicscalingenabled.tooltip": "VM can dynamically scale only when dynamic scalability is enabled on template, service offering and global setting",
814+
"label.dynamicscalingenabled.tooltip": "VM can dynamically scale only when dynamic scaling is enabled on template, service offering and global setting",
815815
"label.edit": "Edit",
816816
"label.edit.acl.list": "Edit ACL List",
817817
"label.edit.acl.rule": "Edit ACL rule",

ui/src/views/compute/EditVM.vue

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
</span>
7373
<a-switch
7474
:default-checked="resource.isdynamicallyscalable"
75-
v-decorator="['isdynamicallyscalable']" />
75+
v-decorator="['isdynamicallyscalable']"
76+
:disabled="!canDynamicScalingEnabled()" />
7677
</a-form-item>
7778
<a-form-item>
7879
<span slot="label">
@@ -125,6 +126,9 @@ export default {
125126
},
126127
data () {
127128
return {
129+
serviceOffering: {},
130+
template: {},
131+
dynamicScalingVmConfig: false,
128132
loading: false,
129133
osTypes: {
130134
loading: false,
@@ -151,6 +155,44 @@ export default {
151155
fetchData () {
152156
this.fetchOsTypes()
153157
this.fetchInstaceGroups()
158+
this.fetchServiceOfferingData()
159+
this.fetchTemplateData()
160+
this.fetchDynamicScalingVmConfig()
161+
},
162+
fetchServiceOfferingData () {
163+
const params = {}
164+
params.id = this.resource.serviceofferingid
165+
params.isrecursive = true
166+
var apiName = 'listServiceOfferings'
167+
api(apiName, params).then(json => {
168+
const offerings = json.listserviceofferingsresponse.serviceoffering
169+
this.serviceOffering = offerings[0]
170+
})
171+
},
172+
fetchTemplateData () {
173+
const params = {}
174+
console.log('templateid ' + this.resource.templateid)
175+
params.id = this.resource.templateid
176+
params.isrecursive = true
177+
params.templatefilter = 'all'
178+
var apiName = 'listTemplates'
179+
api(apiName, params).then(json => {
180+
const templateResponses = json.listtemplatesresponse.template
181+
this.template = templateResponses[0]
182+
})
183+
},
184+
fetchDynamicScalingVmConfig () {
185+
const params = {}
186+
params.name = 'enable.dynamic.scale.vm'
187+
params.zoneid = this.resource.zoneid
188+
var apiName = 'listConfigurations'
189+
api(apiName, params).then(json => {
190+
const configResponse = json.listconfigurationsresponse.configuration
191+
this.dynamicScalingVmConfig = configResponse[0]?.value === 'true'
192+
})
193+
},
194+
canDynamicScalingEnabled () {
195+
return this.template.isdynamicallyscalable && this.serviceOffering.dynamicscalingenabled && this.dynamicScalingVmConfig
154196
},
155197
fetchOsTypes () {
156198
this.osTypes.loading = true

0 commit comments

Comments
 (0)