From fef0e66764faaa75a18f533af1b7b31fefc5974f Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 25 Feb 2021 22:04:00 +0530 Subject: [PATCH] ui: fix add Vmware cluster (#4663) When adding a cluster from existing host-datacenter UI shoudl list and autofill host, DC name while making addCluster API call. Signed-off-by: Abhishek Kumar --- ui/src/views/infra/ClusterAdd.vue | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/ui/src/views/infra/ClusterAdd.vue b/ui/src/views/infra/ClusterAdd.vue index a0665fe92d3..f4c03fe96a0 100644 --- a/ui/src/views/infra/ClusterAdd.vue +++ b/ui/src/views/infra/ClusterAdd.vue @@ -216,11 +216,35 @@ export default { if (this.hypervisor === 'VMware') { this.clustertype = 'ExternalManaged' + if ((this.host === null || this.host.length === 0) && + (this.dataCenter === null || this.dataCenter.length === 0)) { + api('listVmwareDcs', { + zoneid: this.zoneId + }).then(response => { + var vmwaredcs = response.listvmwaredcsresponse.VMwareDC + if (vmwaredcs !== null) { + this.host = vmwaredcs[0].vcenter + this.dataCenter = vmwaredcs[0].name + } + this.addCluster() + }).catch(error => { + this.$notification.error({ + message: `${this.$t('label.error')} ${error.response.status}`, + description: error.response.data.listvmwaredcsresponse.errortext, + duration: 0 + }) + }) + return + } + } + this.addCluster() + }, + addCluster () { + if (this.hypervisor === 'VMware') { const clusternameVal = this.clustername this.url = `http://${this.host}/${this.dataCenter}/${clusternameVal}` this.clustername = `${this.host}/${this.dataCenter}/${clusternameVal}` } - this.loading = true this.parentToggleLoading() api('addCluster', {}, 'POST', {