Sha256: a8dec77ab565d34a7f33f142c1cc702f0d3a139a9416502a2ebf99cae31119ee

Contents?: true

Size: 986 Bytes

Versions: 32

Compression:

Stored size: 986 Bytes

Contents

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

    parameter "NODE_ID", "Node id"
    option ["-i", "--identity-file"], "IDENTITY_FILE", "Path to ssh private key"
    option ["-u", "--user"], "USER", "Login as a user", default: "core"
    option "--private-ip", :flag, "Connect to node's private IP address"
    option "--internal-ip", :flag, "Connect to node's internal IP address (requires VPN connection)"

    def execute
      require_api_url
      require_current_grid
      token = require_token

      node = client(token).get("grids/#{current_grid}/nodes/#{node_id}")
      cmd = ['ssh']
      cmd << "-i #{identity_file}" if identity_file
      if internal_ip?
        ip = "10.81.0.#{node['node_number']}"
      elsif private_ip?
        ip = node['private_ip']
      else
        ip = node['public_ip']
      end
      cmd << "#{user}@#{ip}"
      exec(cmd.join(" "))
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
kontena-cli-0.15.5 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.15.5.rc2 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.15.5.rc1 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.15.4 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.15.4.rc2 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.15.4.rc1 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.15.4.pre1 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.15.3 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.15.2 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.15.1 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.15.0 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.15.0.rc3 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.15.0.rc2 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.15.0.rc1 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.14.7 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.14.6 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.14.5 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.14.4 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.14.3 lib/kontena/cli/nodes/ssh_command.rb
kontena-cli-0.14.2 lib/kontena/cli/nodes/ssh_command.rb