Skip to content

Commit

Permalink
Missing settings for a cloud batch saving and adding shared_options
Browse files Browse the repository at this point in the history
Missing settings for a cloud batch saving and adding shared_options
  • Loading branch information
Ladas committed Aug 11, 2017
1 parent 61474a7 commit a23fe6f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/models/manager_refresh/inventory/persister.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
}
Expand Down

0 comments on commit a23fe6f

Please sign in to comment.