class CfDeployer::DeploymentStrategy::Base
Constants
- BLUE_GREEN_STRATEGY
Attributes
application_name[R]
component_name[R]
context[R]
environment_name[R]
Public Class Methods
new(application_name, component_name, environment_name, context)
click to toggle source
# File lib/cf_deployer/deployment_strategy/base.rb, line 18 def initialize(application_name, component_name, environment_name, context) @application_name = application_name @component_name = component_name @environment_name = environment_name @context = context @auto_scaling_group_drivers = {} end
Public Instance Methods
active_template()
click to toggle source
# File lib/cf_deployer/deployment_strategy/base.rb, line 45 def active_template target_stack = ( active_stack || stack ) (target_stack && target_stack.exists?) ? target_stack.template : nil end
blue_green_strategy?()
click to toggle source
# File lib/cf_deployer/deployment_strategy/base.rb, line 26 def blue_green_strategy? BLUE_GREEN_STRATEGY end
run_hook(hook_name)
click to toggle source
# File lib/cf_deployer/deployment_strategy/base.rb, line 30 def run_hook(hook_name) CfDeployer::Driver::DryRun.guard "Skipping hook #{hook_name}" do unless @params_and_outputs_resolved target_stack = ( active_stack || stack ) unless target_stack.exists? CfDeployer::Log.info "Skipping hook call for #{hook_name} since stack #{target_stack.name} doesn't exist." return end get_parameters_outputs target_stack end hook = Hook.new hook_name, context[hook_name] hook.run context end end
Protected Instance Methods
asg_driver(name)
click to toggle source
# File lib/cf_deployer/deployment_strategy/base.rb, line 101 def asg_driver name @auto_scaling_group_drivers[name] ||= CfDeployer::Driver::AutoScalingGroup.new name end
asg_name_outputs()
click to toggle source
# File lib/cf_deployer/deployment_strategy/base.rb, line 105 def asg_name_outputs @context[:settings][:'auto-scaling-group-name-output'] end
delete_stack(stack)
click to toggle source
# File lib/cf_deployer/deployment_strategy/base.rb, line 56 def delete_stack(stack) # Should this be stack.ready? Outputs won't exist if the stack is still starting. unless stack.exists? CfDeployer::Log.info "Skipping deleting stack #{stack.name} since it doesn't exist." return end get_parameters_outputs stack run_hook :'before-destroy' stack.delete end
get_parameters_outputs(stack)
click to toggle source
# File lib/cf_deployer/deployment_strategy/base.rb, line 67 def get_parameters_outputs(stack) CfDeployer::Driver::DryRun.guard "Skipping get_parameters_outputs" do @params_and_outputs_resolved = true context[:parameters] = stack.parameters context[:outputs] = stack.outputs end end
stack_prefix()
click to toggle source
# File lib/cf_deployer/deployment_strategy/base.rb, line 52 def stack_prefix "#{@application_name}-#{@environment_name}-#{@component_name}" end
template_asg_name_to_ids(stack)
click to toggle source
# File lib/cf_deployer/deployment_strategy/base.rb, line 92 def template_asg_name_to_ids(stack) {}.tap do |result| (asg_name_outputs || []).each do |name| id = stack.find_output(name) result[name] = id if id end end end
warm_up_inactive_stack()
click to toggle source
# File lib/cf_deployer/deployment_strategy/base.rb, line 75 def warm_up_inactive_stack warm_up_stack(inactive_stack, active_stack) end
warm_up_stack(stack, previous_stack = nil, adjust_min_max = false)
click to toggle source
# File lib/cf_deployer/deployment_strategy/base.rb, line 79 def warm_up_stack stack, previous_stack = nil, adjust_min_max = false previous_ids = previous_stack ? template_asg_name_to_ids(previous_stack) : {} template_asg_name_to_ids(stack).each do |name, id| driver = asg_driver(id) description = asg_driver(previous_ids[name] || id).describe if adjust_min_max driver.warm_up_cooled_group(description) else driver.warm_up(description[:desired]) end end end