fix(xapi): allow to unplug VBDs when VM is running

This commit is contained in:
Olivier Lambert 2016-08-11 16:32:06 +02:00
parent db4d46a584
commit 290cc146c8

View File

@ -1839,9 +1839,16 @@ export default class Xapi extends XapiBase {
await this.call('VBD.plug', vbdId)
}
_disconnectVbd (vbd) {
async _disconnectVbd (vbd) {
// TODO: check if VBD is attached before
return this.call('VBD.unplug_force', vbd.$ref)
try {
await this.call('VBD.unplug_force', vbd.$ref)
} catch (error) {
if (error.code === 'VBD_NOT_UNPLUGGABLE') {
await this.call('VBD.set_unpluggable', vbd.$ref, true)
return this.call('VBD.unplug_force', vbd.$ref)
}
}
}
async disconnectVbd (vbdId) {