Skip to content

Commit

Permalink
Merge pull request #459 from agrare/parse_vm_firmware_type
Browse files Browse the repository at this point in the history
Parse VM firmware_type (BIOS/EFI)
  • Loading branch information
gtanzillo committed Oct 7, 2019
2 parents a9165c5 + b90efe0 commit c27abb6
Show file tree
Hide file tree
Showing 8 changed files with 467 additions and 459 deletions.
Expand Up @@ -10,6 +10,7 @@ module ManageIQ::Providers::Vmware::InfraManager::Inventory::Collector::Property
"config.cpuHotAddEnabled",
"config.cpuHotRemoveEnabled",
"config.defaultPowerOps.standbyAction",
"config.firmware",
"config.hardware.device",
"config.hardware.numCoresPerSocket",
"config.hotPlugMemoryIncrementSize",
Expand Down
Expand Up @@ -147,13 +147,15 @@ def parse_virtual_machine_hardware(vm, props)
hardware_hash[:memory_mb] = memory_size_mb unless memory_size_mb.blank?
end

# cast numCoresPerSocket to an integer so that we can check for nil and 0
cpu_cores_per_socket = props.fetch_path(:config, :hardware, :numCoresPerSocket).to_i
hardware_hash[:cpu_cores_per_socket] = cpu_cores_per_socket.zero? ? 1 : cpu_cores_per_socket
hardware_hash[:cpu_sockets] = hardware_hash[:cpu_total_cores] / hardware_hash[:cpu_cores_per_socket]

config_version = props.fetch_path(:config, :version)
hardware_hash[:virtual_hw_version] = config_version.to_s.split('-').last if config_version.present?
config = props[:config]
if config
# cast numCoresPerSocket to an integer so that we can check for nil and 0
cpu_cores_per_socket = config.dig(:hardware, :numCoresPerSocket).to_i
hardware_hash[:cpu_cores_per_socket] = cpu_cores_per_socket.zero? ? 1 : cpu_cores_per_socket
hardware_hash[:cpu_sockets] = hardware_hash[:cpu_total_cores] / hardware_hash[:cpu_cores_per_socket]
hardware_hash[:virtual_hw_version] = config[:version].to_s.split('-').last if config[:version].present?
hardware_hash[:firmware_type] = config[:firmware].to_s.downcase == "efi" ? "EFI" : "BIOS"
end

hardware = persister.hardwares.build(hardware_hash)

Expand Down
Expand Up @@ -1042,6 +1042,8 @@ def self.vm_inv_to_hardware_hash(inv)
bios = MiqUUID.clean_guid(uuid) || uuid
result[:bios] = bios unless bios.blank?

result[:firmware_type] = config["firmware"].to_s.downcase == "efi" ? "EFI" : "BIOS"

if inv["numCpu"].present?
result[:cpu_total_cores] = inv["numCpu"].to_i

Expand Down
Expand Up @@ -89,6 +89,7 @@ module ManageIQ::Providers::Vmware::InfraManager::SelectorSpec
"config.cpuHotAddEnabled",
"config.cpuHotRemoveEnabled",
"config.defaultPowerOps.standbyAction",
"config.firmware",
"config.hardware.device[*].backing.compatibilityMode",
"config.hardware.device[*].backing.datastore",
"config.hardware.device[*].backing.deviceName",
Expand Down
Expand Up @@ -893,6 +893,7 @@ def assert_specific_vm
:cpu_sockets => 1,
:cpu_total_cores => 1,
:virtual_hw_version => "07",
:firmware_type => "BIOS"
)

nic = vm.hardware.guest_devices.find_by(:uid_ems => "00:50:56:8f:56:8d")
Expand Down

Large diffs are not rendered by default.

0 comments on commit c27abb6

Please sign in to comment.