lib/rundock/builder/operation_builder.rb in rundock-0.4.15 vs lib/rundock/builder/operation_builder.rb in rundock-0.4.16

- old
+ new

@@ -1,9 +1,9 @@ module Rundock module Builder class OperationBuilder < Base - def build_first(scenario, node_info, tasks) + def build_first(scenario, node_info, tasks, hooks) if @options[:hostgroup] && !@options[:command] raise CommandArgNotFoundError, %("--command or -c" option is required if hostgroup specified.) end node = nil @@ -30,12 +30,15 @@ if @options[:command] node.add_operation(build_cli_command_operation(@options[:command], node_attribute, @options)) end elsif k == :hook - node_attribute.enable_hooks = Array(v) - node.hooks = HookBuilder.new(@options).build(Array(v)) if node + hooks_builder = HookBuilder.new(@options) + if node + node.hooks = hooks_builder.build(Array(v), hooks) + node_attribute.hooks = hooks_builder.enable_hooks + end else next unless node ope = build_operations(k, Array(v), node_attribute, @options, false) @@ -48,11 +51,10 @@ scen end def build_task(tasks, backend, node_attribute) 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, true) node.add_operation(ope) if ope @@ -66,10 +68,10 @@ scen = Scenario.new @options[:host].split(',').each do |host| backend = BackendBuilder.new(@options, host, nil).build node = Node.new(host, backend) - node.hooks = HookBuilder.new(@options).build(['all']) + 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