Class: Rundock::Node

Inherits:
Object show all
Defined in:
lib/rundock/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, backend) ⇒ Node

Returns a new instance of Node.



9
10
11
12
13
# File 'lib/rundock/node.rb', line 9

def initialize(name, backend)
  @name = name
  @backend = backend
  @operations = []
end

Instance Attribute Details

#backendObject (readonly)

Returns the value of attribute backend.



7
8
9
# File 'lib/rundock/node.rb', line 7

def backend
  @backend
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/rundock/node.rb', line 5

def name
  @name
end

#operationsObject (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



15
16
17
18
# File 'lib/rundock/node.rb', line 15

def add_operation(ope)
  @operations = [] unless @operations
  @operations << ope
end

#complete(scenario) ⇒ Object



20
21
22
23
24
# File 'lib/rundock/node.rb', line 20

def complete(scenario)
  @operations.each do |ope|
    ope.attributes[:nodeinfo].merge!(scenario.node_info)
  end
end

#runObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rundock/node.rb', line 26

def run
  Logger.debug("run node: #{@name}")
  if @operations.blank?
    Logger.warn("no operation running: #{@name}")
    return
  end
  @operations.each do |ope|
    Logger.debug("run operation: #{ope.class}")
    ope.run(@backend, ope.attributes)
  end
end