This is an automated email from the ASF dual-hosted git repository.

nvazquez pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/main by this push:
     new 47a1707  [UI] Addressing Dynamically Scale of KVM VMs (#5923)
47a1707 is described below

commit 47a170757a34a658397e8992a8f5a69f2945ed1a
Author: Bryan Lima <[email protected]>
AuthorDate: Fri Feb 11 16:29:37 2022 -0300

    [UI] Addressing Dynamically Scale of KVM VMs (#5923)
    
    * Externalize config to increment or not VM metrics in memory
    
    * UI fix for dynamically scale of KVM VMs
    
    Co-authored-by: SadiJr <[email protected]>
    Co-authored-by: SadiJr <[email protected]>
    Co-authored-by: SadiJr <[email protected]>
    Co-authored-by: José Flauzino <[email protected]>
---
 ui/public/locales/en.json                        |  1 +
 ui/public/locales/pt_BR.json                     |  1 +
 ui/src/views/compute/ScaleVM.vue                 | 22 +++++++++++++++++++++-
 ui/src/views/compute/wizard/ComputeSelection.vue |  5 +++++
 4 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/ui/public/locales/en.json b/ui/public/locales/en.json
index 9e10469..143904a 100644
--- a/ui/public/locales/en.json
+++ b/ui/public/locales/en.json
@@ -3016,6 +3016,7 @@
 "message.error.zone.name": "Please enter zone name",
 "message.error.zone.type": "Please select zone type",
 "message.error.linstor.resourcegroup": "Please enter the Linstor 
Resource-Group",
+"message.error.fixed.offering.kvm": "It's not possible to scale up VMs that 
utilize KVM hypervisor with a fixed compute offering.",
 "message.fail.to.delete": "Failed to delete.",
 "message.failed.to.add": "Failed to add",
 "message.failed.to.assign.vms": "Failed to assign VMs",
diff --git a/ui/public/locales/pt_BR.json b/ui/public/locales/pt_BR.json
index 9dd3c63..1294c69 100644
--- a/ui/public/locales/pt_BR.json
+++ b/ui/public/locales/pt_BR.json
@@ -2144,6 +2144,7 @@
 "message.enabling.zone.dots": "Habilitando Zona....",
 "message.enter.seperated.list.multiple.cidrs": "Por favor entre a de CIDRs 
separadas por v\u00edrgula, se houver mais de uma",
 "message.enter.token": "Por favor entre o token que voc\u00ea recebeu no 
e-mail privado.",
+"message.error.fixed.offering.kvm": "Não é possível escalar VMs que utilizam o 
hipervisor KVM com oferta de computa\u00e7\u00e3o fixa.",
 "message.generate.keys": "Por favor confirme que voc\u00ea deseja gerar novas 
chaves para este usu\u00e1rio.",
 "message.gslb.delete.confirm": "Confirme que voc\u00ea deseja apagar este 
GSLB",
 "message.gslb.lb.remove.confirm": "Confirme que voc\u00ea deseja remover o 
balanceamento de carga deste GSLB",
diff --git a/ui/src/views/compute/ScaleVM.vue b/ui/src/views/compute/ScaleVM.vue
index 4a3200a..0a0caa0 100644
--- a/ui/src/views/compute/ScaleVM.vue
+++ b/ui/src/views/compute/ScaleVM.vue
@@ -23,6 +23,10 @@
       <a-icon type="loading" style="color: #1890ff;"></a-icon>
     </div>
 
+    <a-alert v-if="fixedOfferingKvm" style="margin-bottom: 5px" type="error" 
show-icon>
+      <span slot="message" v-html="$t('message.error.fixed.offering.kvm')" />
+    </a-alert>
+
     <compute-offering-selection
       :compute-items="offerings"
       :loading="loading"
@@ -40,6 +44,7 @@
       :isConstrained="'serviceofferingdetails' in selectedOffering"
       :minCpu="getMinCpu()"
       :maxCpu="'serviceofferingdetails' in selectedOffering ? 
selectedOffering.serviceofferingdetails.maxcpunumber*1 : 
Number.MAX_SAFE_INTEGER"
+      :cpuSpeed="getCPUSpeed()"
       :minMemory="getMinMemory()"
       :maxMemory="'serviceofferingdetails' in selectedOffering ? 
selectedOffering.serviceofferingdetails.maxmemory*1 : Number.MAX_SAFE_INTEGER"
       :isCustomized="selectedOffering.iscustomized"
@@ -92,7 +97,8 @@ export default {
       loading: false,
       cpuNumberKey: 'details[0].cpuNumber',
       cpuSpeedKey: 'details[0].cpuSpeed',
-      memoryKey: 'details[0].memory'
+      memoryKey: 'details[0].memory',
+      fixedOfferingKvm: false
     }
   },
   beforeCreate () {
@@ -125,6 +131,13 @@ export default {
           return
         }
         this.offerings = response.listserviceofferingsresponse.serviceoffering
+        if (this.resource.state === 'Running' && this.resource.hypervisor === 
'KVM') {
+          this.offerings = this.offerings.filter(offering => offering.id === 
this.resource.serviceofferingid)
+          this.currentOffer = this.offerings[0]
+          if (this.currentOffer === undefined) {
+            this.fixedOfferingKvm = true
+          }
+        }
         this.offerings.map(i => { this.offeringsMap[i.id] = i })
       }).finally(() => {
         this.loading = false
@@ -144,6 +157,13 @@ export default {
       }
       return this.selectedOffering?.serviceofferingdetails?.minmemory * 1 || 32
     },
+    getCPUSpeed () {
+      // We can only scale up while a VM is running
+      if (this.resource.state === 'Running') {
+        return this.resource.cpuspeed
+      }
+      return this.selectedOffering?.serviceofferingdetails?.cpuspeed * 1 || 1
+    },
     getMessage () {
       if (this.resource.hypervisor === 'VMware') {
         return this.$t('message.read.admin.guide.scaling.up')
diff --git a/ui/src/views/compute/wizard/ComputeSelection.vue 
b/ui/src/views/compute/wizard/ComputeSelection.vue
index 8d68fb9..df35162 100644
--- a/ui/src/views/compute/wizard/ComputeSelection.vue
+++ b/ui/src/views/compute/wizard/ComputeSelection.vue
@@ -107,6 +107,10 @@ export default {
       type: Boolean,
       default: true
     },
+    cpuSpeed: {
+      type: Number,
+      default: 0
+    },
     minCpu: {
       type: Number,
       default: 0
@@ -198,6 +202,7 @@ export default {
     fillValue () {
       this.cpuNumberInputValue = this.minCpu
       this.memoryInputValue = this.minMemory
+      this.cpuSpeedInputValue = this.cpuSpeed
 
       if (!this.preFillContent) {
         this.updateComputeCpuNumber(this.cpuNumberInputValue)

Reply via email to