Skip to content

Commit 11ca518

Browse files
committed
use host to list vms
1 parent cd6d42c commit 11ca518

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

plugins/hypervisors/vmware/src/main/java/org/apache/cloudstack/api/command/admin/zone/ListVmwareDcHostsCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ private HostResponse createHostResponse(HostMO hostInstance) throws InvalidPrope
139139
HostResponse response = new HostResponse();
140140
response.setHypervisor(Hypervisor.HypervisorType.VMware.toString());
141141
response.setName(hostInstance.getHostName());
142+
response.setObjectName("host");
142143
return response;
143144
}
144145

145-
146146
private void checkParameters() {
147147
if ((existingVcenterId == null && vcenter == null) || (existingVcenterId != null && vcenter != null)) {
148148
throw new ServerApiException(ApiErrorCode.PARAM_ERROR,

ui/public/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3004,6 +3004,7 @@
30043004
"message.license.agreements.not.accepted": "License agreements not accepted.",
30053005
"message.linstor.resourcegroup.description": "Linstor resource group to use for primary storage.",
30063006
"message.list.zone.vmware.datacenter.empty": "No VMware Datacenter exists in the selected Zone",
3007+
"message.list.zone.vmware.hosts.empty": "No VMware hosts were found in the selected Datacenter",
30073008
"message.listnsp.not.return.providerid": "error: listNetworkServiceProviders API doesn't return VirtualRouter provider ID.",
30083009
"message.load.host.failed": "Failed to load hosts.",
30093010
"message.loadbalancer.stickypolicy.configuration": "Customize the load balancer stickiness policy:",

ui/src/views/tools/SelectVmwareVcenter.vue

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,31 @@
119119
/>
120120
</a-form-item>
121121
</div>
122+
<div v-if="selectedExistingVcenterId">
123+
<a-form-item ref="host" name="host" v-if="hosts.length > 0">
124+
<a-select
125+
v-model:value="form.host"
126+
:loading="loading"
127+
optionFilterProp="label"
128+
:filterOption="(input, option) => {
129+
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
130+
}"
131+
:placeholder="$t('label.vcenter.host')"
132+
@change="onSelectExistingVmwareHost">
133+
<a-select-option v-for="opt in hosts" :key="opt.id">
134+
{{ 'ESXi: ' + opt.host + ' - DC: ' + opt.name }}
135+
</a-select-option>
136+
</a-select>
137+
</a-form-item>
138+
<div v-else>
139+
{{ $t('message.list.zone.vmware.hosts.empty') }}
140+
</div>
141+
</div>
122142
<div class="card-footer">
123143
<a-button
124144
v-if="vcenterSelectedOption == 'existing' || vcenterSelectedOption == 'new'"
125-
:disabled="(vcenterSelectedOption === 'new' && (vcenter === '' || datacentername === '' || username === '' || password === '')) ||
126-
(vcenterSelectedOption === 'existing' && selectedExistingVcenterId === '')"
145+
:disabled="(vcenterSelectedOption === 'new' && ((vcenter === '' || datacentername === '' || username === '' || password === '')) ||
146+
(vcenterSelectedOption === 'existing' && selectedExistingVcenterId === '')) && selectedHost === ''"
127147
:loading="loading"
128148
type="primary"
129149
@click="listVmwareDatacenterVms">{{ $t('label.list.vmware.vcenter.vms') }}</a-button>
@@ -154,6 +174,8 @@ export default {
154174
zones: {},
155175
vcenterSelectedOption: '',
156176
existingvcenter: [],
177+
hosts: [],
178+
selectedHost: '',
157179
selectedExistingVcenterId: '',
158180
selectedPoweredOnVm: false,
159181
vmwareDcVms: [],
@@ -217,7 +239,7 @@ export default {
217239
} else {
218240
params.existingvcenterid = this.selectedExistingVcenterId
219241
}
220-
params.batchsize = 2
242+
params.host = this.selectedhost
221243
api('listVmwareDcVms', params).then(json => {
222244
const obj = {
223245
params: params,
@@ -256,8 +278,33 @@ export default {
256278
this.loading = false
257279
})
258280
},
281+
listZoneVmwareDcHosts () {
282+
this.loading = true
283+
const params = {}
284+
if (this.vcenterSelectedOption === 'new') {
285+
params.datacentername = this.datacenter
286+
params.vcenter = this.vcenter
287+
params.username = this.username
288+
params.password = this.password
289+
} else {
290+
params.existingvcenterid = this.selectedExistingVcenterId
291+
}
292+
api('listVmwareDcHosts', params).then(response => {
293+
if (response.listvmwaredchostsresponse.VMwareDC && response.listvmwaredchostsresponse.VMwareDC.length > 0) {
294+
this.hosts = response.listvmwaredchostsresponse.hosts
295+
}
296+
}).catch(error => {
297+
this.$notifyError(error)
298+
}).finally(() => {
299+
this.loading = false
300+
})
301+
},
259302
onSelectExistingVmwareDatacenter (value) {
260303
this.selectedExistingVcenterId = value
304+
this.listZoneVmwareDcHosts()
305+
},
306+
onSelectExistingVmwareHost (value) {
307+
this.selectedHost = value
261308
},
262309
onVcenterTypeChange () {
263310
this.$emit('onVcenterTypeChanged', this.vcenterSelectedOption)

0 commit comments

Comments
 (0)