From 0eb7bcd013a057356e8fad2f9a5c9932bb7da5e3 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Fri, 23 Jun 2017 16:38:48 +0200 Subject: [PATCH] chore(Xapi#_createTask): replace with upstream Xapi#createTask --- src/xapi/index.js | 26 +++++++------------------- src/xapi/mixins/patching.js | 2 +- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/xapi/index.js b/src/xapi/index.js index c4b306ba3..2b9ffb353 100644 --- a/src/xapi/index.js +++ b/src/xapi/index.js @@ -137,6 +137,10 @@ export default class Xapi extends XapiBase { return loop() } + createTask (name = 'untitled task', description) { + return super.createTask(`[XO] ${name}`, description) + } + // ================================================================= _registerGenericWatcher (fn) { @@ -211,22 +215,6 @@ export default class Xapi extends XapiBase { // ================================================================= - // Create a task. - async _createTask (name = 'untitled task', description = '') { - const ref = await this.call('task.create', `[XO] ${name}`, description) - debug('task created: %s (%s)', name, description) - - this.watchTask(ref)::pFinally(() => { - this.call('task.destroy', ref).then(() => { - debug('task destroyed: %s (%s)', name, description) - }) - }) - - return ref - } - - // ================================================================= - _setObjectProperty (object, name, value) { return this.call( `${getNamespaceForType(object.$type)}.set_${camelToSnakeCase(name)}`, @@ -730,7 +718,7 @@ export default class Xapi extends XapiBase { snapshotRef = (await this._snapshotVm(vm)).$ref } - const taskRef = await this._createTask('VM Export', vm.name_label) + const taskRef = await this.createTask('VM Export', vm.name_label) if (snapshotRef) { this.watchTask(taskRef)::pFinally(() => { this.deleteVm(snapshotRef)::pCatch(noop) @@ -1185,7 +1173,7 @@ export default class Xapi extends XapiBase { } async _importVm (stream, sr, onlyMetadata = false, onVmCreation = undefined) { - const taskRef = await this._createTask('VM import') + const taskRef = await this.createTask('VM import') const query = { force: onlyMetadata ? 'true' @@ -1822,7 +1810,7 @@ export default class Xapi extends XapiBase { @cancellable async _exportVdi ($cancelToken, vdi, base, format = VDI_FORMAT_VHD) { const host = vdi.$SR.$PBDs[0].$host - const taskRef = await this._createTask('VDI Export', vdi.name_label) + const taskRef = await this.createTask('VDI Export', vdi.name_label) const query = { format, diff --git a/src/xapi/mixins/patching.js b/src/xapi/mixins/patching.js index d6d8b4614..856d47fb1 100644 --- a/src/xapi/mixins/patching.js +++ b/src/xapi/mixins/patching.js @@ -212,7 +212,7 @@ export default { // platform_version < 2.1.1 ---------------------------------------- async uploadPoolPatch (stream, patchName = 'unknown') { - const taskRef = await this._createTask('Patch upload', patchName) + const taskRef = await this.createTask('Patch upload', patchName) const task = this.watchTask(taskRef) const [ patchRef ] = await Promise.all([