Class: Dopi::Step
- Inherits:
-
Object
- Object
- Dopi::Step
- Includes:
- DopCommon::NodeFilter, State
- Defined in:
- lib/dopi/step.rb
Constant Summary collapse
- DEFAULT_MAX_IN_FLIGHT =
3
- DEFAULT_MAX_PER_ROLE =
-1
Instance Attribute Summary collapse
-
#nodes ⇒ Object
Returns the value of attribute nodes.
-
#plan ⇒ Object
Returns the value of attribute plan.
Instance Method Summary collapse
- #command_sets ⇒ Object
-
#initialize(step_parser, plan) ⇒ Step
constructor
A new instance of Step.
- #load_state(state_hash) ⇒ Object
- #name ⇒ Object
- #run(run_options) ⇒ Object
- #state_hash ⇒ Object
-
#to_yaml_properties ⇒ Object
Loading queue object from yaml files results in not properly initialized queue and a type error when using it.
- #valid? ⇒ Boolean
Methods included from State
#delete_on_signal, #on_signal, #reset_signals, #send_signal, #signal_procs, #signals, #state, #state_add_child, #state_auto_evaluate_children, #state_auto_evaluate_children=, #state_changed, #state_children, #state_children_done?, #state_children_failed?, #state_children_partial?, #state_children_ready?, #state_children_running?, #state_children_running_noop?, #state_children_starting?, #state_done?, #state_fail, #state_failed?, #state_finish, #state_partial?, #state_ready, #state_ready?, #state_reset, #state_reset_with_children, #state_run, #state_run_noop, #state_running?, #state_running_noop?, #state_start, #state_starting?, #update, #update_mutex
Constructor Details
#initialize(step_parser, plan) ⇒ Step
Returns a new instance of Step.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dopi/step.rb', line 16 def initialize(step_parser, plan) @step_parser = step_parser @plan = plan @nodes = filter_nodes(plan.nodes, step_parser) @next_mutex = Mutex.new @notify_mutex = Mutex.new @queue = Queue.new command_sets.each{|command_set| state_add_child(command_set)} end |
Instance Attribute Details
#nodes ⇒ Object
Returns the value of attribute nodes.
14 15 16 |
# File 'lib/dopi/step.rb', line 14 def nodes @nodes end |
#plan ⇒ Object
Returns the value of attribute plan.
14 15 16 |
# File 'lib/dopi/step.rb', line 14 def plan @plan end |
Instance Method Details
#command_sets ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/dopi/step.rb', line 49 def command_sets @command_sets ||= @nodes.map do |node| delete_plugin_defaults set_plugin_defaults Dopi::CommandSet.new(@step_parser, self, node) end end |
#load_state(state_hash) ⇒ Object
78 79 80 81 82 83 |
# File 'lib/dopi/step.rb', line 78 def load_state(state_hash) command_sets.each do |command_set| command_set_state = state_hash[command_set.name] || [] command_set.load_state(command_set_state) end end |
#name ⇒ Object
35 36 37 |
# File 'lib/dopi/step.rb', line 35 def name @step_parser.name end |
#run(run_options) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/dopi/step.rb', line 57 def run() if state_done? Dopi.log.info("Step '#{name}' is in state 'done'. Skipping") return end Dopi.log.info("Starting to run step '#{name}'") nodes_to_run = filter_nodes(@nodes, [:run_for_nodes]) command_sets_to_run = command_sets.select {|cs| nodes_to_run.include?(cs.node)} unless [:noop] run_canary(, command_sets_to_run) if canary_host run_command_sets(, command_sets_to_run) unless state_failed? else command_sets_to_run.each{|command_set| command_set.run([:noop])} end Dopi.log.info("Step '#{name}' successfully finished.") if state_done? Dopi.log.error("Step '#{name}' failed! Stopping execution.") if state_failed? end |
#state_hash ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/dopi/step.rb', line 85 def state_hash command_sets_hash = {} command_sets.each do |command_set| command_sets_hash[command_set.name] = command_set.state_hash end command_sets_hash end |
#to_yaml_properties ⇒ Object
Loading queue object from yaml files results in not properly initialized queue and a type error when using it. Skip queue when converting to yaml. Will be nil after loading from yaml and must be re-created.
31 32 33 |
# File 'lib/dopi/step.rb', line 31 def to_yaml_properties super - [:@queue] end |