From e35091d526c2e3833e5813e8dc09a0845401a5a7 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Fri, 24 Aug 2018 14:22:45 -0400 Subject: [PATCH 1/2] Move IC::Builder to Inventory::Persister --- .../{inventory_collection => inventory/persister}/builder.rb | 0 .../persister}/builder/automation_manager.rb | 0 .../persister}/builder/cloud_manager.rb | 0 .../persister}/builder/container_manager.rb | 0 .../persister}/builder/infra_manager.rb | 0 .../persister}/builder/network_manager.rb | 0 .../persister}/builder/persister_helper.rb | 0 .../persister}/builder/physical_infra_manager.rb | 0 .../persister}/builder/shared.rb | 0 .../persister}/builder/storage_manager.rb | 0 .../{inventory_collection => persister}/builder_spec.rb | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename app/models/manager_refresh/{inventory_collection => inventory/persister}/builder.rb (100%) rename app/models/manager_refresh/{inventory_collection => inventory/persister}/builder/automation_manager.rb (100%) rename app/models/manager_refresh/{inventory_collection => inventory/persister}/builder/cloud_manager.rb (100%) rename app/models/manager_refresh/{inventory_collection => inventory/persister}/builder/container_manager.rb (100%) rename app/models/manager_refresh/{inventory_collection => inventory/persister}/builder/infra_manager.rb (100%) rename app/models/manager_refresh/{inventory_collection => inventory/persister}/builder/network_manager.rb (100%) rename app/models/manager_refresh/{inventory_collection => inventory/persister}/builder/persister_helper.rb (100%) rename app/models/manager_refresh/{inventory_collection => inventory/persister}/builder/physical_infra_manager.rb (100%) rename app/models/manager_refresh/{inventory_collection => inventory/persister}/builder/shared.rb (100%) rename app/models/manager_refresh/{inventory_collection => inventory/persister}/builder/storage_manager.rb (100%) rename spec/models/manager_refresh/{inventory_collection => persister}/builder_spec.rb (100%) diff --git a/app/models/manager_refresh/inventory_collection/builder.rb b/app/models/manager_refresh/inventory/persister/builder.rb similarity index 100% rename from app/models/manager_refresh/inventory_collection/builder.rb rename to app/models/manager_refresh/inventory/persister/builder.rb diff --git a/app/models/manager_refresh/inventory_collection/builder/automation_manager.rb b/app/models/manager_refresh/inventory/persister/builder/automation_manager.rb similarity index 100% rename from app/models/manager_refresh/inventory_collection/builder/automation_manager.rb rename to app/models/manager_refresh/inventory/persister/builder/automation_manager.rb diff --git a/app/models/manager_refresh/inventory_collection/builder/cloud_manager.rb b/app/models/manager_refresh/inventory/persister/builder/cloud_manager.rb similarity index 100% rename from app/models/manager_refresh/inventory_collection/builder/cloud_manager.rb rename to app/models/manager_refresh/inventory/persister/builder/cloud_manager.rb diff --git a/app/models/manager_refresh/inventory_collection/builder/container_manager.rb b/app/models/manager_refresh/inventory/persister/builder/container_manager.rb similarity index 100% rename from app/models/manager_refresh/inventory_collection/builder/container_manager.rb rename to app/models/manager_refresh/inventory/persister/builder/container_manager.rb diff --git a/app/models/manager_refresh/inventory_collection/builder/infra_manager.rb b/app/models/manager_refresh/inventory/persister/builder/infra_manager.rb similarity index 100% rename from app/models/manager_refresh/inventory_collection/builder/infra_manager.rb rename to app/models/manager_refresh/inventory/persister/builder/infra_manager.rb diff --git a/app/models/manager_refresh/inventory_collection/builder/network_manager.rb b/app/models/manager_refresh/inventory/persister/builder/network_manager.rb similarity index 100% rename from app/models/manager_refresh/inventory_collection/builder/network_manager.rb rename to app/models/manager_refresh/inventory/persister/builder/network_manager.rb diff --git a/app/models/manager_refresh/inventory_collection/builder/persister_helper.rb b/app/models/manager_refresh/inventory/persister/builder/persister_helper.rb similarity index 100% rename from app/models/manager_refresh/inventory_collection/builder/persister_helper.rb rename to app/models/manager_refresh/inventory/persister/builder/persister_helper.rb diff --git a/app/models/manager_refresh/inventory_collection/builder/physical_infra_manager.rb b/app/models/manager_refresh/inventory/persister/builder/physical_infra_manager.rb similarity index 100% rename from app/models/manager_refresh/inventory_collection/builder/physical_infra_manager.rb rename to app/models/manager_refresh/inventory/persister/builder/physical_infra_manager.rb diff --git a/app/models/manager_refresh/inventory_collection/builder/shared.rb b/app/models/manager_refresh/inventory/persister/builder/shared.rb similarity index 100% rename from app/models/manager_refresh/inventory_collection/builder/shared.rb rename to app/models/manager_refresh/inventory/persister/builder/shared.rb diff --git a/app/models/manager_refresh/inventory_collection/builder/storage_manager.rb b/app/models/manager_refresh/inventory/persister/builder/storage_manager.rb similarity index 100% rename from app/models/manager_refresh/inventory_collection/builder/storage_manager.rb rename to app/models/manager_refresh/inventory/persister/builder/storage_manager.rb diff --git a/spec/models/manager_refresh/inventory_collection/builder_spec.rb b/spec/models/manager_refresh/persister/builder_spec.rb similarity index 100% rename from spec/models/manager_refresh/inventory_collection/builder_spec.rb rename to spec/models/manager_refresh/persister/builder_spec.rb From 050072c05bce90e40798a73a0c047d1251259954 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Fri, 24 Aug 2018 14:32:32 -0400 Subject: [PATCH 2/2] Update class names --- .../manager_refresh/inventory/persister.rb | 3 ++- .../inventory/persister/builder.rb | 4 +-- .../persister/builder/automation_manager.rb | 4 +-- .../persister/builder/cloud_manager.rb | 4 +-- .../persister/builder/container_manager.rb | 4 +-- .../persister/builder/infra_manager.rb | 4 +-- .../persister/builder/network_manager.rb | 4 +-- .../persister/builder/persister_helper.rb | 26 +++++++++---------- .../builder/physical_infra_manager.rb | 4 +-- .../inventory/persister/builder/shared.rb | 2 +- .../persister/builder/storage_manager.rb | 4 +-- .../manager_refresh/inventory_collection.rb | 2 -- .../manager_refresh/persister/builder_spec.rb | 10 +++---- .../save_inventory/init_data_helper.rb | 4 +-- 14 files changed, 39 insertions(+), 40 deletions(-) diff --git a/app/models/manager_refresh/inventory/persister.rb b/app/models/manager_refresh/inventory/persister.rb index 613f2f8ac9a..175234b7b29 100644 --- a/app/models/manager_refresh/inventory/persister.rb +++ b/app/models/manager_refresh/inventory/persister.rb @@ -1,10 +1,11 @@ class ManagerRefresh::Inventory::Persister require 'json' require 'yaml' + require_nested :Builder attr_reader :manager, :target, :collections - include ::ManagerRefresh::InventoryCollection::Builder::PersisterHelper + include ::ManagerRefresh::Inventory::Persister::Builder::PersisterHelper # @param manager [ManageIQ::Providers::BaseManager] A manager object # @param target [Object] A refresh Target object diff --git a/app/models/manager_refresh/inventory/persister/builder.rb b/app/models/manager_refresh/inventory/persister/builder.rb index 8200842a229..ea93e79ed2e 100644 --- a/app/models/manager_refresh/inventory/persister/builder.rb +++ b/app/models/manager_refresh/inventory/persister/builder.rb @@ -1,5 +1,5 @@ module ManagerRefresh - class InventoryCollection + class Inventory::Persister # @see test in /spec/models/manager_refresh/inventory_collection/builder_spec.rb class Builder class MissingModelClassError < StandardError; end @@ -12,7 +12,7 @@ class MissingModelClassError < StandardError; end require_nested :StorageManager require_nested :PersisterHelper - include ::ManagerRefresh::InventoryCollection::Builder::Shared + include ::ManagerRefresh::Inventory::Persister::Builder::Shared # Default options for builder # :adv_settings diff --git a/app/models/manager_refresh/inventory/persister/builder/automation_manager.rb b/app/models/manager_refresh/inventory/persister/builder/automation_manager.rb index 2de9a401530..dc97ac1b18d 100644 --- a/app/models/manager_refresh/inventory/persister/builder/automation_manager.rb +++ b/app/models/manager_refresh/inventory/persister/builder/automation_manager.rb @@ -1,7 +1,7 @@ module ManagerRefresh - class InventoryCollection + class Inventory::Persister class Builder - class AutomationManager < ::ManagerRefresh::InventoryCollection::Builder + class AutomationManager < ::ManagerRefresh::Inventory::Persister::Builder def configuration_scripts default_manager_ref add_common_default_values diff --git a/app/models/manager_refresh/inventory/persister/builder/cloud_manager.rb b/app/models/manager_refresh/inventory/persister/builder/cloud_manager.rb index d18ed77147e..ab075595557 100644 --- a/app/models/manager_refresh/inventory/persister/builder/cloud_manager.rb +++ b/app/models/manager_refresh/inventory/persister/builder/cloud_manager.rb @@ -1,7 +1,7 @@ module ManagerRefresh - class InventoryCollection + class Inventory::Persister class Builder - class CloudManager < ::ManagerRefresh::InventoryCollection::Builder + class CloudManager < ::ManagerRefresh::Inventory::Persister::Builder def availability_zones add_common_default_values end diff --git a/app/models/manager_refresh/inventory/persister/builder/container_manager.rb b/app/models/manager_refresh/inventory/persister/builder/container_manager.rb index f0e51fb0c35..cfbc8b10423 100644 --- a/app/models/manager_refresh/inventory/persister/builder/container_manager.rb +++ b/app/models/manager_refresh/inventory/persister/builder/container_manager.rb @@ -1,7 +1,7 @@ module ManagerRefresh - class InventoryCollection + class Inventory::Persister class Builder - class ContainerManager < ::ManagerRefresh::InventoryCollection::Builder + class ContainerManager < ::ManagerRefresh::Inventory::Persister::Builder # TODO: (agrare) Targeted refreshes will require adjusting the associations / arels. (duh) def container_projects add_properties( diff --git a/app/models/manager_refresh/inventory/persister/builder/infra_manager.rb b/app/models/manager_refresh/inventory/persister/builder/infra_manager.rb index 086157f6622..5c64c87df96 100644 --- a/app/models/manager_refresh/inventory/persister/builder/infra_manager.rb +++ b/app/models/manager_refresh/inventory/persister/builder/infra_manager.rb @@ -1,7 +1,7 @@ module ManagerRefresh - class InventoryCollection + class Inventory::Persister class Builder - class InfraManager < ::ManagerRefresh::InventoryCollection::Builder + class InfraManager < ::ManagerRefresh::Inventory::Persister::Builder def networks add_properties( :manager_ref => %i(hardware ipaddress ipv6address), diff --git a/app/models/manager_refresh/inventory/persister/builder/network_manager.rb b/app/models/manager_refresh/inventory/persister/builder/network_manager.rb index 084b0917385..d1cbed84b3f 100644 --- a/app/models/manager_refresh/inventory/persister/builder/network_manager.rb +++ b/app/models/manager_refresh/inventory/persister/builder/network_manager.rb @@ -1,7 +1,7 @@ module ManagerRefresh - class InventoryCollection + class Inventory::Persister class Builder - class NetworkManager < ::ManagerRefresh::InventoryCollection::Builder + class NetworkManager < ::ManagerRefresh::Inventory::Persister::Builder def cloud_subnet_network_ports add_properties( # :model_class => ::CloudSubnetNetworkPort, diff --git a/app/models/manager_refresh/inventory/persister/builder/persister_helper.rb b/app/models/manager_refresh/inventory/persister/builder/persister_helper.rb index 23034f9b931..2349f24b21b 100644 --- a/app/models/manager_refresh/inventory/persister/builder/persister_helper.rb +++ b/app/models/manager_refresh/inventory/persister/builder/persister_helper.rb @@ -1,19 +1,19 @@ -module ManagerRefresh::InventoryCollection::Builder::PersisterHelper +module ManagerRefresh::Inventory::Persister::Builder::PersisterHelper extend ActiveSupport::Concern # Interface for creating InventoryCollection under @collections # - # @param builder_class [ManagerRefresh::InventoryCollection::Builder] or subclasses + # @param builder_class [ManagerRefresh::Inventory::Persister::Builder] or subclasses # @param collection_name [Symbol || Array] used as InventoryCollection:association # @param extra_properties [Hash] props from InventoryCollection.initialize list # - adds/overwrites properties added by builder # # @param settings [Hash] builder settings - # - @see ManagerRefresh::InventoryCollection::Builder.default_options + # - @see ManagerRefresh::Inventory::Persister::Builder.default_options # - @see make_builder_settings() # # @example - # add_collection(ManagerRefresh::InventoryCollection::Builder::CloudManager, :vms) do |builder| + # add_collection(ManagerRefresh::Inventory::Persister::Builder::CloudManager, :vms) do |builder| # builder.add_properties( # :strategy => :local_db_cache_all, # ) @@ -38,36 +38,36 @@ def add_collection(builder_class, collection_name, extra_properties = {}, settin # builder_class for add_collection() def cloud - ::ManagerRefresh::InventoryCollection::Builder::CloudManager + ::ManagerRefresh::Inventory::Persister::Builder::CloudManager end # builder_class for add_collection() def network - ::ManagerRefresh::InventoryCollection::Builder::NetworkManager + ::ManagerRefresh::Inventory::Persister::Builder::NetworkManager end # builder_class for add_collection() def infra - ::ManagerRefresh::InventoryCollection::Builder::InfraManager + ::ManagerRefresh::Inventory::Persister::Builder::InfraManager end # builder_class for add_collection() def storage - ::ManagerRefresh::InventoryCollection::Builder::StorageManager + ::ManagerRefresh::Inventory::Persister::Builder::StorageManager end # builder_class for add_collection() def automation - ::ManagerRefresh::InventoryCollection::Builder::AutomationManager + ::ManagerRefresh::Inventory::Persister::Builder::AutomationManager end # builder class for add_collection() def physical_infra - ::ManagerRefresh::InventoryCollection::Builder::PhysicalInfraManager + ::ManagerRefresh::Inventory::Persister::Builder::PhysicalInfraManager end def container - ::ManagerRefresh::InventoryCollection::Builder::ContainerManager + ::ManagerRefresh::Inventory::Persister::Builder::ContainerManager end # @param extra_settings [Hash] @@ -77,9 +77,9 @@ def container # :without_model_class # - if false and no model_class derived or specified, throws exception # - doesn't try to derive model class automatically - # - @see method ManagerRefresh::InventoryCollection::Builder.auto_model_class + # - @see method ManagerRefresh::Inventory::Persister::Builder.auto_model_class def make_builder_settings(extra_settings = {}) - opts = ::ManagerRefresh::InventoryCollection::Builder.default_options + opts = ::ManagerRefresh::Inventory::Persister::Builder.default_options opts[:adv_settings] = options.try(:[], :inventory_collections).try(:to_hash) || {} opts[:shared_properties] = shared_options diff --git a/app/models/manager_refresh/inventory/persister/builder/physical_infra_manager.rb b/app/models/manager_refresh/inventory/persister/builder/physical_infra_manager.rb index a7d655c828b..7c37dbbfbc6 100644 --- a/app/models/manager_refresh/inventory/persister/builder/physical_infra_manager.rb +++ b/app/models/manager_refresh/inventory/persister/builder/physical_infra_manager.rb @@ -1,7 +1,7 @@ module ManagerRefresh - class InventoryCollection + class Inventory::Persister class Builder - class PhysicalInfraManager < ::ManagerRefresh::InventoryCollection::Builder + class PhysicalInfraManager < ::ManagerRefresh::Inventory::Persister::Builder def physical_servers add_common_default_values end diff --git a/app/models/manager_refresh/inventory/persister/builder/shared.rb b/app/models/manager_refresh/inventory/persister/builder/shared.rb index 59ce2f26719..572bdf4a651 100644 --- a/app/models/manager_refresh/inventory/persister/builder/shared.rb +++ b/app/models/manager_refresh/inventory/persister/builder/shared.rb @@ -1,4 +1,4 @@ -module ManagerRefresh::InventoryCollection::Builder::Shared +module ManagerRefresh::Inventory::Persister::Builder::Shared extend ActiveSupport::Concern included do diff --git a/app/models/manager_refresh/inventory/persister/builder/storage_manager.rb b/app/models/manager_refresh/inventory/persister/builder/storage_manager.rb index 1cb0cf808b1..a7d9343bb90 100644 --- a/app/models/manager_refresh/inventory/persister/builder/storage_manager.rb +++ b/app/models/manager_refresh/inventory/persister/builder/storage_manager.rb @@ -1,7 +1,7 @@ module ManagerRefresh - class InventoryCollection + class Inventory::Persister class Builder - class StorageManager < ::ManagerRefresh::InventoryCollection::Builder + class StorageManager < ::ManagerRefresh::Inventory::Persister::Builder # Nothing there end end diff --git a/app/models/manager_refresh/inventory_collection.rb b/app/models/manager_refresh/inventory_collection.rb index 5f64b7a4d90..5e1620dc601 100644 --- a/app/models/manager_refresh/inventory_collection.rb +++ b/app/models/manager_refresh/inventory_collection.rb @@ -44,8 +44,6 @@ module ManagerRefresh # puts @ems.vms.collect(&:ems_ref) # => ["vm2", "vm3"] # class InventoryCollection - require_nested :Builder - # @return [Boolean] A true value marks that we collected all the data of the InventoryCollection, # meaning we also collected all the references. attr_accessor :data_collection_finalized diff --git a/spec/models/manager_refresh/persister/builder_spec.rb b/spec/models/manager_refresh/persister/builder_spec.rb index 45a5cc649dd..b26d894ef52 100644 --- a/spec/models/manager_refresh/persister/builder_spec.rb +++ b/spec/models/manager_refresh/persister/builder_spec.rb @@ -1,6 +1,6 @@ -require_relative '../persister/test_persister' +require_relative 'test_persister' -describe ManagerRefresh::InventoryCollection::Builder do +describe ManagerRefresh::Inventory::Persister::Builder do before :each do @zone = FactoryGirl.create(:zone) @ems = FactoryGirl.create(:ems_cloud, @@ -15,9 +15,9 @@ def create_persister let(:adv_settings) { {:strategy => :local_db_find_missing_references, :saver_strategy => :concurrent_safe_batch} } - let(:cloud) { ::ManagerRefresh::InventoryCollection::Builder::CloudManager } + let(:cloud) { ::ManagerRefresh::Inventory::Persister::Builder::CloudManager } - let(:network) { ::ManagerRefresh::InventoryCollection::Builder::NetworkManager } + let(:network) { ::ManagerRefresh::Inventory::Persister::Builder::NetworkManager } let(:persister_class) { ::ManagerRefresh::Inventory::Persister } @@ -58,7 +58,7 @@ def create_persister it 'throws exception if model_class not specified' do builder = cloud.prepare_data(:non_existing_ic, persister_class) - expect { builder.to_inventory_collection }.to raise_error(::ManagerRefresh::InventoryCollection::Builder::MissingModelClassError) + expect { builder.to_inventory_collection }.to raise_error(::ManagerRefresh::Inventory::Persister::Builder::MissingModelClassError) end # --- adv. settings (TODO: link to gui)--- diff --git a/spec/models/manager_refresh/save_inventory/init_data_helper.rb b/spec/models/manager_refresh/save_inventory/init_data_helper.rb index 44fab796467..4d91b417b6f 100644 --- a/spec/models/manager_refresh/save_inventory/init_data_helper.rb +++ b/spec/models/manager_refresh/save_inventory/init_data_helper.rb @@ -87,11 +87,11 @@ def container_quota_items_attrs_init_data(extra_attributes = {}) end def cloud - ManagerRefresh::InventoryCollection::Builder::CloudManager + ManagerRefresh::Inventory::Persister::Builder::CloudManager end def network - ManagerRefresh::InventoryCollection::Builder::NetworkManager + ManagerRefresh::Inventory::Persister::Builder::NetworkManager end def persister_class