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
data/test/virtualbox/vm_test.rb
CHANGED
@@ -78,7 +78,35 @@ class VMTest < Test::Unit::TestCase
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
context "populating
|
81
|
+
context "populating relationships" do
|
82
|
+
setup do
|
83
|
+
@caller = mock("caller")
|
84
|
+
end
|
85
|
+
|
86
|
+
should "call populate_array_relationship for arrays" do
|
87
|
+
@klass.expects(:populate_array_relationship).with(@caller, []).once
|
88
|
+
@klass.populate_relationship(@caller, [])
|
89
|
+
end
|
90
|
+
|
91
|
+
should "call populate_single_relationship for non-arrays" do
|
92
|
+
@klass.expects(:populate_single_relationship).with(@caller, nil).once
|
93
|
+
@klass.populate_relationship(@caller, nil)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context "populating single relationships" do
|
98
|
+
setup do
|
99
|
+
@machine = mock("interface")
|
100
|
+
end
|
101
|
+
|
102
|
+
should "return a new machine" do
|
103
|
+
result = mock("result")
|
104
|
+
@klass.expects(:new).with(@machine).returns(result)
|
105
|
+
assert_equal result, @klass.populate_single_relationship(nil, @machine)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "populating array relationship" do
|
82
110
|
setup do
|
83
111
|
@instance = mock("instance")
|
84
112
|
|
@@ -86,7 +114,7 @@ class VMTest < Test::Unit::TestCase
|
|
86
114
|
end
|
87
115
|
|
88
116
|
should "return a proxied collection" do
|
89
|
-
result = @klass.
|
117
|
+
result = @klass.populate_array_relationship(nil, [])
|
90
118
|
assert result.is_a?(VirtualBox::Proxies::Collection)
|
91
119
|
end
|
92
120
|
|
@@ -102,7 +130,7 @@ class VMTest < Test::Unit::TestCase
|
|
102
130
|
expected_result << expected_value
|
103
131
|
end
|
104
132
|
|
105
|
-
assert_equal expected_result, @klass.
|
133
|
+
assert_equal expected_result, @klass.populate_array_relationship(nil, machines)
|
106
134
|
end
|
107
135
|
end
|
108
136
|
end
|
@@ -165,6 +193,21 @@ class VMTest < Test::Unit::TestCase
|
|
165
193
|
@instance.stubs(:running).returns(false)
|
166
194
|
end
|
167
195
|
|
196
|
+
context "reloading" do
|
197
|
+
setup do
|
198
|
+
@instance.stubs(:initialize_attributes)
|
199
|
+
end
|
200
|
+
|
201
|
+
should "just reload the attributes" do
|
202
|
+
@instance.expects(:initialize_attributes).with(@interface).once
|
203
|
+
@instance.reload
|
204
|
+
end
|
205
|
+
|
206
|
+
should "return itself" do
|
207
|
+
assert @instance.equal?(@instance.reload)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
168
211
|
context "destroying" do
|
169
212
|
setup do
|
170
213
|
@instance.stubs(:uuid).returns(:foo)
|
@@ -173,8 +216,13 @@ class VMTest < Test::Unit::TestCase
|
|
173
216
|
@interface.stubs(:parent).returns(@interface_parent)
|
174
217
|
end
|
175
218
|
|
176
|
-
should "destroy relationships
|
219
|
+
should "destroy snapshots, relationships, then the machine" do
|
177
220
|
destroy_seq = sequence("destroy_seq")
|
221
|
+
snapshot = mock("snapshot")
|
222
|
+
snapshot.stubs(:children).returns([])
|
223
|
+
@instance.stubs(:root_snapshot).returns(snapshot)
|
224
|
+
snapshot.expects(:destroy).once.in_sequence(destroy_seq)
|
225
|
+
@instance.expects(:reload).once.in_sequence(destroy_seq)
|
178
226
|
VirtualBox::StorageController.expects(:destroy_relationship).in_sequence(destroy_seq)
|
179
227
|
@interface_parent.expects(:unregister_machine).with(@instance.uuid).in_sequence(destroy_seq)
|
180
228
|
@interface.expects(:delete_settings).once.in_sequence(destroy_seq)
|
@@ -186,15 +234,18 @@ class VMTest < Test::Unit::TestCase
|
|
186
234
|
context "state" do
|
187
235
|
setup do
|
188
236
|
@state = mock("state")
|
237
|
+
@interface = mock("interface")
|
189
238
|
@instance.stubs(:read_attribute).with(:state).returns(@state)
|
239
|
+
@instance.stubs(:interface).returns(@interface)
|
190
240
|
end
|
191
241
|
|
192
|
-
should "
|
242
|
+
should "reload and return the state" do
|
243
|
+
@instance.expects(:load_interface_attribute).with(:state, @instance.interface).once
|
193
244
|
assert_equal @state, @instance.state
|
194
245
|
end
|
195
246
|
|
196
|
-
should "reload the state if
|
197
|
-
@instance.expects(:load_interface_attribute).
|
247
|
+
should "not reload the state if suppress is given" do
|
248
|
+
@instance.expects(:load_interface_attribute).never
|
198
249
|
assert_equal @state, @instance.state(true)
|
199
250
|
end
|
200
251
|
end
|
@@ -202,6 +253,9 @@ class VMTest < Test::Unit::TestCase
|
|
202
253
|
context "starting" do
|
203
254
|
setup do
|
204
255
|
setup_session_mocks
|
256
|
+
|
257
|
+
@instance.stubs(:running?).returns(false)
|
258
|
+
@session.stubs(:state).returns(:open)
|
205
259
|
end
|
206
260
|
|
207
261
|
should "open remote session using the given mode, wait for completion, then close" do
|
@@ -228,6 +282,7 @@ class VMTest < Test::Unit::TestCase
|
|
228
282
|
@console = mock("console")
|
229
283
|
@console.stubs(:send)
|
230
284
|
@session.stubs(:console).returns(@console)
|
285
|
+
@session.stubs(:state).returns(:open)
|
231
286
|
|
232
287
|
@method = :foo
|
233
288
|
end
|
@@ -244,7 +299,7 @@ class VMTest < Test::Unit::TestCase
|
|
244
299
|
|
245
300
|
should "wait for completion if an IProgress is returned" do
|
246
301
|
progress = mock("IProgress")
|
247
|
-
progress.stubs(:is_a?).with(VirtualBox::COM::
|
302
|
+
progress.stubs(:is_a?).with(VirtualBox::COM::Util.versioned_interface(:Progress)).returns(true)
|
248
303
|
progress.expects(:wait_for_completion).with(-1).once
|
249
304
|
@console.expects(:send).with(@method).returns(progress)
|
250
305
|
@instance.control(@method)
|
@@ -281,17 +336,39 @@ class VMTest < Test::Unit::TestCase
|
|
281
336
|
@session.stubs(:machine).returns(@parent)
|
282
337
|
|
283
338
|
@locked_interface = mock("locked_interface")
|
339
|
+
|
340
|
+
@instance.stubs(:saved?).returns(false)
|
341
|
+
@instance.stubs(:valid?).returns(true)
|
342
|
+
@instance.stubs(:with_open_session)
|
284
343
|
end
|
285
344
|
|
286
345
|
should "open the session, save, and close" do
|
287
346
|
save_seq = sequence("save_seq")
|
288
347
|
@instance.expects(:with_open_session).once.yields(@session).in_sequence(save_seq)
|
289
348
|
@session.expects(:machine).returns(@locked_interface).in_sequence(save_seq)
|
349
|
+
@instance.expects(:save_interface_attribute).with(:boot_order, @locked_interface).in_sequence(save_seq)
|
290
350
|
@instance.expects(:save_changed_interface_attributes).with(@locked_interface).in_sequence(save_seq)
|
291
351
|
@instance.expects(:save_relationships).in_sequence(save_seq)
|
292
352
|
|
293
353
|
@instance.save
|
294
354
|
end
|
355
|
+
|
356
|
+
should "raise an exception if saved" do
|
357
|
+
@instance.stubs(:saved?).returns(true)
|
358
|
+
|
359
|
+
assert_raises(VirtualBox::Exceptions::ReadonlyVMStateException) {
|
360
|
+
@instance.save
|
361
|
+
}
|
362
|
+
end
|
363
|
+
|
364
|
+
should "return false if not valid" do
|
365
|
+
@instance.stubs(:valid?).returns(false)
|
366
|
+
assert !@instance.save
|
367
|
+
end
|
368
|
+
|
369
|
+
should "return true if save succeeds" do
|
370
|
+
assert @instance.save
|
371
|
+
end
|
295
372
|
end
|
296
373
|
|
297
374
|
context "opening a session [direct]" do
|
@@ -299,8 +376,22 @@ class VMTest < Test::Unit::TestCase
|
|
299
376
|
setup_session_mocks
|
300
377
|
|
301
378
|
@locked_interface = mock("locked_interface")
|
379
|
+
@locked_interface.stubs(:state).returns(:powered_off)
|
302
380
|
@session.stubs(:machine).returns(@locked_interface)
|
303
381
|
@session.stubs(:state).returns(:closed)
|
382
|
+
@parent.stubs(:open_session)
|
383
|
+
end
|
384
|
+
|
385
|
+
should "close the session if an exception is raised" do
|
386
|
+
@locked_interface.expects(:save_settings).raises(Exception)
|
387
|
+
@session.expects(:close).once
|
388
|
+
|
389
|
+
assert_raises(Exception) do
|
390
|
+
@instance.with_open_session do
|
391
|
+
# After this point, state should be open
|
392
|
+
@session.stubs(:state).returns(:open)
|
393
|
+
end
|
394
|
+
end
|
304
395
|
end
|
305
396
|
|
306
397
|
should "open the session, save, and close" do
|
@@ -317,6 +408,17 @@ class VMTest < Test::Unit::TestCase
|
|
317
408
|
end
|
318
409
|
end
|
319
410
|
|
411
|
+
should "not save settings when the state is saved" do
|
412
|
+
@locked_interface.stubs(:state).returns(:saved)
|
413
|
+
|
414
|
+
save_seq = sequence("save_seq")
|
415
|
+
@parent.expects(:open_session).with(@session, @uuid).in_sequence(save_seq)
|
416
|
+
@locked_interface.expects(:save_settings).never
|
417
|
+
@session.expects(:close).in_sequence(save_seq)
|
418
|
+
|
419
|
+
@instance.with_open_session { |session| }
|
420
|
+
end
|
421
|
+
|
320
422
|
should "only open the session and close once" do
|
321
423
|
open_seq = sequence("open_seq")
|
322
424
|
|
@@ -337,6 +439,7 @@ class VMTest < Test::Unit::TestCase
|
|
337
439
|
context "state methods" do
|
338
440
|
should "check the proper results" do
|
339
441
|
methods = {
|
442
|
+
:starting? => :starting,
|
340
443
|
:running? => :running,
|
341
444
|
:powered_off? => :powered_off,
|
342
445
|
:paused? => :paused,
|
@@ -366,12 +469,13 @@ class VMTest < Test::Unit::TestCase
|
|
366
469
|
|
367
470
|
should "create a new appliance with path and export" do
|
368
471
|
result = mock("result")
|
472
|
+
options = mock("options")
|
369
473
|
VirtualBox::Appliance.expects(:new).returns(@appliance)
|
370
474
|
@appliance.expects(:path=).with(@path)
|
371
|
-
@appliance.expects(:add_machine).with(@instance)
|
475
|
+
@appliance.expects(:add_machine).with(@instance, options)
|
372
476
|
@appliance.expects(:export)
|
373
477
|
|
374
|
-
@instance.export(@path)
|
478
|
+
@instance.export(@path, options)
|
375
479
|
end
|
376
480
|
|
377
481
|
should "forward any block to the appliance export method" do
|
@@ -384,5 +488,135 @@ class VMTest < Test::Unit::TestCase
|
|
384
488
|
end
|
385
489
|
end
|
386
490
|
end
|
491
|
+
|
492
|
+
context "taking a snapshot" do
|
493
|
+
setup do
|
494
|
+
setup_session_mocks
|
495
|
+
|
496
|
+
@progress = mock("progress")
|
497
|
+
@progress.stubs(:wait)
|
498
|
+
|
499
|
+
@console = mock("console")
|
500
|
+
@console.stubs(:take_snapshot).returns(@progress)
|
501
|
+
@session.stubs(:console).returns(@console)
|
502
|
+
|
503
|
+
@instance.stubs(:with_open_session).yields(@session)
|
504
|
+
end
|
505
|
+
|
506
|
+
should "take a snapshot on the console and wait" do
|
507
|
+
name = "foo"
|
508
|
+
description = "baz"
|
509
|
+
@console.expects(:take_snapshot).with(name, description).returns(@progress)
|
510
|
+
@instance.take_snapshot(name, description)
|
511
|
+
end
|
512
|
+
|
513
|
+
should "wait and pass in the given block, if given" do
|
514
|
+
foo = mock("foo")
|
515
|
+
@progress.expects(:wait).yields(foo)
|
516
|
+
foo.expects(:called).once
|
517
|
+
|
518
|
+
@instance.take_snapshot(nil, nil) do |obj|
|
519
|
+
obj.called
|
520
|
+
end
|
521
|
+
end
|
522
|
+
end
|
523
|
+
|
524
|
+
context "root snapshot" do
|
525
|
+
should "return nil if the current snapshot is nil" do
|
526
|
+
@instance.stubs(:current_snapshot).returns(nil)
|
527
|
+
assert_nil @instance.root_snapshot
|
528
|
+
end
|
529
|
+
|
530
|
+
should "return the proper root snapshot" do
|
531
|
+
root = mock("root_snapshot")
|
532
|
+
root.stubs(:parent).returns(nil)
|
533
|
+
|
534
|
+
parent = mock("parent")
|
535
|
+
parent.stubs(:parent).returns(root)
|
536
|
+
|
537
|
+
snapshot = mock("snapshot")
|
538
|
+
snapshot.stubs(:parent).returns(parent)
|
539
|
+
|
540
|
+
@instance.stubs(:current_snapshot).returns(snapshot)
|
541
|
+
assert_equal root, @instance.root_snapshot
|
542
|
+
end
|
543
|
+
end
|
544
|
+
|
545
|
+
context "finding a snapshot" do
|
546
|
+
should "return nil if there is no root snapshot" do
|
547
|
+
@instance.stubs(:current_snapshot).returns(nil)
|
548
|
+
assert_nil @instance.find_snapshot("foo")
|
549
|
+
end
|
550
|
+
|
551
|
+
should "return nil if the snapshot is not found" do
|
552
|
+
snapshot = mock("snapshot")
|
553
|
+
snapshot.stubs(:name).returns("wrong")
|
554
|
+
snapshot.stubs(:uuid).returns(nil)
|
555
|
+
snapshot.stubs(:children).returns([])
|
556
|
+
@instance.stubs(:root_snapshot).returns(snapshot)
|
557
|
+
|
558
|
+
assert_nil @instance.find_snapshot("bar")
|
559
|
+
end
|
560
|
+
|
561
|
+
# TODO: Testing traversing the snapshot tree. Too many mocks :S
|
562
|
+
end
|
563
|
+
|
564
|
+
context "getting the boot order" do
|
565
|
+
setup do
|
566
|
+
@max = 4
|
567
|
+
@global = mock("global")
|
568
|
+
@sys_props = mock("system_properties")
|
569
|
+
|
570
|
+
@sys_props.stubs(:max_boot_position).returns(@max)
|
571
|
+
@global.stubs(:system_properties).returns(@sys_props)
|
572
|
+
VirtualBox::Global.stubs(:global).returns(@global)
|
573
|
+
end
|
574
|
+
|
575
|
+
should "get the boot order for each up to max" do
|
576
|
+
expected = (1..@max).inject([]) do |acc, pos|
|
577
|
+
result = mock("p#{pos}")
|
578
|
+
@interface.expects(:get_boot_order).with(pos).returns(result)
|
579
|
+
acc << result
|
580
|
+
acc
|
581
|
+
end
|
582
|
+
|
583
|
+
assert_equal expected, @instance.get_boot_order(@interface, nil)
|
584
|
+
end
|
585
|
+
end
|
586
|
+
|
587
|
+
context "setting the boot order" do
|
588
|
+
setup do
|
589
|
+
@max = 4
|
590
|
+
@global = mock("global")
|
591
|
+
@sys_props = mock("system_properties")
|
592
|
+
|
593
|
+
@sys_props.stubs(:max_boot_position).returns(@max)
|
594
|
+
@global.stubs(:system_properties).returns(@sys_props)
|
595
|
+
VirtualBox::Global.stubs(:global).returns(@global)
|
596
|
+
end
|
597
|
+
|
598
|
+
should "set the boot order for each up to max" do
|
599
|
+
expected = (1..@max).inject([]) do |acc, pos|
|
600
|
+
result = mock("p#{pos}")
|
601
|
+
@interface.expects(:set_boot_order).with(pos, result)
|
602
|
+
acc << result
|
603
|
+
acc
|
604
|
+
end
|
605
|
+
|
606
|
+
@instance.set_boot_order(@interface, nil, expected)
|
607
|
+
end
|
608
|
+
|
609
|
+
should "set the boot order for max items even if value has less than the proper amount" do
|
610
|
+
items = [1, 2]
|
611
|
+
items.concat(Array.new(@max - items.size))
|
612
|
+
items.each_with_index do |item, i|
|
613
|
+
@interface.expects(:set_boot_order).with(i + 1, item).once
|
614
|
+
end
|
615
|
+
|
616
|
+
assert_equal @max, items.size # sanity
|
617
|
+
|
618
|
+
@instance.set_boot_order(@interface, nil, items)
|
619
|
+
end
|
620
|
+
end
|
387
621
|
end
|
388
|
-
end
|
622
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
2
|
+
|
3
|
+
class VRDPServerTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = VirtualBox::VRDPServer
|
6
|
+
@interface = mock("interface")
|
7
|
+
@parent = mock("parent")
|
8
|
+
end
|
9
|
+
|
10
|
+
context "class methods" do
|
11
|
+
context "populating relationship" do
|
12
|
+
setup do
|
13
|
+
@instance = mock("instance")
|
14
|
+
@klass.stubs(:new).returns(@instance)
|
15
|
+
|
16
|
+
@vrdp_server = mock("vrdp_server")
|
17
|
+
@interface.stubs(:vrdp_server).returns(@vrdp_server)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "call new for the interface" do
|
21
|
+
@klass.expects(:new).with(nil, @vrdp_server).once.returns(@instance)
|
22
|
+
assert_equal @instance, @klass.populate_relationship(nil, @interface)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "saving relationship" do
|
27
|
+
should "call save with the interface on the instance" do
|
28
|
+
instance = mock("instance")
|
29
|
+
instance.expects(:save).once
|
30
|
+
|
31
|
+
@klass.save_relationship(nil, instance)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "initializing" do
|
37
|
+
setup do
|
38
|
+
@klass.any_instance.stubs(:load_interface_attributes)
|
39
|
+
end
|
40
|
+
|
41
|
+
should "load interface attribtues" do
|
42
|
+
@klass.any_instance.expects(:load_interface_attributes).with(@interface).once
|
43
|
+
@klass.new(@parent, @interface)
|
44
|
+
end
|
45
|
+
|
46
|
+
should "not be dirty" do
|
47
|
+
@instance = @klass.new(@parent, @interface)
|
48
|
+
assert !@instance.changed?
|
49
|
+
end
|
50
|
+
|
51
|
+
should "be existing record" do
|
52
|
+
@instance = @klass.new(@parent, @interface)
|
53
|
+
assert !@instance.new_record?
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "instance methods" do
|
58
|
+
setup do
|
59
|
+
@klass.any_instance.stubs(:load_interface_attributes)
|
60
|
+
|
61
|
+
@parent = mock("parent")
|
62
|
+
@interface = mock("interface")
|
63
|
+
@instance = @klass.new(@parent, @interface)
|
64
|
+
end
|
65
|
+
|
66
|
+
context "saving" do
|
67
|
+
setup do
|
68
|
+
@vrdp_server = mock("vrdp_server")
|
69
|
+
@session = mock("session")
|
70
|
+
@machine = mock("machine")
|
71
|
+
@machine.stubs(:vrdp_server).returns(@vrdp_server)
|
72
|
+
@session.stubs(:machine).returns(@machine)
|
73
|
+
@parent.stubs(:with_open_session).yields(@session)
|
74
|
+
end
|
75
|
+
|
76
|
+
should "save the interface settings with the new bios settings" do
|
77
|
+
save_seq = sequence("save_seq")
|
78
|
+
@instance.expects(:save_changed_interface_attributes).with(@vrdp_server).once.in_sequence(save_seq)
|
79
|
+
@instance.save
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|