Skip to content

Commit fdd6b67

Browse files
sudo87sureshanaparti
authored andcommitted
Fix for dynamic scaling toggle for instance (apache#11086)
* Fix for dynamic scaling toggle for instance * Update api/src/main/java/org/apache/cloudstack/api/response/CapabilitiesResponse.java --------- Co-authored-by: Suresh Kumar Anaparti <[email protected]>
1 parent 8b70f94 commit fdd6b67

File tree

6 files changed

+38
-12
lines changed

6 files changed

+38
-12
lines changed

api/src/main/java/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public void execute() {
8282
response.setSharedFsVmMinRamSize((Integer)capabilities.get(ApiConstants.SHAREDFSVM_MIN_RAM_SIZE));
8383
response.setInstanceLeaseEnabled((Boolean) capabilities.get(ApiConstants.INSTANCE_LEASE_ENABLED));
8484
response.setExtensionsPath((String)capabilities.get(ApiConstants.EXTENSIONS_PATH));
85+
response.setDynamicScalingEnabled((Boolean) capabilities.get(ApiConstants.DYNAMIC_SCALING_ENABLED));
8586
response.setObjectName("capability");
8687
response.setResponseName(getCommandName());
8788
this.setResponseObject(response);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ public class CapabilitiesResponse extends BaseResponse {
177177
@Param(description = "The path of the extensions directory", since = "4.21.0", authorized = {RoleType.Admin})
178178
private String extensionsPath;
179179

180+
@SerializedName(ApiConstants.DYNAMIC_SCALING_ENABLED)
181+
@Param(description = "true if dynamically scaling for instances is enabled", since = "4.21.0")
182+
private Boolean dynamicScalingEnabled;
183+
180184
public void setSecurityGroupsEnabled(boolean securityGroupsEnabled) {
181185
this.securityGroupsEnabled = securityGroupsEnabled;
182186
}
@@ -327,4 +331,8 @@ public void setInstanceLeaseEnabled(Boolean instanceLeaseEnabled) {
327331
public void setExtensionsPath(String extensionsPath) {
328332
this.extensionsPath = extensionsPath;
329333
}
334+
335+
public void setDynamicScalingEnabled(Boolean dynamicScalingEnabled) {
336+
this.dynamicScalingEnabled = dynamicScalingEnabled;
337+
}
330338
}

server/src/main/java/com/cloud/server/ManagementServerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5102,6 +5102,7 @@ public Map<String, Object> listCapabilities(final ListCapabilitiesCmd cmd) {
51025102
capabilities.put(ApiConstants.INSTANCES_DISKS_STATS_RETENTION_ENABLED, StatsCollector.vmDiskStatsRetentionEnabled.value());
51035103
capabilities.put(ApiConstants.INSTANCES_DISKS_STATS_RETENTION_TIME, StatsCollector.vmDiskStatsMaxRetentionTime.value());
51045104
capabilities.put(ApiConstants.INSTANCE_LEASE_ENABLED, VMLeaseManager.InstanceLeaseEnabled.value());
5105+
capabilities.put(ApiConstants.DYNAMIC_SCALING_ENABLED, UserVmManager.EnableDynamicallyScaleVm.value());
51055106
if (apiLimitEnabled) {
51065107
capabilities.put("apiLimitInterval", apiLimitInterval);
51075108
capabilities.put("apiLimitMax", apiLimitMax);

ui/src/views/compute/DeployVM.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,7 @@ export default {
15761576
return Boolean('listUserData' in this.$store.getters.apis)
15771577
},
15781578
dynamicScalingVmConfigValue () {
1579-
return this.options.dynamicScalingVmConfig?.[0]?.value === 'true'
1579+
return this.$store.getters.features.dynamicscalingenabled
15801580
},
15811581
isCustomizedDiskIOPS () {
15821582
return this.diskSelected?.iscustomizediops || false
@@ -2750,16 +2750,24 @@ export default {
27502750
param.loading = true
27512751
param.opts = []
27522752
const options = param.options || {}
2753-
if (!('listall' in options) && !['zones', 'pods', 'clusters', 'hosts', 'dynamicScalingVmConfig', 'hypervisors'].includes(name)) {
2753+
if (!('listall' in options) && !['zones', 'pods', 'clusters', 'hosts', 'hypervisors'].includes(name)) {
27542754
options.listall = true
27552755
}
2756-
postAPI(param.list, options).then((response) => {
2756+
getAPI(param.list, options).then((response) => {
27572757
param.loading = false
27582758
_.map(response, (responseItem, responseKey) => {
27592759
if (Object.keys(responseItem).length === 0) {
27602760
this.rowCount[name] = 0
27612761
this.options[name] = []
2762-
return resolve(null)
2762+
return
2763+
}
2764+
if (!responseKey.includes('response')) {
2765+
return
2766+
}
2767+
_.map(responseItem, (response, key) => {
2768+
if (key === 'count') {
2769+
this.rowCount[name] = response
2770+
return
27632771
}
27642772
if (!responseKey.includes('response')) {
27652773
return resolve(null)

ui/src/views/compute/DeployVnfAppliance.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,7 @@ export default {
952952
keyboards: [],
953953
bootTypes: [],
954954
bootModes: [],
955-
ioPolicyTypes: [],
956-
dynamicScalingVmConfig: false
955+
ioPolicyTypes: []
957956
},
958957
rowCount: {},
959958
loading: {
@@ -1330,7 +1329,7 @@ export default {
13301329
return Boolean('listUserData' in this.$store.getters.apis)
13311330
},
13321331
dynamicScalingVmConfigValue () {
1333-
return this.options.dynamicScalingVmConfig?.[0]?.value === 'true'
1332+
return this.$store.getters.features.dynamicscalingenabled
13341333
},
13351334
isCustomizedDiskIOPS () {
13361335
return this.diskSelected?.iscustomizediops || false
@@ -2475,16 +2474,24 @@ export default {
24752474
param.loading = true
24762475
param.opts = []
24772476
const options = param.options || {}
2478-
if (!('listall' in options) && !['zones', 'pods', 'clusters', 'hosts', 'dynamicScalingVmConfig', 'hypervisors'].includes(name)) {
2477+
if (!('listall' in options) && !['zones', 'pods', 'clusters', 'hosts', 'hypervisors'].includes(name)) {
24792478
options.listall = true
24802479
}
2481-
postAPI(param.list, options).then((response) => {
2480+
getAPI(param.list, options).then((response) => {
24822481
param.loading = false
24832482
_.map(response, (responseItem, responseKey) => {
24842483
if (Object.keys(responseItem).length === 0) {
24852484
this.rowCount[name] = 0
24862485
this.options[name] = []
2487-
return resolve(null)
2486+
return
2487+
}
2488+
if (!responseKey.includes('response')) {
2489+
return
2490+
}
2491+
_.map(responseItem, (response, key) => {
2492+
if (key === 'count') {
2493+
this.rowCount[name] = response
2494+
return
24882495
}
24892496
if (!responseKey.includes('response')) {
24902497
return resolve(null)

ui/src/views/compute/EditVM.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ export default {
179179
template: {},
180180
userDataEnabled: false,
181181
securityGroupsEnabled: false,
182-
dynamicScalingVmConfig: false,
183182
loading: false,
184183
securitygroups: {
185184
loading: false,
@@ -239,7 +238,6 @@ export default {
239238
this.fetchInstaceGroups()
240239
this.fetchServiceOfferingData()
241240
this.fetchTemplateData()
242-
this.fetchDynamicScalingVmConfig()
243241
this.fetchUserData()
244242
},
245243
fetchZoneDetails () {
@@ -304,6 +302,9 @@ export default {
304302
canDynamicScalingEnabled () {
305303
return this.template.isdynamicallyscalable && this.serviceOffering.dynamicscalingenabled && this.dynamicScalingVmConfig
306304
},
305+
isDynamicScalingEnabled () {
306+
return this.template.isdynamicallyscalable && this.serviceOffering.dynamicscalingenabled && this.$store.getters.features.dynamicscalingenabled
307+
},
307308
fetchOsTypes () {
308309
this.osTypes.loading = true
309310
this.osTypes.opts = []

0 commit comments

Comments
 (0)