From 27131db35365fa967aca27240aea0e87cb0fd1c6 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Mon, 25 Feb 2019 13:19:23 -0500 Subject: [PATCH] Add an inventory_collection for the EMS There are some attributes that need to be updated on the EMS record by the parser. For graph refresh this is currently done by directly doing an ems.update_attributes! in the parser which breaks our "parser shouldn't connect to the DB" rule. This adds an inventory collection which allows the parser to set properties to be saved on the ext_management_system record. --- .../providers/inventory/persister/builder/shared.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/models/manageiq/providers/inventory/persister/builder/shared.rb b/app/models/manageiq/providers/inventory/persister/builder/shared.rb index 653209706e9..60107ba06da 100644 --- a/app/models/manageiq/providers/inventory/persister/builder/shared.rb +++ b/app/models/manageiq/providers/inventory/persister/builder/shared.rb @@ -37,6 +37,16 @@ def vendor 'unknown' end + def ext_management_system + add_properties( + :manager_ref => %i(guid), + :custom_save_block => lambda do |ems, inventory_collection| + ems_attrs = inventory_collection.data.first&.attributes + ems.update_attributes!(ems_attrs) if ems_attrs + end + ) + end + def vms vm_template_shared end