Class: Moonshot::Tools::ASGRollout::InstanceHealth

Inherits:
Object
  • Object
show all
Defined in:
lib/moonshot/tools/asg_rollout/instance_health.rb

Constant Summary collapse

VALID_ASG_IN_SERVICE_STATES =
['InService'].freeze
VALID_ELB_IN_SERVICE_STATES =
[nil, 'InService'].freeze
VALID_ASG_OUT_OF_SERVICE_STATES =
[nil, 'Missing', 'Detached'].freeze
VALID_ELB_OUT_OF_SERVICE_STATES =
[nil, 'Missing', 'OutOfService'].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(asg_status, elb_status) ⇒ InstanceHealth

Returns a new instance of InstanceHealth.



15
16
17
18
# File 'lib/moonshot/tools/asg_rollout/instance_health.rb', line 15

def initialize(asg_status, elb_status)
  @asg_status = asg_status
  @elb_status = elb_status
end

Instance Attribute Details

#asg_statusObject (readonly)

Returns the value of attribute asg_status.



7
8
9
# File 'lib/moonshot/tools/asg_rollout/instance_health.rb', line 7

def asg_status
  @asg_status
end

#elb_statusObject (readonly)

Returns the value of attribute elb_status.



7
8
9
# File 'lib/moonshot/tools/asg_rollout/instance_health.rb', line 7

def elb_status
  @elb_status
end

Instance Method Details

#in_service?Boolean

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/moonshot/tools/asg_rollout/instance_health.rb', line 26

def in_service?
  VALID_ASG_IN_SERVICE_STATES.include?(@asg_status) &&
    VALID_ELB_IN_SERVICE_STATES.include?(@elb_status)
end

#out_of_service?Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'lib/moonshot/tools/asg_rollout/instance_health.rb', line 31

def out_of_service?
  VALID_ASG_OUT_OF_SERVICE_STATES.include?(@asg_status) &&
    VALID_ELB_OUT_OF_SERVICE_STATES.include?(@elb_status)
end

#to_sObject



20
21
22
23
24
# File 'lib/moonshot/tools/asg_rollout/instance_health.rb', line 20

def to_s
  result = "ASG:#{@asg_status}"
  result << "/ELB:#{@elb_status}" if @elb_status
  result
end