Fix VIF creation.

This commit is contained in:
Julien Fontanet 2015-05-28 11:42:13 +02:00
parent 35bf7dc484
commit 55a1c27d6d
3 changed files with 32 additions and 15 deletions

View File

@ -884,21 +884,13 @@ exports.attachDisk = attachDisk
# FIXME: position should be optional and default to last.
createInterface = $coroutine ({vm, network, position, mtu, mac}) ->
xapi = @getXAPI vm
VIF_ref = $wait xapi.call 'VIF.create', {
VM: vm.ref
network: network.ref
device: position
MTU: mtu ? '1500'
MAC: mac ? ''
other_config: {}
qos_algorithm_type: ''
qos_algorithm_params: {}
}
return $wait(xapi.call( 'VIF.get_record', VIF_ref)).uuid
vif = $wait @getXAPI(vm).createVirtualInterface(vm.id, network.id, {
mac,
mtu,
position
})
return vif.$id
createInterface.params = {
vm: { type: 'string' }

View File

@ -486,6 +486,30 @@ export default class Xapi extends XapiBase {
// =================================================================
async createVirtualInterface (vmId, networkId, {
mac = '',
mtu = 1500,
position = 0
} = {}) {
const vm = this.getObject(vmId)
const network = this.getObject(networkId)
const ref = await this.call('VIF.create', {
device: String(position),
MAC: String(mac),
MTU: String(mtu),
network: network.$ref,
other_config: {},
qos_algorithm_params: {},
qos_algorithm_type: '',
VM: vm.$ref
})
return await this._getOrWaitObject(ref)
}
// =================================================================
async _doDockerAction (vmId, action, containerId) {
const vm = this.getObject(vmId)
const host = vm.$resident_on

View File

@ -312,7 +312,8 @@ export default class Xo extends EventEmitter {
$poolId: {
enumerable: true,
value: pool.$id
}
},
ref: { value: xapiObject.$ref }
})
objects.set(id, xoObject)