chore(xo-server): use @xen-orchestra/xapi/VBD_unplug
This commit is contained in:
parent
9860bd770b
commit
379e4d7596
@ -17,8 +17,7 @@ export { delete_ as delete }
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
export async function disconnect({ vbd }) {
|
||||
const xapi = this.getXapi(vbd)
|
||||
await xapi.disconnectVbd(vbd._xapiRef)
|
||||
await this.getXapiObject(vbd).$unplug()
|
||||
}
|
||||
|
||||
disconnect.params = {
|
||||
|
@ -812,7 +812,7 @@ async function replaceBrickOnSameVM(xosansr, previousBrick, newLvmSr, brickSize)
|
||||
CURRENT_POOL_OPERATIONS[poolId] = { ...OPERATION_OBJECT, state: 3 }
|
||||
await umountDisk(localEndpoint, previousBrickRoot)
|
||||
const previousVBD = previousVM.$VBDs.find(vbd => vbd.device === previousBrickDevice)
|
||||
await xapi.disconnectVbd(previousVBD)
|
||||
await previousVBD.$unplug()
|
||||
await xapi.VDI_destroy(previousVBD.VDI)
|
||||
CURRENT_POOL_OPERATIONS[poolId] = { ...OPERATION_OBJECT, state: 4 }
|
||||
await xapi.callAsync('SR.scan', xapi.getObject(xosansr).$ref)
|
||||
|
@ -1075,23 +1075,6 @@ export default class Xapi extends XapiBase {
|
||||
await this.callAsync('VBD.plug', vbdId)
|
||||
}
|
||||
|
||||
async _disconnectVbd(vbd) {
|
||||
// TODO: check if VBD is attached before
|
||||
try {
|
||||
await this.call('VBD.unplug_force', vbd.$ref)
|
||||
} catch (error) {
|
||||
if (error.code === 'VBD_NOT_UNPLUGGABLE') {
|
||||
await vbd.set_unpluggable(true)
|
||||
return this.call('VBD.unplug_force', vbd.$ref)
|
||||
}
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
async disconnectVbd(vbdId) {
|
||||
await this._disconnectVbd(this.getObject(vbdId))
|
||||
}
|
||||
|
||||
// TODO: remove when no longer used.
|
||||
async destroyVbdsFromVm(vmId) {
|
||||
await Promise.all(this.getObject(vmId).VBDs.map(async ref => this.VBD_destroy(ref)))
|
||||
|
Loading…
Reference in New Issue
Block a user