bbrowning-virtualbox 0.7.6.dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +8 -0
- data/.yardopts +3 -0
- data/Gemfile +16 -0
- data/LICENSE +19 -0
- data/Rakefile +33 -0
- data/Readme.md +70 -0
- data/docs/GettingStarted.md +196 -0
- data/docs/WhatsNew.md +12 -0
- data/features/README.md +33 -0
- data/features/global.feature +19 -0
- data/features/global_extra_data.feature +27 -0
- data/features/step_definitions/abstract_model_steps.rb +39 -0
- data/features/step_definitions/extra_data_steps.rb +36 -0
- data/features/step_definitions/global_steps.rb +29 -0
- data/features/step_definitions/nat_engine_steps.rb +76 -0
- data/features/step_definitions/network_adapter_steps.rb +38 -0
- data/features/step_definitions/shared_folder_steps.rb +76 -0
- data/features/step_definitions/snapshot_steps.rb +74 -0
- data/features/step_definitions/storage_controller_steps.rb +16 -0
- data/features/step_definitions/virtualbox_steps.rb +17 -0
- data/features/step_definitions/vm_steps.rb +50 -0
- data/features/support/env.rb +61 -0
- data/features/support/helpers.rb +38 -0
- data/features/support/hooks.rb +30 -0
- data/features/support/ordered_hash.rb +49 -0
- data/features/support/vboxmanage.rb +191 -0
- data/features/version.feature +16 -0
- data/features/vm.feature +13 -0
- data/features/vm_bios.feature +29 -0
- data/features/vm_cpu.feature +29 -0
- data/features/vm_extra_data.feature +35 -0
- data/features/vm_hw_virt.feature +29 -0
- data/features/vm_nat_engine.feature +57 -0
- data/features/vm_network_adapters.feature +27 -0
- data/features/vm_shared_folders.feature +42 -0
- data/features/vm_snapshots.feature +29 -0
- data/features/vm_storage_controllers.feature +11 -0
- data/lib/virtualbox.rb +11 -0
- data/lib/virtualbox/abstract_model.rb +281 -0
- data/lib/virtualbox/abstract_model/attributable.rb +290 -0
- data/lib/virtualbox/abstract_model/dirty.rb +177 -0
- data/lib/virtualbox/abstract_model/interface_attributes.rb +98 -0
- data/lib/virtualbox/abstract_model/relatable.rb +332 -0
- data/lib/virtualbox/abstract_model/validatable.rb +167 -0
- data/lib/virtualbox/abstract_model/version_matcher.rb +35 -0
- data/lib/virtualbox/appliance.rb +62 -0
- data/lib/virtualbox/audio_adapter.rb +52 -0
- data/lib/virtualbox/bios.rb +50 -0
- data/lib/virtualbox/com.rb +23 -0
- data/lib/virtualbox/com/abstract_enum.rb +43 -0
- data/lib/virtualbox/com/abstract_implementer.rb +45 -0
- data/lib/virtualbox/com/abstract_interface.rb +167 -0
- data/lib/virtualbox/com/base_interface.rb +38 -0
- data/lib/virtualbox/com/ffi/interface.rb +150 -0
- data/lib/virtualbox/com/ffi/interfaces.rb +54 -0
- data/lib/virtualbox/com/ffi/util.rb +119 -0
- data/lib/virtualbox/com/ffi/vboxxpcomc.rb +31 -0
- data/lib/virtualbox/com/ffi_interface.rb +96 -0
- data/lib/virtualbox/com/implementer/base.rb +59 -0
- data/lib/virtualbox/com/implementer/ffi.rb +361 -0
- data/lib/virtualbox/com/implementer/mscom.rb +175 -0
- data/lib/virtualbox/com/implementer/nil.rb +10 -0
- data/lib/virtualbox/com/interface/3.1.x/access_mode.rb +11 -0
- 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/access_mode.rb +11 -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 +44 -0
- data/lib/virtualbox/com/nil_interface.rb +7 -0
- data/lib/virtualbox/com/util.rb +32 -0
- data/lib/virtualbox/cpu.rb +61 -0
- data/lib/virtualbox/dhcp_server.rb +89 -0
- data/lib/virtualbox/dvd.rb +27 -0
- data/lib/virtualbox/exceptions.rb +39 -0
- data/lib/virtualbox/ext/byte_normalizer.rb +17 -0
- data/lib/virtualbox/ext/glob_loader.rb +22 -0
- data/lib/virtualbox/ext/logger.rb +38 -0
- data/lib/virtualbox/ext/platform.rb +27 -0
- data/lib/virtualbox/ext/subclass_listing.rb +24 -0
- data/lib/virtualbox/extra_data.rb +127 -0
- data/lib/virtualbox/forwarded_port.rb +222 -0
- data/lib/virtualbox/global.rb +102 -0
- data/lib/virtualbox/guest_property.rb +116 -0
- data/lib/virtualbox/hard_drive.rb +246 -0
- data/lib/virtualbox/host.rb +71 -0
- data/lib/virtualbox/host_network_interface.rb +137 -0
- data/lib/virtualbox/hw_virtualization.rb +63 -0
- data/lib/virtualbox/lib.rb +84 -0
- data/lib/virtualbox/media.rb +20 -0
- data/lib/virtualbox/medium.rb +145 -0
- data/lib/virtualbox/medium_attachment.rb +61 -0
- data/lib/virtualbox/nat_engine.rb +71 -0
- data/lib/virtualbox/nat_forwarded_port.rb +171 -0
- data/lib/virtualbox/network_adapter.rb +166 -0
- data/lib/virtualbox/proxies/collection.rb +57 -0
- data/lib/virtualbox/shared_folder.rb +220 -0
- data/lib/virtualbox/snapshot.rb +185 -0
- data/lib/virtualbox/storage_controller.rb +160 -0
- data/lib/virtualbox/system_properties.rb +74 -0
- data/lib/virtualbox/usb_controller.rb +59 -0
- data/lib/virtualbox/usb_device_filter.rb +74 -0
- data/lib/virtualbox/version.rb +36 -0
- data/lib/virtualbox/virtual_system_description.rb +47 -0
- data/lib/virtualbox/vm.rb +684 -0
- data/lib/virtualbox/vrdp_server.rb +59 -0
- data/test/test_helper.rb +18 -0
- data/test/virtualbox/abstract_model/attributable_test.rb +269 -0
- data/test/virtualbox/abstract_model/dirty_test.rb +83 -0
- data/test/virtualbox/abstract_model/interface_attributes_test.rb +194 -0
- data/test/virtualbox/abstract_model/relatable_test.rb +348 -0
- data/test/virtualbox/abstract_model/validatable_test.rb +308 -0
- data/test/virtualbox/abstract_model/version_matcher_test.rb +41 -0
- data/test/virtualbox/abstract_model_test.rb +462 -0
- data/test/virtualbox/appliance_test.rb +159 -0
- data/test/virtualbox/audio_adapter_test.rb +83 -0
- data/test/virtualbox/bios_test.rb +83 -0
- data/test/virtualbox/com/abstract_enum_test.rb +49 -0
- data/test/virtualbox/com/abstract_implementer_test.rb +40 -0
- data/test/virtualbox/com/abstract_interface_test.rb +140 -0
- data/test/virtualbox/com/ffi/interface_test.rb +249 -0
- data/test/virtualbox/com/ffi/util_test.rb +108 -0
- data/test/virtualbox/com/ffi_interface_test.rb +42 -0
- data/test/virtualbox/com/implementer/base_test.rb +38 -0
- data/test/virtualbox/com/implementer/ffi_test.rb +527 -0
- data/test/virtualbox/com/implementer/mscom_test.rb +247 -0
- data/test/virtualbox/com/mscom_interface_test.rb +17 -0
- data/test/virtualbox/com/util_test.rb +17 -0
- data/test/virtualbox/cpu_test.rb +103 -0
- data/test/virtualbox/dhcp_server_test.rb +165 -0
- data/test/virtualbox/dvd_test.rb +28 -0
- data/test/virtualbox/ext/byte_normalizer_test.rb +34 -0
- data/test/virtualbox/ext/platform_test.rb +50 -0
- data/test/virtualbox/ext/subclass_listing_test.rb +25 -0
- data/test/virtualbox/extra_data_test.rb +155 -0
- data/test/virtualbox/forwarded_port_test.rb +286 -0
- data/test/virtualbox/global_test.rb +46 -0
- data/test/virtualbox/hard_drive_test.rb +141 -0
- data/test/virtualbox/host_network_interface_test.rb +254 -0
- data/test/virtualbox/host_test.rb +94 -0
- data/test/virtualbox/hw_virtualization_test.rb +103 -0
- data/test/virtualbox/lib_test.rb +93 -0
- data/test/virtualbox/medium_attachment_test.rb +147 -0
- data/test/virtualbox/medium_test.rb +192 -0
- data/test/virtualbox/nat_engine_test.rb +106 -0
- data/test/virtualbox/nat_forwarded_port_test.rb +222 -0
- data/test/virtualbox/network_adapter_test.rb +191 -0
- data/test/virtualbox/proxies/collection_test.rb +102 -0
- data/test/virtualbox/shared_folder_test.rb +219 -0
- data/test/virtualbox/snapshot_test.rb +231 -0
- data/test/virtualbox/storage_controller_test.rb +197 -0
- data/test/virtualbox/system_properties_test.rb +87 -0
- data/test/virtualbox/usb_controller_test.rb +112 -0
- data/test/virtualbox/usb_device_filter_test.rb +93 -0
- data/test/virtualbox/version_test.rb +59 -0
- data/test/virtualbox/virtual_system_description_test.rb +61 -0
- data/test/virtualbox/vm_test.rb +637 -0
- data/test/virtualbox/vrdp_server_test.rb +83 -0
- data/test/virtualbox_test.rb +11 -0
- data/virtualbox.gemspec +25 -0
- metadata +397 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module VirtualBox
|
|
2
|
+
module COM
|
|
3
|
+
class Util
|
|
4
|
+
class << self
|
|
5
|
+
# Returns a boolean true/false whether the given COM interface
|
|
6
|
+
# exists.
|
|
7
|
+
#
|
|
8
|
+
# @return [Boolean]
|
|
9
|
+
def interface?(name)
|
|
10
|
+
COM::Interface.const_get(name.to_sym)
|
|
11
|
+
true
|
|
12
|
+
rescue NameError
|
|
13
|
+
false
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Gets an interface within the current version namespace.
|
|
17
|
+
def versioned_interface(interface)
|
|
18
|
+
Object.module_eval("::VirtualBox::COM::Interface::#{version_const}::#{interface}")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Returns a namespace representation for a version.
|
|
22
|
+
def version_const
|
|
23
|
+
"Version_" + @__version.upcase.gsub(".", "_")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def set_interface_version(version)
|
|
27
|
+
@__version = version
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
module VirtualBox
|
|
2
|
+
# Represents the CPU properties on a VM.
|
|
3
|
+
class CPU < AbstractModel
|
|
4
|
+
attribute :parent, :readonly => true, :property => false
|
|
5
|
+
attribute_scope(:property_getter => Proc.new { |instance, *args| instance.get_property(*args) },
|
|
6
|
+
:property_setter => Proc.new { |instance, *args| instance.set_property(*args) }) do
|
|
7
|
+
attribute :pae, :boolean => true
|
|
8
|
+
attribute :synthetic, :boolean => true
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
# Populates a relationship with another model.
|
|
13
|
+
#
|
|
14
|
+
# **This method typically won't be used except internally.**
|
|
15
|
+
#
|
|
16
|
+
# @return [CPU]
|
|
17
|
+
def populate_relationship(caller, imachine)
|
|
18
|
+
data = new(caller, imachine)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Saves the relationship.
|
|
22
|
+
#
|
|
23
|
+
# **This method typically won't be used except internally.**
|
|
24
|
+
def save_relationship(caller, instance)
|
|
25
|
+
instance.save
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def initialize(parent, imachine)
|
|
30
|
+
write_attribute(:parent, parent)
|
|
31
|
+
|
|
32
|
+
# Load the attributes and mark the whole thing as existing
|
|
33
|
+
load_interface_attributes(imachine)
|
|
34
|
+
clear_dirty!
|
|
35
|
+
existing_record!
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def get_property(interface, key)
|
|
39
|
+
interface.get_cpu_property(key)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def set_property(interface, key, value)
|
|
43
|
+
interface.set_cpu_property(key, value)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def validate
|
|
47
|
+
super
|
|
48
|
+
|
|
49
|
+
validates_inclusion_of :pae, :synthetic, :in => [true, false]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def save
|
|
53
|
+
parent.with_open_session do |session|
|
|
54
|
+
machine = session.machine
|
|
55
|
+
|
|
56
|
+
# Save them
|
|
57
|
+
save_changed_interface_attributes(machine)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
module VirtualBox
|
|
2
|
+
class DHCPServer < AbstractModel
|
|
3
|
+
attribute :parent, :readonly => true, :property => false
|
|
4
|
+
attribute :parent_collection, :readonly => true, :property => false
|
|
5
|
+
attribute :interface, :readonly => true, :property => false
|
|
6
|
+
attribute :enabled
|
|
7
|
+
attribute :ip_address
|
|
8
|
+
attribute :network_mask
|
|
9
|
+
attribute :network_name, :readonly => true
|
|
10
|
+
attribute :lower_ip
|
|
11
|
+
attribute :upper_ip
|
|
12
|
+
|
|
13
|
+
class << self
|
|
14
|
+
# Populates a relationship with another model.
|
|
15
|
+
#
|
|
16
|
+
# **This method typically won't be used except internally.**
|
|
17
|
+
#
|
|
18
|
+
# @return [Array<DHCPServer>]
|
|
19
|
+
def populate_relationship(caller, servers)
|
|
20
|
+
relation = Proxies::Collection.new(caller, self)
|
|
21
|
+
|
|
22
|
+
servers.each do |interface|
|
|
23
|
+
relation << new(interface)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
relation
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Creates a DHCP server for the given network name.
|
|
30
|
+
# This method should not be called directly, its recommended that you call
|
|
31
|
+
# the `create` method on the `dhcp_servers` relationship on
|
|
32
|
+
# `VirtualBox::Global` object.
|
|
33
|
+
def create(proxy, network_name)
|
|
34
|
+
interface = proxy.parent.lib.virtualbox.create_dhcp_server(network_name)
|
|
35
|
+
new(interface)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def initialize(raw)
|
|
40
|
+
initialize_attributes(raw)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def initialize_attributes(raw)
|
|
44
|
+
write_attribute(:interface, raw)
|
|
45
|
+
|
|
46
|
+
load_interface_attributes(interface)
|
|
47
|
+
existing_record!
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def added_to_relationship(proxy)
|
|
51
|
+
write_attribute(:parent, proxy.parent)
|
|
52
|
+
write_attribute(:parent_collection, proxy)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def save
|
|
56
|
+
configs = [:ip_address, :network_mask, :lower_ip, :upper_ip]
|
|
57
|
+
configs_changed = configs.map { |key| changed?(key) }.any? { |i| i }
|
|
58
|
+
|
|
59
|
+
if configs_changed
|
|
60
|
+
interface.set_configuration(ip_address, network_mask, lower_ip, upper_ip)
|
|
61
|
+
|
|
62
|
+
# Clear the dirtiness so that the abstract model doesn't try
|
|
63
|
+
# to save the attributes
|
|
64
|
+
configs.each do |key|
|
|
65
|
+
clear_dirty!(key)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
save_changed_interface_attributes(interface)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Removes the DHCP server.
|
|
73
|
+
def destroy
|
|
74
|
+
parent.lib.virtualbox.remove_dhcp_server(interface)
|
|
75
|
+
parent_collection.delete(self, true)
|
|
76
|
+
true
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Returns the host network associated with this DHCP server, if it
|
|
80
|
+
# exists.
|
|
81
|
+
def host_network
|
|
82
|
+
return nil unless network_name =~ /^HostInterfaceNetworking-(.+?)$/
|
|
83
|
+
|
|
84
|
+
parent.host.network_interfaces.detect do |i|
|
|
85
|
+
i.interface_type == :host_only && i.name == $1.to_s
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module VirtualBox
|
|
2
|
+
# Represents a DVD image stored by VirtualBox. These DVD images can be
|
|
3
|
+
# mounted onto virtual machines. Because DVD just inherits from {Medium},
|
|
4
|
+
# it also inherits all methods and attributes which are on {Medium}. For more
|
|
5
|
+
# attributes, the ability to destroy, etc, please view {Medium}.
|
|
6
|
+
#
|
|
7
|
+
# # Finding all DVDs
|
|
8
|
+
#
|
|
9
|
+
# The only method at the moment of finding DVDs is to use {DVD.all}, which
|
|
10
|
+
# returns an array of {DVD}s.
|
|
11
|
+
#
|
|
12
|
+
# DVD.all
|
|
13
|
+
#
|
|
14
|
+
class DVD < Medium
|
|
15
|
+
class << self
|
|
16
|
+
# Returns an array of all available DVDs as DVD objects
|
|
17
|
+
def all
|
|
18
|
+
Global.global.media.dvds
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Override of {Medium.device_type}.
|
|
22
|
+
def device_type
|
|
23
|
+
:dvd
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module VirtualBox
|
|
2
|
+
# Gem specific exceptions will reside under this namespace for easy
|
|
3
|
+
# documentation and searching.
|
|
4
|
+
module Exceptions
|
|
5
|
+
class Exception < ::Exception; end
|
|
6
|
+
|
|
7
|
+
class NonSettableRelationshipException < Exception; end
|
|
8
|
+
class ValidationFailedException < Exception; end
|
|
9
|
+
class MediumLocationInUseException < Exception; end
|
|
10
|
+
class MediumCreationFailedException < Exception; end
|
|
11
|
+
class MediumNotUpdatableException < Exception; end
|
|
12
|
+
class ReadonlyVMStateException < Exception; end
|
|
13
|
+
class UnsupportedVersionException < Exception; end
|
|
14
|
+
|
|
15
|
+
class FFIException < Exception
|
|
16
|
+
attr_accessor :data
|
|
17
|
+
|
|
18
|
+
def initialize(data={})
|
|
19
|
+
@data = data
|
|
20
|
+
super("Error in API call to #{data[:function]}: #{data[:result_code]}")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# FFI Exceptions, these exceptions are only raised on *nix machines
|
|
25
|
+
# when some error occurs in the foreign function interface.
|
|
26
|
+
class ObjectNotFoundException < FFIException; end
|
|
27
|
+
class InvalidVMStateException < FFIException; end
|
|
28
|
+
class VMErrorException < FFIException; end
|
|
29
|
+
class FileErrorException < FFIException; end
|
|
30
|
+
class SubsystemException < FFIException; end
|
|
31
|
+
class PDMException < FFIException; end
|
|
32
|
+
class InvalidObjectStateException < FFIException; end
|
|
33
|
+
class HostErrorException < FFIException; end
|
|
34
|
+
class NotSupportedException < FFIException; end
|
|
35
|
+
class XMLErrorException < FFIException; end
|
|
36
|
+
class InvalidSessionStateException < FFIException; end
|
|
37
|
+
class ObjectInUseException < FFIException; end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module VirtualBox::ByteNormalizer
|
|
2
|
+
# So that this is only defined once (suppress warnings)
|
|
3
|
+
if !defined?(THOUSAND)
|
|
4
|
+
THOUSAND = 1024.0
|
|
5
|
+
BYTE = 1.0
|
|
6
|
+
KILOBYTE = BYTE * THOUSAND
|
|
7
|
+
MEGABYTE = KILOBYTE * THOUSAND
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def bytes_to_megabytes(b)
|
|
11
|
+
b / MEGABYTE
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def megabytes_to_bytes(mb)
|
|
15
|
+
mb * MEGABYTE
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module VirtualBox
|
|
2
|
+
# Eases the processes of loading specific files then globbing
|
|
3
|
+
# the rest from a specified directory.
|
|
4
|
+
module GlobLoader
|
|
5
|
+
# Glob requires all ruby files in a directory, optionally loading select
|
|
6
|
+
# files initially (since others may depend on them).
|
|
7
|
+
#
|
|
8
|
+
# @param [String] dir The directory to glob
|
|
9
|
+
# @param [Array<String>] initial_files Initial files (relative to `dir`)
|
|
10
|
+
# to load
|
|
11
|
+
def self.glob_require(dir, initial_files=[])
|
|
12
|
+
initial_files.each do |file|
|
|
13
|
+
require File.expand_path(file, dir)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Glob require the rest
|
|
17
|
+
Dir[File.join(dir, "**", "*.rb")].each do |f|
|
|
18
|
+
require File.expand_path(f)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'logger'
|
|
2
|
+
|
|
3
|
+
module VirtualBox
|
|
4
|
+
# Provides logger functionality for VirtualBox. This class is available on most
|
|
5
|
+
# VirtualBox classes through mixins. To access the logger, simply call the {logger}
|
|
6
|
+
# method. This returns a standard Ruby logger which can be modified.
|
|
7
|
+
module Logger
|
|
8
|
+
@@logger = nil
|
|
9
|
+
@@logger_output = nil
|
|
10
|
+
|
|
11
|
+
# Make the logger available both on a class and instance level
|
|
12
|
+
# once included.
|
|
13
|
+
def self.included(base)
|
|
14
|
+
base.extend self
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Sets up the output stream for the logger. This should be called before any
|
|
18
|
+
# calls to {logger}. If the logger has already been instantiated, then a new
|
|
19
|
+
# logger will be created on the next call with the new output setup.
|
|
20
|
+
def logger_output=(value)
|
|
21
|
+
@@logger_output = value
|
|
22
|
+
@@logger = nil
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Accesses the logger. If logger output is specified and this is the first load,
|
|
26
|
+
# then the logger will be properly setup to point to that output. Logging
|
|
27
|
+
# levels should also be set once the logger is created. The logger is a standard
|
|
28
|
+
# Ruby `Logger`.
|
|
29
|
+
#
|
|
30
|
+
# The VirtualBox gem can get very verybose very quickly, so choose a log level
|
|
31
|
+
# which suits the granularity needed.
|
|
32
|
+
#
|
|
33
|
+
# @return [Logger]
|
|
34
|
+
def logger
|
|
35
|
+
@@logger ||= ::Logger.new(@@logger_output)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'rbconfig'
|
|
2
|
+
|
|
3
|
+
module VirtualBox
|
|
4
|
+
class Platform
|
|
5
|
+
class << self
|
|
6
|
+
def mac?
|
|
7
|
+
platform.include?("darwin")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def windows?
|
|
11
|
+
platform.include?("mswin") || platform.include?("mingw") || platform.include?("cygwin")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def linux?
|
|
15
|
+
platform.include?("linux")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def solaris?
|
|
19
|
+
platform.include?("solaris")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def platform
|
|
23
|
+
RbConfig::CONFIG["target_os"].downcase
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# From: http://snippets.dzone.com/posts/show/2992
|
|
2
|
+
module VirtualBox::SubclassListing
|
|
3
|
+
def self.included(base)
|
|
4
|
+
base.extend ClassMethods
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
module ClassMethods
|
|
8
|
+
def subclasses(direct = false)
|
|
9
|
+
classes = []
|
|
10
|
+
if direct
|
|
11
|
+
ObjectSpace.each_object(Class) do |c|
|
|
12
|
+
next unless c.superclass == self
|
|
13
|
+
classes << c
|
|
14
|
+
end
|
|
15
|
+
else
|
|
16
|
+
ObjectSpace.each_object(Class) do |c|
|
|
17
|
+
next unless c.ancestors.include?(self) and (c != self)
|
|
18
|
+
classes << c
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
classes
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
module VirtualBox
|
|
2
|
+
# Represents "extra data" which can be set on a specific
|
|
3
|
+
# virtual machine or on VirtualBox as a whole. Extra data is persistent
|
|
4
|
+
# key-value storage which is available as a way to store any information
|
|
5
|
+
# wanted. VirtualBox uses it for storing statistics and settings. You can
|
|
6
|
+
# use it for anything!
|
|
7
|
+
#
|
|
8
|
+
# # Extra Data on a Virtual Machine
|
|
9
|
+
#
|
|
10
|
+
# Setting extra data on a virtual machine is easy. All {VM} objects have a
|
|
11
|
+
# `extra_data` relationship which is just a simple ruby hash, so you can treat
|
|
12
|
+
# it like one! Once the data is set, simply saving the VM will save the
|
|
13
|
+
# extra data. An example below:
|
|
14
|
+
#
|
|
15
|
+
# vm = VirtualBox::VM.find("FooVM")
|
|
16
|
+
# vm.extra_data["ruby-accessed"] = "yes, yes it was"
|
|
17
|
+
# vm.save
|
|
18
|
+
#
|
|
19
|
+
# Now, let's say you open up the VM again some other time:
|
|
20
|
+
#
|
|
21
|
+
# vm = VirtualBox::VM.find("FooVM")
|
|
22
|
+
# puts vm.extra_data["ruby-accessed"]
|
|
23
|
+
#
|
|
24
|
+
# It acts just like a hash!
|
|
25
|
+
#
|
|
26
|
+
# # Global Extra Data
|
|
27
|
+
#
|
|
28
|
+
# Extra data doesn't need to be tied to a specific virtual machine. It can also
|
|
29
|
+
# exist globally. Setting global extra-data is just as easy:
|
|
30
|
+
#
|
|
31
|
+
# VirtualBox::ExtraData.global["some-key"] = "some value"
|
|
32
|
+
# VirtualBox::ExtraData.global.save
|
|
33
|
+
#
|
|
34
|
+
class ExtraData < Hash
|
|
35
|
+
include AbstractModel::Dirty
|
|
36
|
+
|
|
37
|
+
attr_accessor :parent
|
|
38
|
+
attr_reader :interface
|
|
39
|
+
|
|
40
|
+
@@global_data = nil
|
|
41
|
+
|
|
42
|
+
class << self
|
|
43
|
+
# Gets the global extra data. This will "cache" the data for
|
|
44
|
+
# future use unless you set the `reload` paramter to true.
|
|
45
|
+
#
|
|
46
|
+
# @param [Boolean] reload If true, will reload new global data.
|
|
47
|
+
# @return [Array<ExtraData>]
|
|
48
|
+
def global(reload=false)
|
|
49
|
+
if !@@global_data || reload
|
|
50
|
+
@@global_data = Global.global.extra_data
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
@@global_data
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Populates a relationship with another model.
|
|
57
|
+
#
|
|
58
|
+
# **This method typically won't be used except internally.**
|
|
59
|
+
#
|
|
60
|
+
# @return [Array<ExtraData>]
|
|
61
|
+
def populate_relationship(caller, interface)
|
|
62
|
+
data = new(caller, interface)
|
|
63
|
+
|
|
64
|
+
interface.get_extra_data_keys.each do |key|
|
|
65
|
+
data[key] = interface.get_extra_data(key)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
data.clear_dirty!
|
|
69
|
+
data
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Saves the relationship. This simply calls {#save} on every
|
|
73
|
+
# member of the relationship.
|
|
74
|
+
#
|
|
75
|
+
# **This method typically won't be used except internally.**
|
|
76
|
+
def save_relationship(caller, data)
|
|
77
|
+
data.save
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Initializes an extra data object.
|
|
82
|
+
#
|
|
83
|
+
# @param [Hash] data Initial attributes to populate.
|
|
84
|
+
def initialize(parent, interface)
|
|
85
|
+
@parent = parent
|
|
86
|
+
@interface = interface
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Set an extradata key-value pair. Overrides ruby hash implementation
|
|
90
|
+
# to set dirty state. Otherwise that, behaves the same way.
|
|
91
|
+
def []=(key,value)
|
|
92
|
+
set_dirty!(key, self[key], value)
|
|
93
|
+
super
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Saves extra data. This method does the same thing for both new
|
|
97
|
+
# and existing extra data, since virtualbox will overwrite old data or
|
|
98
|
+
# create it if it doesn't exist.
|
|
99
|
+
#
|
|
100
|
+
# @param [Boolean] raise_errors If true, {Exceptions::CommandFailedException}
|
|
101
|
+
# will be raised if the command failed.
|
|
102
|
+
# @return [Boolean] True if command was successful, false otherwise.
|
|
103
|
+
def save
|
|
104
|
+
changes.each do |key, value|
|
|
105
|
+
interface.set_extra_data(key.to_s, value[1].to_s)
|
|
106
|
+
|
|
107
|
+
clear_dirty!(key)
|
|
108
|
+
|
|
109
|
+
if value[1].nil?
|
|
110
|
+
# Remove the key from the hash altogether
|
|
111
|
+
hash_delete(key.to_s)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Alias away the old delete method so its still accessible somehow
|
|
117
|
+
alias :hash_delete :delete
|
|
118
|
+
|
|
119
|
+
# Deletes the specified extra data.
|
|
120
|
+
#
|
|
121
|
+
# @param [String] key The extra data key to delete
|
|
122
|
+
def delete(key)
|
|
123
|
+
interface.set_extra_data(key.to_s, nil)
|
|
124
|
+
hash_delete(key.to_s)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|