Class: Central::Cli::Nodes::Aws::RestartCommand

Inherits:
Clamp::Command
  • Object
show all
Includes:
Common, StackOptions
Defined in:
lib/central/cli/nodes/aws/restart_command.rb

Instance Method Summary collapse

Methods included from StackOptions

included

Methods included from Common

#access_token=, #add_master, #api_url, #api_url=, #clear_current_stack, #client, #current_master, #current_master=, #current_master_index, #current_stack, #current_stack=, #ensure_custom_ssl_ca, #require_api_url, #require_current_stack, #require_token, #reset_client, #save_settings, #settings, #settings_filename

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/central/cli/nodes/aws/restart_command.rb', line 11

def execute
  require_api_url
  require_current_stack

  require 'central/machine/aws'

  client = Fog::Compute.new(provider: 'AWS', aws_access_key_id: access_key, aws_secret_access_key: secret_key, region: region)
  instance = client.servers.all('tag:central_name' => name).first
  if instance
    instance.reboot
    ShellSpinner "Restarting AWS instance #{name.colorize(:cyan)} " do
      instance.wait_for { ready? }
    end
  else
    abort "Cannot find instance #{name.colorize(:cyan)} in AWS"
  end
end