From 2a6c476189e2d7f9af1fa805e87969baa9ab6a64 Mon Sep 17 00:00:00 2001 From: Pierre Donias Date: Thu, 27 Jul 2017 19:39:08 +0200 Subject: [PATCH] fix(vm.create): assign device to VDIs (#586) --- src/api/vm.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/vm.coffee b/src/api/vm.coffee index 0cb532779..951c241e8 100644 --- a/src/api/vm.coffee +++ b/src/api/vm.coffee @@ -7,6 +7,7 @@ concat = require 'lodash/concat' endsWith = require 'lodash/endsWith' escapeStringRegexp = require 'escape-string-regexp' eventToPromise = require 'event-to-promise' +maxBy = require 'lodash/maxBy' merge = require 'lodash/merge' sortBy = require 'lodash/sortBy' startsWith = require 'lodash/startsWith' @@ -83,7 +84,9 @@ create = $coroutine (params) -> vms: 1 } vdiSizesByDevice = {} + highestDevice = -1 forEach(xapi.getObject(template._xapiId).$VBDs, (vbd) => + highestDevice = Math.max(highestDevice, vbd.userdevice) if ( vbd.type is 'Disk' and (vdi = vbd.$VDI) @@ -102,7 +105,7 @@ create = $coroutine (params) -> limits.disk += size return $assign({}, vdi, { - device: vdi.userdevice ? vdi.device ? vdi.position, + device: ++highestDevice, size, SR: sr._xapiId, type: vdi.type @@ -276,7 +279,6 @@ create.params = { items: { type: 'object' properties: { - device: { type: 'string' } size: { type: ['integer', 'string'] } SR: { type: 'string' } type: { type: 'string' }