class Rundock::Node

Attributes

backend[R]
hooks[RW]
name[R]
operations[R]

Public Class Methods

new(name, backend) click to toggle source
# File lib/rundock/node.rb, line 10
def initialize(name, backend)
  @name = name
  @backend = backend
  @operations = []
  @hooks = []
end

Public Instance Methods

add_operation(ope) click to toggle source
# File lib/rundock/node.rb, line 17
def add_operation(ope)
  @operations ||= []
  @operations << ope
end
run() click to toggle source
# File lib/rundock/node.rb, line 22
def run
  Logger.formatter.on_rec
  Logger.debug("run node: #{@name}")
  Logger.warn("no operation running: #{@name}") if @operations.blank?

  node_attributes = []

  @operations.each do |ope|
    Logger.debug("run operation: #{ope.class}")
    node_attributes << ope.attributes
    ope.attributes[:nodename] = @name
    ope.run(@backend, ope.attributes)
  end

  log_buffer = Logger.formatter.flush unless Logger.formatter.buffer.empty?

  @hooks.each do |h|
    Logger.debug("run hook: #{h.name}")
    h.hook(node_attributes, log_buffer)
  end

  Logger.formatter.off_rec
end