Class: Virtuoso::API::VM

Inherits:
Object
  • Object
show all
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

VirtualBox::VM

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#connectionObject (readonly)

The libvirt connection instance.



7
8
9
# File 'lib/virtuoso/api/vm.rb', line 7

def connection
  @connection
end

#disk_imageObject

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

#domainObject (readonly)

The libvirt domain object.



10
11
12
# File 'lib/virtuoso/api/vm.rb', line 10

def domain
  @domain
end

#memoryObject

The memory for the VM.



16
17
18
# File 'lib/virtuoso/api/vm.rb', line 16

def memory
  @memory
end

#nameObject

The name of the VM.



13
14
15
# File 'lib/virtuoso/api/vm.rb', line 13

def name
  @name
end

Instance Method Details

#destroyObject

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

#reloadObject

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

#saveObject

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

#startObject

Starts the VM.



52
# File 'lib/virtuoso/api/vm.rb', line 52

def start; end

#stateSymbol

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.

Returns:

  • (Symbol)


40
# File 'lib/virtuoso/api/vm.rb', line 40

def state; end

#stopObject

Stops the VM.



55
# File 'lib/virtuoso/api/vm.rb', line 55

def stop; end