Class: FSSH::CLI
- Inherits:
-
Object
- Object
- FSSH::CLI
- Defined in:
- lib/fssh/cli.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
-
#gateway ⇒ Object
readonly
Returns the value of attribute gateway.
-
#instances ⇒ Object
readonly
Returns the value of attribute instances.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#server_name ⇒ Object
readonly
Returns the value of attribute server_name.
Instance Method Summary collapse
- #find_gateway ⇒ Object
- #find_instances ⇒ Object
- #find_server ⇒ Object
- #hops ⇒ Object
-
#initialize(server_name) ⇒ CLI
constructor
A new instance of CLI.
- #private_key_exists? ⇒ Boolean
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
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/fssh/cli.rb', line 8 def config @config end |
#config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
8 9 10 |
# File 'lib/fssh/cli.rb', line 8 def config_file @config_file end |
#gateway ⇒ Object (readonly)
Returns the value of attribute gateway.
9 10 11 |
# File 'lib/fssh/cli.rb', line 9 def gateway @gateway end |
#instances ⇒ Object (readonly)
Returns the value of attribute instances.
9 10 11 |
# File 'lib/fssh/cli.rb', line 9 def instances @instances end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
9 10 11 |
# File 'lib/fssh/cli.rb', line 9 def server @server end |
#server_name ⇒ Object (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_gateway ⇒ Object
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_instances ⇒ Object
16 17 18 19 |
# File 'lib/fssh/cli.rb', line 16 def find_instances @instances = FSSH::ServerManager.instances !!@instances end |
#find_server ⇒ Object
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.("Name" => @server_name).first !!@server.base else true end end |
#hops ⇒ Object
47 48 49 |
# File 'lib/fssh/cli.rb', line 47 def hops @hops ||= [@gateway, @server].compact end |
#private_key_exists? ⇒ Boolean
43 44 45 |
# File 'lib/fssh/cli.rb', line 43 def private_key_exists? File.exist?(File.(@config.local_private_key_file)) end |