Sha256: 6076981a5e93e2c5da5cee42a450583a9956e1a70f8f141ba5c28f28951237a0

Contents?: true

Size: 985 Bytes

Versions: 18

Compression:

Stored size: 985 Bytes

Contents

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

    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

18 entries across 18 versions & 1 rubygems

Version Path
kontena-cli-0.14.7 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.14.6 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.14.5 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.14.4 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.14.3 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.14.2 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.14.1 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.14.0 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.13.4 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.13.3 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.13.2 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.13.1 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.13.0.1 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.13.0 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.12.3 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.12.2 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.12.1 lib/kontena/cli/nodes/aws/restart_command.rb
kontena-cli-0.12.0 lib/kontena/cli/nodes/aws/restart_command.rb