Class: Groundskeeper::Ssh
- Inherits:
-
Object
- Object
- Groundskeeper::Ssh
- Defined in:
- lib/groundskeeper/ssh.rb
Overview
Wraps ssh executable.
Constant Summary collapse
- COMMAND =
"ssh"
- DEFAULT_CONNECT_TIMEOUT_IN_S =
5
- CONNECT_WITH_TIMEOUT =
ssh arguments
"-o ConnectTimeout=#{DEFAULT_CONNECT_TIMEOUT_IN_S}".freeze
- REMOTE_ECHO =
"%<options>s %<username>s@%<domain_name>s \"echo 'groundskeeper'\""
Instance Attribute Summary collapse
-
#domain_name ⇒ Object
readonly
Returns the value of attribute domain_name.
-
#ssh ⇒ Object
readonly
Returns the value of attribute ssh.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #can_connect? ⇒ Boolean
-
#initialize(ssh, username, domain_name) ⇒ Ssh
constructor
A new instance of Ssh.
Constructor Details
#initialize(ssh, username, domain_name) ⇒ Ssh
Returns a new instance of Ssh.
19 20 21 22 23 |
# File 'lib/groundskeeper/ssh.rb', line 19 def initialize(ssh, username, domain_name) @ssh = ssh @username = username @domain_name = domain_name end |
Instance Attribute Details
#domain_name ⇒ Object (readonly)
Returns the value of attribute domain_name.
13 14 15 |
# File 'lib/groundskeeper/ssh.rb', line 13 def domain_name @domain_name end |
#ssh ⇒ Object (readonly)
Returns the value of attribute ssh.
13 14 15 |
# File 'lib/groundskeeper/ssh.rb', line 13 def ssh @ssh end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
13 14 15 |
# File 'lib/groundskeeper/ssh.rb', line 13 def username @username end |
Class Method Details
.build(username, domain_name) ⇒ Object
15 16 17 |
# File 'lib/groundskeeper/ssh.rb', line 15 def self.build(username, domain_name) new Executable.new(COMMAND), username, domain_name end |
Instance Method Details
#can_connect? ⇒ Boolean
25 26 27 28 29 30 |
# File 'lib/groundskeeper/ssh.rb', line 25 def can_connect? ssh.execute(format(REMOTE_ECHO, options: CONNECT_WITH_TIMEOUT, username: username, domain_name: domain_name)).strip == "groundskeeper" end |