Class: Virtuoso::API::VM
- Inherits:
-
Object
- Object
- Virtuoso::API::VM
- Defined in:
- lib/virtuoso/api/vm.rb
Overview
Base class specifying the API that all VMs within a hypervisor must conform to.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
The libvirt connection instance.
-
#disk_image ⇒ Object
The disk image to use as the main boot drive.
-
#domain ⇒ Object
readonly
The libvirt domain object.
-
#memory ⇒ Object
The memory for the VM.
-
#name ⇒ Object
The name of the VM.
Instance Method Summary collapse
-
#destroy ⇒ Object
Destroys the VM, deleting any information about it.
-
#initialize(connection, domain = nil) ⇒ VM
constructor
Initializes a VM with the given libvirt connection.
-
#reload ⇒ Object
Reloads information from about a VM which exists.
-
#save ⇒ Object
Saves the VM.
-
#start ⇒ Object
Starts the VM.
-
#state ⇒ Symbol
Returns the current state of the VM.
-
#stop ⇒ Object
Stops the VM.
Constructor Details
#initialize(connection, domain = nil) ⇒ VM
Initializes a VM with the given libvirt connection.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/virtuoso/api/vm.rb', line 22 def initialize(connection, domain=nil) @connection = connection @domain = domain # Set reasonable defaults for fields if we can @name = "My Virtuoso VM" @memory = 524288 # 512 MB # Load in the proper data reload if domain end |
Instance Attribute Details
#connection ⇒ Object (readonly)
The libvirt connection instance.
7 8 9 |
# File 'lib/virtuoso/api/vm.rb', line 7 def connection @connection end |
#disk_image ⇒ Object
The disk image to use as the main boot drive.
19 20 21 |
# File 'lib/virtuoso/api/vm.rb', line 19 def disk_image @disk_image end |
#domain ⇒ Object (readonly)
The libvirt domain object.
10 11 12 |
# File 'lib/virtuoso/api/vm.rb', line 10 def domain @domain end |
#memory ⇒ Object
The memory for the VM.
16 17 18 |
# File 'lib/virtuoso/api/vm.rb', line 16 def memory @memory end |
#name ⇒ Object
The name of the VM.
13 14 15 |
# File 'lib/virtuoso/api/vm.rb', line 13 def name @name end |
Instance Method Details
#destroy ⇒ Object
Destroys the VM, deleting any information about it. This will not destroy any disk images, nor will it stop the VM if it is running.
49 |
# File 'lib/virtuoso/api/vm.rb', line 49 def destroy; end |
#reload ⇒ Object
Reloads information from about a VM which exists. Since Virtuoso can't enforce any sort of VM locking, it is possible a VM changes in the background by some other process while it is being modified. In that case, when you attempt to save, your changes will either overwrite the previous settings, or fail altogether (if someone else destroyed the VM, for example). It is up to the developer to be knowledgeable about his or her environment and account for this accordingly. If you know that a VM changed, or you're just being careful, #reload may be called to reload the data associated with this VM and bring it up to date.
67 |
# File 'lib/virtuoso/api/vm.rb', line 67 def reload; end |
#save ⇒ Object
Saves the VM. If the VM is new, this is expected to create it initially, otherwise this is expected to update the existing VM.
45 |
# File 'lib/virtuoso/api/vm.rb', line 45 def save; end |
#start ⇒ Object
Starts the VM.
52 |
# File 'lib/virtuoso/api/vm.rb', line 52 def start; end |
#state ⇒ Symbol
Returns the current state of the VM. This is expected to always return the current, up-to-date state (therefore it is not cached and updated only on #reload). The state is meant to be returned as a symbol.
40 |
# File 'lib/virtuoso/api/vm.rb', line 40 def state; end |
#stop ⇒ Object
Stops the VM.
55 |
# File 'lib/virtuoso/api/vm.rb', line 55 def stop; end |