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', {