From 8153f2db0b104e51260008d83e1e177e183264da Mon Sep 17 00:00:00 2001 From: utchoang Date: Tue, 31 Aug 2021 14:33:29 +0700 Subject: [PATCH 1/5] scale VM: fix compute offering selection not working --- ui/src/components/view/InfoCard.vue | 2 +- ui/src/views/compute/DeployVM.vue | 20 ++++++++++++++++---- ui/src/views/compute/ScaleVM.vue | 18 ++++++++++++++---- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/ui/src/components/view/InfoCard.vue b/ui/src/components/view/InfoCard.vue index 5fd0fab1a376..51d91c04a521 100644 --- a/ui/src/components/view/InfoCard.vue +++ b/ui/src/components/view/InfoCard.vue @@ -26,7 +26,7 @@ @click="$message.success(`${$t('label.copied.clipboard')} : ${name}`)" v-clipboard:copy="name" > - + diff --git a/ui/src/views/compute/DeployVM.vue b/ui/src/views/compute/DeployVM.vue index b1c24ccdd406..7866d1069243 100644 --- a/ui/src/views/compute/DeployVM.vue +++ b/ui/src/views/compute/DeployVM.vue @@ -210,10 +210,10 @@ :preFillContent="dataPreFill" :computeOfferingId="instanceConfig.computeofferingid" :isConstrained="'serviceofferingdetails' in serviceOffering" - :minCpu="'serviceofferingdetails' in serviceOffering ? serviceOffering.serviceofferingdetails.mincpunumber*1 : 0" - :maxCpu="'serviceofferingdetails' in serviceOffering ? serviceOffering.serviceofferingdetails.maxcpunumber*1 : Number.MAX_SAFE_INTEGER" - :minMemory="'serviceofferingdetails' in serviceOffering ? serviceOffering.serviceofferingdetails.minmemory*1 : 0" - :maxMemory="'serviceofferingdetails' in serviceOffering ? serviceOffering.serviceofferingdetails.maxmemory*1 : Number.MAX_SAFE_INTEGER" + :minCpu="getMinCpu()" + :maxCpu="getMaxCpu()" + :minMemory="getMinMemory()" + :maxMemory="getMaxMemory()" :isCustomized="serviceOffering.iscustomized" :isCustomizedIOps="'iscustomizediops' in serviceOffering && serviceOffering.iscustomizediops" @handler-error="handlerError" @@ -2035,6 +2035,18 @@ export default { }, updateIOPSValue (input, value) { this[input] = value + }, + getMinCpu () { + return this.serviceOffering?.serviceofferingdetails?.mincpunumber * 1 || 0 + }, + getMaxCpu () { + return this.serviceOffering?.serviceofferingdetails?.maxcpunumber * 1 || Number.MAX_SAFE_INTEGER + }, + getMinMemory () { + return this.serviceOffering?.serviceofferingdetails?.minmemory * 1 || 0 + }, + getMaxMemory () { + return this.serviceOffering?.serviceofferingdetails?.maxmemory * 1 || Number.MAX_SAFE_INTEGER } } } diff --git a/ui/src/views/compute/ScaleVM.vue b/ui/src/views/compute/ScaleVM.vue index f26534051517..ed933c41e5ba 100644 --- a/ui/src/views/compute/ScaleVM.vue +++ b/ui/src/views/compute/ScaleVM.vue @@ -39,9 +39,11 @@ :computeOfferingId="selectedOffering.id" :isConstrained="'serviceofferingdetails' in selectedOffering" :minCpu="getMinCpu()" - :maxCpu="'serviceofferingdetails' in selectedOffering ? selectedOffering.serviceofferingdetails.maxcpunumber*1 : Number.MAX_SAFE_INTEGER" + :maxCpu="getMaxCpu()" :minMemory="getMinMemory()" - :maxMemory="'serviceofferingdetails' in selectedOffering ? selectedOffering.serviceofferingdetails.maxmemory*1 : Number.MAX_SAFE_INTEGER" + :maxMemory="getMaxMemory()" + :isCustomized="selectedOffering.iscustomized" + :isCustomizedIOps="'iscustomizediops' in selectedOffering && selectedOffering.iscustomizediops" @update-compute-cpunumber="updateFieldValue" @update-compute-cpuspeed="updateFieldValue" @update-compute-memory="updateFieldValue" /> @@ -120,14 +122,22 @@ export default { if (this.resource.state === 'Running') { return this.resource.cpunumber } - return 'serviceofferingdetails' in this.selectedOffering ? this.selectedOffering.serviceofferingdetails.mincpunumber * 1 : 1 + + return this.selectedOffering?.serviceofferingdetails?.mincpunumber * 1 || 1 + }, + getMaxCpu () { + return this.selectedOffering?.serviceofferingdetails?.maxcpunumber * 1 || Number.MAX_SAFE_INTEGER }, getMinMemory () { // We can only scale up while a VM is running if (this.resource.state === 'Running') { return this.resource.memory } - return 'serviceofferingdetails' in this.selectedOffering ? this.selectedOffering.serviceofferingdetails.minmemory * 1 : 32 + + return this.selectedOffering?.serviceofferingdetails?.minmemory * 1 || 32 + }, + getMaxMemory () { + return this.selectedOffering?.serviceofferingdetails?.maxmemory * 1 || Number.MAX_SAFE_INTEGER }, getMessage () { if (this.resource.hypervisor === 'VMware') { From 610fcbb53058946a8853cbd99322ba2f1d9b74a7 Mon Sep 17 00:00:00 2001 From: utchoang Date: Wed, 1 Sep 2021 11:59:12 +0700 Subject: [PATCH 2/5] hidden slider when cpuspeed empty & show customiops --- ui/src/views/compute/DeployVM.vue | 20 ++++--------------- ui/src/views/compute/ScaleVM.vue | 14 +++---------- .../views/compute/wizard/ComputeSelection.vue | 13 +++++++++--- 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/ui/src/views/compute/DeployVM.vue b/ui/src/views/compute/DeployVM.vue index 7866d1069243..b1c24ccdd406 100644 --- a/ui/src/views/compute/DeployVM.vue +++ b/ui/src/views/compute/DeployVM.vue @@ -210,10 +210,10 @@ :preFillContent="dataPreFill" :computeOfferingId="instanceConfig.computeofferingid" :isConstrained="'serviceofferingdetails' in serviceOffering" - :minCpu="getMinCpu()" - :maxCpu="getMaxCpu()" - :minMemory="getMinMemory()" - :maxMemory="getMaxMemory()" + :minCpu="'serviceofferingdetails' in serviceOffering ? serviceOffering.serviceofferingdetails.mincpunumber*1 : 0" + :maxCpu="'serviceofferingdetails' in serviceOffering ? serviceOffering.serviceofferingdetails.maxcpunumber*1 : Number.MAX_SAFE_INTEGER" + :minMemory="'serviceofferingdetails' in serviceOffering ? serviceOffering.serviceofferingdetails.minmemory*1 : 0" + :maxMemory="'serviceofferingdetails' in serviceOffering ? serviceOffering.serviceofferingdetails.maxmemory*1 : Number.MAX_SAFE_INTEGER" :isCustomized="serviceOffering.iscustomized" :isCustomizedIOps="'iscustomizediops' in serviceOffering && serviceOffering.iscustomizediops" @handler-error="handlerError" @@ -2035,18 +2035,6 @@ export default { }, updateIOPSValue (input, value) { this[input] = value - }, - getMinCpu () { - return this.serviceOffering?.serviceofferingdetails?.mincpunumber * 1 || 0 - }, - getMaxCpu () { - return this.serviceOffering?.serviceofferingdetails?.maxcpunumber * 1 || Number.MAX_SAFE_INTEGER - }, - getMinMemory () { - return this.serviceOffering?.serviceofferingdetails?.minmemory * 1 || 0 - }, - getMaxMemory () { - return this.serviceOffering?.serviceofferingdetails?.maxmemory * 1 || Number.MAX_SAFE_INTEGER } } } diff --git a/ui/src/views/compute/ScaleVM.vue b/ui/src/views/compute/ScaleVM.vue index ed933c41e5ba..7b71d2efcbd4 100644 --- a/ui/src/views/compute/ScaleVM.vue +++ b/ui/src/views/compute/ScaleVM.vue @@ -32,16 +32,16 @@ @handle-search-filter="($event) => fetchData($event)" /> - + - + Date: Wed, 1 Sep 2021 13:18:20 +0700 Subject: [PATCH 3/5] remove logs --- ui/src/views/compute/wizard/ComputeSelection.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/src/views/compute/wizard/ComputeSelection.vue b/ui/src/views/compute/wizard/ComputeSelection.vue index e958a1cf0089..52d7b3eba7ad 100644 --- a/ui/src/views/compute/wizard/ComputeSelection.vue +++ b/ui/src/views/compute/wizard/ComputeSelection.vue @@ -192,7 +192,6 @@ export default { } }, mounted () { - console.log(this.isCustomizedIOps) if (this.isCustomized) { this.fillValue() } From 7bc2bc0edc7bf8dcc9674a76d01fbc7152c0647f Mon Sep 17 00:00:00 2001 From: utchoang Date: Wed, 1 Sep 2021 16:42:56 +0700 Subject: [PATCH 4/5] fix condition --- ui/src/views/compute/wizard/ComputeSelection.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/views/compute/wizard/ComputeSelection.vue b/ui/src/views/compute/wizard/ComputeSelection.vue index 52d7b3eba7ad..5cfbe24d21d8 100644 --- a/ui/src/views/compute/wizard/ComputeSelection.vue +++ b/ui/src/views/compute/wizard/ComputeSelection.vue @@ -25,7 +25,7 @@ :validate-status="errors.cpu.status" :help="errors.cpu.message"> - + Date: Wed, 1 Sep 2021 16:44:46 +0700 Subject: [PATCH 5/5] fix condition for coltranned --- ui/src/views/compute/wizard/ComputeSelection.vue | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ui/src/views/compute/wizard/ComputeSelection.vue b/ui/src/views/compute/wizard/ComputeSelection.vue index 5cfbe24d21d8..6f6e2a428609 100644 --- a/ui/src/views/compute/wizard/ComputeSelection.vue +++ b/ui/src/views/compute/wizard/ComputeSelection.vue @@ -175,10 +175,8 @@ export default { }, computed: { colContraned () { - if (this.isConstrained) { - if (this.maxCpu && isNaN(this.maxCpu)) { - return 12 - } + if (this.isConstrained && this.maxCpu && !isNaN(this.maxCpu)) { + return 12 } return 8