Skip to content
Open
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
14 changes: 11 additions & 3 deletions crowbar_framework/app/models/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def initialize(node, role = nil)
raise Crowbar::Error::NotFound.new
end
end
Node.ensure_node_role(node, @role.name)
# deep clone of @role.default_attributes, used when saving node
@attrs_last_saved = @role.default_attributes.deep_dup
@node = node
Expand Down Expand Up @@ -1701,13 +1702,20 @@ def create_new_role(new_name, machine)
role.default_attributes["crowbar"]["network"] = {}
role.save

# This run_list call is to add the crowbar tracking role to the node. (SAFE)
machine.run_list.run_list_items << "role[#{role.name}]"
machine.save
Node.ensure_node_role(machine, role.name)

role
end

def ensure_node_role(node, role_name = nil)
role_name = make_role_name(node.name) if role_name.nil?
return if node.run_list.include?("role[#{role_name}]")

# This run_list call is to add the crowbar tracking role to the node. (SAFE)
node.run_list << "role[#{role_name}]"
node.save
end

def create_new(new_name)
machine = Chef::Node.new
machine.name "#{new_name}"
Expand Down