You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by GitBox <gi...@apache.org> on 2019/12/11 18:50:27 UTC

[GitHub] [cloudstack-primate] rhtyd commented on a change in pull request #67: VM Migration Action form

rhtyd commented on a change in pull request #67: VM Migration Action form
URL: https://github.com/apache/cloudstack-primate/pull/67#discussion_r356771992
 
 

 ##########
 File path: src/views/compute/MigrateWizard.vue
 ##########
 @@ -36,12 +85,146 @@ export default {
   },
   data () {
     return {
+      loading: true,
+      hosts: [],
+      selectedIndex: null,
+      searchQuery: ''
     }
   },
+  mounted () {
+    this.fetchData()
+  },
   methods: {
+    fetchData () {
+      this.loading = true
+      api('findHostsForMigration', {
+        virtualmachineid: this.resource.id,
+        keyword: this.searchQuery
+      }).then(response => {
+        this.hosts = response.findhostsformigrationresponse.host
+        this.loading = false
+      }).catch(error => {
+        this.$message.error('Failed to load hosts: ' + error)
+      })
+    },
+    submitForm () {
+      this.loading = true
+      api('migrateVirtualMachine', {
+        hostid: this.hosts[this.selectedIndex].id,
+        virtualmachineid: this.resource.id
+      }).then(response => {
+        this.pollActionCompletion(response.migratevirtualmachineresponse.jobid)
+      }).catch(error => {
+        console.error(error)
+        this.$message.error('Failed to migrate host.')
+      })
+    },
+    pollActionCompletion (jobId) {
+      api('queryAsyncJobResult', { jobId }).then(json => {
 
 Review comment:
   @RitchieVincent This seems to be fairly commonly used method/pattern, can you consider refactoring this out to a utility method that we can use as a mixin (see AutogenView or other components for example on using mixins, the utils/mixin.js is one example).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services