Class: Asg::Rebooter::InstanceRebooter

Inherits:
Object
  • Object
show all
Defined in:
lib/asg/rebooter/instance_rebooter.rb

Constant Summary collapse

REBOOT_TIMEOUT =
60

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(asg) ⇒ InstanceRebooter

Returns a new instance of InstanceRebooter.



8
9
10
# File 'lib/asg/rebooter/instance_rebooter.rb', line 8

def initialize(asg)
  @asg = asg
end

Instance Attribute Details

#asgObject (readonly)

Returns the value of attribute asg.



6
7
8
# File 'lib/asg/rebooter/instance_rebooter.rb', line 6

def asg
  @asg
end

#asg_configObject (readonly)

Returns the value of attribute asg_config.



6
7
8
# File 'lib/asg/rebooter/instance_rebooter.rb', line 6

def asg_config
  @asg_config
end

#target_group_configObject (readonly)

Returns the value of attribute target_group_config.



6
7
8
# File 'lib/asg/rebooter/instance_rebooter.rb', line 6

def target_group_config
  @target_group_config
end

Instance Method Details

#executeObject



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
# File 'lib/asg/rebooter/instance_rebooter.rb', line 12

def execute
  puts "[start] Starting reboot sequence for: #{asg.name}"

  begin
    prepare_configuration

    instances.each do |instance|
      puts "#{'*' * 4} #{instance.instance_id} #{'*' * 4}"
      puts "#{instance.instance_id} [enter_standby]"
      instance.enter_standby

      puts "#{instance.instance_id} [reboot]"
      instance.reboot

      sleep REBOOT_TIMEOUT # TODO: Ensure instance is rebooted: how to do this?

      puts "#{instance.instance_id} [exit_standby]"
      instance.exit_standby

      puts "#{instance.instance_id} [wait_for_healthy]"
      target_group.wait_for_healthy(instance)

      puts "\n"
    end
  ensure
    restore_configuration
  end
end