feat(xo-server/vm.snapshot): add saveMemory param (#3807)
Related to #3795
This commit is contained in:
parent
4d4e87aa93
commit
917701e2f6
@ -747,12 +747,18 @@ export { convertToTemplate as convert }
|
||||
// TODO: implement resource sets
|
||||
export const snapshot = defer(async function(
|
||||
$defer,
|
||||
{ vm, name = `${vm.name_label}_${new Date().toISOString()}` }
|
||||
{
|
||||
vm,
|
||||
name = `${vm.name_label}_${new Date().toISOString()}`,
|
||||
saveMemory = false,
|
||||
}
|
||||
) {
|
||||
await checkPermissionOnSrs.call(this, vm)
|
||||
|
||||
const xapi = this.getXapi(vm)
|
||||
const { $id: snapshotId } = await xapi.snapshotVm(vm._xapiRef, name)
|
||||
const { $id: snapshotId } = await (saveMemory
|
||||
? xapi.checkpointVm(vm._xapiRef, name)
|
||||
: xapi.snapshotVm(vm._xapiRef, name))
|
||||
$defer.onFailure(() => xapi.deleteVm(snapshotId))
|
||||
|
||||
const { user } = this
|
||||
@ -765,6 +771,7 @@ export const snapshot = defer(async function(
|
||||
snapshot.params = {
|
||||
id: { type: 'string' },
|
||||
name: { type: 'string', optional: true },
|
||||
saveMemory: { type: 'boolean', optional: true },
|
||||
}
|
||||
|
||||
snapshot.resolve = {
|
||||
|
@ -12,6 +12,16 @@ const XEN_VGA_VALUES = ['std', 'cirrus']
|
||||
const XEN_VIDEORAM_VALUES = [1, 2, 4, 8, 16]
|
||||
|
||||
export default {
|
||||
// https://xapi-project.github.io/xen-api/classes/vm.html#checkpoint
|
||||
checkpointVm(vmId, nameLabel) {
|
||||
const vm = this.getObject(vmId)
|
||||
return this.asyncCall(
|
||||
'VM.checkpoint',
|
||||
vm.$ref,
|
||||
nameLabel != null ? nameLabel : vm.name_label
|
||||
)
|
||||
},
|
||||
|
||||
// TODO: clean up on error.
|
||||
@deferrable
|
||||
async createVm(
|
||||
|
Loading…
Reference in New Issue
Block a user