Class: CCSH::Host
- Inherits:
-
Object
- Object
- CCSH::Host
- Defined in:
- lib/ccsh/host.rb
Instance Attribute Summary collapse
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#name ⇒ Object
Returns the value of attribute name.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#private_key ⇒ Object
Returns the value of attribute private_key.
-
#ssh_options ⇒ Object
Returns the value of attribute ssh_options.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #contain?(target) ⇒ Boolean
-
#initialize ⇒ Host
constructor
A new instance of Host.
- #run(command) ⇒ Object
Constructor Details
#initialize ⇒ Host
Returns a new instance of Host.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ccsh/host.rb', line 13 def initialize @name = '' @port = 22 @user = 'root' @groups = '' @hostname = '127.0.0.1' @password = nil @private_key = nil = [] end |
Instance Attribute Details
#groups ⇒ Object
Returns the value of attribute groups.
6 7 8 |
# File 'lib/ccsh/host.rb', line 6 def groups @groups end |
#hostname ⇒ Object
Returns the value of attribute hostname.
7 8 9 |
# File 'lib/ccsh/host.rb', line 7 def hostname @hostname end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/ccsh/host.rb', line 3 def name @name end |
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/ccsh/host.rb', line 8 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
4 5 6 |
# File 'lib/ccsh/host.rb', line 4 def port @port end |
#private_key ⇒ Object
Returns the value of attribute private_key.
9 10 11 |
# File 'lib/ccsh/host.rb', line 9 def private_key @private_key end |
#ssh_options ⇒ Object
Returns the value of attribute ssh_options.
10 11 12 |
# File 'lib/ccsh/host.rb', line 10 def end |
#timeout ⇒ Object
Returns the value of attribute timeout.
11 12 13 |
# File 'lib/ccsh/host.rb', line 11 def timeout @timeout end |
#user ⇒ Object
Returns the value of attribute user.
5 6 7 |
# File 'lib/ccsh/host.rb', line 5 def user @user end |
Instance Method Details
#contain?(target) ⇒ Boolean
41 42 43 |
# File 'lib/ccsh/host.rb', line 41 def contain?(target) return @groups.include? target end |
#run(command) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ccsh/host.rb', line 24 def run(command) CCSH::Utils.verbose("Running command '#{@command}' on #{@hostname}") command = CCSH::SSH.start do |ssh| ssh.user = @user ssh.port = @port ssh. = ssh.password = @password ssh.private_key = @private_key ssh. = ssh.command = command ssh.hostname = @hostname || @name end return command end |