chore(Xapi#exportDeltaVm): make it cancelable
This commit is contained in:
parent
7bcece7f76
commit
bc853da09a
@ -770,8 +770,9 @@ export default class Xapi extends XapiBase {
|
||||
}
|
||||
|
||||
// Create a snapshot of the VM and returns a delta export object.
|
||||
@cancellable
|
||||
@deferrable.onFailure
|
||||
async exportDeltaVm ($onFailure, vmId, baseVmId = undefined, {
|
||||
async exportDeltaVm ($onFailure, $cancelToken, vmId, baseVmId = undefined, {
|
||||
snapshotNameLabel = undefined,
|
||||
// Contains a vdi.$id set of vmId.
|
||||
fullVdisRequired = [],
|
||||
|
@ -3,6 +3,7 @@ import escapeStringRegexp from 'escape-string-regexp'
|
||||
import eventToPromise from 'event-to-promise'
|
||||
import execa from 'execa'
|
||||
import splitLines from 'split-lines'
|
||||
import { CancelToken } from 'promise-toolbox'
|
||||
import { createParser as createPairsParser } from 'parse-pairs'
|
||||
import { createReadStream, readdir, stat } from 'fs'
|
||||
import { satisfies as versionSatisfies } from 'semver'
|
||||
@ -416,11 +417,12 @@ export default class {
|
||||
// 2. Copy.
|
||||
let size = 0
|
||||
const dstVm = await (async () => {
|
||||
const delta = await srcXapi.exportDeltaVm(srcVm.$id, localBaseUuid, {
|
||||
const { cancel, token } = CancelToken.source()
|
||||
const delta = await srcXapi.exportDeltaVm(token, srcVm.$id, localBaseUuid, {
|
||||
snapshotNameLabel: `XO_DELTA_EXPORT: ${targetSr.name_label} (${targetSr.uuid})`
|
||||
})
|
||||
$onFailure(() => srcXapi.deleteVm(delta.vm.uuid)::pCatch(noop))
|
||||
forEach(delta.streams, stream => $onFailure(stream.cancel))
|
||||
$onFailure(() => srcXapi.deleteVm(delta.vm.uuid))
|
||||
$onFailure(cancel)
|
||||
|
||||
delta.vm.name_label += ` (${shortDate(Date.now())})`
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user