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

rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack-primate.git


The following commit(s) were added to refs/heads/master by this push:
     new e8625b5  storage: Filter out storage pool on which the volume 
currently exists on (#638)
e8625b5 is described below

commit e8625b57accebb7793e5b48e32b7ec87c8644f70
Author: Pearl Dsilva <[email protected]>
AuthorDate: Tue Sep 1 09:21:44 2020 +0530

    storage: Filter out storage pool on which the volume currently exists on 
(#638)
    
    Remove the primary store on which the volume is currently present on from 
the list of possible storage pools to migrate volume.
---
 src/locales/en.json                 |  1 +
 src/views/storage/MigrateVolume.vue | 61 +++++++++++++++++++++----------------
 2 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/src/locales/en.json b/src/locales/en.json
index 791da76..def524e 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -2926,6 +2926,7 @@
 "message.no.more.hosts.available": "No more hosts are available for migration",
 "message.no.network.support": "Your selected hypervisor, vSphere, does not 
have any additional network features.  Please continue to step 5.",
 "message.no.network.support.configuration.not.true": "You do not have any zone 
that has security group enabled. Thus, no additional network features.  Please 
continue to step 5.",
+"message.no.primary.stores": "No primary storage pools available for 
migration",
 "message.no.projects": "You do not have any projects.<br/>Please create a new 
one from the projects section.",
 "message.no.projects.adminonly": "You do not have any projects.<br/>Please ask 
your administrator to create a new project.",
 "message.number.clusters": "<h2><span> # of </span> Clusters</h2>",
diff --git a/src/views/storage/MigrateVolume.vue 
b/src/views/storage/MigrateVolume.vue
index 0fae82a..ad1193a 100644
--- a/src/views/storage/MigrateVolume.vue
+++ b/src/views/storage/MigrateVolume.vue
@@ -19,28 +19,32 @@
   <div class="migrate-volume-container">
 
     <div class="modal-form">
-      <p class="modal-form__label">{{ $t('label.storagepool') }}</p>
-      <a-select v-model="selectedStoragePool" style="width: 100%;">
-        <a-select-option v-for="(storagePool, index) in storagePools" 
:value="storagePool.id" :key="index">
-          {{ storagePool.name }} <span v-if="resource.virtualmachineid">{{ 
storagePool.suitableformigration ? `(${$t('label.suitable')})` : 
`(${$t('label.not.suitable')})` }}</span>
-        </a-select-option>
-      </a-select>
-      <template v-if="this.resource.virtualmachineid">
-        <p class="modal-form__label" @click="replaceDiskOffering = 
!replaceDiskOffering" style="cursor:pointer;">
-          {{ $t('label.usenewdiskoffering') }}
-        </p>
-        <a-checkbox v-model="replaceDiskOffering" />
-
-        <template v-if="replaceDiskOffering">
-          <p class="modal-form__label">{{ $t('label.newdiskoffering') }}</p>
-          <a-select v-model="selectedDiskOffering" style="width: 100%;">
-            <a-select-option v-for="(diskOffering, index) in diskOfferings" 
:value="diskOffering.id" :key="index">
-              {{ diskOffering.displaytext }}
-            </a-select-option>
-          </a-select>
+      <div v-if="storagePools.length > 0">
+        <p class="modal-form__label">{{ $t('label.storagepool') }}</p>
+        <a-select v-model="selectedStoragePool" style="width: 100%;">
+          <a-select-option v-for="(storagePool, index) in storagePools" 
:value="storagePool.id" :key="index">
+            {{ storagePool.name }} <span v-if="resource.virtualmachineid">{{ 
storagePool.suitableformigration ? `(${$t('label.suitable')})` : 
`(${$t('label.not.suitable')})` }}</span>
+          </a-select-option>
+        </a-select>
+        <template v-if="this.resource.virtualmachineid">
+          <p class="modal-form__label" @click="replaceDiskOffering = 
!replaceDiskOffering" style="cursor:pointer;">
+            {{ $t('label.usenewdiskoffering') }}
+          </p>
+          <a-checkbox v-model="replaceDiskOffering" />
+
+          <template v-if="replaceDiskOffering">
+            <p class="modal-form__label">{{ $t('label.newdiskoffering') }}</p>
+            <a-select v-model="selectedDiskOffering" style="width: 100%;">
+              <a-select-option v-for="(diskOffering, index) in diskOfferings" 
:value="diskOffering.id" :key="index">
+                {{ diskOffering.displaytext }}
+              </a-select-option>
+            </a-select>
+          </template>
         </template>
-
-      </template>
+      </div>
+      <a-alert style="margin-top: 15px" type="warning" v-else>
+        <span slot="message" v-html="$t('message.no.primary.stores')" />
+      </a-alert>
     </div>
 
     <a-divider />
@@ -68,7 +72,7 @@ export default {
       required: true
     }
   },
-  inject: ['parentFetchData', 'parentToggleLoading'],
+  inject: ['parentFetchData'],
   data () {
     return {
       storagePools: [],
@@ -101,6 +105,7 @@ export default {
           zoneid: this.resource.zoneid
         }).then(response => {
           this.storagePools = response.liststoragepoolsresponse.storagepool || 
[]
+          this.storagePools = this.storagePools.filter(pool => { return 
pool.id !== this.resource.storageid })
           if (Array.isArray(this.storagePools) && this.storagePools.length) {
             this.selectedStoragePool = this.storagePools[0].id || ''
           }
@@ -125,8 +130,10 @@ export default {
       this.$parent.$parent.close()
     },
     submitMigrateVolume () {
-      this.closeModal()
-      this.parentToggleLoading()
+      if (this.storagePools.length === 0) {
+        this.closeModal()
+        return
+      }
       api('migrateVolume', {
         livemigrate: this.resource.vmstate === 'Running',
         storageid: this.selectedStoragePool,
@@ -138,23 +145,23 @@ export default {
           successMessage: this.$t('message.success.migrate.volume'),
           successMethod: () => {
             this.parentFetchData()
-            this.parentToggleLoading()
           },
           errorMessage: this.$t('message.migrate.volume.failed'),
           errorMethod: () => {
             this.parentFetchData()
-            this.parentToggleLoading()
           },
           loadingMessage: this.$t('message.migrate.volume.processing'),
           catchMessage: this.$t('error.fetching.async.job.result'),
           catchMethod: () => {
             this.parentFetchData()
-            this.parentToggleLoading()
           }
         })
       }).catch(error => {
         this.$notifyError(error)
         this.closeModal()
+      }).finally(() => {
+        this.closeModal()
+        this.parentFetchData()
       })
     }
   }

Reply via email to