Class: Bcome::Orchestrator::Recipe
- Includes:
- ValidateAndSet
- Defined in:
- lib/orchestrator/recipe.rb
Instance Attribute Summary collapse
-
#bootstrap ⇒ Object
readonly
Returns the value of attribute bootstrap.
-
#command_groups ⇒ Object
readonly
Returns the value of attribute command_groups.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#recipe_identifier ⇒ Object
readonly
Returns the value of attribute recipe_identifier.
Class Method Summary collapse
- .as_menu_items(stack_level_instance) ⇒ Object
- .by_identifier(identifier, stack_level_instance) ⇒ Object
- .execute!(params) ⇒ Object
Instance Method Summary collapse
- #as_bootstrap ⇒ Object
- #execute!(current_context_machines) ⇒ Object
-
#initialize(json, node_targets, all_machines, direct_commands) ⇒ Recipe
constructor
A new instance of Recipe.
- #json_attributes ⇒ Object
- #optional_json_attributes ⇒ Object
- #set_command_groups(json, node_targets, all_machines, direct_commands) ⇒ Object
Methods included from ValidateAndSet
Constructor Details
#initialize(json, node_targets, all_machines, direct_commands) ⇒ Recipe
Returns a new instance of Recipe.
28 29 30 31 |
# File 'lib/orchestrator/recipe.rb', line 28 def initialize(json, node_targets, all_machines, direct_commands) validate_and_set(json) set_command_groups(json, node_targets, all_machines, direct_commands) end |
Instance Attribute Details
#bootstrap ⇒ Object (readonly)
Returns the value of attribute bootstrap.
24 25 26 |
# File 'lib/orchestrator/recipe.rb', line 24 def bootstrap @bootstrap end |
#command_groups ⇒ Object (readonly)
Returns the value of attribute command_groups.
24 25 26 |
# File 'lib/orchestrator/recipe.rb', line 24 def command_groups @command_groups end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
24 25 26 |
# File 'lib/orchestrator/recipe.rb', line 24 def description @description end |
#recipe_identifier ⇒ Object (readonly)
Returns the value of attribute recipe_identifier.
24 25 26 |
# File 'lib/orchestrator/recipe.rb', line 24 def recipe_identifier @recipe_identifier end |
Class Method Details
.as_menu_items(stack_level_instance) ⇒ Object
18 19 20 |
# File 'lib/orchestrator/recipe.rb', line 18 def (stack_level_instance) stack_level_instance.recipes.collect {|recipe| { :command => recipe.recipe_identifier, :description => recipe.description } } end |
.by_identifier(identifier, stack_level_instance) ⇒ Object
13 14 15 16 |
# File 'lib/orchestrator/recipe.rb', line 13 def by_identifier(identifier, stack_level_instance) all_recipes = stack_level_instance.recipes return all_recipes.select{|recipe| recipe.recipe_identifier == identifier }.first end |
.execute!(params) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/orchestrator/recipe.rb', line 5 def execute!(params) raise "No recipe name provided" unless params && params.is_a?(Hash) && params[:name] recipe = by_identifier(params[:name]) raise "No recipe found matching #{params[:name]}" unless recipe recipe.execute! return end |
Instance Method Details
#as_bootstrap ⇒ Object
49 50 51 |
# File 'lib/orchestrator/recipe.rb', line 49 def as_bootstrap bootstrap ? true : false end |
#execute!(current_context_machines) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/orchestrator/recipe.rb', line 41 def execute!(current_context_machines) @command_groups.each do |command_group| puts "\nExecuting command group".informational command_group.execute!(current_context_machines, as_bootstrap) puts "\n" end end |
#json_attributes ⇒ Object
33 34 35 |
# File 'lib/orchestrator/recipe.rb', line 33 def json_attributes [:recipe_identifier, :description, :bootstrap] end |
#optional_json_attributes ⇒ Object
37 38 39 |
# File 'lib/orchestrator/recipe.rb', line 37 def optional_json_attributes [:bootstrap] end |
#set_command_groups(json, node_targets, all_machines, direct_commands) ⇒ Object
53 54 55 56 57 |
# File 'lib/orchestrator/recipe.rb', line 53 def set_command_groups(json, node_targets, all_machines, direct_commands) commands_json = json[:commands] raise "Expecting commands within an Orchestrator recipe as an Array" unless commands_json.is_a?(Array) @command_groups = ::Bcome::Orchestrator::Factory.create_command_groups_from_json(commands_json, node_targets, all_machines, direct_commands) end |