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

Dealing with disks which have no controller key #77

Merged
merged 1 commit into from
Aug 1, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1078,11 +1078,16 @@ def self.vm_inv_to_disk_hashes(inv, storage_uids, storage_profile_by_disk_mor =
device_type << (backing['fileName'].nil? ? "-raw" : "-image") if device_type == 'cdrom'

controller = inv.detect { |d| d['key'] == device['controllerKey'] }
controller_type = case controller.xsiType
when /IDE/ then 'ide'
when /SIO/ then 'sio'
else 'scsi'
end
controller_type =
if controller
case controller.xsiType
when /IDE/ then 'ide'
when /SIO/ then 'sio'
else 'scsi'
end
else
'unknown'
end

storage_mor = backing['datastore']

Expand All @@ -1092,7 +1097,7 @@ def self.vm_inv_to_disk_hashes(inv, storage_uids, storage_profile_by_disk_mor =
:controller_type => controller_type,
:present => true,
:filename => backing['fileName'] || backing['deviceName'],
:location => "#{controller['busNumber']}:#{device['unitNumber']}",
:location => controller ? "#{controller['busNumber']}:#{device['unitNumber']}" : nil
}

if device_type == 'disk'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,21 @@ def assert_specific_vm
)
expect(disk.storage).to eq(@storage)

# test the case when a disk has no controller https://bugzilla.redhat.com/show_bug.cgi?id=1465761
disk = v.hardware.disks.find_by_device_name("Hard disk 2")
expect(disk).to have_attributes(
:device_name => "Hard disk 2",
:device_type => "disk",
:controller_type => "unknown",
:present => true,
:filename => "[StarM1-Prod1 (1)] JoeF 4.0.1/JoeF 4.0.1_1.vmdk",
:location => nil,
:size => 3_221_226_496,
:mode => "persistent",
:disk_type => "thin",
:start_connected => true
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge 👍 for the test 😄

expect(v.hardware.guest_devices.size).to eq(1)
nic = v.hardware.nics.first
expect(nic).to have_attributes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77108,15 +77108,7 @@
str: "3145729"
"@vimType":
"@xsiType": :"SOAP::SOAPLong"
unitNumber: !str:VimString
str: "1"
"@vimType":
"@xsiType": :"SOAP::SOAPInt"
controllerKey: !str:VimString
str: "1000"
"@vimType":
"@xsiType": :"SOAP::SOAPInt"
deviceInfo: !map:VimHash
deviceInfo: !map:VimHash
label: !str:VimString
str: Hard disk 2
"@vimType":
Expand Down