virtualbox 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +0 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/virtualbox/abstract_model/attributable.rb +1 -0
- data/lib/virtualbox/abstract_model/validatable.rb +133 -10
- data/lib/virtualbox/abstract_model.rb +3 -3
- data/lib/virtualbox/appliance.rb +5 -2
- data/lib/virtualbox/audio_adapter.rb +11 -3
- data/lib/virtualbox/bios.rb +10 -4
- data/lib/virtualbox/com/abstract_enum.rb +6 -5
- data/lib/virtualbox/com/abstract_implementer.rb +4 -2
- data/lib/virtualbox/com/abstract_interface.rb +6 -4
- data/lib/virtualbox/com/base_interface.rb +38 -0
- data/lib/virtualbox/com/ffi/interface.rb +14 -5
- data/lib/virtualbox/com/ffi/interfaces.rb +36 -32
- data/lib/virtualbox/com/ffi/util.rb +22 -4
- data/lib/virtualbox/com/ffi_interface.rb +39 -8
- data/lib/virtualbox/com/implementer/base.rb +2 -2
- data/lib/virtualbox/com/implementer/ffi.rb +55 -44
- data/lib/virtualbox/com/implementer/mscom.rb +2 -4
- data/lib/virtualbox/com/interface/3.1.x/appliance.rb +22 -0
- data/lib/virtualbox/com/interface/3.1.x/audio_adapter.rb +15 -0
- data/lib/virtualbox/com/interface/3.1.x/audio_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/audio_driver_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/bios_boot_menu_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/bios_settings.rb +21 -0
- data/lib/virtualbox/com/interface/3.1.x/clipboard_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/console.rb +50 -0
- data/lib/virtualbox/com/interface/3.1.x/cpu_property_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/device_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/dhcp_server.rb +22 -0
- data/lib/virtualbox/com/interface/3.1.x/firmware_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/guest_os_type.rb +23 -0
- data/lib/virtualbox/com/interface/3.1.x/host.rb +42 -0
- data/lib/virtualbox/com/interface/3.1.x/host_network_interface.rb +30 -0
- data/lib/virtualbox/com/interface/3.1.x/host_network_interface_medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/host_network_interface_status.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/host_network_interface_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/host_usb_device.rb +13 -0
- data/lib/virtualbox/com/interface/3.1.x/host_usb_device_filter.rb +13 -0
- data/lib/virtualbox/com/interface/3.1.x/hw_virt_ex_property_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/machine.rb +105 -0
- data/lib/virtualbox/com/interface/3.1.x/machine_state.rb +14 -0
- data/lib/virtualbox/com/interface/3.1.x/medium.rb +50 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_attachment.rb +18 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_format.rb +18 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_variant.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/network_adapter.rb +30 -0
- data/lib/virtualbox/com/interface/3.1.x/network_adapter_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/network_attachment_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/nsiexception.rb +23 -0
- data/lib/virtualbox/com/interface/3.1.x/nsisupports.rb +15 -0
- data/lib/virtualbox/com/interface/3.1.x/parallel_port.rb +17 -0
- data/lib/virtualbox/com/interface/3.1.x/port_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/progress.rb +63 -0
- data/lib/virtualbox/com/interface/3.1.x/serial_port.rb +19 -0
- data/lib/virtualbox/com/interface/3.1.x/session.rb +18 -0
- data/lib/virtualbox/com/interface/3.1.x/session_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/session_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/shared_folder.rb +17 -0
- data/lib/virtualbox/com/interface/3.1.x/snapshot.rb +20 -0
- data/lib/virtualbox/com/interface/3.1.x/storage_bus.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/storage_controller.rb +23 -0
- data/lib/virtualbox/com/interface/3.1.x/storage_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/system_properties.rb +37 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_controller.rb +20 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_device.rb +24 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_device_filter.rb +23 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_device_filter_action.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_device_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/virtual_box_error_info.rb +17 -0
- data/lib/virtualbox/com/interface/3.1.x/virtual_system_description.rb +19 -0
- data/lib/virtualbox/com/interface/3.1.x/virtual_system_description_type.rb +14 -0
- data/lib/virtualbox/com/interface/3.1.x/virtual_system_description_value_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/virtualbox.rb +67 -0
- data/lib/virtualbox/com/interface/3.1.x/vrdp_auth_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/vrdp_server.rb +19 -0
- data/lib/virtualbox/com/interface/3.2.x/appliance.rb +22 -0
- data/lib/virtualbox/com/interface/3.2.x/audio_adapter.rb +15 -0
- data/lib/virtualbox/com/interface/3.2.x/audio_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/audio_driver_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/bios_boot_menu_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/bios_settings.rb +21 -0
- data/lib/virtualbox/com/interface/3.2.x/clipboard_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/console.rb +50 -0
- data/lib/virtualbox/com/interface/3.2.x/cpu_property_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/device_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/dhcp_server.rb +22 -0
- data/lib/virtualbox/com/interface/3.2.x/firmware_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/guest.rb +13 -0
- data/lib/virtualbox/com/interface/3.2.x/guest_os_type.rb +33 -0
- data/lib/virtualbox/com/interface/3.2.x/host.rb +43 -0
- data/lib/virtualbox/com/interface/3.2.x/host_network_interface.rb +30 -0
- data/lib/virtualbox/com/interface/3.2.x/host_network_interface_medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/host_network_interface_status.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/host_network_interface_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/host_usb_device.rb +13 -0
- data/lib/virtualbox/com/interface/3.2.x/host_usb_device_filter.rb +13 -0
- data/lib/virtualbox/com/interface/3.2.x/hw_virt_ex_property_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/keyboard_hid_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/machine.rb +118 -0
- data/lib/virtualbox/com/interface/3.2.x/machine_state.rb +14 -0
- data/lib/virtualbox/com/interface/3.2.x/medium.rb +51 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_attachment.rb +18 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_format.rb +18 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_variant.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/nat_alias_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/nat_engine.rb +27 -0
- data/lib/virtualbox/com/interface/3.2.x/nat_protocol.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/network_adapter.rb +34 -0
- data/lib/virtualbox/com/interface/3.2.x/network_adapter_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/network_attachment_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/nsiexception.rb +23 -0
- data/lib/virtualbox/com/interface/3.2.x/nsisupports.rb +15 -0
- data/lib/virtualbox/com/interface/3.2.x/parallel_port.rb +17 -0
- data/lib/virtualbox/com/interface/3.2.x/pointing_hid_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/port_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/progress.rb +63 -0
- data/lib/virtualbox/com/interface/3.2.x/serial_port.rb +19 -0
- data/lib/virtualbox/com/interface/3.2.x/session.rb +18 -0
- data/lib/virtualbox/com/interface/3.2.x/session_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/session_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/shared_folder.rb +17 -0
- data/lib/virtualbox/com/interface/3.2.x/snapshot.rb +20 -0
- data/lib/virtualbox/com/interface/3.2.x/storage_bus.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/storage_controller.rb +24 -0
- data/lib/virtualbox/com/interface/3.2.x/storage_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/system_properties.rb +42 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_controller.rb +21 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_device.rb +24 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_device_filter.rb +23 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_device_filter_action.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_device_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/virtual_box_error_info.rb +17 -0
- data/lib/virtualbox/com/interface/3.2.x/virtual_system_description.rb +19 -0
- data/lib/virtualbox/com/interface/3.2.x/virtual_system_description_type.rb +14 -0
- data/lib/virtualbox/com/interface/3.2.x/virtual_system_description_value_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/virtualbox.rb +67 -0
- data/lib/virtualbox/com/interface/3.2.x/vrdp_auth_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/vrdp_server.rb +21 -0
- data/lib/virtualbox/com/mscom_interface.rb +9 -4
- data/lib/virtualbox/com/nil_interface.rb +7 -0
- data/lib/virtualbox/com/util.rb +16 -2
- data/lib/virtualbox/com.rb +1 -1
- data/lib/virtualbox/cpu.rb +61 -0
- data/lib/virtualbox/dhcp_server.rb +89 -0
- data/lib/virtualbox/dvd.rb +2 -2
- data/lib/virtualbox/exceptions.rb +4 -0
- data/lib/virtualbox/ext/platform.rb +2 -2
- data/lib/virtualbox/extra_data.rb +5 -6
- data/lib/virtualbox/forwarded_port.rb +11 -7
- data/lib/virtualbox/global.rb +17 -6
- data/lib/virtualbox/hard_drive.rb +129 -66
- data/lib/virtualbox/host.rb +71 -0
- data/lib/virtualbox/host_network_interface.rb +137 -0
- data/lib/virtualbox/hw_virtualization.rb +12 -6
- data/lib/virtualbox/lib.rb +2 -2
- data/lib/virtualbox/media.rb +2 -2
- data/lib/virtualbox/medium.rb +10 -3
- data/lib/virtualbox/medium_attachment.rb +2 -2
- data/lib/virtualbox/network_adapter.rb +12 -4
- data/lib/virtualbox/proxies/collection.rb +26 -6
- data/lib/virtualbox/shared_folder.rb +22 -15
- data/lib/virtualbox/snapshot.rb +185 -0
- data/lib/virtualbox/storage_controller.rb +3 -3
- data/lib/virtualbox/system_properties.rb +1 -1
- data/lib/virtualbox/usb_controller.rb +8 -4
- data/lib/virtualbox/usb_device_filter.rb +74 -0
- data/lib/virtualbox/version.rb +12 -1
- data/lib/virtualbox/virtual_system_description.rb +4 -4
- data/lib/virtualbox/vm.rb +273 -64
- data/lib/virtualbox/vrdp_server.rb +59 -0
- data/test/test_helper.rb +7 -1
- data/test/virtualbox/abstract_model/attributable_test.rb +8 -0
- data/test/virtualbox/abstract_model/relatable_test.rb +5 -5
- data/test/virtualbox/abstract_model/validatable_test.rb +186 -3
- data/test/virtualbox/abstract_model_test.rb +3 -3
- data/test/virtualbox/appliance_test.rb +8 -1
- data/test/virtualbox/com/abstract_enum_test.rb +1 -0
- data/test/virtualbox/com/abstract_implementer_test.rb +4 -3
- data/test/virtualbox/com/abstract_interface_test.rb +3 -2
- data/test/virtualbox/com/ffi/interface_test.rb +4 -4
- data/test/virtualbox/com/ffi/util_test.rb +23 -1
- data/test/virtualbox/com/implementer/base_test.rb +4 -3
- data/test/virtualbox/com/implementer/ffi_test.rb +18 -10
- data/test/virtualbox/cpu_test.rb +103 -0
- data/test/virtualbox/dhcp_server_test.rb +165 -0
- data/test/virtualbox/extra_data_test.rb +4 -3
- data/test/virtualbox/forwarded_port_test.rb +17 -4
- data/test/virtualbox/hard_drive_test.rb +54 -5
- data/test/virtualbox/host_network_interface_test.rb +254 -0
- data/test/virtualbox/host_test.rb +94 -0
- data/test/virtualbox/network_adapter_test.rb +30 -1
- data/test/virtualbox/proxies/collection_test.rb +63 -21
- data/test/virtualbox/shared_folder_test.rb +16 -13
- data/test/virtualbox/snapshot_test.rb +231 -0
- data/test/virtualbox/storage_controller_test.rb +1 -1
- data/test/virtualbox/usb_controller_test.rb +7 -0
- data/test/virtualbox/usb_device_filter_test.rb +93 -0
- data/test/virtualbox/version_test.rb +13 -1
- data/test/virtualbox/vm_test.rb +245 -11
- data/test/virtualbox/vrdp_server_test.rb +83 -0
- data/virtualbox.gemspec +183 -97
- metadata +182 -96
- data/TODO +0 -9
- data/lib/virtualbox/com/interface/appliance.rb +0 -20
- data/lib/virtualbox/com/interface/audio_adapter.rb +0 -13
- data/lib/virtualbox/com/interface/audio_controller_type.rb +0 -9
- data/lib/virtualbox/com/interface/audio_driver_type.rb +0 -9
- data/lib/virtualbox/com/interface/bios_boot_menu_mode.rb +0 -9
- data/lib/virtualbox/com/interface/bios_settings.rb +0 -19
- data/lib/virtualbox/com/interface/clipboard_mode.rb +0 -9
- data/lib/virtualbox/com/interface/console.rb +0 -48
- data/lib/virtualbox/com/interface/cpu_property_type.rb +0 -9
- data/lib/virtualbox/com/interface/device_type.rb +0 -9
- data/lib/virtualbox/com/interface/dhcp_server.rb +0 -20
- data/lib/virtualbox/com/interface/firmware_type.rb +0 -9
- data/lib/virtualbox/com/interface/guest_os_type.rb +0 -21
- data/lib/virtualbox/com/interface/host.rb +0 -40
- data/lib/virtualbox/com/interface/host_network_interface.rb +0 -28
- data/lib/virtualbox/com/interface/host_network_interface_medium_type.rb +0 -9
- data/lib/virtualbox/com/interface/host_network_interface_status.rb +0 -9
- data/lib/virtualbox/com/interface/host_network_interface_type.rb +0 -9
- data/lib/virtualbox/com/interface/host_usb_device.rb +0 -11
- data/lib/virtualbox/com/interface/host_usb_device_filter.rb +0 -11
- data/lib/virtualbox/com/interface/hw_virt_ex_property_type.rb +0 -9
- data/lib/virtualbox/com/interface/machine.rb +0 -103
- data/lib/virtualbox/com/interface/machine_state.rb +0 -12
- data/lib/virtualbox/com/interface/medium.rb +0 -48
- data/lib/virtualbox/com/interface/medium_attachment.rb +0 -16
- data/lib/virtualbox/com/interface/medium_format.rb +0 -16
- data/lib/virtualbox/com/interface/medium_state.rb +0 -9
- data/lib/virtualbox/com/interface/medium_type.rb +0 -9
- data/lib/virtualbox/com/interface/medium_variant.rb +0 -9
- data/lib/virtualbox/com/interface/network_adapter.rb +0 -28
- data/lib/virtualbox/com/interface/network_adapter_type.rb +0 -9
- data/lib/virtualbox/com/interface/network_attachment_type.rb +0 -9
- data/lib/virtualbox/com/interface/nsiexception.rb +0 -21
- data/lib/virtualbox/com/interface/nsisupports.rb +0 -13
- data/lib/virtualbox/com/interface/parallel_port.rb +0 -15
- data/lib/virtualbox/com/interface/port_mode.rb +0 -9
- data/lib/virtualbox/com/interface/progress.rb +0 -58
- data/lib/virtualbox/com/interface/serial_port.rb +0 -17
- data/lib/virtualbox/com/interface/session.rb +0 -16
- data/lib/virtualbox/com/interface/session_state.rb +0 -9
- data/lib/virtualbox/com/interface/session_type.rb +0 -9
- data/lib/virtualbox/com/interface/shared_folder.rb +0 -15
- data/lib/virtualbox/com/interface/snapshot.rb +0 -18
- data/lib/virtualbox/com/interface/storage_bus.rb +0 -9
- data/lib/virtualbox/com/interface/storage_controller.rb +0 -21
- data/lib/virtualbox/com/interface/storage_controller_type.rb +0 -9
- data/lib/virtualbox/com/interface/system_properties.rb +0 -35
- data/lib/virtualbox/com/interface/usb_controller.rb +0 -18
- data/lib/virtualbox/com/interface/usb_device.rb +0 -22
- data/lib/virtualbox/com/interface/usb_device_filter.rb +0 -21
- data/lib/virtualbox/com/interface/usb_device_filter_action.rb +0 -9
- data/lib/virtualbox/com/interface/usb_device_state.rb +0 -9
- data/lib/virtualbox/com/interface/virtual_box_error_info.rb +0 -15
- data/lib/virtualbox/com/interface/virtual_system_description.rb +0 -17
- data/lib/virtualbox/com/interface/virtual_system_description_type.rb +0 -12
- data/lib/virtualbox/com/interface/virtual_system_description_value_type.rb +0 -9
- data/lib/virtualbox/com/interface/virtualbox.rb +0 -54
- data/lib/virtualbox/com/interface/vrdp_auth_type.rb +0 -9
- data/lib/virtualbox/com/interface/vrdp_server.rb +0 -17
@@ -67,7 +67,8 @@ module VirtualBox
|
|
67
67
|
# attribute :hostport
|
68
68
|
#
|
69
69
|
class ForwardedPort < AbstractModel
|
70
|
-
attribute :parent, :readonly => true
|
70
|
+
attribute :parent, :readonly => true, :property => false
|
71
|
+
attribute :parent_collection, :readonly => true, :property => false
|
71
72
|
attribute :name
|
72
73
|
attribute :instance, :default => "0"
|
73
74
|
attribute :device, :default => "pcnet"
|
@@ -75,7 +76,7 @@ module VirtualBox
|
|
75
76
|
attribute :guestport
|
76
77
|
attribute :hostport
|
77
78
|
|
78
|
-
class <<self
|
79
|
+
class << self
|
79
80
|
# Populates a relationship with another model.
|
80
81
|
#
|
81
82
|
# **This method typically won't be used except internally.**
|
@@ -89,6 +90,7 @@ module VirtualBox
|
|
89
90
|
|
90
91
|
port = new({
|
91
92
|
:parent => caller,
|
93
|
+
:parent_collection => relation,
|
92
94
|
:name => $4.to_s,
|
93
95
|
:instance => $3.to_s,
|
94
96
|
:device => $2.to_s,
|
@@ -182,8 +184,6 @@ module VirtualBox
|
|
182
184
|
|
183
185
|
# Destroys the port forwarding mapping.
|
184
186
|
#
|
185
|
-
# @param [Boolean] raise_errors If true, {Exceptions::CommandFailedException}
|
186
|
-
# will be raised if the command failed.
|
187
187
|
# @return [Boolean] True if command was successful, false otherwise.
|
188
188
|
def destroy
|
189
189
|
results = []
|
@@ -193,6 +193,9 @@ module VirtualBox
|
|
193
193
|
results << parent.extra_data.delete("#{key_prefix(true)}GuestPort")
|
194
194
|
results << parent.extra_data.delete("#{key_prefix(true)}HostPort")
|
195
195
|
|
196
|
+
# Remove it from any collection
|
197
|
+
parent_collection.delete(self, true) if parent_collection
|
198
|
+
|
196
199
|
new_record!
|
197
200
|
end
|
198
201
|
|
@@ -201,8 +204,9 @@ module VirtualBox
|
|
201
204
|
|
202
205
|
# Relationship callback when added to a collection. This is automatically
|
203
206
|
# called by any relationship collection when this object is added.
|
204
|
-
def added_to_relationship(
|
205
|
-
write_attribute(:parent, parent)
|
207
|
+
def added_to_relationship(proxy)
|
208
|
+
write_attribute(:parent, proxy.parent)
|
209
|
+
write_attribute(:parent_collection, proxy)
|
206
210
|
end
|
207
211
|
|
208
212
|
# Returns the prefix to be used for the extra data key. Forwarded ports
|
@@ -216,4 +220,4 @@ module VirtualBox
|
|
216
220
|
"VBoxInternal\/Devices\/#{device}\/#{instance}\/LUN#0\/Config\/#{name_value}\/"
|
217
221
|
end
|
218
222
|
end
|
219
|
-
end
|
223
|
+
end
|
data/lib/virtualbox/global.rb
CHANGED
@@ -42,10 +42,12 @@ module VirtualBox
|
|
42
42
|
relationship :media, :Media, :lazy => true
|
43
43
|
relationship :extra_data, :ExtraData, :lazy => true
|
44
44
|
relationship :system_properties, :SystemProperties, :lazy => true
|
45
|
+
relationship :host, :Host, :lazy => true
|
46
|
+
relationship :dhcp_servers, :DHCPServer, :lazy => true
|
45
47
|
|
46
48
|
@@global_data = nil
|
47
49
|
|
48
|
-
class <<self
|
50
|
+
class << self
|
49
51
|
# Retrieves the global data. The return value of this call is cached,
|
50
52
|
# and can be reloaded by setting the `reload` parameter to true. Besides
|
51
53
|
# explicitly setting the parameter, some actions within the library
|
@@ -76,10 +78,19 @@ module VirtualBox
|
|
76
78
|
end
|
77
79
|
|
78
80
|
def load_relationship(name)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
81
|
+
# "Lazy loaded" associations table. These associate the relationship
|
82
|
+
# with the data it needs to load. The data is wrapped in lambdas so
|
83
|
+
# that the evaluation doesn't occur unless necessary.
|
84
|
+
relationships = {
|
85
|
+
:vms => lambda { lib.virtualbox.machines },
|
86
|
+
:media => lambda { lib },
|
87
|
+
:extra_data => lambda { lib.virtualbox },
|
88
|
+
:system_properties => lambda { lib.virtualbox.system_properties },
|
89
|
+
:host => lambda { lib.virtualbox.host },
|
90
|
+
:dhcp_servers => lambda { lib.virtualbox.dhcp_servers }
|
91
|
+
}
|
92
|
+
|
93
|
+
populate_relationship(name, relationships[name].call)
|
83
94
|
end
|
84
95
|
end
|
85
|
-
end
|
96
|
+
end
|
@@ -8,16 +8,18 @@ module VirtualBox
|
|
8
8
|
#
|
9
9
|
# VirtualBox::HardDrive.all
|
10
10
|
#
|
11
|
-
# Or:
|
11
|
+
# Or use find with the UUID of the HardDrive:
|
12
12
|
#
|
13
|
-
# VirtualBox::HardDrive.find("
|
13
|
+
# VirtualBox::HardDrive.find("4a896f0b-b3a3-4dec-8c26-8406c6fccd6e")
|
14
14
|
#
|
15
15
|
# # Creating a Hard Drive
|
16
16
|
#
|
17
|
-
#
|
18
|
-
#
|
17
|
+
# Hard Drives can be created by intilizing an empty hard drive, assigning
|
18
|
+
# values to the necessary attributes, and calling save on the object.
|
19
|
+
# Below is a simple example of how this works:
|
19
20
|
#
|
20
21
|
# hd = VirtualBox::HardDrive.new
|
22
|
+
# hd.format = "VDI" # Or any format list with `VBoxManage list hddbackends`
|
21
23
|
# hd.location = "foo.vdi"
|
22
24
|
# hd.size = 2400 # in megabytes
|
23
25
|
# hd.save
|
@@ -26,38 +28,32 @@ module VirtualBox
|
|
26
28
|
# hd.uuid
|
27
29
|
# hd.location # will return a full path now
|
28
30
|
#
|
29
|
-
# Although `VDI` is the default format for newly created hard drives, other
|
30
|
-
# formats are supported:
|
31
|
-
#
|
32
|
-
# hd = VirtualBox::HardDrive.new
|
33
|
-
# hd.format = "VMDK"
|
34
|
-
# hd.location = "bar.vmdk"
|
35
|
-
# hd.size = 9001 # Its over 9000! (If you don't understand the reference, just ignore this comment)
|
36
|
-
# hd.save
|
37
|
-
#
|
38
|
-
# Any formats listed by your VirtualBox installation's `VBoxManage list hddbackends` command
|
39
|
-
# can be used with the virtualbox gem.
|
40
|
-
#
|
41
31
|
# # Destroying Hard Drives
|
42
32
|
#
|
43
|
-
# Hard drives can also be deleted
|
44
|
-
# disk. **This operation is not reversable**.
|
33
|
+
# Hard drives can also be deleted. **This operation is not reversable**.
|
45
34
|
#
|
46
|
-
# hd = VirtualBox::HardDrive.find("
|
35
|
+
# hd = VirtualBox::HardDrive.find("...")
|
47
36
|
# hd.destroy
|
48
37
|
#
|
38
|
+
# This will only unregister the Hard Drive from VirtualBox and will not destroy
|
39
|
+
# the storage space on the disk. To destroy the storage space, pass `true` to
|
40
|
+
# the destroy method, example:
|
41
|
+
#
|
42
|
+
# hd.destroy(true)
|
43
|
+
#
|
49
44
|
# # Cloning Hard Drives
|
50
45
|
#
|
51
|
-
# Hard
|
46
|
+
# Hard Drives can just as easily be cloned as they can be created or destroyed.
|
52
47
|
#
|
53
|
-
# hd = VirtualBox::HardDrive.find("
|
54
|
-
# cloned_hd = hd.clone("bar")
|
48
|
+
# hd = VirtualBox::HardDrive.find("...")
|
49
|
+
# cloned_hd = hd.clone("bar.vdi")
|
55
50
|
#
|
56
51
|
# In addition to simply cloning hard drives, this command can be used to
|
57
|
-
# clone to a different format
|
52
|
+
# clone to a different format. If the format is not passed in (as with the
|
53
|
+
# the above example, the system default format will be used). example:
|
58
54
|
#
|
59
|
-
# hd = VirtualBox::HardDrive.find("
|
60
|
-
# hd.clone("bar", "VMDK") # Will clone and convert to VMDK format
|
55
|
+
# hd = VirtualBox::HardDrive.find("...")
|
56
|
+
# hd.clone("bar.vmdk", "VMDK") # Will clone and convert to VMDK format
|
61
57
|
#
|
62
58
|
# # Attributes
|
63
59
|
#
|
@@ -70,35 +66,38 @@ module VirtualBox
|
|
70
66
|
# listed below. If you aren't sure what this means or you can't understand
|
71
67
|
# why the below is listed, please read {Attributable}.
|
72
68
|
#
|
73
|
-
# attribute :format, :default => "VDI"
|
74
|
-
# attribute :
|
69
|
+
# attribute :format, :default => "VDI"
|
70
|
+
# attribute :location
|
71
|
+
# attribute :logical_size
|
75
72
|
# attribute :physical_size, :readonly => true, :property => :size
|
76
73
|
#
|
77
74
|
# There are more attributes on the {Medium} model, which {HardDrive} inherits
|
78
75
|
# from.
|
76
|
+
#
|
79
77
|
class HardDrive < Medium
|
80
78
|
include ByteNormalizer
|
81
79
|
|
82
|
-
attribute :format, :default => "VDI"
|
83
|
-
attribute :
|
80
|
+
attribute :format, :default => "VDI"
|
81
|
+
attribute :location
|
82
|
+
attribute :logical_size
|
84
83
|
attribute :physical_size, :readonly => true, :property => :size
|
85
84
|
|
86
|
-
class <<self
|
85
|
+
class << self
|
87
86
|
# Returns an array of all available hard drives as HardDrive
|
88
87
|
# objects.
|
89
88
|
#
|
90
89
|
# @return [Array<HardDrive>]
|
91
90
|
def all
|
92
|
-
Global.global.media.hard_drives
|
91
|
+
Global.global(true).media.hard_drives
|
93
92
|
end
|
94
93
|
|
95
|
-
# Finds one specific hard drive by UUID
|
96
|
-
#
|
94
|
+
# Finds one specific hard drive by UUID. If the hard drive
|
95
|
+
# can not be found, will return `nil`.
|
97
96
|
#
|
98
97
|
# @param [String] id The UUID of the hard drive
|
99
98
|
# @return [HardDrive]
|
100
|
-
def find(id
|
101
|
-
all.
|
99
|
+
def find(id)
|
100
|
+
all.detect { |hd| hd.uuid == id }
|
102
101
|
end
|
103
102
|
|
104
103
|
# Override of {Medium.device_type}.
|
@@ -107,58 +106,118 @@ module VirtualBox
|
|
107
106
|
end
|
108
107
|
end
|
109
108
|
|
109
|
+
# Overwrite the AbstractModel initialize to make the imedium parameter
|
110
|
+
# optional so that new Hard Drives can be created
|
111
|
+
def initialize(imedium = nil)
|
112
|
+
super if imedium
|
113
|
+
end
|
114
|
+
|
110
115
|
# Custom getter to convert the physical size from bytes to megabytes.
|
111
116
|
def physical_size
|
112
117
|
bytes_to_megabytes(read_attribute(:physical_size))
|
113
118
|
end
|
114
119
|
|
115
|
-
#
|
116
|
-
|
117
|
-
|
118
|
-
|
120
|
+
# Get an array of machines attached to this Virtual Machine
|
121
|
+
def machines
|
122
|
+
interface.machine_ids.collect { |id| VirtualBox::VM.find(id) }
|
123
|
+
end
|
124
|
+
|
125
|
+
# Validates a hard drive for the minimum attributes required to
|
126
|
+
# create or save.
|
127
|
+
def validate
|
128
|
+
super
|
129
|
+
|
130
|
+
medium_formats = Global.global.system_properties.medium_formats.collect { |mf| mf.id }
|
131
|
+
validates_inclusion_of :format, :in => medium_formats, :message => "must be one of the following: #{medium_formats.join(', ')}."
|
132
|
+
|
133
|
+
validates_presence_of :location
|
134
|
+
|
135
|
+
max_vdi_size = Global.global.system_properties.max_vdi_size
|
136
|
+
validates_inclusion_of :logical_size, :in => (0..max_vdi_size), :message => "must be between 0 and #{max_vdi_size}."
|
137
|
+
end
|
138
|
+
|
139
|
+
# Creates a new {COM::Interface::Medium} instance. This simply creates
|
140
|
+
# the new {COM::Interface::Medium} structure. It does not (and shouldn't)
|
141
|
+
# create the storage space on the host system. See the create method for
|
142
|
+
# an example on to create the storage space.
|
119
143
|
#
|
120
144
|
# @param [String] outputfile The output file. This can be a full path
|
121
145
|
# or just a filename. If its just a filename, it will be placed in
|
122
|
-
# the default hard drives directory.
|
123
|
-
# @param [String] format The format to convert to.
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
def
|
146
|
+
# the default hard drives directory. Should not be present already.
|
147
|
+
# @param [String] format The format to convert to. If not present, the
|
148
|
+
# systems default will be used.
|
149
|
+
# @return [COM::Interface::Medium] The new {COM::Interface::Medium} instance
|
150
|
+
# or will raise a {Exceptions::MediumCreationFailedException} on failure.
|
151
|
+
def create_hard_disk_medium(outputfile, format = nil)
|
128
152
|
# Get main VirtualBox object
|
129
153
|
virtualbox = Lib.lib.virtualbox
|
130
154
|
|
155
|
+
# Assign the default format if it isn't set yet
|
156
|
+
format ||= virtualbox.system_properties.default_hard_disk_format
|
157
|
+
|
131
158
|
# Expand path relative to the default hard disk folder. This allows
|
132
159
|
# filenames to exist in the default folder while full paths will use
|
133
160
|
# the paths specified.
|
134
161
|
outputfile = File.expand_path(outputfile, virtualbox.system_properties.default_hard_disk_folder)
|
135
162
|
|
136
|
-
#
|
163
|
+
# If the outputfile path is in use by another Hard Drive, lets fail
|
164
|
+
# now with a meaningful exception rather than simply return a nil
|
165
|
+
raise Exceptions::MediumLocationInUseException.new(outputfile) if File.exist?(outputfile)
|
166
|
+
|
167
|
+
# Create the new {COM::Interface::Medium} instance.
|
137
168
|
new_medium = virtualbox.create_hard_disk(format, outputfile)
|
138
169
|
|
139
|
-
#
|
170
|
+
# Raise an error if the creation of the {COM::Interface::Medium}
|
171
|
+
# instance failed
|
172
|
+
raise Exceptions::MediumCreationFailedException.new unless new_medium
|
173
|
+
|
174
|
+
# Return the new {COM::Interface::Medium} instance.
|
175
|
+
new_medium
|
176
|
+
end
|
177
|
+
|
178
|
+
# Clone hard drive, possibly also converting formats. All formats
|
179
|
+
# supported by your local VirtualBox installation are supported
|
180
|
+
# here. If no format is specified, the systems default will be used.
|
181
|
+
#
|
182
|
+
# @param [String] outputfile The output file. This can be a full path
|
183
|
+
# or just a filename. If its just a filename, it will be placed in
|
184
|
+
# the default hard drives directory. Should not be present already.
|
185
|
+
# @param [String] format The format to convert to. If not present, the
|
186
|
+
# systems default will be used.
|
187
|
+
# @return [HardDrive] The new, cloned hard drive, or nil on failure.
|
188
|
+
def clone(outputfile, format = nil)
|
189
|
+
# Create the new Hard Disk medium
|
190
|
+
new_medium = create_hard_disk_medium(outputfile, format)
|
191
|
+
|
192
|
+
# Clone the current drive onto the new Hard Disk medium
|
140
193
|
interface.clone_to(new_medium, :standard, nil).wait_for_completion(-1)
|
194
|
+
|
195
|
+
# Locate the newly cloned hard drive
|
196
|
+
self.class.find(new_medium.id) if new_medium.respond_to?(:id)
|
141
197
|
end
|
142
198
|
|
143
199
|
# Creates a new hard drive.
|
144
200
|
#
|
145
201
|
# **This method should NEVER be called. Call {#save} instead.**
|
146
202
|
#
|
147
|
-
# @param [Boolean] raise_errors If true, {Exceptions::CommandFailedException}
|
148
|
-
# will be raised if the command failed.
|
149
203
|
# @return [Boolean] True if command was successful, false otherwise.
|
150
|
-
def create
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
204
|
+
def create
|
205
|
+
return false unless new_record?
|
206
|
+
raise Exceptions::ValidationFailedException.new(errors) if !valid?
|
207
|
+
|
208
|
+
# Create the new Hard Disk medium
|
209
|
+
new_medium = create_hard_disk_medium(location, format)
|
155
210
|
|
156
|
-
#
|
211
|
+
# Create the storage on the host system
|
212
|
+
new_medium.create_base_storage(logical_size, :standard).wait_for_completion(-1)
|
157
213
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
214
|
+
# Update the current Hard Drive instance with the uuid and
|
215
|
+
# other attributes assigned after storage was written
|
216
|
+
write_attribute(:interface, new_medium)
|
217
|
+
initialize_attributes(new_medium)
|
218
|
+
|
219
|
+
# If the uuid is present, then everything worked
|
220
|
+
uuid && !uuid.to_s.empty?
|
162
221
|
end
|
163
222
|
|
164
223
|
# Saves the hard drive object. If the hard drive is new,
|
@@ -168,16 +227,20 @@ module VirtualBox
|
|
168
227
|
# Currently, **saving existing hard drives does nothing**.
|
169
228
|
# This is a limitation of VirtualBox, rather than the library itself.
|
170
229
|
#
|
171
|
-
# @param [Boolean] raise_errors If true, {Exceptions::CommandFailedException}
|
172
|
-
# will be raised if the command failed.
|
173
230
|
# @return [Boolean] True if command was successful, false otherwise.
|
174
|
-
def save
|
231
|
+
def save
|
232
|
+
return true if !new_record? && !changed?
|
233
|
+
raise Exceptions::ValidationFailedException.new(errors) if !valid?
|
234
|
+
|
175
235
|
if new_record?
|
176
|
-
# Create a new hard drive
|
177
|
-
create(raise_errors)
|
236
|
+
create # Create a new hard drive
|
178
237
|
else
|
179
|
-
|
238
|
+
# Mediums like Hard Drives are not updatable, they need to be recreated
|
239
|
+
# Because Hard Drives contain info and paritions, it's easier to error
|
240
|
+
# out now than try and do some complicated logic
|
241
|
+
msg = "Hard Drives cannot be updated. You need to create one from scratch."
|
242
|
+
raise Exceptions::MediumNotUpdatableException.new(msg)
|
180
243
|
end
|
181
244
|
end
|
182
245
|
end
|
183
|
-
end
|
246
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module VirtualBox
|
2
|
+
# Represents information about the host machine. This includes
|
3
|
+
# information such as memory available, processors, dvds, network
|
4
|
+
# interfaces, etc.
|
5
|
+
#
|
6
|
+
# This information is different from system properties in that some
|
7
|
+
# parts represent data which is stored in the VirtualBox "registry"
|
8
|
+
# (such as the dvd drives, host only network interfaces, etc.)
|
9
|
+
class Host < AbstractModel
|
10
|
+
attribute :parent, :readonly => true, :property => false
|
11
|
+
attribute :interface, :readonly => true, :property => false
|
12
|
+
attribute :processor_count, :readonly => true
|
13
|
+
attribute :processor_online_count, :readonly => true
|
14
|
+
attribute :memory_size, :readonly => true
|
15
|
+
attribute :memory_available, :readonly => true
|
16
|
+
attribute :operating_system, :readonly => true
|
17
|
+
attribute :os_version, :readonly => true
|
18
|
+
attribute :utc_time, :readonly => true
|
19
|
+
attribute :acceleration_3d_available, :readonly => true
|
20
|
+
relationship :network_interfaces, :HostNetworkInterface
|
21
|
+
|
22
|
+
class << self
|
23
|
+
# Populates the system properties relationship for anything
|
24
|
+
# which is related to it.
|
25
|
+
#
|
26
|
+
# **This method typically won't be used except internally.**
|
27
|
+
#
|
28
|
+
# @return [SystemProperties]
|
29
|
+
def populate_relationship(caller, data)
|
30
|
+
new(caller, data)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Saves the relationship. This simply calls {#save} on the
|
34
|
+
# relationship object.
|
35
|
+
#
|
36
|
+
# **This method typically won't be used except internally.**
|
37
|
+
def save_relationship(caller, item)
|
38
|
+
item.save
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Initializes the system properties object. This shouldn't be called
|
43
|
+
# directly. Instead `Global#system_properties` should be used to
|
44
|
+
# retrieve this object.
|
45
|
+
def initialize(caller, raw)
|
46
|
+
initialize_attributes(caller, raw)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Initializes the attributes of an existing shared folder.
|
50
|
+
def initialize_attributes(caller, raw)
|
51
|
+
# Save the interface and parent
|
52
|
+
write_attribute(:parent, caller)
|
53
|
+
write_attribute(:interface, raw)
|
54
|
+
|
55
|
+
# Load the attributes from the interface
|
56
|
+
load_interface_attributes(interface)
|
57
|
+
|
58
|
+
# Get the relationships setup
|
59
|
+
populate_relationship(:network_interfaces, interface)
|
60
|
+
|
61
|
+
# Clear dirty and mark as existing
|
62
|
+
clear_dirty!
|
63
|
+
existing_record!
|
64
|
+
end
|
65
|
+
|
66
|
+
# Saves the system properties.
|
67
|
+
def save
|
68
|
+
save_changed_interface_attributes(interface)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
module VirtualBox
|
2
|
+
# Represents a network interface on the host. There are generally
|
3
|
+
# two types of network interfaces wihch exist on the host: bridged
|
4
|
+
# and host-only. This class represents both.
|
5
|
+
class HostNetworkInterface < AbstractModel
|
6
|
+
attribute :parent, :readonly => true, :property => false
|
7
|
+
attribute :parent_collection, :readonly => true, :property => false
|
8
|
+
attribute :interface, :readonly => true, :property => false
|
9
|
+
attribute :name, :readonly => true
|
10
|
+
attribute :uuid, :readonly => true, :property => :id
|
11
|
+
attribute :network_name, :readonly => true
|
12
|
+
attribute :dhcp_enabled, :readonly => true
|
13
|
+
attribute :ip_address, :readonly => true
|
14
|
+
attribute :network_mask, :readonly => true
|
15
|
+
attribute :ip_v6_supported, :readonly => true
|
16
|
+
attribute :ip_v6_address, :readonly => true
|
17
|
+
attribute :ip_v6_network_mask_prefix_length, :readonly => true
|
18
|
+
attribute :hardware_address, :readonly => true
|
19
|
+
attribute :medium_type, :readonly => true
|
20
|
+
attribute :status, :readonly => true
|
21
|
+
attribute :interface_type, :readonly => true
|
22
|
+
|
23
|
+
class << self
|
24
|
+
# Populates a relationship with another model.
|
25
|
+
#
|
26
|
+
# **This method typically won't be used except internally.**
|
27
|
+
#
|
28
|
+
# @return [Array<HostNetworkInterface>]
|
29
|
+
def populate_relationship(caller, ihost)
|
30
|
+
relation = Proxies::Collection.new(caller, self, ihost)
|
31
|
+
|
32
|
+
ihost.network_interfaces.each do |inet|
|
33
|
+
relation << new(inet)
|
34
|
+
end
|
35
|
+
|
36
|
+
relation
|
37
|
+
end
|
38
|
+
|
39
|
+
# Creates a host only network interface. This method should not
|
40
|
+
# be called directly. Instead, the `create` method on the
|
41
|
+
# `Global#host` relationship should be called instead. Example:
|
42
|
+
#
|
43
|
+
# VirtualBox::Global.global.host.network_interfaces.create
|
44
|
+
#
|
45
|
+
# The above will create a host only network interface, add it to
|
46
|
+
# the collection, and will return the instance of the new
|
47
|
+
# interface.
|
48
|
+
def create(proxy, interface)
|
49
|
+
inet, progress = interface.create_host_only_network_interface
|
50
|
+
progress.wait
|
51
|
+
|
52
|
+
new(inet)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def initialize(inet)
|
57
|
+
initialize_attributes(inet)
|
58
|
+
end
|
59
|
+
|
60
|
+
def initialize_attributes(inet)
|
61
|
+
write_attribute(:interface, inet)
|
62
|
+
|
63
|
+
load_interface_attributes(inet)
|
64
|
+
existing_record!
|
65
|
+
end
|
66
|
+
|
67
|
+
def added_to_relationship(proxy)
|
68
|
+
write_attribute(:parent, proxy.parent)
|
69
|
+
write_attribute(:parent_collection, proxy)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Gets the DHCP server associated with the network interface. Only
|
73
|
+
# host only network interfaces have dhcp servers. If a DHCP server
|
74
|
+
# doesn't exist for this network interface, one will be created.
|
75
|
+
def dhcp_server(create_if_not_found=true)
|
76
|
+
return nil if interface_type != :host_only
|
77
|
+
|
78
|
+
# Try to find the dhcp server in the list of DHCP servers.
|
79
|
+
dhcp_name = "HostInterfaceNetworking-#{name}"
|
80
|
+
result = parent.parent.dhcp_servers.find do |dhcp|
|
81
|
+
dhcp.network_name == dhcp_name
|
82
|
+
end
|
83
|
+
|
84
|
+
# If no DHCP server is found, create one
|
85
|
+
result = parent.parent.dhcp_servers.create(dhcp_name) if result.nil? && create_if_not_found
|
86
|
+
result
|
87
|
+
end
|
88
|
+
|
89
|
+
# Gets the VMs which have an adapter which is attached to this
|
90
|
+
# network interface.
|
91
|
+
def attached_vms
|
92
|
+
parent.parent.vms.find_all do |vm|
|
93
|
+
result = vm.network_adapters.find do |adapter|
|
94
|
+
adapter.host_interface == name
|
95
|
+
end
|
96
|
+
|
97
|
+
!result.nil?
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Sets up the static IPV4 configuration for the host only network
|
102
|
+
# interface. This allows the caller to set the IPV4 address of the
|
103
|
+
# interface as well as the netmask.
|
104
|
+
def enable_static(ip, netmask=nil)
|
105
|
+
netmask ||= network_mask
|
106
|
+
|
107
|
+
interface.enable_static_ip_config(ip, netmask)
|
108
|
+
reload
|
109
|
+
end
|
110
|
+
|
111
|
+
# Reloads the information regarding this host only network
|
112
|
+
# interface.
|
113
|
+
def reload
|
114
|
+
# Find the interface again and reload the data
|
115
|
+
inet = parent.interface.find_host_network_interface_by_id(uuid)
|
116
|
+
initialize_attributes(inet)
|
117
|
+
self
|
118
|
+
end
|
119
|
+
|
120
|
+
# Destroy the host only network interface. Warning: If any VMs are
|
121
|
+
# currently attached to this network interface, their networks
|
122
|
+
# will fail to work after removing this. Therefore, one should be
|
123
|
+
# careful to make sure to remove all VMs from this network prior
|
124
|
+
# to destroying it.
|
125
|
+
def destroy
|
126
|
+
return false if interface_type == :bridged
|
127
|
+
|
128
|
+
parent.interface.remove_host_only_network_interface(uuid).wait
|
129
|
+
dhcp_server.destroy if dhcp_server(false)
|
130
|
+
|
131
|
+
# Remove from collection
|
132
|
+
parent_collection.delete(self, true) if parent_collection
|
133
|
+
|
134
|
+
true
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -4,13 +4,13 @@ module VirtualBox
|
|
4
4
|
attribute :parent, :readonly => true, :property => false
|
5
5
|
attribute_scope(:property_getter => Proc.new { |instance, *args| instance.get_property(*args) },
|
6
6
|
:property_setter => Proc.new { |instance, *args| instance.set_property(*args) }) do
|
7
|
-
attribute :enabled
|
8
|
-
attribute :exclusive
|
9
|
-
attribute :vpid
|
10
|
-
attribute :nested_paging
|
7
|
+
attribute :enabled, :boolean => true
|
8
|
+
attribute :exclusive, :boolean => true
|
9
|
+
attribute :vpid, :boolean => true
|
10
|
+
attribute :nested_paging, :boolean => true
|
11
11
|
end
|
12
12
|
|
13
|
-
class <<self
|
13
|
+
class << self
|
14
14
|
# Populates a relationship with another model.
|
15
15
|
#
|
16
16
|
# **This method typically won't be used except internally.**
|
@@ -45,6 +45,12 @@ module VirtualBox
|
|
45
45
|
interface.set_hw_virt_ex_property(key, value)
|
46
46
|
end
|
47
47
|
|
48
|
+
def validate
|
49
|
+
super
|
50
|
+
|
51
|
+
validates_inclusion_of :enabled, :exclusive, :vpid, :nested_paging, :in => [true, false]
|
52
|
+
end
|
53
|
+
|
48
54
|
def save
|
49
55
|
parent.with_open_session do |session|
|
50
56
|
machine = session.machine
|
@@ -54,4 +60,4 @@ module VirtualBox
|
|
54
60
|
end
|
55
61
|
end
|
56
62
|
end
|
57
|
-
end
|
63
|
+
end
|
data/lib/virtualbox/lib.rb
CHANGED
@@ -25,7 +25,7 @@ module VirtualBox
|
|
25
25
|
attr_reader :virtualbox
|
26
26
|
attr_reader :session
|
27
27
|
|
28
|
-
class <<self
|
28
|
+
class << self
|
29
29
|
# Resets the initialized library (if there is any). This is primarily only
|
30
30
|
# used for testing.
|
31
31
|
def reset!
|
@@ -79,4 +79,4 @@ module VirtualBox
|
|
79
79
|
@session = @interface.session
|
80
80
|
end
|
81
81
|
end
|
82
|
-
end
|
82
|
+
end
|
data/lib/virtualbox/media.rb
CHANGED
@@ -5,7 +5,7 @@ module VirtualBox
|
|
5
5
|
relationship :hard_drives, :HardDrive
|
6
6
|
relationship :dvds, :DVD
|
7
7
|
|
8
|
-
class <<self
|
8
|
+
class << self
|
9
9
|
def populate_relationship(caller, lib)
|
10
10
|
new(caller, lib)
|
11
11
|
end
|
@@ -17,4 +17,4 @@ module VirtualBox
|
|
17
17
|
populate_relationship(:dvds, lib.virtualbox.dvd_images)
|
18
18
|
end
|
19
19
|
end
|
20
|
-
end
|
20
|
+
end
|