Class: Arver::SSHCommandWrapper
- Inherits:
-
CommandWrapper
- Object
- CommandWrapper
- Arver::SSHCommandWrapper
- Defined in:
- lib/arver/ssh_command_wrapper.rb
Instance Attribute Summary collapse
-
#as_root ⇒ Object
Returns the value of attribute as_root.
-
#host ⇒ Object
Returns the value of attribute host.
-
#on_boot ⇒ Object
Returns the value of attribute on_boot.
-
#port ⇒ Object
Returns the value of attribute port.
-
#user ⇒ Object
Returns the value of attribute user.
Attributes inherited from CommandWrapper
#arguments_array, #command, #output, #return_value
Class Method Summary collapse
- .create(cmd, args, host, as_root = false, on_boot = false) ⇒ Object
- .is_system_running?(partition) ⇒ Boolean
Instance Method Summary collapse
Methods inherited from CommandWrapper
#execute, #run, shellescape, #shellescape, #success?
Instance Attribute Details
#as_root ⇒ Object
Returns the value of attribute as_root.
3 4 5 |
# File 'lib/arver/ssh_command_wrapper.rb', line 3 def as_root @as_root end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/arver/ssh_command_wrapper.rb', line 3 def host @host end |
#on_boot ⇒ Object
Returns the value of attribute on_boot.
3 4 5 |
# File 'lib/arver/ssh_command_wrapper.rb', line 3 def on_boot @on_boot end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/arver/ssh_command_wrapper.rb', line 3 def port @port end |
#user ⇒ Object
Returns the value of attribute user.
3 4 5 |
# File 'lib/arver/ssh_command_wrapper.rb', line 3 def user @user end |
Class Method Details
.create(cmd, args, host, as_root = false, on_boot = false) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/arver/ssh_command_wrapper.rb', line 5 def self.create( cmd, args, host, as_root = false, on_boot = false) c = SSHCommandWrapper.new c.host= host c.as_root= as_root c.command= cmd c.arguments_array= args c.on_boot = on_boot c end |
.is_system_running?(partition) ⇒ Boolean
23 24 25 26 27 |
# File 'lib/arver/ssh_command_wrapper.rb', line 23 def self.is_system_running?(partition) wr = Arver::SSHCommandWrapper.create("systemctl", ["is-system-running"], partition.parent, true, true) wr.execute wr.success? && !['initializing','starting'].include?(wr.output.chomp) end |
Instance Method Details
#escaped_command ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/arver/ssh_command_wrapper.rb', line 15 def escaped_command addr = (on_boot ? host.boot_address : nil) || host.address user = on_boot ? 'root' : host.username port = on_boot ? '22' : host.port sudo = if as_root && on_boot && host.username != "root" then "sudo" else "" end "ssh -p #{shellescape(port)} #{shellescape(user)}@#{shellescape(addr)} #{sudo} #{super}" end |