Class: CfDeployer::Driver::AutoScalingGroup

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/cf_deployer/driver/auto_scaling_group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, timeout = CfDeployer::Defaults::Timeout) ⇒ AutoScalingGroup

Returns a new instance of AutoScalingGroup.



10
11
12
13
# File 'lib/cf_deployer/driver/auto_scaling_group.rb', line 10

def initialize name, timeout = CfDeployer::Defaults::Timeout
  @group_name = name
  @timeout = timeout
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



8
9
10
# File 'lib/cf_deployer/driver/auto_scaling_group.rb', line 8

def group
  @group
end

#group_nameObject (readonly)

Returns the value of attribute group_name.



8
9
10
# File 'lib/cf_deployer/driver/auto_scaling_group.rb', line 8

def group_name
  @group_name
end

Instance Method Details

#cool_downObject



37
38
39
40
41
42
43
# File 'lib/cf_deployer/driver/auto_scaling_group.rb', line 37

def cool_down
  Log.info "Cooling down #{group_name}"
  CfDeployer::Driver::DryRun.guard "Skipping ASG cooldown" do
    aws_group.update :min_size => 0, :max_size => 0
    aws_group.set_desired_capacity 0
  end
end

#describeObject



15
16
17
# File 'lib/cf_deployer/driver/auto_scaling_group.rb', line 15

def describe
  { desired: aws_group.desired_capacity, min: aws_group.min_size, max: aws_group.max_size }
end

#instance_statusesObject



45
46
47
48
49
50
51
# File 'lib/cf_deployer/driver/auto_scaling_group.rb', line 45

def instance_statuses
  instance_info = {}
  ec2_instances.each do |instance|
    instance_info[instance.id] = CfDeployer::Driver::Instance.new(instance).status
  end
  instance_info
end

#warm_up(desired) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/cf_deployer/driver/auto_scaling_group.rb', line 19

def warm_up desired
  return if desired < aws_group.min_size
  desired = aws_group.max_size if desired > aws_group.max_size
  Log.info "warming up auto scaling group #{group_name} to #{desired}"

  CfDeployer::Driver::DryRun.guard "Skipping ASG warmup" do
    aws_group.set_desired_capacity desired
    wait_for_healthy_instance desired
  end
end

#warm_up_cooled_group(options) ⇒ Object



30
31
32
33
34
35
# File 'lib/cf_deployer/driver/auto_scaling_group.rb', line 30

def warm_up_cooled_group options
  CfDeployer::Driver::DryRun.guard 'Skipping update of ASG min & max instance count' do
    aws_group.update :min_size =>  options[:min], :max_size => options[:max]
  end
  warm_up options[:desired]
end