Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ public Long getSize() {
return size;
}

public void setSize(Long size) {
this.size = size;
}

public Long getMinIops() {
return minIops;
}
Expand Down
7 changes: 7 additions & 0 deletions server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,7 @@ private void changeDiskOfferingForRootVolume(Long vmId, DiskOfferingVO newDiskOf
Long maxIopsInNewDiskOffering = null;
boolean autoMigrate = false;
boolean shrinkOk = false;
Long rootDiskSize = null;
if (customParameters.containsKey(ApiConstants.MIN_IOPS)) {
minIopsInNewDiskOffering = Long.parseLong(customParameters.get(ApiConstants.MIN_IOPS));
}
Expand All @@ -2046,7 +2047,13 @@ private void changeDiskOfferingForRootVolume(Long vmId, DiskOfferingVO newDiskOf
if (customParameters.containsKey(ApiConstants.SHRINK_OK)) {
shrinkOk = Boolean.parseBoolean(customParameters.get(ApiConstants.SHRINK_OK));
}
if (customParameters.containsKey(ApiConstants.ROOT_DISK_SIZE)) {
rootDiskSize = Long.parseLong(customParameters.get(ApiConstants.ROOT_DISK_SIZE));
}
ChangeOfferingForVolumeCmd changeOfferingForVolumeCmd = new ChangeOfferingForVolumeCmd(rootVolumeOfVm.getId(), newDiskOffering.getId(), minIopsInNewDiskOffering, maxIopsInNewDiskOffering, autoMigrate, shrinkOk);
if (rootDiskSize != null) {
changeOfferingForVolumeCmd.setSize(rootDiskSize);
}
Volume result = _volumeService.changeDiskOfferingForVolume(changeOfferingForVolumeCmd);
if (result == null) {
throw new CloudRuntimeException("Failed to change disk offering of the root volume");
Expand Down
57 changes: 55 additions & 2 deletions ui/src/views/compute/ScaleVM.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@
@update-compute-cpuspeed="updateFieldValue"
@update-compute-memory="updateFieldValue" />

<disk-size-selection
v-if="selectedDiskOffering && (selectedDiskOffering.iscustomized || selectedDiskOffering.iscustomizediops)"
:inputDecorator="rootDiskSizeKey"
:minDiskSize="minDiskSize"
:rootDiskSelected="selectedDiskOffering"
:isCustomized="selectedDiskOffering.iscustomized"
@handler-error="handlerError"
@update-disk-size="updateFieldValue"
@update-root-disk-iops-value="updateIOPSValue"/>

<a-form-item :label="$t('label.automigrate.volume')">
<tooltip-label slot="label" :title="$t('label.automigrate.volume')" :tooltip="apiParams.automigrate.description"/>
<a-switch
Expand All @@ -72,12 +82,14 @@
import { api } from '@/api'
import ComputeOfferingSelection from '@views/compute/wizard/ComputeOfferingSelection'
import ComputeSelection from '@views/compute/wizard/ComputeSelection'
import DiskSizeSelection from '@views/compute/wizard/DiskSizeSelection'

export default {
name: 'ScaleVM',
components: {
ComputeOfferingSelection,
ComputeSelection
ComputeSelection,
DiskSizeSelection
},
props: {
resource: {
Expand All @@ -91,14 +103,19 @@ export default {
offeringsMap: {},
offerings: [],
selectedOffering: {},
selectedDiskOffering: {},
autoMigrate: true,
total: 0,
params: { id: this.resource.id },
loading: false,
cpuNumberKey: 'details[0].cpuNumber',
cpuSpeedKey: 'details[0].cpuSpeed',
memoryKey: 'details[0].memory',
fixedOfferingKvm: false
rootDiskSizeKey: 'details[0].rootdisksize',
minIopsKey: 'details[0].minIops',
maxIopsKey: 'details[0].maxIops',
fixedOfferingKvm: false,
minDiskSize: 0
}
},
beforeCreate () {
Expand Down Expand Up @@ -162,14 +179,37 @@ export default {
if (this.resource.state === 'Running') {
return this.resource.cpuspeed
}
this.getMinDiskSize()
return this.selectedOffering?.serviceofferingdetails?.cpuspeed * 1 || 1
},
getTemplate () {
return new Promise((resolve, reject) => {
api('listTemplates', {
templatefilter: 'all',
id: this.resource.templateid
}).then(response => {
var template = response?.listtemplatesresponse?.template?.[0] || null
resolve(template)
}).catch(error => {
reject(error)
})
})
},
async getMinDiskSize () {
const template = await this.getTemplate()
this.minDiskSize = Math.ceil(template?.size / (1024 * 1024 * 1024) || 0)
},
getMessage () {
if (this.resource.hypervisor === 'VMware') {
return this.$t('message.read.admin.guide.scaling.up')
}
return this.$t('message.change.offering.confirm')
},
updateIOPSValue (input, value) {
console.log(input)
const key = input === 'minIops' ? this.minIopsKey : this.maxIopsKey
this.params[key] = value
},
updateComputeOffering (id) {
// Delete custom details
delete this.params[this.cpuNumberKey]
Expand All @@ -178,6 +218,16 @@ export default {

this.params.serviceofferingid = id
this.selectedOffering = this.offeringsMap[id]
api('listDiskOfferings', {
id: this.selectedOffering.diskofferingid
}).then(response => {
const diskOfferings = response.listdiskofferingsresponse.diskoffering || []
if (this.offerings) {
this.selectedDiskOffering = diskOfferings[0]
}
}).catch(error => {
this.$notifyError(error)
})
this.params.automigrate = this.autoMigrate
},
updateFieldValue (name, value) {
Expand All @@ -186,6 +236,9 @@ export default {
closeAction () {
this.$emit('close-action')
},
handlerError (error) {
this.error = error
},
handleSubmit () {
if (this.loading) return
this.loading = true
Expand Down
4 changes: 2 additions & 2 deletions ui/src/views/compute/wizard/DiskSizeSelection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ export default {
fillValue () {
this.inputValue = this.minDiskSize
if (this.inputDecorator === 'rootdisksize') {
this.inputValue = this.preFillContent.rootdisksize ? this.preFillContent.rootdisksize : this.minDiskSize
this.inputValue = this.preFillContent?.rootdisksize ? this.preFillContent.rootdisksize : this.minDiskSize
} else if (this.inputDecorator === 'size') {
this.inputValue = this.preFillContent.size ? this.preFillContent.size : this.minDiskSize
this.inputValue = this.preFillContent?.size ? this.preFillContent.size : this.minDiskSize
}
this.$emit('update-disk-size', this.inputDecorator, this.inputValue)
},
Expand Down