diff --git a/app/models/manager_refresh/inventory/persister.rb b/app/models/manager_refresh/inventory/persister.rb index ad5975ff828..c5f2f2e0708 100644 --- a/app/models/manager_refresh/inventory/persister.rb +++ b/app/models/manager_refresh/inventory/persister.rb @@ -105,6 +105,11 @@ def initialize_inventory_collections # can be implemented in a subclass end + def shared_options + # can be implemented in a subclass + {} + end + # Adds 1 ManagerRefresh::InventoryCollection under a target.collections using :association key as index # # @param options [Hash] Hash used for ManagerRefresh::InventoryCollection initialize @@ -131,7 +136,7 @@ def add_inventory_collection(options) # @param options [Hash] Hash used for ManagerRefresh::InventoryCollection initialize def add_inventory_collections(default, inventory_collections, options = {}) inventory_collections.each do |inventory_collection| - add_inventory_collection(default.send(inventory_collection, options)) + add_inventory_collection(shared_options.merge(default.send(inventory_collection, options))) end end diff --git a/app/models/manager_refresh/inventory_collection_default/cloud_manager.rb b/app/models/manager_refresh/inventory_collection_default/cloud_manager.rb index 5048ecb988c..967859a53ee 100644 --- a/app/models/manager_refresh/inventory_collection_default/cloud_manager.rb +++ b/app/models/manager_refresh/inventory_collection_default/cloud_manager.rb @@ -8,6 +8,8 @@ def vms(extra_attributes = {}) :attributes_blacklist => [:genealogy_parent], :unique_index_columns => [:ems_id, :ems_ref], :use_ar_object => true, # Because of raw_power_state setter + # TODO(lsmola) can't do batch strategy for vms because of key_pairs relation + :saver_strategy => :default, :batch_extra_attributes => [:power_state, :state_changed_on, :previous_state], :builder_params => { :ems_id => ->(persister) { persister.manager.id }, diff --git a/app/models/manager_refresh/inventory_collection_default/network_manager.rb b/app/models/manager_refresh/inventory_collection_default/network_manager.rb index 1e365065849..653fd7b5d11 100644 --- a/app/models/manager_refresh/inventory_collection_default/network_manager.rb +++ b/app/models/manager_refresh/inventory_collection_default/network_manager.rb @@ -23,6 +23,8 @@ def network_ports(extra_attributes = {}) :model_class => ::NetworkPort, :association => :network_ports, :use_ar_object => true, + # TODO(lsmola) can't do batch strategy for network_ports because of security_groups relation + :saver_strategy => :default, :builder_params => { :ems_id => ->(persister) { persister.manager.try(:network_manager).try(:id) || persister.manager.id }, }