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, targets, tasks, hooks) ⇒ 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
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rundock/builder/operation_builder.rb', line 63 def build_cli scen = Scenario.new hosts = @options[:host].split(',') hosts.each do |host| @options[:host] = host backend = BackendBuilder.new(@options, host, nil).build node = Node.new(host, backend) node.hooks = HookBuilder.new(@options).build(['all'], nil) node.add_operation( build_cli_command_operation( @options[:command], Rundock::Attribute::NodeAttribute.new, @options ) ) scen.nodes.push(node) end scen end |
#build_first(scenario, targets, tasks, hooks) ⇒ 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, targets, tasks, hooks) parsing_node_attribute = Rundock::Attribute::NodeAttribute.new(task_info: {}) scen = Scenario.new scen.tasks = tasks scenario.each do |sn| nodes = [] operations = [] hook_contents = [] sn.deep_symbolize_keys.each do |sk, sv| if %i[target target_group].include?(sk) target_builder = TargetBuilder.new(@options) nodes, = target_builder.build(sv, targets) nodes.each do |n| if n.is_a?(Node) parsing_node_attribute = build_node_attribute(scen, n.name, parsing_node_attribute, tasks, [n.name.to_sym]) operations = Array(build_cli_command_operation(@options[:command], parsing_node_attribute, @options)) if @options[:command] end end elsif sk == :hook hooks_builder = HookBuilder.new(@options) hook_contents = hooks_builder.build(Array(sv), hooks) parsing_node_attribute.hooks = hooks_builder.enable_hooks else ope = build_operations(sk, Array(sv), parsing_node_attribute, @options, false) operations << ope if ope end end nodes.each do |n| operations.each do |o| n.add_operation(o) end n.hooks = hook_contents end scen.nodes.concat(nodes) end scen end |
#build_task(tasks, backend, node_attribute) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# 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 node_attribute.define_attr(:parrent_task_args, node_attribute.task_args) if node_attribute.respond_to?(:task_args) tasks.each do |k, v| ope = build_operations(k, Array(v), node_attribute, nil, true) node.add_operation(ope) if ope end scen.nodes.push(node) if node scen end |