fix(vm.create): assign device to VDIs (#586)
This commit is contained in:
parent
7132a68a73
commit
2a6c476189
@ -7,6 +7,7 @@ concat = require 'lodash/concat'
|
|||||||
endsWith = require 'lodash/endsWith'
|
endsWith = require 'lodash/endsWith'
|
||||||
escapeStringRegexp = require 'escape-string-regexp'
|
escapeStringRegexp = require 'escape-string-regexp'
|
||||||
eventToPromise = require 'event-to-promise'
|
eventToPromise = require 'event-to-promise'
|
||||||
|
maxBy = require 'lodash/maxBy'
|
||||||
merge = require 'lodash/merge'
|
merge = require 'lodash/merge'
|
||||||
sortBy = require 'lodash/sortBy'
|
sortBy = require 'lodash/sortBy'
|
||||||
startsWith = require 'lodash/startsWith'
|
startsWith = require 'lodash/startsWith'
|
||||||
@ -83,7 +84,9 @@ create = $coroutine (params) ->
|
|||||||
vms: 1
|
vms: 1
|
||||||
}
|
}
|
||||||
vdiSizesByDevice = {}
|
vdiSizesByDevice = {}
|
||||||
|
highestDevice = -1
|
||||||
forEach(xapi.getObject(template._xapiId).$VBDs, (vbd) =>
|
forEach(xapi.getObject(template._xapiId).$VBDs, (vbd) =>
|
||||||
|
highestDevice = Math.max(highestDevice, vbd.userdevice)
|
||||||
if (
|
if (
|
||||||
vbd.type is 'Disk' and
|
vbd.type is 'Disk' and
|
||||||
(vdi = vbd.$VDI)
|
(vdi = vbd.$VDI)
|
||||||
@ -102,7 +105,7 @@ create = $coroutine (params) ->
|
|||||||
limits.disk += size
|
limits.disk += size
|
||||||
|
|
||||||
return $assign({}, vdi, {
|
return $assign({}, vdi, {
|
||||||
device: vdi.userdevice ? vdi.device ? vdi.position,
|
device: ++highestDevice,
|
||||||
size,
|
size,
|
||||||
SR: sr._xapiId,
|
SR: sr._xapiId,
|
||||||
type: vdi.type
|
type: vdi.type
|
||||||
@ -276,7 +279,6 @@ create.params = {
|
|||||||
items: {
|
items: {
|
||||||
type: 'object'
|
type: 'object'
|
||||||
properties: {
|
properties: {
|
||||||
device: { type: 'string' }
|
|
||||||
size: { type: ['integer', 'string'] }
|
size: { type: ['integer', 'string'] }
|
||||||
SR: { type: 'string' }
|
SR: { type: 'string' }
|
||||||
type: { type: 'string' }
|
type: { type: 'string' }
|
||||||
|
Loading…
Reference in New Issue
Block a user