Class: Ec2::Blackout::AutoScalingGroup
- Inherits:
-
Object
- Object
- Ec2::Blackout::AutoScalingGroup
- Defined in:
- lib/ec2-blackout/auto_scaling_group.rb
Constant Summary collapse
- TIMESTAMP_TAG_NAME =
'ec2:blackout:on'
- DESIRED_CAPACITY_TAG_NAME =
'ec2:blackout:desired_capacity'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(group, options) ⇒ AutoScalingGroup
constructor
A new instance of AutoScalingGroup.
- #start ⇒ Object
- #startable? ⇒ Boolean
- #stop ⇒ Object
- #stoppable? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(group, options) ⇒ AutoScalingGroup
Returns a new instance of AutoScalingGroup.
13 14 15 |
# File 'lib/ec2-blackout/auto_scaling_group.rb', line 13 def initialize(group, ) @group, @options = group, end |
Class Method Details
.groups(region, options) ⇒ Object
7 8 9 10 11 |
# File 'lib/ec2-blackout/auto_scaling_group.rb', line 7 def self.groups(region, ) AWS::AutoScaling.new(:region => region).groups.map do |group| Ec2::Blackout::AutoScalingGroup.new(group, ) end end |
Instance Method Details
#start ⇒ Object
22 23 24 25 |
# File 'lib/ec2-blackout/auto_scaling_group.rb', line 22 def start restore_desired_capacity untag end |
#startable? ⇒ Boolean
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ec2-blackout/auto_scaling_group.rb', line 43 def startable? if @group.max_size == 0 [false, "maximum ASG size is zero"] elsif @options.force true elsif ![TIMESTAMP_TAG_NAME] [false, "instance was not originally stopped by ec2-blackout"] else true end end |
#stop ⇒ Object
17 18 19 20 |
# File 'lib/ec2-blackout/auto_scaling_group.rb', line 17 def stop tag zero_desired_capacity end |
#stoppable? ⇒ Boolean
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ec2-blackout/auto_scaling_group.rb', line 27 def stoppable? AWS.memoize do if @options.() [false, "matches exclude tags"] elsif !@options.() [false, "does not match include tags"] elsif @group.desired_capacity == 0 [false, "group has already been stopped"] elsif @group.min_size > 0 [false, "minimum ASG size is greater than zero - set min_size to 0 if you want to be able to stop this AutoScalingGroup"] else true end end end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/ec2-blackout/auto_scaling_group.rb', line 55 def to_s "autoscaling group #{@group.name}" end |