core/rails/app/models/node_role.rb
# Gather all of the attribute data needed for a single noderole run.
# It should be run to create whatever information will be needed
# for the actual run before doing the actual run in a delayed job.
# RETURNS the attribute data needed for a single noderole run.
Gather all of the attribute data needed for a single noderole run.
It should be run to create whatever information will be needed
for the actual run before doing the actual run in a delayed job.
RETURNS the attribute data needed for a single noderole run.
Gather all of the attribute data needed for a single noderole run . It should be run to create whatever information will be needed for the actual run before doing the actual run in a delayed job . RETURNS the attribute data needed for a single noderole run .
def all_transition_data
    res = {}
    NodeRole.transaction do
      node_req_attrs = role.role_require_attribs.select do |rrr|
        attr = rrr.attrib
        raise("RoleRequiresAttrib: Cannot find required attrib #{rrr.attrib_name}") if attr.nil?
        attr.role_id.nil?
      end
      node_req_attrs.each do |req_attr|
        Rails.logger.info("NodeRole all_transition_data: Adding node attribute #{req_attr.attrib_name} to attribute blob for #{name} run")
        v = req_attr.attrib.extract(node,:all,true)
        res.deep_merge!(v) unless v.nil?
      end
      parent_attrib_links.each do |al|
        Rails.logger.info("NodeRole all_transition_data: Adding role attribute #{al.attrib.name} from #{al.parent.name}")
        res.deep_merge!(al.attrib.extract(al.parent.deployment_role,:all,true))
        res.deep_merge!(al.attrib.extract(al.parent,:all,true))
      end
      all_parents.where(node_id: node.id).each do |pnr|
        res.deep_merge!(pnr.all_committed_data)
      end
      Rails.logger.info("Jig: Merging attribute data from #{name} for jig run.")
      res.deep_merge!(all_committed_data)
      attribs.each do |attr|
        res.deep_merge!(attr.extract(self,:all,true))
      end
      if node.discovery["reservations"]
        res["rebar_wall"] ||= Hash.new
        res["rebar_wall"]["reservations"] = node.discovery["reservations"]
      end
      res["variant"] = node.variant
      res["hints"] = node.hint
      res["quirks"] = node.quirks
    end
    res
  end
def all_transition_data res = { } NodeRole . transaction do node_req_attrs = role . role_require_attribs . select do | rrr | attr = rrr . attrib raise ( "RoleRequiresAttrib: Cannot find required attrib #{rrr.attrib_name}" ) if attr . nil? attr . role_id . nil? end node_req_attrs . each do | req_attr | Rails . logger . info ( "NodeRole all_transition_data: Adding node attribute #{req_attr.attrib_name} to attribute blob for #{name} run" ) v = req_attr . attrib . extract ( node , :all , true ) res . deep_merge! ( v ) unless v . nil? end parent_attrib_links . each do | al | Rails . logger . info ( "NodeRole all_transition_data: Adding role attribute #{al.attrib.name} from #{al.parent.name}" ) res . deep_merge! ( al . attrib . extract ( al . parent . deployment_role , :all , true ) ) res . deep_merge! ( al . attrib . extract ( al . parent , :all , true ) ) end all_parents . where ( node_id : node . id ) . each do | pnr | res . deep_merge! ( pnr . all_committed_data ) end Rails . logger . info ( "Jig: Merging attribute data from #{name} for jig run." ) res . deep_merge! ( all_committed_data ) attribs . each do | attr | res . deep_merge! ( attr . extract ( self , :all , true ) ) end if node . discovery [ "reservations" ] res [ "rebar_wall" ] ||= Hash . new res [ "rebar_wall" ] [ "reservations" ] = node . discovery [ "reservations" ] end res [ "variant" ] = node . variant res [ "hints" ] = node . hint res [ "quirks" ] = node . quirks end res end
Gather all of the attribute data needed for a single noderole run.
Gather all of the attribute data needed for a single noderole run .
# Figure out which attribs will be satisfied from node data vs. # which will be satisfied from noderoles. # For all the node attrs, resolve them.  Prefer hints. # Start with the node data. # Next, do the same for the attribs we want from a noderole. # And all the noderole data from the parent noderoles on this node. # This needs to eventaully go away once I figure ot the best way to pull # attrib data that hsould always be present on a node. # Add this noderole's attrib data. # Make sure we capture default attrib values # Add information about the resource reservations this node has in place # Add variant # Add any hints. # Add quirks # And we are done.