Module: Bcome::Orchestrator::Factory
- Defined in:
- lib/orchestrator/factory.rb
Class Method Summary collapse
- .create_command_groups_from_json(json, node_targets, all_machines, direct_commands) ⇒ Object
- .create_direct_commands_from_json(json) ⇒ Object
- .create_node_targets_from_json(json, machines) ⇒ Object
- .create_recipes_from_json(json, node_targets, all_machines, direct_commands) ⇒ Object
- .system_node_targets(machines) ⇒ Object
- .validate_json_collection(json) ⇒ Object
Class Method Details
.create_command_groups_from_json(json, node_targets, all_machines, direct_commands) ⇒ Object
10 11 12 13 |
# File 'lib/orchestrator/factory.rb', line 10 def create_command_groups_from_json(json, node_targets, all_machines, direct_commands) validate_json_collection(json) return json.collect{|instance_json| ::Bcome::Orchestrator::CommandGroup::Base.new_of_type_from(instance_json, node_targets, all_machines, direct_commands) } end |
.create_direct_commands_from_json(json) ⇒ Object
27 28 29 30 |
# File 'lib/orchestrator/factory.rb', line 27 def create_direct_commands_from_json(json) validate_json_collection(json) return json.collect{|instance_json| ::Bcome::Orchestrator::DirectCommand::Group.new(instance_json) } end |
.create_node_targets_from_json(json, machines) ⇒ Object
15 16 17 18 19 |
# File 'lib/orchestrator/factory.rb', line 15 def create_node_targets_from_json(json, machines) validate_json_collection(json) user_defined_targets = json.collect{|instance_json| ::Bcome::Orchestrator::NodeTarget::Base.new_of_type_from(instance_json, machines) } return user_defined_targets + system_node_targets(machines) end |
.create_recipes_from_json(json, node_targets, all_machines, direct_commands) ⇒ Object
5 6 7 8 |
# File 'lib/orchestrator/factory.rb', line 5 def create_recipes_from_json(json, node_targets, all_machines, direct_commands) validate_json_collection(json) return json.collect{|instance_json| ::Bcome::Orchestrator::Recipe.new(instance_json, node_targets, all_machines, direct_commands) } end |
.system_node_targets(machines) ⇒ Object
21 22 23 24 25 |
# File 'lib/orchestrator/factory.rb', line 21 def system_node_targets(machines) [ ::Bcome::Orchestrator::NodeTarget::All.new(:node_selections => machines, :target_key => "all") ] end |
.validate_json_collection(json) ⇒ Object
32 33 34 |
# File 'lib/orchestrator/factory.rb', line 32 def validate_json_collection(json) raise "Cannot create Orchestrator recipes - expecting a JSON array" unless json.is_a?(Array) end |