Class: VirtualMachine
- Inherits:
-
Object
- Object
- VirtualMachine
- Defined in:
- lib/remote_execution/virtual_machine.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#args ⇒ Object
Returns the value of attribute args.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#log_file ⇒ Object
Returns the value of attribute log_file.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(ip_address, username, *args) ⇒ VirtualMachine
constructor
A new instance of VirtualMachine.
- #invoke(commands) ⇒ Object
- #ssh_test(session, command) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(ip_address, username, *args) ⇒ VirtualMachine
Returns a new instance of VirtualMachine.
13 14 15 16 17 18 19 |
# File 'lib/remote_execution/virtual_machine.rb', line 13 def initialize(ip_address, username, *args) @ip_address = ip_address @username = username args[0].store(:timeout, 5) @args = args @active = false end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
11 12 13 |
# File 'lib/remote_execution/virtual_machine.rb', line 11 def active @active end |
#args ⇒ Object
Returns the value of attribute args.
11 12 13 |
# File 'lib/remote_execution/virtual_machine.rb', line 11 def args @args end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
11 12 13 |
# File 'lib/remote_execution/virtual_machine.rb', line 11 def ip_address @ip_address end |
#log_file ⇒ Object
Returns the value of attribute log_file.
11 12 13 |
# File 'lib/remote_execution/virtual_machine.rb', line 11 def log_file @log_file end |
#username ⇒ Object
Returns the value of attribute username.
11 12 13 |
# File 'lib/remote_execution/virtual_machine.rb', line 11 def username @username end |
Instance Method Details
#invoke(commands) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/remote_execution/virtual_machine.rb', line 33 def invoke(commands) Net::SSH.start(ip_address, username, *args) do |ssh| commands.each do |command| print command , "\n" s_ssh ssh, command end end end |
#ssh_test(session, command) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/remote_execution/virtual_machine.rb', line 25 def ssh_test(session,command) res = session.exec!(command) puts res if res!='' and res!="attributes.json\n" @active = true end end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/remote_execution/virtual_machine.rb', line 21 def to_s "[IP: #{ip_address}, user: #{username}]" end |