Class: FSSH::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/fssh/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_name) ⇒ CLI

Returns a new instance of CLI.



11
12
13
14
# File 'lib/fssh/cli.rb', line 11

def initialize(server_name)
  @server_name = server_name
  load_config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/fssh/cli.rb', line 8

def config
  @config
end

#config_fileObject (readonly)

Returns the value of attribute config_file.



8
9
10
# File 'lib/fssh/cli.rb', line 8

def config_file
  @config_file
end

#gatewayObject (readonly)

Returns the value of attribute gateway.



9
10
11
# File 'lib/fssh/cli.rb', line 9

def gateway
  @gateway
end

#instancesObject (readonly)

Returns the value of attribute instances.



9
10
11
# File 'lib/fssh/cli.rb', line 9

def instances
  @instances
end

#serverObject (readonly)

Returns the value of attribute server.



9
10
11
# File 'lib/fssh/cli.rb', line 9

def server
  @server
end

#server_nameObject (readonly)

Returns the value of attribute server_name.



8
9
10
# File 'lib/fssh/cli.rb', line 8

def server_name
  @server_name
end

Instance Method Details

#find_gatewayObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fssh/cli.rb', line 21

def find_gateway
  running = @instances.filter_running
  @gateway_config = @config.resolve_gateway(server_name)

  if @gateway_config
    @gateway = running.filter_group(@gateway_config[:name]).first
    true
  else
    false
  end
end

#find_instancesObject



16
17
18
19
# File 'lib/fssh/cli.rb', line 16

def find_instances
  @instances = FSSH::ServerManager.instances
  !!@instances
end

#find_serverObject



33
34
35
36
37
38
39
40
41
# File 'lib/fssh/cli.rb', line 33

def find_server
  if !@gateway_config || @gateway_config[:name] != @server_name
    running = @instances.filter_running
    @server = running.filter_tags("Name" => @server_name).first
    !!@server.base
  else
    true
  end
end

#hopsObject



47
48
49
# File 'lib/fssh/cli.rb', line 47

def hops
  @hops ||= [@gateway, @server].compact
end

#private_key_exists?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/fssh/cli.rb', line 43

def private_key_exists?
  File.exist?(File.expand_path(@config.local_private_key_file))
end