From 260a668e0f84d462208f4ee14af07fd214a7992e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadej=20Borov=C5=A1ak?= Date: Wed, 28 Mar 2018 08:07:04 +0200 Subject: [PATCH] Add computer systems to inventory Since computer systems are in 1:1 relation with the physical servers and carry no data on its own, we add them to the database at the same time as the servers. --- .../redfish/inventory/parser/physical_infra_manager.rb | 1 + .../redfish/inventory/persister/physical_infra_manager.rb | 1 + .../manageiq/providers/redfish/physical_infra_manager.rb | 3 +++ .../providers/redfish/physical_infra_manager/refresher_spec.rb | 1 + 4 files changed, 6 insertions(+) diff --git a/app/models/manageiq/providers/redfish/inventory/parser/physical_infra_manager.rb b/app/models/manageiq/providers/redfish/inventory/parser/physical_infra_manager.rb index 6a3e35c..e334867 100644 --- a/app/models/manageiq/providers/redfish/inventory/parser/physical_infra_manager.rb +++ b/app/models/manageiq/providers/redfish/inventory/parser/physical_infra_manager.rb @@ -27,6 +27,7 @@ def physical_servers :location_led_state => s["IndicatorLED"], :physical_rack_id => 0 ) + persister.computer_systems.build(:managed_entity => server) end end diff --git a/app/models/manageiq/providers/redfish/inventory/persister/physical_infra_manager.rb b/app/models/manageiq/providers/redfish/inventory/persister/physical_infra_manager.rb index a906c5d..22f5404 100644 --- a/app/models/manageiq/providers/redfish/inventory/persister/physical_infra_manager.rb +++ b/app/models/manageiq/providers/redfish/inventory/persister/physical_infra_manager.rb @@ -4,6 +4,7 @@ def initialize_inventory_collections collections = %i( physical_servers physical_server_details + computer_systems ) add_inventory_collections(physical_infra, collections) end diff --git a/app/models/manageiq/providers/redfish/physical_infra_manager.rb b/app/models/manageiq/providers/redfish/physical_infra_manager.rb index 1051b55..cd8a385 100644 --- a/app/models/manageiq/providers/redfish/physical_infra_manager.rb +++ b/app/models/manageiq/providers/redfish/physical_infra_manager.rb @@ -12,6 +12,9 @@ class PhysicalInfraManager < ManageIQ::Providers::PhysicalInfraManager :source => :asset_detail, :through => :physical_servers, :as => :physical_server + has_many :computer_systems, + :through => :physical_servers, + :as => :computer_system def self.ems_type @ems_type ||= "redfish_ph_infra".freeze diff --git a/spec/models/manageiq/providers/redfish/physical_infra_manager/refresher_spec.rb b/spec/models/manageiq/providers/redfish/physical_infra_manager/refresher_spec.rb index eb9e1da..9b283da 100644 --- a/spec/models/manageiq/providers/redfish/physical_infra_manager/refresher_spec.rb +++ b/spec/models/manageiq/providers/redfish/physical_infra_manager/refresher_spec.rb @@ -24,6 +24,7 @@ def assert_ems expect(ems.physical_servers.count).to eq(1) expect(ems.physical_servers.map(&:ems_ref)).to match_array([server_id]) expect(ems.physical_server_details.count).to eq(1) + expect(ems.computer_systems.count).to eq(1) end def assert_physical_servers