Sha256: 6412d078ab857cc475844d7bcd2731c6709d059b83f8a6fa8faf4eece6a733a0

Contents?: true

Size: 826 Bytes

Versions: 22

Compression:

Stored size: 826 Bytes

Contents

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

    parameter "NAME", "Node name"
    option "--token", "TOKEN", "DigitalOcean API token", required: true

    def execute
      require_api_url
      require_current_grid

      require 'kontena/machine/digital_ocean'

      client = DropletKit::Client.new(access_token: token)
      droplet = client.droplets.all.find{|d| d.name == name}
      if droplet
        ShellSpinner "Restarting DigitalOcean droplet #{name.colorize(:cyan)} " do
          client.droplet_actions.reboot(droplet_id: droplet.id)
          sleep 5 until client.droplets.find(id: droplet.id).status == 'active'
        end
      else
        abort "Cannot find droplet #{name.colorize(:cyan)} in DigitalOcean"
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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