Skip to content

Commit 6850147

Browse files
author
Dahn Highland
committed
Merge branch '4.19' into 4.20
2 parents bc5728a + 5d5ac17 commit 6850147

13 files changed

+391
-384
lines changed

Diff for: plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java

+294-352
Large diffs are not rendered by default.

Diff for: plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/wrapper/xen56/XenServer56FenceCommandWrapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public Answer execute(final FenceCommand command, final XenServer56Resource xenS
5454
for (final VM vm : vms) {
5555
logger.info("Fence command for VM " + command.getVmName());
5656
vm.powerStateReset(conn);
57-
vm.destroy(conn);
57+
xenServer56.destroyVm(vm, conn);
5858
}
5959
return new FenceAnswer(command);
6060
} catch (final XmlRpcException e) {

Diff for: plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/wrapper/xen56p1/XenServer56FP1FenceCommandWrapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public Answer execute(final FenceCommand command, final XenServer56Resource xenS
6666
}
6767
logger.info("Fence command for VM " + command.getVmName());
6868
vm.powerStateReset(conn);
69-
vm.destroy(conn);
69+
xenServer56.destroyVm(vm, conn);
7070
for (final VDI vdi : vdis) {
7171
final Map<String, String> smConfig = vdi.getSmConfig(conn);
7272
for (final String key : smConfig.keySet()) {

Diff for: plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCreateVMSnapshotCommandWrapper.java

+11-12
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public Answer execute(final CreateVMSnapshotCommand command, final CitrixResourc
6969
try {
7070
// check if VM snapshot already exists
7171
final Set<VM> vmSnapshots = VM.getByNameLabel(conn, command.getTarget().getSnapshotName());
72-
if (vmSnapshots == null || vmSnapshots.size() > 0) {
72+
if (vmSnapshots == null || !vmSnapshots.isEmpty()) {
7373
return new CreateVMSnapshotAnswer(command, command.getTarget(), command.getVolumeTOs());
7474
}
7575

@@ -98,6 +98,7 @@ public Answer execute(final CreateVMSnapshotCommand command, final CitrixResourc
9898
vm = citrixResourceBase.getVM(conn, vmName);
9999
vmState = vm.getPowerState(conn);
100100
} catch (final Exception e) {
101+
logger.debug("Failed to find VM with name: {} due to:", vmName, e);
101102
if (!snapshotMemory) {
102103
vm = citrixResourceBase.createWorkingVM(conn, vmName, guestOSType, platformEmulator, listVolumeTo);
103104
}
@@ -107,7 +108,7 @@ public Answer execute(final CreateVMSnapshotCommand command, final CitrixResourc
107108
return new CreateVMSnapshotAnswer(command, false, "Creating VM Snapshot Failed due to can not find vm: " + vmName);
108109
}
109110

110-
// call Xenserver API
111+
// call XenServer API
111112
if (!snapshotMemory) {
112113
task = vm.snapshotAsync(conn, vmSnapshotName);
113114
} else {
@@ -136,15 +137,15 @@ public Answer execute(final CreateVMSnapshotCommand command, final CitrixResourc
136137
vmSnapshot = Types.toVM(ref);
137138
try {
138139
Thread.sleep(5000);
139-
} catch (final InterruptedException ex) {
140+
} catch (final InterruptedException ignored) {
140141

141142
}
142143
// calculate used capacity for this VM snapshot
143144
for (final VolumeObjectTO volumeTo : command.getVolumeTOs()) {
144145
try {
145146
final long size = citrixResourceBase.getVMSnapshotChainSize(conn, volumeTo, command.getVmName(), vmSnapshotName);
146147
volumeTo.setSize(size);
147-
} catch (final CloudRuntimeException cre) {
148+
} catch (final CloudRuntimeException ignored) {
148149
}
149150
}
150151

@@ -161,13 +162,13 @@ public Answer execute(final CreateVMSnapshotCommand command, final CitrixResourc
161162
} else {
162163
msg = e.toString();
163164
}
164-
logger.warn("Creating VM Snapshot " + command.getTarget().getSnapshotName() + " failed due to: " + msg, e);
165+
logger.warn("Creating VM Snapshot {} failed due to: {}", command.getTarget().getSnapshotName(), msg, e);
165166
return new CreateVMSnapshotAnswer(command, false, msg);
166167
} finally {
167168
try {
168169
if (!success) {
169170
if (vmSnapshot != null) {
170-
logger.debug("Delete existing VM Snapshot " + vmSnapshotName + " after making VolumeTO failed");
171+
logger.debug("Delete existing VM Snapshot {} after making VolumeTO failed", vmSnapshotName);
171172
final Set<VBD> vbds = vmSnapshot.getVBDs(conn);
172173
for (final VBD vbd : vbds) {
173174
final VBD.Record vbdr = vbd.getRecord(conn);
@@ -176,16 +177,14 @@ public Answer execute(final CreateVMSnapshotCommand command, final CitrixResourc
176177
vdi.destroy(conn);
177178
}
178179
}
179-
vmSnapshot.destroy(conn);
180+
citrixResourceBase.destroyVm(vmSnapshot, conn, true);
180181
}
181182
}
182-
if (vmState == VmPowerState.HALTED) {
183-
if (vm != null) {
184-
vm.destroy(conn);
185-
}
183+
if (vmState == VmPowerState.HALTED && vm != null) {
184+
citrixResourceBase.destroyVm(vm, conn);
186185
}
187186
} catch (final Exception e2) {
188-
logger.error("delete snapshot error due to " + e2.getMessage());
187+
logger.error("delete snapshot error due to {}", e2.getMessage());
189188
}
190189
}
191190
}

Diff for: plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixDeleteVMSnapshotCommandWrapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public Answer execute(final DeleteVMSnapshotCommand command, final CitrixResourc
6666
if (command.getTarget().getType() == VMSnapshot.Type.DiskAndMemory) {
6767
vdiList.add(snapshot.getSuspendVDI(conn));
6868
}
69-
snapshot.destroy(conn);
69+
citrixResourceBase.destroyVm(snapshot, conn, true);
7070
for (final VDI vdi : vdiList) {
7171
vdi.destroy(conn);
7272
}

Diff for: plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixRevertToVMSnapshotCommandWrapper.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ public Answer execute(final RevertToVMSnapshotCommand command, final CitrixResou
5151
final VMSnapshot.Type vmSnapshotType = command.getTarget().getType();
5252
final Boolean snapshotMemory = vmSnapshotType == VMSnapshot.Type.DiskAndMemory;
5353
final Connection conn = citrixResourceBase.getConnection();
54-
PowerState vmState = null;
55-
VM vm = null;
54+
PowerState vmState;
55+
VM vm;
5656
try {
5757

5858
final Set<VM> vmSnapshots = VM.getByNameLabel(conn, command.getTarget().getSnapshotName());
59-
if (vmSnapshots == null || vmSnapshots.size() == 0) {
59+
if (vmSnapshots == null || vmSnapshots.isEmpty()) {
6060
return new RevertToVMSnapshotAnswer(command, false, "Cannot find vmSnapshot with name: " + command.getTarget().getSnapshotName());
6161
}
6262

@@ -66,6 +66,7 @@ public Answer execute(final RevertToVMSnapshotCommand command, final CitrixResou
6666
try {
6767
vm = citrixResourceBase.getVM(conn, vmName);
6868
} catch (final Exception e) {
69+
logger.debug("Failed to find VM with name: {} due to:", vmName, e);
6970
vm = citrixResourceBase.createWorkingVM(conn, vmName, command.getGuestOSType(), command.getPlatformEmulator(), listVolumeTo);
7071
}
7172

@@ -77,7 +78,7 @@ public Answer execute(final RevertToVMSnapshotCommand command, final CitrixResou
7778
citrixResourceBase.revertToSnapshot(conn, vmSnapshot, vmName, vm.getUuid(conn), snapshotMemory, citrixResourceBase.getHost().getUuid());
7879
vm = citrixResourceBase.getVM(conn, vmName);
7980
final Set<VBD> vbds = vm.getVBDs(conn);
80-
final Map<String, VDI> vdiMap = new HashMap<String, VDI>();
81+
final Map<String, VDI> vdiMap = new HashMap<>();
8182
// get vdi:vbdr to a map
8283
for (final VBD vbd : vbds) {
8384
final VBD.Record vbdr = vbd.getRecord(conn);
@@ -88,7 +89,7 @@ public Answer execute(final RevertToVMSnapshotCommand command, final CitrixResou
8889
}
8990

9091
if (!snapshotMemory) {
91-
vm.destroy(conn);
92+
citrixResourceBase.destroyVm(vm, conn);
9293
vmState = PowerState.PowerOff;
9394
} else {
9495
vmState = PowerState.PowerOn;
@@ -103,7 +104,7 @@ public Answer execute(final RevertToVMSnapshotCommand command, final CitrixResou
103104

104105
return new RevertToVMSnapshotAnswer(command, listVolumeTo, vmState);
105106
} catch (final Exception e) {
106-
logger.error("revert vm " + vmName + " to snapshot " + command.getTarget().getSnapshotName() + " failed due to " + e.getMessage());
107+
logger.error("revert vm {} to snapshot {} failed due to {}", vmName, command.getTarget().getSnapshotName(), e.getMessage());
107108
return new RevertToVMSnapshotAnswer(command, false, e.getMessage());
108109
}
109110
}

Diff for: plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixStartCommandWrapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public Answer execute(final StartCommand command, final CitrixResourceBase citri
7373
for (final VM v : vms) {
7474
final VM.Record vRec = v.getRecord(conn);
7575
if (vRec.powerState == VmPowerState.HALTED) {
76-
v.destroy(conn);
76+
citrixResourceBase.destroyVm(v, conn, true);
7777
} else if (vRec.powerState == VmPowerState.RUNNING) {
7878
final String host = vRec.residentOn.getUuid(conn);
7979
final String msg = "VM " + vmName + " is runing on host " + host;

Diff for: plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixStopCommandWrapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public Answer execute(final StopCommand command, final CitrixResourceBase citrix
141141
for (final VIF vif : vifs) {
142142
networks.add(vif.getNetwork(conn));
143143
}
144-
vm.destroy(conn);
144+
citrixResourceBase.destroyVm(vm, conn);
145145
final SR sr = citrixResourceBase.getISOSRbyVmName(conn, command.getVmName(), false);
146146
citrixResourceBase.removeSR(conn, sr);
147147
final SR configDriveSR = citrixResourceBase.getISOSRbyVmName(conn, command.getVmName(), true);

Diff for: ui/public/locales/en.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,9 @@
625625
"label.create.template": "Create Template",
626626
"label.create.tier.aclid.description": "The ACL associated with the Network Tier.",
627627
"label.create.tier.externalid.description": "ID of the Network in an external system.",
628-
"label.create.tier.gateway.description": "The Network Tier's gateway in the super CIDR range, not overlapping with the CIDR of other Network Tiers in this VPC.",
628+
"label.create.tier.gateway.description": "Gateway IP must be within VPC CIDR ({value})",
629629
"label.create.tier.name.description": "A unique name for the Network Tier.",
630-
"label.create.tier.netmask.description": "The Network Tier's netmask. For example 255.255.255.0",
630+
"label.create.tier.netmask.description": "Network Tier's netmask must be more restrictive than {value}",
631631
"label.create.tier.networkofferingid.description": "The Network offering for the Network Tier.",
632632
"label.create.tungsten.routing.policy": "Create Tungsten-Fabric routing policy",
633633
"label.create.user": "Create User",

Diff for: ui/src/components/view/ResourceLimitTab.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
>
2828
<div v-for="(item, index) in dataResource" :key="index">
2929
<a-form-item
30-
v-if="item.resourcetypename !== 'project'"
30+
v-if="item.resourcetypename !== 'project' || !$route.path.startsWith('/project')"
3131
:v-bind="item.resourcetypename"
3232
:label="$t('label.max' + (item.resourcetypename ? item.resourcetypename.replace('_', '') : '')) + (item.tag ? ' [' + item.tag + ']': '')"
3333
:name="item.key"

Diff for: ui/src/utils/network.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
// Parsing CIDR into Gateway,Netmask Placeholders
19+
20+
export function getNetmaskFromCidr (cidr) {
21+
if (!cidr?.includes('/')) return undefined
22+
const [, maskBits] = cidr.split('/')
23+
const subnetMasks = {
24+
8: '255.0.0.0',
25+
9: '255.128.0.0',
26+
10: '255.192.0.0',
27+
11: '255.224.0.0',
28+
12: '255.240.0.0',
29+
13: '255.248.0.0',
30+
14: '255.252.0.0',
31+
15: '255.254.0.0',
32+
16: '255.255.0.0',
33+
17: '255.255.128.0',
34+
18: '255.255.192.0',
35+
19: '255.255.224.0',
36+
20: '255.255.240.0',
37+
21: '255.255.248.0',
38+
22: '255.255.252.0',
39+
23: '255.255.254.0',
40+
24: '255.255.255.0',
41+
25: '255.255.255.128',
42+
26: '255.255.255.192',
43+
27: '255.255.255.224',
44+
28: '255.255.255.240',
45+
29: '255.255.255.248',
46+
30: '255.255.255.252',
47+
31: '255.255.255.254',
48+
32: '255.255.255.255'
49+
}
50+
return subnetMasks[+maskBits] || '255.255.255.0'
51+
}

Diff for: ui/src/views/dashboard/UsageDashboard.vue

+6-2
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,13 @@ export default {
460460
},
461461
listProject () {
462462
this.loading = true
463-
api('listProjects', { id: store.getters.project.id }).then(json => {
463+
const params = {
464+
id: store.getters.project.id,
465+
listall: true
466+
}
467+
api('listProjects', params).then(json => {
464468
this.loading = false
465-
if (json && json.listprojectsresponse && json.listprojectsresponse.project) {
469+
if (json?.listprojectsresponse?.project) {
466470
this.project = json.listprojectsresponse.project[0]
467471
}
468472
})

Diff for: ui/src/views/network/VpcTiersTab.vue

+14-4
Original file line numberDiff line numberDiff line change
@@ -242,18 +242,18 @@
242242
</a-form-item>
243243
<a-form-item ref="gateway" name="gateway" :colon="false">
244244
<template #label>
245-
<tooltip-label :title="$t('label.gateway')" :tooltip="$t('label.create.tier.gateway.description')"/>
245+
<tooltip-label :title="$t('label.gateway')" :tooltip="gatewayPlaceholder"/>
246246
</template>
247247
<a-input
248-
:placeholder="$t('label.create.tier.gateway.description')"
248+
:placeholder="gatewayPlaceholder"
249249
v-model:value="form.gateway"></a-input>
250250
</a-form-item>
251251
<a-form-item ref="netmask" name="netmask" :colon="false">
252252
<template #label>
253-
<tooltip-label :title="$t('label.netmask')" :tooltip="$t('label.create.tier.netmask.description')"/>
253+
<tooltip-label :title="$t('label.netmask')" :tooltip="netmaskPlaceholder"/>
254254
</template>
255255
<a-input
256-
:placeholder="$t('label.create.tier.netmask.description')"
256+
:placeholder="netmaskPlaceholder"
257257
v-model:value="form.netmask"></a-input>
258258
</a-form-item>
259259
<a-form-item ref="externalId" name="externalId" :colon="false">
@@ -363,6 +363,7 @@ import { api } from '@/api'
363363
import { mixinForm } from '@/utils/mixin'
364364
import Status from '@/components/widgets/Status'
365365
import TooltipLabel from '@/components/widgets/TooltipLabel'
366+
import { getNetmaskFromCidr } from '@/utils/network'
366367
367368
export default {
368369
name: 'VpcTiersTab',
@@ -400,6 +401,8 @@ export default {
400401
selectedNetworkOffering: {},
401402
privateMtuMax: 1500,
402403
errorPrivateMtu: '',
404+
gatewayPlaceholder: '',
405+
netmaskPlaceholder: '',
403406
algorithms: {
404407
Source: 'source',
405408
'Round-robin': 'roundrobin',
@@ -696,6 +699,13 @@ export default {
696699
this.initForm()
697700
this.fetchNetworkAclList()
698701
this.fetchNetworkOfferings()
702+
const cidr = this.resource.cidr
703+
const netmask = getNetmaskFromCidr(cidr)
704+
if (netmask) {
705+
this.gatewayPlaceholder = this.$t('label.create.tier.gateway.description', { value: cidr })
706+
this.netmaskPlaceholder = this.$t('label.create.tier.netmask.description', { value: netmask })
707+
}
708+
699709
this.showCreateNetworkModal = true
700710
this.rules = {
701711
name: [{ required: true, message: this.$t('label.required') }],

0 commit comments

Comments
 (0)