fix(vm.create): select SR of first disk-VDI (#391)

Fixes vatesfr/xo-web#1493
This commit is contained in:
Julien Fontanet 2016-09-12 16:32:43 +02:00 committed by GitHub
parent 37a4221e43
commit 6165f1b405
2 changed files with 13 additions and 3 deletions

View File

@ -1948,6 +1948,7 @@ export default class Xapi extends XapiBase {
sruuid: sr.uuid,
configuration: config
})
await this.registerDockerContainer(vmId)
}
// Generic Config Drive

View File

@ -116,8 +116,12 @@ export default {
})
}
let nDisks = 0
// Modify existing (previous template) disks if necessary
existingVdis && await Promise.all(mapToArray(existingVdis, async ({ size, $SR: srId, ...properties }, userdevice) => {
++nDisks
const vbd = find(vm.$VBDs, { userdevice })
if (!vbd) {
return
@ -144,6 +148,8 @@ export default {
if (vdis) {
const devices = await this.call('VM.get_allowed_VBD_devices', vm.$ref)
await Promise.all(mapToArray(vdis, (vdiDescription, i) => {
++nDisks
return this._createVdi(
vdiDescription.size, // FIXME: Should not be done in Xapi.
{
@ -183,13 +189,16 @@ export default {
if (cloudConfig != null) {
// 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.
let srRef
forEach(vm.$VBDs, vbd => {
const vdi = vbd.$VDI
if (vdi) {
let vdi
if (
vbd.type === 'Disk' &&
(vdi = vbd.$VDI)
) {
srRef = vdi.SR
return false
}