Sha256: 54cb7025f2c17d12cd656a9a41281410bac0de58a0a743ffa3669976f01c44f9

Contents?: true

Size: 947 Bytes

Versions: 16

Compression:

Stored size: 947 Bytes

Contents

module Kontena::Cli::Nodes::Aws
  class RestartCommand < Clamp::Command
    include Kontena::Cli::Common

    parameter "NAME", "Node name"
    option "--access-key", "ACCESS_KEY", "AWS access key ID", required: true
    option "--secret-key", "SECRET_KEY", "AWS secret key", required: true
    option "--region", "REGION", "EC2 Region", required: true

    def execute
      require_api_url
      require_current_grid

      require 'kontena/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:kontena_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
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
kontena-cli-0.11.7 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.11.6 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.11.5 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.11.4 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.11.3 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.11.2 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.11.1 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.11.0 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.10.3 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.10.2 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.10.1 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.10.0 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.9.3 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.9.2 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.9.1 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.9.0 lib/kontena/cli/nodes/aws/restart_command.rb