Skip to content

Commit

Permalink
Merge pull request #8340 from lfu/add_disk_1331184
Browse files Browse the repository at this point in the history
Fix an error that nil can't be coerced into Fixnum with VM Reconfigure
  • Loading branch information
gmcculloug committed Apr 29, 2016
2 parents d6fe9b2 + 8d30c0f commit bb444d1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def add_disks(vim_obj, vmcs, disks)
controller_key, unit_number = vim_obj.send(:getScsiCandU)

# if there is no scsi controller
if controller_key.nil?
if controller_key.blank?
controller_key, unit_number = [-99, 0]
add_scsi_controller(vmcs, 0, controller_key)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,26 @@
expect(subject).to eq('independent_nonpersistent')
end
end

context '#add_disks' do
let(:vim) { double("vim object") }
let(:vmcs) { double("VirtualMachineConfigSpec").as_null_object }
let(:disk) { {:disk_size_in_mb => 1024} }

it 'with valid controller key' do
allow(vim).to receive(:getScsiCandU).and_return([200, 1])

expect(vm).not_to receive(:add_scsi_controller)
expect(vm).to receive(:add_disk_config_spec).with(vmcs, disk).once
vm.add_disks(vim, vmcs, [disk])
end

it 'with no controller key' do
allow(vim).to receive(:getScsiCandU).and_return({})

expect(vm).to receive(:add_scsi_controller).with(vmcs, 0, -99).once
expect(vm).to receive(:add_disk_config_spec).with(vmcs, disk).once
vm.add_disks(vim, vmcs, [disk])
end
end
end

0 comments on commit bb444d1

Please sign in to comment.