Class: Rundock::Node
Instance Attribute Summary collapse
-
#backend ⇒ Object
readonly
Returns the value of attribute backend.
-
#hooks ⇒ Object
Returns the value of attribute hooks.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#operations ⇒ Object
readonly
Returns the value of attribute operations.
Instance Method Summary collapse
- #add_operation(ope) ⇒ Object
-
#initialize(name, backend) ⇒ Node
constructor
A new instance of Node.
- #run ⇒ Object
Constructor Details
#initialize(name, backend) ⇒ Node
Returns a new instance of Node.
10 11 12 13 14 15 |
# File 'lib/rundock/node.rb', line 10 def initialize(name, backend) @name = name @backend = backend @operations = [] @hooks = [] end |
Instance Attribute Details
#backend ⇒ Object (readonly)
Returns the value of attribute backend.
7 8 9 |
# File 'lib/rundock/node.rb', line 7 def backend @backend end |
#hooks ⇒ Object
Returns the value of attribute hooks.
8 9 10 |
# File 'lib/rundock/node.rb', line 8 def hooks @hooks end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/rundock/node.rb', line 5 def name @name end |
#operations ⇒ Object (readonly)
Returns the value of attribute operations.
6 7 8 |
# File 'lib/rundock/node.rb', line 6 def operations @operations end |
Instance Method Details
#add_operation(ope) ⇒ Object
17 18 19 20 |
# File 'lib/rundock/node.rb', line 17 def add_operation(ope) @operations ||= [] @operations << ope end |
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# 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 |