From 2693c24076adcf34ee364997bd4dc6d9efaaa13d Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Thu, 31 May 2018 14:56:43 -0400 Subject: [PATCH] Add host_guest_devices association inv_collection Add the host_guest_devices association and inventory collection for graph refresh. --- .../manageiq/providers/infra_manager.rb | 1 + .../infra_manager.rb | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/app/models/manageiq/providers/infra_manager.rb b/app/models/manageiq/providers/infra_manager.rb index aafad5dce7f9..4678d96aec37 100644 --- a/app/models/manageiq/providers/infra_manager.rb +++ b/app/models/manageiq/providers/infra_manager.rb @@ -12,6 +12,7 @@ class InfraManager < BaseManager has_many :host_storages, :through => :hosts has_many :host_switches, :through => :hosts has_many :host_networks, :through => :hosts, :source => :networks + has_many :host_guest_devices, :through => :host_hardwares, :source => :guest_devices has_many :snapshots, :through => :vms_and_templates has_many :switches, -> { distinct }, :through => :hosts has_many :lans, -> { distinct }, :through => :hosts diff --git a/app/models/manager_refresh/inventory_collection_default/infra_manager.rb b/app/models/manager_refresh/inventory_collection_default/infra_manager.rb index 4684f1e2ac5b..263958eeba69 100644 --- a/app/models/manager_refresh/inventory_collection_default/infra_manager.rb +++ b/app/models/manager_refresh/inventory_collection_default/infra_manager.rb @@ -34,6 +34,29 @@ def host_networks(extra_attributes = {}) attributes.merge!(extra_attributes) end + def host_guest_devices(extra_attributes = {}) + attributes = { + :model_class => ::GuestDevice, + :manager_ref => %i(hardware uid_ems), + :association => :host_guest_devices, + :parent_inventory_collections => [:hosts], + :inventory_object_attributes => %i( + address + controller_type + device_name + device_type + lan + location + network + present + switch + uid_ems + ), + } + + attributes.merge!(extra_attributes) + end + def guest_devices(extra_attributes = {}) attributes = { :model_class => ::GuestDevice,