@@ -211,38 +211,27 @@ const methods = {
211
211
212
212
// TODO: set vm.suspend_SR
213
213
// Creates the user defined VDIs.
214
- const allowedUserDevices = await this . call ( 'VM.get_allowed_VBD_devices' , vm . $ref )
215
- await Promise . all (
216
- _vdisToCreate . map ( async ( vdi , i ) => {
217
- const vdiRef = await this . VDI_create ( {
218
- name_description : vdi . name_description ,
219
- name_label : vdi . name_label ,
220
- virtual_size : vdi . size ,
221
- SR : this . getObject ( vdi . sr , 'SR' ) . $ref ,
222
- } )
223
- $defer . onFailure ( ( ) => this . VDI_destroy ( vdiRef ) )
224
-
225
- // Either the CD or the 1st disk is bootable (only useful for PV VMs)
226
- let bootable = false
227
- if ( ! hasBootableDisk && i === 0 ) {
228
- bootable = true
229
- }
214
+ for ( const [ i , vdi ] of _vdisToCreate . entries ( ) ) {
215
+ const vdiRef = await this . VDI_create ( {
216
+ name_description : vdi . name_description ,
217
+ name_label : vdi . name_label ,
218
+ virtual_size : vdi . size ,
219
+ SR : this . getObject ( vdi . sr , 'SR' ) . $ref ,
220
+ } )
221
+ $defer . onFailure ( ( ) => this . VDI_destroy ( vdiRef ) )
230
222
231
- let userdevice = vdi . userdevice
232
- if ( userdevice === undefined ) {
233
- userdevice = allowedUserDevices . shift ( )
234
- if ( userdevice === '3' ) {
235
- userdevice = allowedUserDevices . shift ( )
236
- }
237
- }
238
- await this . VBD_create ( {
239
- bootable,
240
- userdevice,
241
- VDI : vdiRef ,
242
- VM : vm . $ref ,
243
- } )
223
+ // Either the CD or the 1st disk is bootable (only useful for PV VMs)
224
+ let bootable = false
225
+ if ( ! hasBootableDisk && i === 0 ) {
226
+ bootable = true
227
+ }
228
+ await this . VBD_create ( {
229
+ bootable,
230
+ userdevice : vdi . userdevice ,
231
+ VDI : vdiRef ,
232
+ VM : vm . $ref ,
244
233
} )
245
- )
234
+ }
246
235
247
236
// Modify existing (previous template) disks if necessary
248
237
// Wait until all VDIs are created, otherwise VBD_create may throw an OTHER_OPERATION_IN_PROGRESS error
0 commit comments