Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have parent inventory collections as dependencies #15903

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/manager_refresh/inventory_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def initialize(model_class: nil, manager_ref: nil, association: nil, parent: nil
@custom_save_block = custom_save_block
@custom_reconnect_block = custom_reconnect_block
@check_changed = check_changed.nil? ? true : check_changed
@internal_attributes = [:__feedback_edge_set_parent]
@internal_attributes = [:__feedback_edge_set_parent, :__parent_inventory_collections]
@complete = complete.nil? ? true : complete
@update_only = update_only.nil? ? false : update_only
@builder_params = builder_params
Expand Down
13 changes: 9 additions & 4 deletions app/models/manager_refresh/inventory_collection/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,17 @@ def scan!
end

# Transform :parent_inventory_collections symbols to InventoryCollection objects
if targeted? && parent_inventory_collections.present?
if parent_inventory_collections.present?
self.parent_inventory_collections = parent_inventory_collections.map do |inventory_collection_index|
ic = indexed_inventory_collections[inventory_collection_index]
raise "Can't find InventoryCollection #{inventory_collection_index} from #{inventory_collection}" unless ic
ic
end
if ic.nil?
raise "Can't find InventoryCollection #{inventory_collection_index} from #{inventory_collection}" if targeted?
else
# Add parent_inventory_collection as a dependency, so e.g. disconnect is done in a right order
(dependency_attributes[:__parent_inventory_collections] ||= Set.new) << ic
ic
end
end.compact
end

# Mark InventoryCollection as finalized aka. scanned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@
:attributes_whitelist => [:raw_power_state, :ext_management_system]
)

expect(inventory_collection.attributes_whitelist).to match_array([:__feedback_edge_set_parent, :ems_ref,
expect(inventory_collection.attributes_whitelist).to match_array([:__feedback_edge_set_parent,
:__parent_inventory_collections, :ems_ref,
:name, :location, :raw_power_state,
:ext_management_system])
end
Expand All @@ -358,7 +359,8 @@
:attributes_whitelist => [:raw_power_state, :ext_management_system]
)

expect(inventory_collection.attributes_whitelist).to match_array([:__feedback_edge_set_parent, :uid_ems,
expect(inventory_collection.attributes_whitelist).to match_array([:__feedback_edge_set_parent,
:__parent_inventory_collections, :uid_ems,
:name, :location, :raw_power_state,
:ext_management_system])
end
Expand Down