Class: Ctrl::Commands::Ssh

Inherits:
Base
  • Object
show all
Defined in:
lib/ctrl/commands/ssh.rb

Instance Method Summary collapse

Methods inherited from Base

#client, perform

Instance Method Details

#instancesObject



7
8
9
10
11
# File 'lib/ctrl/commands/ssh.rb', line 7

def instances
  @instances ||= ListInstances.new(
    attributes.merge(instance_state: 'running')
  ).instances
end

#nat_instanceObject



17
18
19
20
21
# File 'lib/ctrl/commands/ssh.rb', line 17

def nat_instance
  @nat_instance ||= ListInstances.new(
    attributes.merge(instance_state: 'running', instance_name: 'nat')
  ).instances.first
end

#performObject



23
24
25
26
27
28
29
30
# File 'lib/ctrl/commands/ssh.rb', line 23

def perform
  cmd = Ctrl::SshCommand.new(
    nat_instance: nat_instance,
    target_instance: selected_instance
  )

  exec cmd.to_s
end

#selected_instanceObject



13
14
15
# File 'lib/ctrl/commands/ssh.rb', line 13

def selected_instance
  @selected_instance ||= Ctrl::InstanceSelector.new(instances: instances).perform
end