Skip to content

Commit

Permalink
crowbar: Fix Node.get_network_by_type for overridden attributes
Browse files Browse the repository at this point in the history
We were looking for attributes overriding the network proposal only on
the node role, but this is not consistent with what the cookbook does
(it looks at attributes on the node itself), and customer using this
feature are more likely to edit the node directly.

So reflect that by looking at the node attributes, which does include
the attributes from the node role anyhow.
  • Loading branch information
vuntz committed Apr 26, 2018
1 parent d2458a5 commit 9cad67d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crowbar_framework/app/models/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,11 @@ def networks

def get_network_by_type(type)
return nil if @role.nil?
return nil unless crowbar["crowbar"]["network"].key?(type)
return nil unless @node["crowbar"]["network"].key?(type)
# note that node might not be part of network proposal yet (for instance:
# if discovered, and IP got allocated by user)
return nil if @node["network"]["networks"].nil? || !@node["network"]["networks"].key?(type)
@node["network"]["networks"][type].to_hash.merge(crowbar["crowbar"]["network"][type].to_hash)
@node["network"]["networks"][type].to_hash.merge(@node["crowbar"]["network"][type].to_hash)
end

def set_network_attribute(network, attribute, value)
Expand Down

0 comments on commit 9cad67d

Please sign in to comment.