feat(xapi/VIF_create): MAC must be passed explicitely

This commit is contained in:
Julien Fontanet 2021-03-24 16:38:19 +01:00
parent 1fd330d7a4
commit 45a0ff26c5
2 changed files with 30 additions and 19 deletions

View File

@ -325,11 +325,16 @@ exports.importDeltaVm = defer(async function importDeltaVm(
}
if (network) {
return xapi.VIF_create({
...vif,
network: network.$ref,
VM: vmRef,
})
return xapi.VIF_create(
{
...vif,
network: network.$ref,
VM: vmRef,
},
{
MAC: vif.MAC,
}
)
}
}),
])

View File

@ -1,20 +1,26 @@
const isVmRunning = require('./_isVmRunning')
module.exports = class Vif {
async create({
currently_attached = true,
device,
ipv4_allowed,
ipv6_allowed,
locking_mode,
MAC,
MTU,
network,
other_config = {},
qos_algorithm_params = {},
qos_algorithm_type = '',
VM,
}) {
async create(
{
currently_attached = true,
device,
ipv4_allowed,
ipv6_allowed,
locking_mode,
MTU,
network,
other_config = {},
qos_algorithm_params = {},
qos_algorithm_type = '',
VM,
},
{
// duplicated MAC addresses can lead to issues,
// therefore it should be passed explicitely
MAC = '',
} = {}
) {
const [powerState, ...rest] = await Promise.all([
this.getField('VM', VM, 'power_state'),
device ?? (await this.call('VM.get_allowed_VIF_devices', VM))[0],