Class: VirtConsole
- Inherits:
-
Object
- Object
- VirtConsole
- Defined in:
- lib/version.rb,
lib/virt_console.rb
Constant Summary collapse
- VERSION =
"1.0.4"
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(hash) ⇒ VirtConsole
constructor
A new instance of VirtConsole.
Constructor Details
#initialize(hash) ⇒ VirtConsole
Returns a new instance of VirtConsole.
4 5 6 7 |
# File 'lib/virt_console.rb', line 4 def initialize(hash) @path = hash[:path] @command = hash[:command] end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
3 4 5 |
# File 'lib/virt_console.rb', line 3 def command @command end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/virt_console.rb', line 3 def port @port end |
Instance Method Details
#execute ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/virt_console.rb', line 8 def execute sp = SerialPort.open("#{@path}", baud = 9600, data_bits = 8, stop_bits = 1) { |tty| tty.sync = true line = "" Thread.new { tty.write @command + "\015" } until line =~ /^(Execution Completed|Ready|Disk Shrink Completed|Disk Extend Completed)\.$/ do line = (tty.readline.chomp!) print "#{line}\n" end print "\n" } end |