Skip to content

Commit 39c5641

Browse files
committed
Merge branch '4.20' of https://github.com/apache/cloudstack
2 parents fd74895 + 83c3ea2 commit 39c5641

File tree

6 files changed

+39
-14
lines changed

6 files changed

+39
-14
lines changed

engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/StorageVMSnapshotStrategy.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public VMSnapshot takeVMSnapshot(VMSnapshot vmSnapshot) {
181181
thawAnswer = (FreezeThawVMAnswer) agentMgr.send(hostId, thawCmd);
182182
if (thawAnswer != null && thawAnswer.getResult()) {
183183
logger.info(String.format(
184-
"Virtual machne is thawed. The freeze of virtual machine took %s milliseconds.",
184+
"Virtual machine is thawed. The freeze of virtual machine took %s milliseconds.",
185185
TimeUnit.MILLISECONDS.convert(elapsedTime(startFreeze), TimeUnit.NANOSECONDS)));
186186
}
187187
} else {
@@ -427,9 +427,14 @@ protected SnapshotInfo createDiskSnapshot(VMSnapshot vmSnapshot, List<SnapshotIn
427427
String snapshotName = vmSnapshot.getId() + "_" + vol.getUuid();
428428
SnapshotVO snapshot = new SnapshotVO(vol.getDataCenterId(), vol.getAccountId(), vol.getDomainId(), vol.getId(), vol.getDiskOfferingId(),
429429
snapshotName, (short) Snapshot.Type.GROUP.ordinal(), Snapshot.Type.GROUP.name(), vol.getSize(), vol.getMinIops(), vol.getMaxIops(), Hypervisor.HypervisorType.KVM, null);
430+
VMSnapshotOptions options = ((VMSnapshotVO) vmSnapshot).getOptions();
431+
boolean quiescevm = false;
432+
if (options != null) {
433+
quiescevm = options.needQuiesceVM();
434+
}
430435

431436
snapshot = snapshotDao.persist(snapshot);
432-
vol.addPayload(setPayload(vol, snapshot));
437+
vol.addPayload(setPayload(vol, snapshot, quiescevm));
433438
SnapshotInfo snapshotInfo = snapshotDataFactory.getSnapshot(snapshot.getId(), vol.getDataStore());
434439
snapshotInfo.addPayload(vol.getpayload());
435440
SnapshotStrategy snapshotStrategy = storageStrategyFactory.getSnapshotStrategy(snapshotInfo, SnapshotOperation.TAKE);
@@ -447,14 +452,14 @@ protected SnapshotInfo createDiskSnapshot(VMSnapshot vmSnapshot, List<SnapshotIn
447452
return snapshotInfo;
448453
}
449454

450-
protected CreateSnapshotPayload setPayload(VolumeInfo vol, SnapshotVO snapshotCreate) {
455+
protected CreateSnapshotPayload setPayload(VolumeInfo vol, SnapshotVO snapshotCreate, boolean quiescevm) {
451456
CreateSnapshotPayload payload = new CreateSnapshotPayload();
452457
payload.setSnapshotId(snapshotCreate.getId());
453458
payload.setSnapshotPolicyId(SnapshotVO.MANUAL_POLICY_ID);
454459
payload.setLocationType(snapshotCreate.getLocationType());
455460
payload.setAccount(accountService.getAccount(vol.getAccountId()));
456461
payload.setAsyncBackup(false);
457-
payload.setQuiescevm(false);
462+
payload.setQuiescevm(quiescevm);
458463
return payload;
459464
}
460465
}

engine/storage/snapshot/src/test/java/org/apache/cloudstack/storage/vmsnapshot/VMSnapshotStrategyKVMTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy;
3838
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy.SnapshotOperation;
3939
import org.apache.cloudstack.engine.subsystem.api.storage.StorageStrategyFactory;
40+
import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotOptions;
4041
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
4142
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
4243
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
@@ -151,7 +152,7 @@ public void setUp() throws Exception {
151152

152153
@Test
153154
public void testCreateDiskSnapshotBasedOnStrategy() throws Exception {
154-
VMSnapshot vmSnapshot = Mockito.mock(VMSnapshot.class);
155+
VMSnapshotVO vmSnapshot = Mockito.mock(VMSnapshotVO.class);
155156
List<SnapshotInfo> forRollback = new ArrayList<>();
156157
VolumeInfo vol = Mockito.mock(VolumeInfo.class);
157158
SnapshotInfo snapshotInfo = Mockito.mock(SnapshotInfo.class);
@@ -162,6 +163,7 @@ public void testCreateDiskSnapshotBasedOnStrategy() throws Exception {
162163
SnapshotVO snapshot = new SnapshotVO(vol.getDataCenterId(), vol.getAccountId(), vol.getDomainId(),
163164
vol.getId(),vol.getDiskOfferingId(), vmUuid + "_" + volUuid,(short) SnapshotVO.MANUAL_POLICY_ID,
164165
"MANUAL",vol.getSize(),vol.getMinIops(),vol.getMaxIops(), Hypervisor.HypervisorType.KVM, null);
166+
when(vmSnapshot.getOptions()).thenReturn(new VMSnapshotOptions(true));
165167
when(vmSnapshot.getUuid()).thenReturn(vmUuid);
166168
when(vol.getUuid()).thenReturn(volUuid);
167169
when(_snapshotDao.persist(any())).thenReturn(snapshot);

test/integration/smoke/test_vm_strict_host_tags.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def test_06_deploy_vm_on_any_host_with_strict_tags_failure(self):
190190
self.cleanup.append(vm)
191191
self.fail("VM should not be deployed")
192192
except Exception as e:
193-
self.assertTrue("No suitable host found for vm " in str(e))
193+
self.assertTrue("No destination found for a deployment for VM instance" in str(e))
194194

195195

196196
class TestScaleVMStrictTags(cloudstackTestCase):
@@ -310,7 +310,7 @@ def test_02_scale_vm_strict_tags_failure(self):
310310
vm.start(self.apiclient)
311311
self.fail("VM should not be be able scale and start")
312312
except Exception as e:
313-
self.assertTrue("No suitable host found for vm " in str(e))
313+
self.assertTrue("Unable to orchestrate the start of VM instance" in str(e))
314314

315315

316316
class TestRestoreVMStrictTags(cloudstackTestCase):
@@ -423,7 +423,7 @@ def test_02_restore_vm_strict_tags_failure(self):
423423
vm.restore(self.apiclient, templateid=self.template_t2.id, expunge=True)
424424
self.fail("VM should not be restored")
425425
except Exception as e:
426-
self.assertTrue("No suitable host found for vm " in str(e))
426+
self.assertTrue("Unable to start VM with specified id" in str(e))
427427

428428

429429
class TestMigrateVMStrictTags(cloudstackTestCase):

ui/src/config/section/compute.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,13 @@ export default {
190190
label: 'label.action.vmsnapshot.create',
191191
docHelp: 'adminguide/virtual_machines.html#virtual-machine-snapshots',
192192
dataView: true,
193-
args: ['virtualmachineid', 'name', 'description', 'snapshotmemory', 'quiescevm'],
193+
args: (record, store) => {
194+
var args = ['virtualmachineid', 'name', 'description', 'snapshotmemory']
195+
if (['KVM', 'VMware'].includes(record.hypervisor)) {
196+
args.push('quiescevm')
197+
}
198+
return args
199+
},
194200
show: (record) => {
195201
return (((['Running'].includes(record.state) && record.hypervisor !== 'LXC') ||
196202
(['Stopped'].includes(record.state) && ((record.hypervisor !== 'KVM' && record.hypervisor !== 'LXC') ||

ui/src/views/compute/CreateSnapshotWizard.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@
5555
v-model:value="form.name"
5656
:placeholder="apiParams.name.description"/>
5757
</a-form-item>
58-
<a-form-item name="quiescevm" ref="quiescevm" v-if="isQuiesceVm">
58+
<a-form-item name="quiescevm" ref="quiescevm" v-if="isQuiesceVm && hypervisorSupportsQuiesceVm">
5959
<template #label>
6060
<tooltip-label :title="$t('label.quiescevm')" :tooltip="apiParams.quiescevm.description"/>
6161
</template>
6262
<a-switch v-model:checked="form.quiescevm"/>
6363
</a-form-item>
64-
<a-form-item name="asyncbackup" ref="asyncbackup">
64+
<a-form-item name="asyncbackup" ref="asyncbackup" v-if="!supportsStorageSnapshot">
6565
<template #label>
6666
<tooltip-label :title="$t('label.asyncbackup')" :tooltip="apiParams.asyncbackup.description"/>
6767
</template>
@@ -98,6 +98,7 @@ export default {
9898
return {
9999
loading: false,
100100
isQuiesceVm: false,
101+
hypervisorSupportsQuiesceVm: false,
101102
supportsStorageSnapshot: false,
102103
listVolumes: []
103104
}
@@ -119,6 +120,9 @@ export default {
119120
},
120121
fetchData () {
121122
this.loading = true
123+
if (['KVM', 'VMware'].includes(this.resource.hypervisor)) {
124+
this.hypervisorSupportsQuiesceVm = true
125+
}
122126
123127
api('listVolumes', { virtualMachineId: this.resource.id, listall: true })
124128
.then(json => {
@@ -141,7 +145,10 @@ export default {
141145
if (values.asyncbackup) {
142146
params.asyncbackup = values.asyncbackup
143147
}
144-
params.quiescevm = values.quiescevm
148+
params.quiescevm = false
149+
if (values.quiescevm) {
150+
params.quiescevm = values.quiescevm
151+
}
145152
146153
const title = this.$t('label.action.vmstoragesnapshot.create')
147154
const description = values.name || values.volumeid

ui/src/views/storage/TakeSnapshot.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@
6666
</a-select-option>
6767
</a-select>
6868
</a-form-item>
69-
<a-form-item :label="$t('label.asyncbackup')" name="asyncbackup" ref="asyncbackup">
69+
<a-form-item :label="$t('label.asyncbackup')" name="asyncbackup" ref="asyncbackup" v-if="!supportsStorageSnapshot">
7070
<a-switch v-model:checked="form.asyncbackup" />
7171
</a-form-item>
72-
<a-form-item :label="$t('label.quiescevm')">
72+
<a-form-item :label="$t('label.quiescevm')" name="quiescevm" ref="quiescevm" v-if="quiescevm && hypervisorSupportsQuiesceVm">
7373
<a-switch v-model:checked="form.quiescevm" />
7474
</a-form-item>
7575
<a-divider/>
@@ -152,6 +152,7 @@ export default {
152152
return {
153153
actionLoading: false,
154154
quiescevm: false,
155+
hypervisorSupportsQuiesceVm: false,
155156
supportsStorageSnapshot: false,
156157
inputValue: '',
157158
inputKey: '',
@@ -168,6 +169,10 @@ export default {
168169
created () {
169170
this.initForm()
170171
this.quiescevm = this.resource.quiescevm
172+
if (['KVM', 'VMware'].includes(this.resource.hypervisor)) {
173+
this.hypervisorSupportsQuiesceVm = true
174+
}
175+
171176
this.supportsStorageSnapshot = this.resource.supportsstoragesnapshot
172177
this.fetchZoneData()
173178
},

0 commit comments

Comments
 (0)