Class: Moxprox::Machine
- Inherits:
-
Struct
- Object
- Struct
- Moxprox::Machine
- Defined in:
- lib/moxprox/machine.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#node ⇒ Object
Returns the value of attribute node.
Instance Method Summary collapse
- #config ⇒ Object
- #request(path, method = "get", query = {}) ⇒ Object
- #shutdown(&block) ⇒ Object
- #start(&block) ⇒ Object
- #status ⇒ Object
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id
2 3 4 |
# File 'lib/moxprox/machine.rb', line 2 def id @id end |
#node ⇒ Object
Returns the value of attribute node
2 3 4 |
# File 'lib/moxprox/machine.rb', line 2 def node @node end |
Instance Method Details
#config ⇒ Object
19 20 21 |
# File 'lib/moxprox/machine.rb', line 19 def config request("config") end |
#request(path, method = "get", query = {}) ⇒ Object
29 30 31 |
# File 'lib/moxprox/machine.rb', line 29 def request(path, method = "get", query = {}) node.request("qemu/#{id}/#{path}", method, query) end |
#shutdown(&block) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/moxprox/machine.rb', line 11 def shutdown(&block) logger.info "shutting down machine #{id} on #{node.name}" upid = request("status/shutdown", "post") if block_given? node.wait_for_task(upid, &block) end end |
#start(&block) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/moxprox/machine.rb', line 3 def start(&block) logger.info "starting machine #{id} on #{node.name}" upid = request("status/start", "post") if block_given? node.wait_for_task(upid, &block) end end |
#status ⇒ Object
23 24 25 26 27 |
# File 'lib/moxprox/machine.rb', line 23 def status res = request("status/current") logger.debug "status of machine #{id} on #{node.name}: #{res["status"]}" res["status"].to_sym end |