chore(Xapi#_createTask): replace with upstream Xapi#createTask
This commit is contained in:
parent
87f694f698
commit
0eb7bcd013
@ -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,
|
||||
|
@ -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([
|
||||
|
Loading…
Reference in New Issue
Block a user