fix issue xo-web/#287

This commit is contained in:
Olivier Lambert 2015-06-10 16:22:13 +02:00
parent 74b0697da1
commit 51abeabb33
2 changed files with 12 additions and 5 deletions

View File

@ -1,3 +1,4 @@
// TODO: move into vm and rename to removeInterface
async function delete_ ({vif}) {
// TODO: check if VIF is attached before
await this.getXAPI(vif).call('VIF.destroy', vif.ref)
@ -13,7 +14,7 @@ delete_.resolve = {
}
// -------------------------------------------------------------------
// TODO: move into vm and rename to disconnectInterface
export async function disconnect ({vif}) {
// TODO: check if VIF is attached before
await this.getXAPI(vif).call('VIF.unplug_force', vif.ref)
@ -28,7 +29,7 @@ disconnect.resolve = {
}
// -------------------------------------------------------------------
// TODO: move into vm and rename to connectInterface
export async function connect ({vif}) {
// TODO: check if VIF is attached before
await this.getXAPI(vif).call('VIF.plug', vif.ref)

View File

@ -528,7 +528,9 @@ export default class Xapi extends XapiBase {
VM: vm.$ref
})
await this.call('VBD.plug', vbdRef)
if (isVmRunning(vm)) {
await this.call('VBD.plug', vbdRef)
}
}
// =================================================================
@ -541,7 +543,7 @@ export default class Xapi extends XapiBase {
const vm = this.getObject(vmId)
const network = this.getObject(networkId)
const ref = await this.call('VIF.create', {
const vifRef = await this.call('VIF.create', {
device: String(position),
MAC: String(mac),
MTU: String(mtu),
@ -552,7 +554,11 @@ export default class Xapi extends XapiBase {
VM: vm.$ref
})
return await this._getOrWaitObject(ref)
if (isVmRunning(vm)) {
await this.call('VIF.plug', vifRef)
}
return await this._getOrWaitObject(vifRef)
}
// =================================================================