Class: VirtualBox::HWVirtualization

Inherits:
AbstractModel show all
Defined in:
lib/virtualbox/hw_virtualization.rb

Overview

Represents the HW virtualization properties on a VM.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractModel

#destroy, #errors, errors_for_relationship, #existing_record!, #inspect, #lazy_attribute?, #lazy_relationship?, #new_record!, #new_record?, #parent_machine, #populate_attributes, #populate_relationship, #populate_relationships, reload!, #reload!, reload?, reloaded!, #save!, #save_attribute, #save_changed_interface_attributes, #save_interface_attribute, #set_relationship, #write_attribute

Methods included from AbstractModel::Validatable

#__validates_extract_options, #add_error, #clear_errors, #errors, #errors_on, #full_error_messages, #valid?, #validates_format_of, #validates_inclusion_of, #validates_numericality_of, #validates_presence_of

Methods included from AbstractModel::Relatable

#destroy_relationship, #destroy_relationships, #has_relationship?, included, #lazy_relationship?, #loaded_relationship?, #populate_relationship, #populate_relationships, #read_relationship, #relationship_class, #relationship_data, #save_relationship, #save_relationships, #set_relationship

Methods included from AbstractModel::VersionMatcher

#assert_version_match, #split_version, #version_match?

Methods included from AbstractModel::Dirty

#changed?, #changes, #clear_dirty!, #ignore_dirty, #method_missing, #set_dirty!

Methods included from AbstractModel::InterfaceAttributes

#load_interface_attribute, #load_interface_attributes, #save_interface_attribute, #save_interface_attributes, #spec_to_proc

Methods included from AbstractModel::Attributable

#attributes, #has_attribute?, included, #lazy_attribute?, #loaded_attribute?, #populate_attributes, #read_attribute, #readonly_attribute?, #write_attribute

Methods included from Logger

included, #logger, #logger_output=

Constructor Details

#initialize(parent, imachine) ⇒ HWVirtualization

Returns a new instance of HWVirtualization.



32
33
34
35
36
37
38
39
# File 'lib/virtualbox/hw_virtualization.rb', line 32

def initialize(parent, imachine)
  write_attribute(:parent, parent)

  # Load the attributes and mark the whole thing as existing
  load_interface_attributes(imachine)
  clear_dirty!
  existing_record!
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class VirtualBox::AbstractModel::Dirty

Class Method Details

.populate_relationship(caller, imachine) ⇒ HWVirtualization

Populates a relationship with another model.

**This method typically won’t be used except internally.**

Returns:



20
21
22
# File 'lib/virtualbox/hw_virtualization.rb', line 20

def populate_relationship(caller, imachine)
  data = new(caller, imachine)
end

.save_relationship(caller, instance) ⇒ Object

Saves the relationship.

**This method typically won’t be used except internally.**



27
28
29
# File 'lib/virtualbox/hw_virtualization.rb', line 27

def save_relationship(caller, instance)
  instance.save
end

Instance Method Details

#get_property(interface, key) ⇒ Object



41
42
43
# File 'lib/virtualbox/hw_virtualization.rb', line 41

def get_property(interface, key)
  interface.get_hw_virt_ex_property(key)
end

#saveObject



55
56
57
58
59
60
61
62
# File 'lib/virtualbox/hw_virtualization.rb', line 55

def save
  parent.with_open_session do |session|
    machine = session.machine

    # Save them
    save_changed_interface_attributes(machine)
  end
end

#set_property(interface, key, value) ⇒ Object



45
46
47
# File 'lib/virtualbox/hw_virtualization.rb', line 45

def set_property(interface, key, value)
  interface.set_hw_virt_ex_property(key, value)
end

#validateObject



49
50
51
52
53
# File 'lib/virtualbox/hw_virtualization.rb', line 49

def validate
  super

  validates_inclusion_of :enabled, :exclusive, :vpid, :nested_paging, :in => [true, false]
end