fix(vm.create): select SR of first disk-VDI (#391)
Fixes vatesfr/xo-web#1493
This commit is contained in:
parent
37a4221e43
commit
6165f1b405
@ -1948,6 +1948,7 @@ export default class Xapi extends XapiBase {
|
|||||||
sruuid: sr.uuid,
|
sruuid: sr.uuid,
|
||||||
configuration: config
|
configuration: config
|
||||||
})
|
})
|
||||||
|
await this.registerDockerContainer(vmId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic Config Drive
|
// Generic Config Drive
|
||||||
|
@ -116,8 +116,12 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let nDisks = 0
|
||||||
|
|
||||||
// Modify existing (previous template) disks if necessary
|
// Modify existing (previous template) disks if necessary
|
||||||
existingVdis && await Promise.all(mapToArray(existingVdis, async ({ size, $SR: srId, ...properties }, userdevice) => {
|
existingVdis && await Promise.all(mapToArray(existingVdis, async ({ size, $SR: srId, ...properties }, userdevice) => {
|
||||||
|
++nDisks
|
||||||
|
|
||||||
const vbd = find(vm.$VBDs, { userdevice })
|
const vbd = find(vm.$VBDs, { userdevice })
|
||||||
if (!vbd) {
|
if (!vbd) {
|
||||||
return
|
return
|
||||||
@ -144,6 +148,8 @@ export default {
|
|||||||
if (vdis) {
|
if (vdis) {
|
||||||
const devices = await this.call('VM.get_allowed_VBD_devices', vm.$ref)
|
const devices = await this.call('VM.get_allowed_VBD_devices', vm.$ref)
|
||||||
await Promise.all(mapToArray(vdis, (vdiDescription, i) => {
|
await Promise.all(mapToArray(vdis, (vdiDescription, i) => {
|
||||||
|
++nDisks
|
||||||
|
|
||||||
return this._createVdi(
|
return this._createVdi(
|
||||||
vdiDescription.size, // FIXME: Should not be done in Xapi.
|
vdiDescription.size, // FIXME: Should not be done in Xapi.
|
||||||
{
|
{
|
||||||
@ -183,13 +189,16 @@ export default {
|
|||||||
|
|
||||||
if (cloudConfig != null) {
|
if (cloudConfig != null) {
|
||||||
// Refresh the record.
|
// Refresh the record.
|
||||||
vm = this.getObject(vm.$id)
|
vm = await this._waitObject(vm.$id, vm => vm.VBDs.length === nDisks)
|
||||||
|
|
||||||
// Find the SR of the first VDI.
|
// Find the SR of the first VDI.
|
||||||
let srRef
|
let srRef
|
||||||
forEach(vm.$VBDs, vbd => {
|
forEach(vm.$VBDs, vbd => {
|
||||||
const vdi = vbd.$VDI
|
let vdi
|
||||||
if (vdi) {
|
if (
|
||||||
|
vbd.type === 'Disk' &&
|
||||||
|
(vdi = vbd.$VDI)
|
||||||
|
) {
|
||||||
srRef = vdi.SR
|
srRef = vdi.SR
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user