Class: VBOX::VM

Inherits:
Object
  • Object
show all
Defined in:
lib/vbox/vm.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVM

Returns a new instance of VM.



5
6
7
# File 'lib/vbox/vm.rb', line 5

def initialize
  @all_vars = {}
end

Instance Attribute Details

#all_varsObject

Returns the value of attribute all_vars.



3
4
5
# File 'lib/vbox/vm.rb', line 3

def all_vars
  @all_vars
end

#dir_sizeObject

Returns the value of attribute dir_size.



3
4
5
# File 'lib/vbox/vm.rb', line 3

def dir_size
  @dir_size
end

#memory_sizeObject

Returns the value of attribute memory_size.



3
4
5
# File 'lib/vbox/vm.rb', line 3

def memory_size
  @memory_size
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/vbox/vm.rb', line 3

def name
  @name
end

#stateObject

Returns the value of attribute state.



3
4
5
# File 'lib/vbox/vm.rb', line 3

def state
  @state
end

#uuidObject

Returns the value of attribute uuid.



3
4
5
# File 'lib/vbox/vm.rb', line 3

def uuid
  @uuid
end

Class Method Details

.allObject



46
47
48
# File 'lib/vbox/vm.rb', line 46

def all
  VBOX.api.list_vms
end

.find(name_or_uuid) ⇒ Object Also known as: []



54
55
56
# File 'lib/vbox/vm.rb', line 54

def find name_or_uuid
  VBOX.api.get_vm_details name_or_uuid
end

.firstObject



50
51
52
# File 'lib/vbox/vm.rb', line 50

def first
  all.first
end

Instance Method Details

#clone!(params) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vbox/vm.rb', line 15

def clone! params
  raise "argument must be a Hash" unless params.is_a?(Hash)
  raise "no :snapshot key" unless params[:snapshot]
  r = VBOX.api.clone self.name, params
  case r
  when Array
    if r.first.is_a?(VM)
      r
    else
      r.map{ |name| VM.find(name) }
    end
  when String
    VM.find(r)
  when nil
    nil
  else
    r
  end
end