fix(xapi/VIF_create): explicit error when no allowed devices

Related to #7380
This commit is contained in:
Julien Fontanet 2024-02-14 11:44:58 +01:00
parent 7a1bc16468
commit 39c10a7197
2 changed files with 13 additions and 1 deletions

View File

@ -21,9 +21,20 @@ export default class Vif {
MAC = '',
} = {}
) {
if (device === undefined) {
const allowedDevices = await this.call('VM.get_allowed_VIF_devices', VM)
if (allowedDevices.length === 0) {
const error = new Error('could not find an allowed VIF device')
error.poolUuid = this.pool.uuid
error.vmRef = VM
throw error
}
device = allowedDevices[0]
}
const [powerState, ...rest] = await Promise.all([
this.getField('VM', VM, 'power_state'),
device ?? (await this.call('VM.get_allowed_VIF_devices', VM))[0],
MTU ?? (await this.getField('network', network, 'MTU')),
])
;[device, MTU] = rest

View File

@ -34,6 +34,7 @@
<!--packages-start-->
- @xen-orchestra/backups patch
- @xen-orchestra/xapi patch
- xo-server patch
- xo-server-audit patch
- xo-web patch