Skip to content

Commit fef0e66

Browse files
authored
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 <abhishek.mrt22@gmail.com>
1 parent a234501 commit fef0e66

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

ui/src/views/infra/ClusterAdd.vue

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,35 @@ export default {
216216
217217
if (this.hypervisor === 'VMware') {
218218
this.clustertype = 'ExternalManaged'
219+
if ((this.host === null || this.host.length === 0) &&
220+
(this.dataCenter === null || this.dataCenter.length === 0)) {
221+
api('listVmwareDcs', {
222+
zoneid: this.zoneId
223+
}).then(response => {
224+
var vmwaredcs = response.listvmwaredcsresponse.VMwareDC
225+
if (vmwaredcs !== null) {
226+
this.host = vmwaredcs[0].vcenter
227+
this.dataCenter = vmwaredcs[0].name
228+
}
229+
this.addCluster()
230+
}).catch(error => {
231+
this.$notification.error({
232+
message: `${this.$t('label.error')} ${error.response.status}`,
233+
description: error.response.data.listvmwaredcsresponse.errortext,
234+
duration: 0
235+
})
236+
})
237+
return
238+
}
239+
}
240+
this.addCluster()
241+
},
242+
addCluster () {
243+
if (this.hypervisor === 'VMware') {
219244
const clusternameVal = this.clustername
220245
this.url = `http://${this.host}/${this.dataCenter}/${clusternameVal}`
221246
this.clustername = `${this.host}/${this.dataCenter}/${clusternameVal}`
222247
}
223-
224248
this.loading = true
225249
this.parentToggleLoading()
226250
api('addCluster', {}, 'POST', {

0 commit comments

Comments
 (0)