Class: Bcome::Orchestrator::CommandGroup::Base
- Includes:
- ValidateAndSet
- Defined in:
- lib/orchestrator/command_group/base.rb
Instance Attribute Summary collapse
-
#machines ⇒ Object
readonly
Returns the value of attribute machines.
Class Method Summary collapse
- .klass_for_type ⇒ Object
- .new_of_type_from(json, node_targets, all_machines, direct_command_groups) ⇒ Object
Instance Method Summary collapse
- #execute!(*params) ⇒ Object
-
#initialize(json) ⇒ Base
constructor
A new instance of Base.
- #json_attributes ⇒ Object
- #set_machines(node_targets) ⇒ Object
Methods included from ValidateAndSet
Constructor Details
#initialize(json) ⇒ Base
Returns a new instance of Base.
33 34 35 |
# File 'lib/orchestrator/command_group/base.rb', line 33 def initialize(json) validate_and_set(json) end |
Instance Attribute Details
#machines ⇒ Object (readonly)
Returns the value of attribute machines.
29 30 31 |
# File 'lib/orchestrator/command_group/base.rb', line 29 def machines @machines end |
Class Method Details
.klass_for_type ⇒ Object
21 22 23 24 25 26 |
# File 'lib/orchestrator/command_group/base.rb', line 21 def klass_for_type { "DIRECT" => ::Bcome::Orchestrator::CommandGroup::Direct, "CUSTOM" => ::Bcome::Orchestrator::CommandGroup::Custom } end |
.new_of_type_from(json, node_targets, all_machines, direct_command_groups) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/orchestrator/command_group/base.rb', line 5 def new_of_type_from(json, node_targets, all_machines, direct_command_groups) raise "Missing command type in #{json.inspect}" unless json.has_key?(:type) raise "Invalid command of type #{json[:type]} in #{json.inspect}" unless klass_for_type.keys.include?(json[:type]) klass = klass_for_type[json[:type]] command_group = klass.new(json) command_group.set_machines(node_targets) if klass == ::Bcome::Orchestrator::CommandGroup::Direct command_group.direct_command_groups = direct_command_groups end return command_group end |
Instance Method Details
#execute!(*params) ⇒ Object
51 52 53 |
# File 'lib/orchestrator/command_group/base.rb', line 51 def execute!(*params) raise "Should be overidden" end |
#json_attributes ⇒ Object
37 38 39 |
# File 'lib/orchestrator/command_group/base.rb', line 37 def json_attributes raise "json_attributes should be overidden on derived Orchestrator::Command classes" end |
#set_machines(node_targets) ⇒ Object
41 42 43 44 45 |
# File 'lib/orchestrator/command_group/base.rb', line 41 def set_machines(node_targets) @machines ||= node_targets.select{ |nt| nt.target_key == @target_nodes_key }.collect(&:node_selections).flatten! end |