fix issue xo-web/#287
This commit is contained in:
parent
74b0697da1
commit
51abeabb33
@ -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)
|
||||
|
12
src/xapi.js
12
src/xapi.js
@ -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)
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user