Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an error that nil can't be coerced into Fixnum with VM Reconfigure #8340

Merged
merged 1 commit into from
Apr 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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