Class: QEMU::Monitor
- Inherits:
-
Object
- Object
- QEMU::Monitor
- Defined in:
- lib/qemu/monitor.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #command(command) ⇒ Object
-
#initialize(attributes = {}) ⇒ Monitor
constructor
A new instance of Monitor.
- #loadvm(name = "default") ⇒ Object
- #reset ⇒ Object
- #savevm(name = "default") ⇒ Object
- #telnet ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Monitor
Returns a new instance of Monitor.
8 9 10 11 |
# File 'lib/qemu/monitor.rb', line 8 def initialize(attributes = {}) attributes = { :host => "localhost", :timeout => 30 }.merge(attributes) attributes.each { |k,v| send "#{k}=", v } end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
6 7 8 |
# File 'lib/qemu/monitor.rb', line 6 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/qemu/monitor.rb', line 6 def port @port end |
#timeout ⇒ Object
Returns the value of attribute timeout.
6 7 8 |
# File 'lib/qemu/monitor.rb', line 6 def timeout @timeout end |
Instance Method Details
#command(command) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/qemu/monitor.rb', line 17 def command(command) telnet.tap do |telnet| telnet.cmd command telnet.close end end |
#loadvm(name = "default") ⇒ Object
32 33 34 |
# File 'lib/qemu/monitor.rb', line 32 def loadvm(name = "default") command "loadvm #{name}" end |
#reset ⇒ Object
24 25 26 |
# File 'lib/qemu/monitor.rb', line 24 def reset command "system_reset" end |
#savevm(name = "default") ⇒ Object
28 29 30 |
# File 'lib/qemu/monitor.rb', line 28 def savevm(name = "default") command "savevm #{name}" end |
#telnet ⇒ Object
13 14 15 |
# File 'lib/qemu/monitor.rb', line 13 def telnet Net::Telnet::new "Host" => host, "Port" => port, "Timeout" => timeout, "Prompt" => /\(qemu\) / end |