RitchieVincent commented on a change in pull request #67: VM Migration Action form URL: https://github.com/apache/cloudstack-primate/pull/67#discussion_r356819620
########## 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: I've now created a reusable method which can be used for this in `utils/methods.js`. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services