@@ -136,7 +136,7 @@ def vm_path_name(attributes)
136136 def device_change ( attributes )
137137 devices = [ ]
138138 if ( nics = attributes [ :interfaces ] )
139- devices << nics . map { |nic | create_interface ( nic , nics . index ( nic ) , :add , attributes ) }
139+ devices << nics . each_with_index . map { |nic , index | create_interface ( nic , index , :add , attributes ) }
140140 end
141141
142142 if ( scsi_controllers = attributes [ :scsi_controllers ] || attributes [ 'scsi_controller' ] )
@@ -152,7 +152,7 @@ def device_change(attributes)
152152 end
153153
154154 if ( cdroms = attributes [ :cdroms ] )
155- devices << cdroms . map { |cdrom | create_cdrom ( cdrom , cdroms . index ( cdrom ) ) }
155+ devices << cdroms . each_with_index . map { |cdrom , index | create_cdrom ( cdrom , index ) }
156156 end
157157
158158 devices << create_virtual_tpm if attributes [ :virtual_tpm ]
@@ -189,9 +189,9 @@ def boot_order(attributes, vm_cfg)
189189 if nics = attributes [ :interfaces ]
190190 # key is based on 4000 + the interface index
191191 # we allow booting from all network interfaces, the first interface has the highest priority
192- nics . each do |nic |
192+ nics . each_with_index do |_nic , index |
193193 boot_order << RbVmomi ::VIM ::VirtualMachineBootOptionsBootableEthernetDevice . new (
194- deviceKey : 4000 + nics . index ( nic )
194+ deviceKey : 4000 + index
195195 )
196196 end
197197 end
0 commit comments