Class: Sfn::Command::Realize
- Inherits:
-
Sfn::Command
- Object
- Bogo::Cli::Command
- Sfn::Command
- Sfn::Command::Realize
- Defined in:
- lib/sfn/command/realize.rb
Overview
Realize command
Constant Summary
Constants inherited from Sfn::Command
CONFIG_BASE_NAME, VALID_CONFIG_EXTENSIONS
Instance Method Summary collapse
-
#execute! ⇒ Object
Run the stack realize command.
Methods included from Sfn::CommandModule::Planning
#build_planner, #display_plan_information, #print_plan_items, #print_plan_result
Methods included from Sfn::CommandModule::Base
Methods inherited from Sfn::Command
Methods included from Sfn::CommandModule::Callbacks
#api_action!, #callbacks_for, #run_callbacks_for
Constructor Details
This class inherits a constructor from Sfn::Command
Instance Method Details
#execute! ⇒ Object
Run the stack realize command
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/sfn/command/realize.rb', line 11 def execute! name_required! name = name_args.first stack_info = "#{ui.color("Name:", :bold)} #{name}" begin stack = provider.stacks.get(name) rescue Miasma::Error::ApiError::RequestError raise Error::StackNotFound, "Failed to locate stack: #{name}" end if config[:plan_name] ui.debug "Setting custom plan name - #{config[:plan_name]}" # ensure custom attribute is dirty so we can modify stack.custom = stack.custom.dup stack.custom[:plan_name] = config[:plan_name] end ui.info " -> Loading plan information..." plan = stack.plan if plan.nil? raise Error::StackPlanNotFound, "Failed to locate plan for stack `#{name}`" end display_plan_information(plan) return if config[:plan_only] if config[:merge_api_options] config.fetch(:options, Smash.new).each_pair do |key, value| if stack.respond_to?("#{key}=") stack.send("#{key}=", value) end end end begin api_action!(:api_stack => stack) do stack.plan_execute if config[:poll] poll_stack(stack.name) if [:update_complete, :create_complete]. include?(stack.reload.state) ui.info "Stack plan apply complete: " \ "#{ui.color("SUCCESS", :green)}" namespace.const_get(:Describe). new({:outputs => true}, [name]).execute! else ui.fatal "Update of stack #{ui.color(name, :bold)}: " \ "#{ui.color("FAILED", :red, :bold)}" raise Error::StackStateIncomplete end else ui.warn "Stack state polling has been disabled." ui.info "Stack plan apply initialized for " \ "#{ui.color(name, :green)}" end end rescue Miasma::Error::ApiError::RequestError => e if e..downcase.include?("no updates") ui.warn "No changes detected for stack (#{stack.name})" else raise end end end |