From 4df5ba0889d5d50b7e306d9faa63baa41483f611 Mon Sep 17 00:00:00 2001 From: Martin Slemr Date: Wed, 4 Jul 2018 10:49:56 +0200 Subject: [PATCH] Provider generator for persister With new definitions of InventoryCollections --- .../%provider_name%/inventory/persister.rb | 19 +++++++++++++++++++ .../inventory/persister/cloud_manager.rb | 8 +++++--- .../definitions/cloud_collections.rb | 9 +++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 lib/generators/provider/templates/app/models/manageiq/providers/%provider_name%/inventory/persister.rb create mode 100644 lib/generators/provider/templates/app/models/manageiq/providers/%provider_name%/inventory/persister/definitions/cloud_collections.rb diff --git a/lib/generators/provider/templates/app/models/manageiq/providers/%provider_name%/inventory/persister.rb b/lib/generators/provider/templates/app/models/manageiq/providers/%provider_name%/inventory/persister.rb new file mode 100644 index 00000000000..177322fcbdb --- /dev/null +++ b/lib/generators/provider/templates/app/models/manageiq/providers/%provider_name%/inventory/persister.rb @@ -0,0 +1,19 @@ +class ManageIQ::Providers::<%= class_name %>::Inventory::Persister < ManagerRefresh::Inventory::Persister + require_nested :CloudManager + + def strategy + nil + end + + def parent + manager.presence + end + + def shared_options + { + :strategy => strategy, + :targeted => targeted?, + :parent => parent + } + end +end diff --git a/lib/generators/provider/templates/app/models/manageiq/providers/%provider_name%/inventory/persister/cloud_manager.rb b/lib/generators/provider/templates/app/models/manageiq/providers/%provider_name%/inventory/persister/cloud_manager.rb index 9080e055bfb..eaf90fc82ae 100644 --- a/lib/generators/provider/templates/app/models/manageiq/providers/%provider_name%/inventory/persister/cloud_manager.rb +++ b/lib/generators/provider/templates/app/models/manageiq/providers/%provider_name%/inventory/persister/cloud_manager.rb @@ -1,5 +1,7 @@ -class ManageIQ::Providers::<%= class_name %>::Inventory::Persister::CloudManager < ManagerRefresh::Inventory::Persister - include ManagerRefresh::Inventory::CloudManager +class ManageIQ::Providers::<%= class_name %>::Inventory::Persister::CloudManager < ManageIQ::Providers::<%= class_name %>::Inventory::Persister + include ManageIQ::Providers::<%= class_name %>::Inventory::Persister::Definitions::CloudCollections - has_cloud_manager_vms + def initialize_inventory_collections + initialize_cloud_inventory_collections + end end diff --git a/lib/generators/provider/templates/app/models/manageiq/providers/%provider_name%/inventory/persister/definitions/cloud_collections.rb b/lib/generators/provider/templates/app/models/manageiq/providers/%provider_name%/inventory/persister/definitions/cloud_collections.rb new file mode 100644 index 00000000000..bc7fa277cec --- /dev/null +++ b/lib/generators/provider/templates/app/models/manageiq/providers/%provider_name%/inventory/persister/definitions/cloud_collections.rb @@ -0,0 +1,9 @@ +module ManageIQ::Providers::<%= class_name %>::Inventory::Persister::Definitions::CloudCollections + extend ActiveSupport::Concern + + def initialize_cloud_inventory_collections + %i(vms).each do |name| + add_collection(cloud, name) + end + end +end