lib/rundock/builder/operation_builder.rb in rundock-0.2.2 vs lib/rundock/builder/operation_builder.rb in rundock-0.2.3

- old
+ new

@@ -6,25 +6,25 @@ raise CommandArgNotFoundError, %("--command or -c" option is required if hostgroup specified.) end node = nil scen = Scenario.new - node_attributes = { :task => {} } - tasks.each { |k, v| node_attributes[:task][k] = v } if tasks + 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.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 backend = BackendBuilder.new(@options, v, node_info).build node = Node.new(v, backend) - node_attributes[:nodename] = v - + node_attribute.nodename = v if @options[:command] node.add_operation(build_cli_command_operation(@options[:command], @options)) end else if @options[:command] && (k == :command || k == :task) @@ -32,26 +32,26 @@ next end next unless node - ope = build_operations(k, Array(v), node_attributes, @options) + ope = build_operations(k, Array(v), node_attribute, @options) node.add_operation(ope) end end end scen.nodes.push(node) if node scen end - def build_task(tasks, backend, node_attributes) - node = Node.new(node_attributes[:nodename], backend) + 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_attributes, nil) + ope = build_operations(k, Array(v), node_attribute, nil) node.add_operation(ope) end scen.nodes.push(node) if node scen @@ -71,18 +71,19 @@ end private def build_cli_command_operation(command, cli_options) - node_attributes = {} - node_attributes[:errexit] = !cli_options[:run_anyway] + node_attribute = Rundock::Attribute::NodeAttribute.new + node_attribute.errexit = !cli_options[:run_anyway] Rundock::OperationFactory.instance(:command).create(Array(command), nil) end def build_operations(ope_type, ope_content, node_attributes, cli_options) - node_attributes[:errexit] = !cli_options[:run_anyway] if cli_options - node_attributes[:errexit] = true if cli_options.nil? - Rundock::OperationFactory.instance(ope_type).create(Array(ope_content), node_attributes) + node_attributes.errexit = !cli_options[:run_anyway] if cli_options + node_attributes.errexit = true if cli_options.nil? + node_attributes.define_attr(ope_type, ope_content) + Rundock::OperationFactory.instance(ope_type).create(Array(ope_content), node_attributes.list) end end end end