lib/rundock/builder/operation_builder.rb in rundock-0.4.10 vs lib/rundock/builder/operation_builder.rb in rundock-0.4.11

- old
+ new

@@ -36,11 +36,11 @@ node.hooks = HookBuilder.new(@options).build(Array(v)) if node else next unless node - ope = build_operations(k, Array(v), node_attribute, @options) + ope = build_operations(k, Array(v), node_attribute, @options, false) node.add_operation(ope) if ope end end end @@ -52,11 +52,11 @@ node = Node.new(node_attribute.nodename, backend) node.hooks = HookBuilder.new(nil).build_from_attributes(node_attribute.nodeinfo) scen = Scenario.new tasks.each do |k, v| - ope = build_operations(k, Array(v), node_attribute, nil) + ope = build_operations(k, Array(v), node_attribute, nil, true) node.add_operation(ope) if ope end scen.nodes.push(node) if node scen @@ -82,19 +82,29 @@ def build_cli_command_operation(command, node_attributes, cli_options) node_attributes.errexit = !cli_options[:run_anyway] Rundock::OperationFactory.instance(:command).create(Array(command), node_attributes.list) end - def build_operations(ope_type, ope_content, node_attributes, cli_options) - if cli_options && - cli_options[:command] && + def build_operations(ope_type, ope_content, node_attributes, cli_options, recursive) + cli_options = {} if cli_options.nil? + + if cli_options[:command] && (ope_type == :command || ope_type == :task) Logger.debug(%("--command or -c" option is specified and ignore scenario file.)) return end - node_attributes.errexit = !cli_options[:run_anyway] if cli_options - node_attributes.errexit = true if cli_options.nil? + unless recursive + # apply cli options + if !cli_options.key?(:run_anyway) + node_attributes.errexit = true + else + node_attributes.errexit = !cli_options[:run_anyway] + end + node_attributes.dry_run = (cli_options && cli_options[:dry_run]) ? true : false + end + + # override by scenario node_attributes.define_attr(ope_type, ope_content) Rundock::OperationFactory.instance(ope_type).create(Array(ope_content), node_attributes.list) end end end