Class: Rundock::Builder::OperationBuilder
- Defined in:
- lib/rundock/builder/operation_builder.rb
Constant Summary
Constants inherited from Base
Base::BuilderNotImplementedError
Instance Method Summary collapse
- #build_cli ⇒ Object
- #build_first(scenario, node_info, tasks) ⇒ Object
- #build_task(tasks, backend, node_attribute) ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from Rundock::Builder::Base
Instance Method Details
#build_cli ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rundock/builder/operation_builder.rb', line 61 def build_cli scen = Scenario.new [:host].split(',').each do |host| backend = BackendBuilder.new(, host, nil).build node = Node.new(host, backend) node.add_operation(build_cli_command_operation([:command], )) scen.nodes.push(node) end scen end |
#build_first(scenario, node_info, tasks) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rundock/builder/operation_builder.rb', line 4 def build_first(scenario, node_info, tasks) if [:hostgroup] && ![:command] raise CommandArgNotFoundError, %("--command or -c" option is required if hostgroup specified.) end node = nil scen = Scenario.new node_attribute = Rundock::Attribute::NodeAttribute.new(task_info: {}) tasks.each { |k, v| node_attribute.task_info[k] = v } if tasks scen.node_info = node_info scen.node_info = {} unless node_info scen.tasks = tasks # use scenario file scenario.each do |n| scen.nodes.push(node) if node n.deep_symbolize_keys.each do |k, v| if k == :node node_attribute.finalize_node builder = BackendBuilder.new(, v, node_info) backend = builder.build node = Node.new(v, backend) node_attribute.nodename = v scen.node_info[v.to_sym] = node_attribute.nodeinfo = builder. if [:command] node.add_operation(build_cli_command_operation([:command], )) end else next unless node ope = build_operations(k, Array(v), node_attribute, ) node.add_operation(ope) if ope end end end scen.nodes.push(node) if node scen.complete end |
#build_task(tasks, backend, node_attribute) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rundock/builder/operation_builder.rb', line 48 def build_task(tasks, backend, node_attribute) node = Node.new(node_attribute.nodename, backend) scen = Scenario.new tasks.each do |k, v| ope = build_operations(k, Array(v), node_attribute, nil) node.add_operation(ope) if ope end scen.nodes.push(node) if node scen end |