diff --git a/app/models/manageiq/providers/vmware/infra_manager/inventory/parser/host_system.rb b/app/models/manageiq/providers/vmware/infra_manager/inventory/parser/host_system.rb index f7902ed96..cd2b1c973 100644 --- a/app/models/manageiq/providers/vmware/infra_manager/inventory/parser/host_system.rb +++ b/app/models/manageiq/providers/vmware/infra_manager/inventory/parser/host_system.rb @@ -113,9 +113,7 @@ 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, "") @@ -123,6 +121,15 @@ def parse_host_system_product(host_hash, props) 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? diff --git a/spec/models/manageiq/providers/vmware/infra_manager/refresher_spec.rb b/spec/models/manageiq/providers/vmware/infra_manager/refresher_spec.rb index d0003a200..012cc7c2f 100644 --- a/spec/models/manageiq/providers/vmware/infra_manager/refresher_spec.rb +++ b/spec/models/manageiq/providers/vmware/infra_manager/refresher_spec.rb @@ -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", @@ -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",