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,35 @@
|
|
|
1
|
+
Feature: VM Extra Data
|
|
2
|
+
As a virtualbox library user
|
|
3
|
+
I want to access and update VM extra data
|
|
4
|
+
|
|
5
|
+
Background:
|
|
6
|
+
Given I find a VM identified by "test_vm_A"
|
|
7
|
+
And I delete the "VM" extra data "VirtualBoxGemTest/Key"
|
|
8
|
+
And I reload the VM
|
|
9
|
+
And the "extra_data" relationship
|
|
10
|
+
|
|
11
|
+
Scenario: Reading extra data
|
|
12
|
+
When I get the extra data of "test_vm_A"
|
|
13
|
+
Then all the extra data should match
|
|
14
|
+
|
|
15
|
+
@unsafe
|
|
16
|
+
Scenario: Writing extra data
|
|
17
|
+
When I set the extra data "VirtualBoxGemTest/Key" to "Value"
|
|
18
|
+
And I save the relationship
|
|
19
|
+
And I get the extra data of "test_vm_A"
|
|
20
|
+
Then the extra data should include "VirtualBoxGemTest/Key" as "Value"
|
|
21
|
+
|
|
22
|
+
@unsafe
|
|
23
|
+
Scenario: Deleting extra data
|
|
24
|
+
When I set the extra data "VirtualBoxGemTest/Key" to "Value"
|
|
25
|
+
And I save the relationship
|
|
26
|
+
And I delete the extra data "VirtualBoxGemTest/Key"
|
|
27
|
+
And I get the extra data of "test_vm_A"
|
|
28
|
+
Then the extra data should not include "VirtualBoxGemTest/Key"
|
|
29
|
+
|
|
30
|
+
@unsafe
|
|
31
|
+
Scenario: Writing extra data and saving VM
|
|
32
|
+
When I set the extra data "VirtualBoxGemTest/Key" to "Value"
|
|
33
|
+
And I save the model
|
|
34
|
+
And I get the extra data of "test_vm_A"
|
|
35
|
+
Then the extra data should include "VirtualBoxGemTest/Key" as "Value"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Feature: Virtual Machine HW Virtualization
|
|
2
|
+
As a virtualbox library user
|
|
3
|
+
I want to read and update HW Virtualization settings
|
|
4
|
+
|
|
5
|
+
Background:
|
|
6
|
+
Given I find a VM identified by "test_vm_A"
|
|
7
|
+
And I set the VM properties:
|
|
8
|
+
| name | value |
|
|
9
|
+
| hwvirtex | on |
|
|
10
|
+
| nestedpaging | on |
|
|
11
|
+
And I reload the VM
|
|
12
|
+
And the "hw_virt" relationship
|
|
13
|
+
|
|
14
|
+
Scenario: Reading
|
|
15
|
+
Then the "HW virt" properties should match
|
|
16
|
+
|
|
17
|
+
@unsafe
|
|
18
|
+
Scenario: Updating
|
|
19
|
+
When I set the relationship property "enabled" to "false"
|
|
20
|
+
And I save the relationship
|
|
21
|
+
And I reload the VM info
|
|
22
|
+
Then the "HW virt" properties should match
|
|
23
|
+
|
|
24
|
+
@unsafe
|
|
25
|
+
Scenario: Updating and saving via VM
|
|
26
|
+
When I set the relationship property "nested_paging" to "false"
|
|
27
|
+
And I save the model
|
|
28
|
+
And I reload the VM info
|
|
29
|
+
Then the "HW virt" properties should match
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Feature: Virtual Machine NAT Engine
|
|
2
|
+
As a virtualbox library user
|
|
3
|
+
I want to read and update the NAT engine on a network adapter
|
|
4
|
+
|
|
5
|
+
Background:
|
|
6
|
+
Given I find a VM identified by "test_vm_A"
|
|
7
|
+
And the forwarded ports are cleared
|
|
8
|
+
And the adapters are reset
|
|
9
|
+
And the following adapters are set:
|
|
10
|
+
| slot | type |
|
|
11
|
+
| 1 | nat |
|
|
12
|
+
And the "network_adapters" relationship
|
|
13
|
+
And the "nat_driver" relationship on collection item "1"
|
|
14
|
+
|
|
15
|
+
Scenario: Reading the NAT engine
|
|
16
|
+
Then the NAT network should exist
|
|
17
|
+
|
|
18
|
+
@unsafe
|
|
19
|
+
Scenario: Reading Forwarded Ports
|
|
20
|
+
Given I read the adapter in slot "1"
|
|
21
|
+
And I create a forwarded port named "ssh" from "22" to "2222" via VBoxManage
|
|
22
|
+
And I reload the VM
|
|
23
|
+
And I read the adapter in slot "1"
|
|
24
|
+
Then the forwarded port "ssh" should exist
|
|
25
|
+
And the forwarded ports should match
|
|
26
|
+
|
|
27
|
+
@unsafe
|
|
28
|
+
Scenario: Creating Forwarded Ports
|
|
29
|
+
Given I read the adapter in slot "1"
|
|
30
|
+
When I create a forwarded port named "ssh" from "22" to "2222"
|
|
31
|
+
And I save the relationship
|
|
32
|
+
And I reload the VM info
|
|
33
|
+
Then the forwarded port "ssh" should exist
|
|
34
|
+
And the forwarded ports should match
|
|
35
|
+
|
|
36
|
+
@unsafe
|
|
37
|
+
Scenario: Updating Forwarded Ports
|
|
38
|
+
Given I read the adapter in slot "1"
|
|
39
|
+
And I create a forwarded port named "ssh" from "22" to "2222" via VBoxManage
|
|
40
|
+
And I reload the VM
|
|
41
|
+
And I read the adapter in slot "1"
|
|
42
|
+
When I update the forwarded port named "ssh":
|
|
43
|
+
| attribute | value |
|
|
44
|
+
| hostport | 3333 |
|
|
45
|
+
And I save the relationship
|
|
46
|
+
And I reload the VM info
|
|
47
|
+
Then the forwarded ports should match
|
|
48
|
+
|
|
49
|
+
@unsafe
|
|
50
|
+
Scenario: Deleting Forwarded Ports
|
|
51
|
+
Given I read the adapter in slot "1"
|
|
52
|
+
And I create a forwarded port named "ssh" from "22" to "2222" via VBoxManage
|
|
53
|
+
And I reload the VM
|
|
54
|
+
And I read the adapter in slot "1"
|
|
55
|
+
When I delete the forwarded port named "ssh"
|
|
56
|
+
And I reload the VM info
|
|
57
|
+
Then the forwarded port "ssh" should not exist
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Feature: Virtual Machine Network Adapters
|
|
2
|
+
As a virtualbox library user
|
|
3
|
+
I want to read and update network adapters
|
|
4
|
+
|
|
5
|
+
Background:
|
|
6
|
+
Given I find a VM identified by "test_vm_A"
|
|
7
|
+
And the "network_adapters" relationship
|
|
8
|
+
|
|
9
|
+
@unsafe
|
|
10
|
+
Scenario: Reading adapters
|
|
11
|
+
Given the adapters are reset
|
|
12
|
+
And the following adapters are set:
|
|
13
|
+
| slot | type |
|
|
14
|
+
| 1 | nat |
|
|
15
|
+
Then the network adapter properties should match
|
|
16
|
+
|
|
17
|
+
@unsafe
|
|
18
|
+
Scenario: Updating adapters
|
|
19
|
+
Given the adapters are reset
|
|
20
|
+
And the following adapters are set:
|
|
21
|
+
| slot | type |
|
|
22
|
+
| 1 | nat |
|
|
23
|
+
When I update the adapter in slot "1"
|
|
24
|
+
And I set the property "cable_connected" to "false"
|
|
25
|
+
And I save the VM
|
|
26
|
+
And I reload the VM info
|
|
27
|
+
Then the network adapter properties should match
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Feature: Virtual Machine Shared Folders
|
|
2
|
+
As a virtualbox library user
|
|
3
|
+
I want to read and update shared folders
|
|
4
|
+
|
|
5
|
+
Background:
|
|
6
|
+
Given I find a VM identified by "test_vm_A"
|
|
7
|
+
And I remove all shared folders
|
|
8
|
+
And I reload the VM
|
|
9
|
+
And the "shared_folders" relationship
|
|
10
|
+
|
|
11
|
+
@unsafe
|
|
12
|
+
Scenario: Reading Shared Folders
|
|
13
|
+
Given a shared folder "foo" exists
|
|
14
|
+
Then the shared folder properties should match
|
|
15
|
+
|
|
16
|
+
@unsafe
|
|
17
|
+
Scenario: Creating Shared Folders
|
|
18
|
+
Given no shared folder "bar" exists
|
|
19
|
+
When I create a new shared folder "bar" with path "/baz"
|
|
20
|
+
And I add the new record to the relationship
|
|
21
|
+
And I save the model
|
|
22
|
+
And I reload the VM info
|
|
23
|
+
Then the shared folder "bar" should exist
|
|
24
|
+
Then the shared folder properties should match
|
|
25
|
+
|
|
26
|
+
@unsafe
|
|
27
|
+
Scenario: Updating Shared Folders
|
|
28
|
+
Given a shared folder "foo" exists
|
|
29
|
+
When I update the shared folder named "foo":
|
|
30
|
+
| attribute | value |
|
|
31
|
+
| host_path | /new_path |
|
|
32
|
+
And I save the model
|
|
33
|
+
And I reload the VM info
|
|
34
|
+
Then the shared folder properties should match
|
|
35
|
+
|
|
36
|
+
@unsafe
|
|
37
|
+
Scenario: Deleting Shared Folders
|
|
38
|
+
Given a shared folder "foo" exists
|
|
39
|
+
When I delete the shared folder "foo"
|
|
40
|
+
And I reload the VM info
|
|
41
|
+
Then the shared folder "foo" should not exist
|
|
42
|
+
Then the shared folder properties should match
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Feature: Virtual Machine Snapshots
|
|
2
|
+
As a virtualbox library user
|
|
3
|
+
I want to manage a VM's snapshots
|
|
4
|
+
|
|
5
|
+
Background:
|
|
6
|
+
Given I find a VM identified by "test_vm_A"
|
|
7
|
+
And the snapshots are cleared
|
|
8
|
+
And the "current_snapshot" relationship
|
|
9
|
+
|
|
10
|
+
Scenario: Reading the snapshots
|
|
11
|
+
Given the following snapshot tree is created:
|
|
12
|
+
| key | children |
|
|
13
|
+
| foo | bar,baz |
|
|
14
|
+
| bar | bar1,bar2 |
|
|
15
|
+
And I reload the VM
|
|
16
|
+
Then the snapshots should match
|
|
17
|
+
|
|
18
|
+
Scenario: Taking a snapshot
|
|
19
|
+
When I take a snapshot "foo"
|
|
20
|
+
And I reload the VM info
|
|
21
|
+
Then the snapshot "foo" should exist
|
|
22
|
+
|
|
23
|
+
Scenario: Deleting a snapshot
|
|
24
|
+
Given the snapshot "foo" is created
|
|
25
|
+
And I reload the VM
|
|
26
|
+
When I find the snapshot named "foo"
|
|
27
|
+
And I destroy the snapshot
|
|
28
|
+
And I reload the VM info
|
|
29
|
+
Then the snapshot "foo" should not exist
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Feature: Virtual Machine Storage Controllers
|
|
2
|
+
As a virtualbox library user
|
|
3
|
+
I want to read and update storage controllers on a VM
|
|
4
|
+
|
|
5
|
+
Background:
|
|
6
|
+
Given I find a VM identified by "test_vm_A"
|
|
7
|
+
And the "storage_controllers" relationship
|
|
8
|
+
|
|
9
|
+
Scenario: Reading Storage Controllers
|
|
10
|
+
Then the number of storage controllers should match
|
|
11
|
+
And the storage controller properties should match
|
data/lib/virtualbox.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Load the glob loader, which will handle the loading of all the other files
|
|
2
|
+
libdir = File.join(File.dirname(__FILE__), "virtualbox")
|
|
3
|
+
require File.expand_path("ext/glob_loader", libdir)
|
|
4
|
+
|
|
5
|
+
# Load them up
|
|
6
|
+
VirtualBox::GlobLoader.glob_require(libdir, %w{ext/logger ext/platform ext/subclass_listing ext/byte_normalizer com abstract_model medium})
|
|
7
|
+
|
|
8
|
+
# Setup the top-level module methods
|
|
9
|
+
module VirtualBox
|
|
10
|
+
extend Version
|
|
11
|
+
end
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
['abstract_model/attributable',
|
|
2
|
+
'abstract_model/interface_attributes',
|
|
3
|
+
'abstract_model/dirty',
|
|
4
|
+
'abstract_model/relatable',
|
|
5
|
+
'abstract_model/validatable'].each do |lib|
|
|
6
|
+
require File.expand_path(lib, File.dirname(__FILE__))
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
module VirtualBox
|
|
10
|
+
# AbstractModel is the base class used for most of virtualbox's classes.
|
|
11
|
+
# It provides convenient ActiveRecord-style model behavior to subclasses.
|
|
12
|
+
#
|
|
13
|
+
# @abstract
|
|
14
|
+
class AbstractModel
|
|
15
|
+
include Logger
|
|
16
|
+
|
|
17
|
+
include Attributable
|
|
18
|
+
include InterfaceAttributes
|
|
19
|
+
include Dirty
|
|
20
|
+
include Relatable
|
|
21
|
+
include Validatable
|
|
22
|
+
|
|
23
|
+
class << self
|
|
24
|
+
# Returns whether or not the class should be reloaded.
|
|
25
|
+
#
|
|
26
|
+
# @return [Boolean]
|
|
27
|
+
def reload?
|
|
28
|
+
!!@_reload
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def reload!
|
|
32
|
+
@_reload = true
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def reloaded!
|
|
36
|
+
@_reload = false
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Default errors for relationship implementation, since this is
|
|
40
|
+
# a pretty stable method.
|
|
41
|
+
def errors_for_relationship(caller, data)
|
|
42
|
+
return data.errors if data.respond_to?(:errors)
|
|
43
|
+
nil
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Signals to the class that it should be reloaded. This simply toggles
|
|
48
|
+
# a boolean value to true. It is up to the subclass to implement functionality
|
|
49
|
+
# around it. See {reload?}
|
|
50
|
+
def reload!
|
|
51
|
+
self.class.reload!
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Returns a boolean denoting if the record is new or existing. This
|
|
55
|
+
# method is provided for subclasses to use to differentiate between
|
|
56
|
+
# creating a new object or saving an existing one. An example of this
|
|
57
|
+
# is {HardDrive#save} which will create a new hard drive if it didn't
|
|
58
|
+
# previously exist, or save an old one if it did exist.
|
|
59
|
+
def new_record?
|
|
60
|
+
new_record! if !defined?(@new_record) || @new_record.nil?
|
|
61
|
+
@new_record
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Explicitly resets the model to a new record. If you're using this
|
|
65
|
+
# method outside of virtualbox library core, you should really be
|
|
66
|
+
# asking yourself "why?"
|
|
67
|
+
def new_record!
|
|
68
|
+
@new_record = true
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Explicitly sets the model to not be a new record. If you're using
|
|
72
|
+
# this method outside of virtualbox library core, you should really
|
|
73
|
+
# be asking yourself "why?"
|
|
74
|
+
def existing_record!
|
|
75
|
+
@new_record = false
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Returns the errors for a model.
|
|
79
|
+
def errors
|
|
80
|
+
self.class.relationships.inject(super) do |acc, data|
|
|
81
|
+
name, options = data
|
|
82
|
+
|
|
83
|
+
if options && options[:klass].respond_to?(:errors_for_relationship)
|
|
84
|
+
errors = options[:klass].errors_for_relationship(self, relationship_data[name])
|
|
85
|
+
acc.merge!(name => errors) if errors && !errors.empty?
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
acc
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Validates the model and relationships.
|
|
93
|
+
def validate(*args)
|
|
94
|
+
# First clear all previous errors
|
|
95
|
+
clear_errors
|
|
96
|
+
|
|
97
|
+
# Then do the validations
|
|
98
|
+
failed = false
|
|
99
|
+
self.class.relationships.each do |name, options|
|
|
100
|
+
next unless options && options[:klass].respond_to?(:validate_relationship)
|
|
101
|
+
failed = true if !options[:klass].validate_relationship(self, relationship_data[name], *args)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
return !failed
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Saves the model attributes and relationships.
|
|
108
|
+
#
|
|
109
|
+
# The method can be passed any arbitrary arguments, which are
|
|
110
|
+
# implementation specific (see {VM#save}, which does this).
|
|
111
|
+
def save(*args)
|
|
112
|
+
# Go through changed attributes and call save_attribute for
|
|
113
|
+
# those only
|
|
114
|
+
changes.each do |key, values|
|
|
115
|
+
save_attribute(key, values[1], *args)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Go through and only save the loaded relationships, since
|
|
119
|
+
# only those would be modified.
|
|
120
|
+
self.class.relationships.each do |name, options|
|
|
121
|
+
save_relationship(name, *args)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# No longer a new record
|
|
125
|
+
@new_record = false
|
|
126
|
+
|
|
127
|
+
true
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Saves the model and raises an {Exceptions::ValidationFailedException}
|
|
131
|
+
# if the model is invalid, instead of returning false.
|
|
132
|
+
def save!(*args)
|
|
133
|
+
raise Exceptions::ValidationFailedException.new(errors.inspect) if !save(*args)
|
|
134
|
+
true
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Saves a single attribute of the model. This method on the abstract
|
|
138
|
+
# model does nothing on its own, and is expected to be overridden
|
|
139
|
+
# by any subclasses.
|
|
140
|
+
#
|
|
141
|
+
# This method clears the dirty status of the attribute.
|
|
142
|
+
def save_attribute(key, value, *args)
|
|
143
|
+
clear_dirty!(key)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Saves only changed interface attributes.
|
|
147
|
+
def save_changed_interface_attributes(interface)
|
|
148
|
+
changes.each do |key, values|
|
|
149
|
+
save_interface_attribute(key, interface)
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Overrides {InterfaceAttributes.save_interface_attribute} to clear the
|
|
154
|
+
# dirty state of the attribute.
|
|
155
|
+
def save_interface_attribute(key, interface)
|
|
156
|
+
super
|
|
157
|
+
clear_dirty!(key)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Overriding {Attributable#lazy_attribute?} to always return false for
|
|
161
|
+
# new records, since new records shouldn't load lazy data.
|
|
162
|
+
def lazy_attribute?(*args)
|
|
163
|
+
return false if new_record?
|
|
164
|
+
super
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Overriding {Relatable#lazy_relationship?} to always return false for
|
|
168
|
+
# new records, since new records shouldn't load lazy data.
|
|
169
|
+
def lazy_relationship?(*args)
|
|
170
|
+
return false if new_record?
|
|
171
|
+
super
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Sets the initial attributes from a hash. This method is meant to be used
|
|
175
|
+
# once to initially setup the attributes. It is **not a mass-assignment**
|
|
176
|
+
# method for updating attributes.
|
|
177
|
+
#
|
|
178
|
+
# This method does **not** affect dirtiness, but also does not clear it.
|
|
179
|
+
# This means that if you call populate_attributes, the same attributes
|
|
180
|
+
# that were dirty before the call will be dirty after the call (but no
|
|
181
|
+
# more and no less). This distinction is important because most subclasses
|
|
182
|
+
# of AbstractModel only save changed attributes, and ignore unchanged
|
|
183
|
+
# attributes. Attempting to change attributes through this method will
|
|
184
|
+
# cause them to not be saved, which is surely unexpected behaviour for
|
|
185
|
+
# most users.
|
|
186
|
+
#
|
|
187
|
+
# Calling this method will also cause the model to assume that it is not
|
|
188
|
+
# a new record (see {#new_record?}).
|
|
189
|
+
def populate_attributes(attribs, opts={})
|
|
190
|
+
ignore_dirty do
|
|
191
|
+
super(attribs)
|
|
192
|
+
|
|
193
|
+
populate_relationships(attribs) unless opts[:ignore_relationships]
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# No longer a new record
|
|
197
|
+
existing_record!
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# Loads and populates the relationships with the given data. This method
|
|
201
|
+
# is meant to be used once to initially setup the relatoinships.
|
|
202
|
+
#
|
|
203
|
+
# This methods does **not** affect dirtiness, but also does not clear it.
|
|
204
|
+
#
|
|
205
|
+
# Calling this method will also cuase the model to assume that it is not
|
|
206
|
+
# a new record (see {#new_record?})
|
|
207
|
+
def populate_relationships(data)
|
|
208
|
+
existing_record!
|
|
209
|
+
ignore_dirty { super }
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Populates a single relationship with the given data.
|
|
213
|
+
def populate_relationship(name, data)
|
|
214
|
+
existing_record!
|
|
215
|
+
ignore_dirty { super }
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Overwrites {Attributable#write_attribute} to set the dirty state of
|
|
219
|
+
# the written attribute. See {Dirty#set_dirty!} as well.
|
|
220
|
+
def write_attribute(name, value)
|
|
221
|
+
set_dirty!(name, read_attribute(name), value) unless lazy_attribute?(name) && !loaded_attribute?(name)
|
|
222
|
+
super
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Overwrites {Relatable#set_relationship} to set the dirty state of the
|
|
226
|
+
# relationship. See {Dirty#set_dirty!} as well.
|
|
227
|
+
def set_relationship(key, value)
|
|
228
|
+
existing = relationship_data[key]
|
|
229
|
+
new_value = super
|
|
230
|
+
set_dirty!(key, existing, new_value)
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Destroys the model. The exact behaviour of this method is expected to be
|
|
234
|
+
# defined on the subclasses. This method on AbstractModel simply
|
|
235
|
+
# propagates the destroy to the dependent relationships. For more information
|
|
236
|
+
# on relationships, see {Relatable}.
|
|
237
|
+
def destroy(*args)
|
|
238
|
+
# Destroy dependent relationships
|
|
239
|
+
self.class.relationships.each do |name, options|
|
|
240
|
+
destroy_relationship(name, *args) if options[:dependent] == :destroy
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
# Gets the root machine of an AbstractModel by traversing a
|
|
245
|
+
# `parent` attribute until it reaches a type of {VM}.
|
|
246
|
+
#
|
|
247
|
+
# @return [VM]
|
|
248
|
+
def parent_machine
|
|
249
|
+
current = parent
|
|
250
|
+
current = current.parent while current && !current.is_a?(VM)
|
|
251
|
+
current
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# Creates a human-readable format for this model. This method overrides the
|
|
255
|
+
# default `#<class>` syntax since this doesn't work well for AbstractModels.
|
|
256
|
+
# Instead, it abbreviates it, instead showing all the attributes and their
|
|
257
|
+
# values, and `...` for relationships. For attributes which are themselves
|
|
258
|
+
# AbstractModels, it shows the class name to avoid extremely verbose inspections
|
|
259
|
+
# and infinite loops.
|
|
260
|
+
def inspect
|
|
261
|
+
values = []
|
|
262
|
+
|
|
263
|
+
self.class.attributes.each do |name, options|
|
|
264
|
+
value = read_attribute(name)
|
|
265
|
+
value = if value.is_a?(AbstractModel) || value.is_a?(COM::AbstractInterface) || value.is_a?(Proxies::Collection)
|
|
266
|
+
"#<#{value.class.name}>"
|
|
267
|
+
else
|
|
268
|
+
value.inspect
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
values.push("#{name.inspect}=#{value}")
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
self.class.relationships.each do |name, options|
|
|
275
|
+
values.push("#{name.inspect}=...")
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
"#<#{self.class} #{values.sort.join(", ")}>".strip
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
end
|