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

Handle a HostSystem with missing product vendor #882

Merged
merged 1 commit into from
Sep 18, 2023
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 @@ -113,16 +113,23 @@ def parse_host_system_product(host_hash, props)
product = props.fetch_path(:summary, :config, :product)
return if product.nil?

vendor = product[:vendor].split(",").first.to_s.downcase
vendor = "unknown" unless Host::VENDOR_TYPES.include?(vendor)
host_hash[:vmm_vendor] = vendor
host_hash[:vmm_vendor] = host_system_vendor(product[:vendor])

product_name = product[:name]
host_hash[:vmm_product] = product_name.nil? ? nil : product_name.to_s.gsub(/^VMware\s*/i, "")
host_hash[:vmm_version] = product[:version]
host_hash[:vmm_buildnumber] = product[:build]
end

def host_system_vendor(vendor)
return "unknown" if vendor.nil?

vendor = vendor.split(",").first.to_s.downcase
vendor = "unknown" unless Host::VENDOR_TYPES.include?(vendor)

vendor
end

def parse_host_system_runtime(host_hash, props)
runtime = props.fetch_path(:summary, :runtime)
return if runtime.nil?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,15 @@
expect(custom_attrs.first).to have_attributes(:name => "foo", :value => "baz", :source => "VC")
end

it "with a host without a vendor sets vmm_vendor to unknown" do
host_system = RbVmomi::VIM.HostSystem(vim, "host-41")
host_config_storage_device_stub(host_system)
run_targeted_refresh(targeted_update_set([host_missing_vendor_object_update(host_system)]))

host = ems.hosts.find_by(:ems_ref => "host-41")
expect(host).to have_attributes(:vmm_vendor => "unknown")
end

it "deleting a host" do
managed_object_not_found_fault = RbVmomi::Fault.new(
"The object 'vim.HostSystem:host-41' has already been deleted or has not been completely created",
Expand Down Expand Up @@ -1078,6 +1087,18 @@ def host_create_object_update(host)
)
end

def host_missing_vendor_object_update(host)
RbVmomi::VIM.ObjectUpdate(
:kind => "enter",
:obj => host,
:changeSet => [
RbVmomi::VIM.PropertyChange(:name => "config.network.dnsConfig", :op => "assign", :val => {:domainName => "example.com", :hostName => "myhost"}),
RbVmomi::VIM.PropertyChange(:name => "summary.config.product", :op => "assign", :val => {:build => "5.0.0.19", :name => "VMware ESX", :osType => "vmnix-x86", :version => "5.0.0"}),
],
:missingSet => []
)
end

def host_delete_object_update(host)
RbVmomi::VIM.ObjectUpdate(
:kind => "leave",
Expand Down