Skip to content

Commit 4c31f9d

Browse files
author
Dahn Highland
committed
Merge release branch 4.20 to main
* 4.20: xenserver: do not destroy halted hypervisor vm (#9175) define the limit of projects through the UI (#10652) fix projects metrics on dashboard (#10651) systemvm: Bump systemvm template version to debian 12.10 (#10628) Enhance VPC Network Tier form to auto-populate Gateway, and Netmask (#10617)
2 parents f275c28 + 6850147 commit 4c31f9d

17 files changed

+398
-391
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: pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5151
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
5252
<project.systemvm.template.location>https://download.cloudstack.org/systemvm</project.systemvm.template.location>
53-
<project.systemvm.template.version>4.20.0.0</project.systemvm.template.version>
53+
<project.systemvm.template.version>4.20.1.0</project.systemvm.template.version>
5454
<sonar.organization>apache</sonar.organization>
5555
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
5656

Diff for: tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"format": "qcow2",
3333
"headless": true,
3434
"http_directory": "http",
35-
"iso_checksum": "sha512:04a2a128852c2dff8bb71779ad325721385051eb1264d897bdb5918ab207a9b1de636ded149c56c61a09eb8c7f428496815e70d3be31b1b1cf4c70bf6427cedd",
36-
"iso_url": "https://cdimage.debian.org/mirror/cdimage/release/12.9.0/arm64/iso-cd/debian-12.9.0-arm64-netinst.iso",
35+
"iso_checksum": "sha512:022895e699231c94abf7012f86cabc587dc576f07f856c87609d5d40c1f921d805a5a862cba94c1a47d09aaa565ec445222e338e73d1fa1affc4fc5908bb50ad",
36+
"iso_url": "https://cdimage.debian.org/mirror/cdimage/release/12.10.0/arm64/iso-cd/debian-12.10.0-arm64-netinst.iso",
3737
"net_device": "virtio-net",
3838
"output_directory": "../dist",
3939
"qemu_binary": "qemu-system-aarch64",

Diff for: tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
"format": "qcow2",
3232
"headless": true,
3333
"http_directory": "http",
34-
"iso_checksum": "sha512:04a2a128852c2dff8bb71779ad325721385051eb1264d897bdb5918ab207a9b1de636ded149c56c61a09eb8c7f428496815e70d3be31b1b1cf4c70bf6427cedd",
35-
"iso_url": "https://cdimage.debian.org/mirror/cdimage/release/12.9.0/arm64/iso-cd/debian-12.9.0-arm64-netinst.iso",
34+
"iso_checksum": "sha512:022895e699231c94abf7012f86cabc587dc576f07f856c87609d5d40c1f921d805a5a862cba94c1a47d09aaa565ec445222e338e73d1fa1affc4fc5908bb50ad",
35+
"iso_url": "https://cdimage.debian.org/mirror/cdimage/release/12.10.0/arm64/iso-cd/debian-12.10.0-arm64-netinst.iso",
3636
"net_device": "virtio-net",
3737
"output_directory": "../dist",
3838
"qemu_binary": "qemu-system-aarch64",

Diff for: tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"format": "qcow2",
2828
"headless": true,
2929
"http_directory": "http",
30-
"iso_checksum": "sha512:9ebe405c3404a005ce926e483bc6c6841b405c4d85e0c8a7b1707a7fe4957c617ae44bd807a57ec3e5c2d3e99f2101dfb26ef36b3720896906bdc3aaeec4cd80",
31-
"iso_url": "https://cdimage.debian.org/mirror/cdimage/release/12.9.0/amd64/iso-cd/debian-12.9.0-amd64-netinst.iso",
30+
"iso_checksum": "sha512:cb089def0684fd93c9c2fbe45fd16ecc809c949a6fd0c91ee199faefe7d4b82b64658a264a13109d59f1a40ac3080be2f7bd3d8bf3e9cdf509add6d72576a79b",
31+
"iso_url": "https://cdimage.debian.org/mirror/cdimage/release/12.10.0/amd64/iso-cd/debian-12.10.0-amd64-netinst.iso",
3232
"net_device": "virtio-net",
3333
"output_directory": "../dist",
3434
"qemuargs": [

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -636,9 +636,9 @@
636636
"label.create.template": "Create Template",
637637
"label.create.tier.aclid.description": "The ACL associated with the Network Tier.",
638638
"label.create.tier.externalid.description": "ID of the Network in an external system.",
639-
"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.",
639+
"label.create.tier.gateway.description": "Gateway IP must be within VPC CIDR ({value})",
640640
"label.create.tier.name.description": "A unique name for the Network Tier.",
641-
"label.create.tier.netmask.description": "The Network Tier's netmask. For example 255.255.255.0",
641+
"label.create.tier.netmask.description": "Network Tier's netmask must be more restrictive than {value}",
642642
"label.create.tier.networkofferingid.description": "The Network offering for the Network Tier.",
643643
"label.create.tungsten.routing.policy": "Create Tungsten-Fabric routing policy",
644644
"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
@@ -463,9 +463,13 @@ export default {
463463
},
464464
listProject () {
465465
this.loading = true
466-
api('listProjects', { id: store.getters.project.id }).then(json => {
466+
const params = {
467+
id: store.getters.project.id,
468+
listall: true
469+
}
470+
api('listProjects', params).then(json => {
467471
this.loading = false
468-
if (json && json.listprojectsresponse && json.listprojectsresponse.project) {
472+
if (json?.listprojectsresponse?.project) {
469473
this.project = json.listprojectsresponse.project[0]
470474
}
471475
})

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)