feat(xo-server): VDI_destroy instead of deleteVdi
This commit is contained in:
parent
779591db36
commit
594a148a39
@ -44,7 +44,7 @@ export const create = defer(async function ($defer, { name, size, sr, vm, bootab
|
||||
size,
|
||||
sr: sr._xapiId,
|
||||
})
|
||||
$defer.onFailure(() => xapi.deleteVdi(vdi.$id))
|
||||
$defer.onFailure(() => vdi.$destroy())
|
||||
|
||||
if (attach) {
|
||||
await xapi.createVbd({
|
||||
@ -195,7 +195,7 @@ async function handleImport(req, res, { type, name, description, vmdkData, srId,
|
||||
await xapi.importVdiContent(vdi, vhdStream, VDI_FORMAT_VHD)
|
||||
res.end(format.response(0, vdi.$id))
|
||||
} catch (e) {
|
||||
await xapi.deleteVdi(vdi)
|
||||
await vdi.$destroy()
|
||||
throw e
|
||||
}
|
||||
resolve()
|
||||
|
@ -15,7 +15,7 @@ export async function delete_({ vdi }) {
|
||||
undefined
|
||||
)
|
||||
|
||||
await this.getXapi(vdi).deleteVdi(vdi._xapiId)
|
||||
await this.getXapiObject(vdi).$destroy()
|
||||
|
||||
if (resourceSet !== undefined) {
|
||||
await this.releaseLimitsInResourceSet({ disk: vdi.size }, resourceSet)
|
||||
|
@ -810,7 +810,7 @@ async function replaceBrickOnSameVM(xosansr, previousBrick, newLvmSr, brickSize)
|
||||
await umountDisk(localEndpoint, previousBrickRoot)
|
||||
const previousVBD = previousVM.$VBDs.find(vbd => vbd.device === previousBrickDevice)
|
||||
await xapi.disconnectVbd(previousVBD)
|
||||
await xapi.deleteVdi(previousVBD.VDI)
|
||||
await xapi.VDI_destroy(previousVBD.VDI)
|
||||
CURRENT_POOL_OPERATIONS[poolId] = { ...OPERATION_OBJECT, state: 4 }
|
||||
await xapi.callAsync('SR.scan', xapi.getObject(xosansr).$ref)
|
||||
} finally {
|
||||
|
@ -664,7 +664,7 @@ export default class Xapi extends XapiBase {
|
||||
//
|
||||
// The snapshot must not exist otherwise it could break the
|
||||
// next export.
|
||||
this._deleteVdi(vdi.$ref)::ignoreErrors()
|
||||
vdi.$destroy()::ignoreErrors()
|
||||
return
|
||||
}
|
||||
|
||||
@ -794,7 +794,7 @@ export default class Xapi extends XapiBase {
|
||||
},
|
||||
sr: mapVdisSrs[vdi.uuid] || srId,
|
||||
})
|
||||
$defer.onFailure.call(this, '_deleteVdi', suspendVdi.$ref)
|
||||
$defer.onFailure.call(this, 'VDI_destroy', suspendVdi.$ref)
|
||||
}
|
||||
|
||||
// 1. Create the VMs.
|
||||
@ -838,7 +838,7 @@ export default class Xapi extends XapiBase {
|
||||
}
|
||||
|
||||
newVdi = await this._getOrWaitObject(await this._cloneVdi(baseVdi))
|
||||
$defer.onFailure(() => this._deleteVdi(newVdi.$ref))
|
||||
$defer.onFailure(() => newVdi.$destroy())
|
||||
|
||||
await newVdi.update_other_config(TAG_COPY_SRC, vdi.uuid)
|
||||
} else if (vdiRef === delta.vm.suspend_VDI) {
|
||||
@ -854,7 +854,7 @@ export default class Xapi extends XapiBase {
|
||||
},
|
||||
sr: mapVdisSrs[vdi.uuid] || srId,
|
||||
})
|
||||
$defer.onFailure(() => this._deleteVdi(newVdi.$ref))
|
||||
$defer.onFailure(() => newVdi.$destroy())
|
||||
}
|
||||
|
||||
await asyncMapSettled(vbds[vdiRef], vbd =>
|
||||
@ -1066,7 +1066,7 @@ export default class Xapi extends XapiBase {
|
||||
'[XO] Supplemental pack ISO',
|
||||
'small temporary VDI to store a supplemental pack ISO'
|
||||
)
|
||||
$defer(() => this._deleteVdi(vdi.$ref))
|
||||
$defer(() => vdi.$destroy())
|
||||
|
||||
await this._callInstallationPlugin(this.getObject(hostId).$ref, vdi.uuid)
|
||||
}
|
||||
@ -1092,7 +1092,7 @@ export default class Xapi extends XapiBase {
|
||||
'[XO] Supplemental pack ISO',
|
||||
'small temporary VDI to store a supplemental pack ISO'
|
||||
)
|
||||
$defer(() => this._deleteVdi(vdi.$ref))
|
||||
$defer(() => vdi.$destroy())
|
||||
|
||||
// Install pack sequentially to prevent concurrent access to the unique VDI
|
||||
for (const host of hosts) {
|
||||
@ -1125,7 +1125,7 @@ export default class Xapi extends XapiBase {
|
||||
'[XO] Supplemental pack ISO',
|
||||
'small temporary VDI to store a supplemental pack ISO'
|
||||
)
|
||||
$defer(() => this._deleteVdi(vdi.$ref))
|
||||
$defer(() => vdi.$destroy())
|
||||
|
||||
await this._callInstallationPlugin(host.$ref, vdi.uuid)
|
||||
})
|
||||
@ -1197,7 +1197,7 @@ export default class Xapi extends XapiBase {
|
||||
size: disk.capacity,
|
||||
sr: sr.$ref,
|
||||
}))
|
||||
$defer.onFailure(() => this._deleteVdi(vdi.$ref))
|
||||
$defer.onFailure(() => vdi.$destroy())
|
||||
compression[disk.path] = disk.compression
|
||||
return this.createVbd({
|
||||
userdevice: String(disk.position),
|
||||
@ -1596,25 +1596,12 @@ export default class Xapi extends XapiBase {
|
||||
vdi: newVdi,
|
||||
})
|
||||
})
|
||||
await this._deleteVdi(vdi.$ref)
|
||||
await vdi.$destroy()
|
||||
|
||||
return newVdi
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: check whether the VDI is attached.
|
||||
async _deleteVdi(vdiRef) {
|
||||
log.debug(`Deleting VDI ${vdiRef}`)
|
||||
|
||||
try {
|
||||
await this.callAsync('VDI.destroy', vdiRef)
|
||||
} catch (error) {
|
||||
if (error?.code !== 'HANDLE_INVALID') {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_resizeVdi(vdi, size) {
|
||||
log.debug(`Resizing VDI ${vdi.name_label} from ${vdi.virtual_size} to ${size}`)
|
||||
|
||||
@ -1705,10 +1692,6 @@ export default class Xapi extends XapiBase {
|
||||
)
|
||||
}
|
||||
|
||||
async deleteVdi(vdiId) {
|
||||
await this._deleteVdi(this.getObject(vdiId).$ref)
|
||||
}
|
||||
|
||||
async resizeVdi(vdiId, size) {
|
||||
await this._resizeVdi(this.getObject(vdiId), size)
|
||||
}
|
||||
@ -2028,7 +2011,7 @@ export default class Xapi extends XapiBase {
|
||||
size: buffer.length,
|
||||
sr: sr.$ref,
|
||||
})
|
||||
$defer.onFailure(() => this._deleteVdi(vdi.$ref))
|
||||
$defer.onFailure(() => vdi.$destroy())
|
||||
|
||||
// Then, generate a FAT fs
|
||||
const { mkdir, writeFile } = promisifyAll(fatfs.createFileSystem(fatfsBuffer(buffer)))
|
||||
@ -2071,7 +2054,7 @@ export default class Xapi extends XapiBase {
|
||||
size: stream.length,
|
||||
sr: sr.$ref,
|
||||
})
|
||||
$defer.onFailure(() => this._deleteVdi(vdi.$ref))
|
||||
$defer.onFailure(() => vdi.$destroy())
|
||||
|
||||
await this.importVdiContent(vdi.$id, stream, { format: VDI_FORMAT_RAW })
|
||||
|
||||
|
@ -392,7 +392,7 @@ export default {
|
||||
'[XO] Patch ISO',
|
||||
'small temporary VDI to store a patch ISO'
|
||||
)
|
||||
$defer(() => this._deleteVdi(vdi.$ref))
|
||||
$defer(() => vdi.$destroy())
|
||||
|
||||
return vdi
|
||||
},
|
||||
|
@ -534,8 +534,8 @@ export default class {
|
||||
}),
|
||||
base => base.snapshot_time
|
||||
)
|
||||
forEach(bases, base => {
|
||||
xapi.deleteVdi(base.$id)::ignoreErrors()
|
||||
forEach(bases, baseVdi => {
|
||||
baseVdi.$destroy()::ignoreErrors()
|
||||
})
|
||||
|
||||
// Export full or delta backup.
|
||||
|
Loading…
Reference in New Issue
Block a user