Fix VIF creation.
This commit is contained in:
parent
35bf7dc484
commit
55a1c27d6d
@ -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' }
|
||||
|
24
src/xapi.js
24
src/xapi.js
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user