virtualbox 0.7.9 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/lib/virtualbox/appliance.rb +3 -3
  2. data/lib/virtualbox/com/ffi/interfaces.rb +12 -3
  3. data/lib/virtualbox/com/ffi/util.rb +3 -1
  4. data/lib/virtualbox/com/implementer/ffi.rb +23 -3
  5. data/lib/virtualbox/com/interface/4.0.x/access_mode.rb +11 -0
  6. data/lib/virtualbox/com/interface/4.0.x/appliance.rb +23 -0
  7. data/lib/virtualbox/com/interface/4.0.x/audio_adapter.rb +15 -0
  8. data/lib/virtualbox/com/interface/4.0.x/audio_controller_type.rb +11 -0
  9. data/lib/virtualbox/com/interface/4.0.x/audio_driver_type.rb +11 -0
  10. data/lib/virtualbox/com/interface/4.0.x/auth_type.rb +11 -0
  11. data/lib/virtualbox/com/interface/4.0.x/bios_boot_menu_mode.rb +11 -0
  12. data/lib/virtualbox/com/interface/4.0.x/bios_settings.rb +21 -0
  13. data/lib/virtualbox/com/interface/4.0.x/cleanup_mode.rb +12 -0
  14. data/lib/virtualbox/com/interface/4.0.x/clipboard_mode.rb +11 -0
  15. data/lib/virtualbox/com/interface/4.0.x/console.rb +50 -0
  16. data/lib/virtualbox/com/interface/4.0.x/cpu_property_type.rb +11 -0
  17. data/lib/virtualbox/com/interface/4.0.x/device_type.rb +11 -0
  18. data/lib/virtualbox/com/interface/4.0.x/dhcp_server.rb +22 -0
  19. data/lib/virtualbox/com/interface/4.0.x/event_source.rb +13 -0
  20. data/lib/virtualbox/com/interface/4.0.x/fault_tolerance_state.rb +11 -0
  21. data/lib/virtualbox/com/interface/4.0.x/firmware_type.rb +11 -0
  22. data/lib/virtualbox/com/interface/4.0.x/guest.rb +13 -0
  23. data/lib/virtualbox/com/interface/4.0.x/guest_os_type.rb +33 -0
  24. data/lib/virtualbox/com/interface/4.0.x/host.rb +43 -0
  25. data/lib/virtualbox/com/interface/4.0.x/host_network_interface.rb +30 -0
  26. data/lib/virtualbox/com/interface/4.0.x/host_network_interface_medium_type.rb +11 -0
  27. data/lib/virtualbox/com/interface/4.0.x/host_network_interface_status.rb +11 -0
  28. data/lib/virtualbox/com/interface/4.0.x/host_network_interface_type.rb +11 -0
  29. data/lib/virtualbox/com/interface/4.0.x/host_usb_device.rb +13 -0
  30. data/lib/virtualbox/com/interface/4.0.x/host_usb_device_filter.rb +13 -0
  31. data/lib/virtualbox/com/interface/4.0.x/hw_virt_ex_property_type.rb +12 -0
  32. data/lib/virtualbox/com/interface/4.0.x/keyboard_hid_type.rb +11 -0
  33. data/lib/virtualbox/com/interface/4.0.x/lock_type.rb +11 -0
  34. data/lib/virtualbox/com/interface/4.0.x/machine.rb +132 -0
  35. data/lib/virtualbox/com/interface/4.0.x/machine_state.rb +14 -0
  36. data/lib/virtualbox/com/interface/4.0.x/medium.rb +53 -0
  37. data/lib/virtualbox/com/interface/4.0.x/medium_attachment.rb +18 -0
  38. data/lib/virtualbox/com/interface/4.0.x/medium_format.rb +18 -0
  39. data/lib/virtualbox/com/interface/4.0.x/medium_state.rb +11 -0
  40. data/lib/virtualbox/com/interface/4.0.x/medium_type.rb +11 -0
  41. data/lib/virtualbox/com/interface/4.0.x/medium_variant.rb +11 -0
  42. data/lib/virtualbox/com/interface/4.0.x/nat_alias_mode.rb +11 -0
  43. data/lib/virtualbox/com/interface/4.0.x/nat_engine.rb +27 -0
  44. data/lib/virtualbox/com/interface/4.0.x/nat_protocol.rb +11 -0
  45. data/lib/virtualbox/com/interface/4.0.x/network_adapter.rb +35 -0
  46. data/lib/virtualbox/com/interface/4.0.x/network_adapter_type.rb +11 -0
  47. data/lib/virtualbox/com/interface/4.0.x/network_attachment_type.rb +11 -0
  48. data/lib/virtualbox/com/interface/4.0.x/nsiexception.rb +23 -0
  49. data/lib/virtualbox/com/interface/4.0.x/nsisupports.rb +15 -0
  50. data/lib/virtualbox/com/interface/4.0.x/parallel_port.rb +17 -0
  51. data/lib/virtualbox/com/interface/4.0.x/pointing_hid_type.rb +11 -0
  52. data/lib/virtualbox/com/interface/4.0.x/port_mode.rb +11 -0
  53. data/lib/virtualbox/com/interface/4.0.x/progress.rb +64 -0
  54. data/lib/virtualbox/com/interface/4.0.x/serial_port.rb +19 -0
  55. data/lib/virtualbox/com/interface/4.0.x/session.rb +18 -0
  56. data/lib/virtualbox/com/interface/4.0.x/session_state.rb +11 -0
  57. data/lib/virtualbox/com/interface/4.0.x/session_type.rb +11 -0
  58. data/lib/virtualbox/com/interface/4.0.x/shared_folder.rb +17 -0
  59. data/lib/virtualbox/com/interface/4.0.x/snapshot.rb +20 -0
  60. data/lib/virtualbox/com/interface/4.0.x/storage_bus.rb +11 -0
  61. data/lib/virtualbox/com/interface/4.0.x/storage_controller.rb +24 -0
  62. data/lib/virtualbox/com/interface/4.0.x/storage_controller_type.rb +11 -0
  63. data/lib/virtualbox/com/interface/4.0.x/system_properties.rb +42 -0
  64. data/lib/virtualbox/com/interface/4.0.x/usb_controller.rb +21 -0
  65. data/lib/virtualbox/com/interface/4.0.x/usb_device.rb +24 -0
  66. data/lib/virtualbox/com/interface/4.0.x/usb_device_filter.rb +23 -0
  67. data/lib/virtualbox/com/interface/4.0.x/usb_device_filter_action.rb +11 -0
  68. data/lib/virtualbox/com/interface/4.0.x/usb_device_state.rb +11 -0
  69. data/lib/virtualbox/com/interface/4.0.x/virtual_box_error_info.rb +17 -0
  70. data/lib/virtualbox/com/interface/4.0.x/virtual_system_description.rb +19 -0
  71. data/lib/virtualbox/com/interface/4.0.x/virtual_system_description_type.rb +14 -0
  72. data/lib/virtualbox/com/interface/4.0.x/virtual_system_description_value_type.rb +11 -0
  73. data/lib/virtualbox/com/interface/4.0.x/virtualbox.rb +50 -0
  74. data/lib/virtualbox/com/interface/4.0.x/vrde_server.rb +23 -0
  75. data/lib/virtualbox/host_network_interface.rb +1 -1
  76. data/lib/virtualbox/hw_virtualization.rb +1 -0
  77. data/lib/virtualbox/network_adapter.rb +1 -1
  78. data/lib/virtualbox/system_properties.rb +2 -3
  79. data/lib/virtualbox/version.rb +1 -1
  80. data/lib/virtualbox/vm.rb +20 -44
  81. data/lib/virtualbox/{vrdp_server.rb → vrde_server.rb} +9 -11
  82. data/test/virtualbox/host_network_interface_test.rb +1 -0
  83. data/test/virtualbox/vm_test.rb +35 -26
  84. data/test/virtualbox/{vrdp_server_test.rb → vrde_server_test.rb} +8 -8
  85. metadata +77 -7
@@ -0,0 +1,24 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Interface
4
+ module Version_4_0_X
5
+ class StorageController < AbstractInterface
6
+ IID = "6bf8335b-d14a-44a5-9b45-ddc49ce7d5b2"
7
+
8
+ property :name, WSTRING, :readonly => true
9
+ property :max_devices_per_port_count, T_UINT32, :readonly => true
10
+ property :min_port_count, T_UINT32, :readonly => true
11
+ property :max_port_count, T_UINT32, :readonly => true
12
+ property :instance, T_UINT32
13
+ property :port_count, T_UINT32
14
+ property :bus, :StorageBus, :readonly => true
15
+ property :controller_type, :StorageControllerType
16
+ property :use_host_io_cache, T_BOOL
17
+
18
+ function :get_ide_emulation_port, T_INT32, [T_INT32]
19
+ function :set_ide_emulation_port, nil, [T_INT32, T_INT32]
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Interface
4
+ module Version_4_0_X
5
+ class StorageControllerType < AbstractEnum
6
+ map [:null, :lsi_logic, :bus_logic, :intel_ahci, :piix3, :piix4, :ich6, :i82078, :lsi_logic_sas]
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,42 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Interface
4
+ module Version_4_0_X
5
+ class SystemProperties < AbstractInterface
6
+ IID = "8030645c-8fef-4320-bb7b-c829f00069dc"
7
+
8
+ property :min_guest_ram, T_UINT32, :readonly => true
9
+ property :max_guest_ram, T_UINT32, :readonly => true
10
+ property :min_guest_vram, T_UINT32, :readonly => true
11
+ property :max_guest_vram, T_UINT32, :readonly => true
12
+ property :min_guest_cpu_count, T_UINT32, :readonly => true
13
+ property :max_guest_cpu_count, T_UINT32, :readonly => true
14
+ property :max_guest_monitors, T_UINT32, :readonly => true
15
+ property :info_vd_size, T_INT64, :readonly => true
16
+ property :network_adapter_count, T_UINT32, :readonly => true
17
+ property :serial_port_count, T_UINT32, :readonly => true
18
+ property :parallel_port_count, T_UINT32, :readonly => true
19
+ property :max_boot_position, T_UINT32, :readonly => true
20
+ property :default_machine_folder, WSTRING
21
+ property :medium_formats, [:MediumFormat], :readonly => true
22
+ property :default_hard_disk_format, WSTRING
23
+ property :free_disk_space_warning, T_UINT64
24
+ property :free_disk_space_percent_warning, T_UINT32
25
+ property :free_disk_space_error, T_UINT64
26
+ property :free_disk_space_percent_error, T_UINT64
27
+ property :vrde_auth_library, WSTRING
28
+ property :web_service_auth_library, WSTRING
29
+ property :log_history_count, T_UINT32
30
+ property :default_audio_driver, :AudioDriverType, :readonly => true
31
+
32
+ function :get_max_devices_per_port_for_storage_bus, T_UINT32, [:StorageBus]
33
+ function :get_min_port_count_for_storage_bus, T_UINT32, [:StorageBus]
34
+ function :get_max_port_count_for_storage_bus, T_UINT32, [:StorageBus]
35
+ function :get_max_instances_of_storage_bus, T_UINT32, [:StorageBus]
36
+ function :get_device_types_for_storage_bus, [:DeviceType], [:StorageBus]
37
+ function :get_default_io_cache_setting_for_storage_controller, T_BOOL, [:StorageControllerType]
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,21 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Interface
4
+ module Version_4_0_X
5
+ class USBController < AbstractInterface
6
+ IID = "238540fa-4b73-435a-a38e-4e1d9eab5c17"
7
+
8
+ property :enabled, T_BOOL
9
+ property :enabled_ehci, T_BOOL
10
+ property :proxy_available, T_BOOL, :readonly => true
11
+ property :usb_standard, T_UINT16, :readonly => true
12
+ property :device_filters, [:USBDeviceFilter], :readonly => true
13
+
14
+ function :create_device_filter, :USBDeviceFilter, [WSTRING]
15
+ function :insert_device_filter, nil, [T_UINT32, :USBDeviceFilter]
16
+ function :remove_device_filter, :USBDeviceFilter, [T_UINT32]
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Interface
4
+ module Version_4_0_X
5
+ class USBDevice < AbstractInterface
6
+ IID = "f8967b0b-4483-400f-92b5-8b675d98a85b"
7
+
8
+ property :id, WSTRING, :readonly => true
9
+ property :vendor_id, T_UINT16, :readonly => true
10
+ property :product_id, T_UINT16, :readonly => true
11
+ property :revision, T_UINT16, :readonly => true
12
+ property :manfacturer, WSTRING, :readonly => true
13
+ property :product, WSTRING, :readonly => true
14
+ property :serial_number, WSTRING, :readonly => true
15
+ property :address, WSTRING, :readonly => true
16
+ property :port, T_UINT16, :readonly => true
17
+ property :version, T_UINT16, :readonly => true
18
+ property :port_version, T_UINT16, :readonly => true
19
+ property :remote, T_BOOL, :readonly => true
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Interface
4
+ module Version_4_0_X
5
+ class USBDeviceFilter < AbstractInterface
6
+ IID = "d6831fb4-1a94-4c2c-96ef-8d0d6192066d"
7
+
8
+ property :name, WSTRING
9
+ property :active, T_BOOL
10
+ property :vendor_id, WSTRING
11
+ property :product_id, WSTRING
12
+ property :revision, WSTRING
13
+ property :manufacturer, WSTRING
14
+ property :product, WSTRING
15
+ property :serial_number, WSTRING
16
+ property :port, WSTRING
17
+ property :remote, WSTRING
18
+ property :masked_interfaces, T_UINT32
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,11 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Interface
4
+ module Version_4_0_X
5
+ class USBDeviceFilterAction < AbstractEnum
6
+ map [:null, :ignore, :hold]
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Interface
4
+ module Version_4_0_X
5
+ class USBDeviceState < AbstractEnum
6
+ map [:not_supported, :unavailable, :busy, :available, :help, :captured]
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Interface
4
+ module Version_4_0_X
5
+ class VirtualBoxErrorInfo < AbstractInterface
6
+ IID = "4b86d186-407e-4f9e-8be8-e50061be8725"
7
+
8
+ property :result_code, T_UINT32, :readonly => true
9
+ property :interface_i_d, WSTRING, :readonly => true
10
+ property :component, WSTRING, :readonly => true
11
+ property :text, WSTRING, :readonly => true
12
+ property :next, :VirtualBoxErrorInfo, :readonly => true
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Interface
4
+ module Version_4_0_X
5
+ class VirtualSystemDescription < AbstractInterface
6
+ IID = "d7525e6c-531a-4c51-8e04-41235083a3d8"
7
+
8
+ property :count, T_UINT32, :readonly => true
9
+
10
+ function :get_description, nil, [[:out, [:VirtualSystemDescriptionType]], [:out, [WSTRING]], [:out, [WSTRING]], [:out, [WSTRING]], [:out, [WSTRING]]]
11
+ function :get_description_by_type, nil, [:VirtualSystemDescriptionType, [:out, [:VirtualSystemDescriptionType]], [:out, [WSTRING]], [:out, [WSTRING]], [:out, [WSTRING]], [:out, [WSTRING]]]
12
+ function :get_values_by_type, [WSTRING], [:VirtualSystemDescriptionType, :VirtualSystemDescriptionValueType]
13
+ function :set_final_values, nil, [[T_BOOL], [WSTRING], [WSTRING]]
14
+ function :add_description, nil, [:VirtualSystemDescriptionType, WSTRING, WSTRING]
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Interface
4
+ module Version_4_0_X
5
+ class VirtualSystemDescriptionType < AbstractEnum
6
+ map [:null, :ignore, :os, :name, :product, :vendor, :version, :product_url, :vendor_url,
7
+ :description, :license, :misc, :cpu, :memory, :hard_disk_controller_ide,
8
+ :hard_disk_controller_sata, :hard_disk_controller_scsi, :hard_disk_controller_sas, :hard_disk_image,
9
+ :floppy, :cdrom, :network_adapter, :usb_controller, :sound_card]
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Interface
4
+ module Version_4_0_X
5
+ class VirtualSystemDescriptionValueType < AbstractEnum
6
+ map [:null, :reference, :original, :auto, :extra_config]
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,50 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Interface
4
+ module Version_4_0_X
5
+ class VirtualBox < AbstractInterface
6
+ IID_STR = "D2DE270C-1D4B-4C9E-843F-BBB9B47269FF"
7
+
8
+ property :version, WSTRING, :readonly => true
9
+ property :revision, T_ULONG, :readonly => true
10
+ property :package_type, WSTRING, :readonly => true
11
+ property :home_folder, WSTRING, :readonly => true
12
+ property :settings_file_path, WSTRING, :readonly => true
13
+ property :host, :Host, :readonly => true
14
+ property :system_properties, :SystemProperties, :readonly => true
15
+ property :machines, [:Machine], :readonly => true
16
+ property :hard_disks, [:Medium], :readonly => true
17
+ property :dvd_images, [:Medium], :readonly => true
18
+ property :floppy_images, [:Medium], :readonly => true
19
+ property :progress_operations, [:Progress], :readonly => true
20
+ property :guest_os_types, [:GuestOSType], :readonly => true
21
+ property :shared_folders, [:SharedFolder], :readonly => true
22
+ property :performance_collector, :PerformanceCollector, :readonly => true
23
+ property :dhcp_servers, [:DHCPServer], :readonly => true
24
+ property :event_source, :EventSource, :readonly => true
25
+ property :extension_pack_manager, :ExtPackManager, :readonly => true
26
+
27
+ function :compose_machine_filename, WSTRING, [WSTRING, WSTRING]
28
+ function :create_machine, :Machine, [WSTRING, WSTRING, WSTRING, WSTRING, T_BOOL]
29
+ function :open_machine, :Machine, [WSTRING]
30
+ function :register_machine, nil, [:Machine]
31
+ function :find_machine, :Machine, [WSTRING]
32
+ function :create_appliance, :Appliance, []
33
+ function :create_hard_disk, :Medium, [WSTRING, WSTRING]
34
+ function :open_medium, :Medium, [WSTRING, :DeviceType, :AccessMode]
35
+ function :find_medium, :Medium, [WSTRING, :DeviceType]
36
+ function :get_guest_os_type, :GuestOSType, [WSTRING]
37
+ function :create_shared_folder, nil, [WSTRING, WSTRING, T_BOOL, T_BOOL]
38
+ function :remove_shared_folder, nil, [WSTRING]
39
+ function :get_extra_data_keys, [WSTRING], []
40
+ function :get_extra_data, WSTRING, [WSTRING]
41
+ function :set_extra_data, nil, [WSTRING, WSTRING]
42
+ function :create_dhcp_server, :DHCPServer, [WSTRING]
43
+ function :find_dhcp_server_by_network_name, :DHCPServer, [WSTRING]
44
+ function :remove_dhcp_server, nil, [:DHCPServer]
45
+ function :check_firmware_present, T_BOOL, [:FirmwareType, WSTRING, [:out, WSTRING], [:out, WSTRING]]
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,23 @@
1
+ module VirtualBox
2
+ module COM
3
+ module Interface
4
+ module Version_4_0_X
5
+ class VRDEServer < AbstractInterface
6
+ IID = "72e671bc-1712-4052-ad6b-e45e76d9d3e4"
7
+
8
+ property :enabled, T_BOOL
9
+ property :auth_type, :AuthType
10
+ property :auth_timeout, T_UINT32
11
+ property :allow_multi_connection, T_BOOL
12
+ property :reuse_single_connection, T_BOOL
13
+ property :vrde_ext_pack, WSTRING
14
+ property :auth_library, WSTRING
15
+ property :vrde_properties, [WSTRING], :readonly => true
16
+
17
+ function :set_vrde_property, nil, [WSTRING, WSTRING]
18
+ function :get_vrde_property, WSTRING, [WSTRING]
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -91,7 +91,7 @@ module VirtualBox
91
91
  def attached_vms
92
92
  parent.parent.vms.find_all do |vm|
93
93
  result = vm.network_adapters.find do |adapter|
94
- adapter.host_interface == name
94
+ adapter.enabled? && adapter.host_interface == name
95
95
  end
96
96
 
97
97
  !result.nil?
@@ -8,6 +8,7 @@ module VirtualBox
8
8
  attribute :exclusive, :boolean => true
9
9
  attribute :vpid, :boolean => true
10
10
  attribute :nested_paging, :boolean => true
11
+ attribute :force, :boolean => true
11
12
  end
12
13
 
13
14
  class << self
@@ -59,7 +59,7 @@ module VirtualBox
59
59
  attribute :internal_network
60
60
  attribute :host_interface
61
61
  attribute :interface, :readonly => true, :property => false
62
- relationship :nat_driver, :NATEngine, :version => "3.2", :lazy => true
62
+ relationship :nat_driver, :NATEngine, :lazy => true
63
63
 
64
64
  class << self
65
65
  # Populates the nic relationship for anything which is related to it.
@@ -12,16 +12,15 @@ module VirtualBox
12
12
  attribute :max_guest_vram, :readonly => true
13
13
  attribute :min_guest_cpu_count, :readonly => true
14
14
  attribute :max_guest_cpu_count, :readonly => true
15
- attribute :max_vdi_size, :readonly => true
15
+ attribute :info_vd_size, :readonly => true
16
16
  attribute :network_adapter_count, :readonly => true
17
17
  attribute :serial_port_count, :readonly => true
18
18
  attribute :parallel_port_count, :readonly => true
19
19
  attribute :max_boot_position, :readonly => true
20
20
  attribute :default_machine_folder
21
- attribute :default_hard_disk_folder
22
21
  attribute :medium_formats, :readonly => true
23
22
  attribute :default_hard_disk_format
24
- attribute :remote_display_auth_library
23
+ attribute :vrde_auth_library
25
24
  attribute :web_service_auth_library
26
25
  attribute :log_history_count
27
26
  attribute :default_audio_driver, :readonly => true
@@ -1,5 +1,5 @@
1
1
  module VirtualBox
2
- VERSION = "0.7.9"
2
+ VERSION = "0.8.0"
3
3
 
4
4
  module Version
5
5
  # Returns a boolean denoting whether the current VirtualBox
data/lib/virtualbox/vm.rb CHANGED
@@ -146,8 +146,6 @@ module VirtualBox
146
146
  attribute :accessible, :readonly => true, :boolean => true
147
147
  attribute :hardware_version
148
148
  attribute :hardware_uuid
149
- # TODO: Removed in 3.2.x, how should we handle this?
150
- # attribute :statistics_update_interval
151
149
  attribute :firmware_type
152
150
  attribute :snapshot_folder
153
151
  attribute :settings_file_path, :readonly => true
@@ -169,7 +167,7 @@ module VirtualBox
169
167
  relationship :bios, :BIOS
170
168
  relationship :hw_virt, :HWVirtualization
171
169
  relationship :cpu, :CPU
172
- relationship :vrdp_server, :VRDPServer
170
+ relationship :vrde_server, :VRDEServer
173
171
  relationship :storage_controllers, :StorageController, :dependent => :destroy
174
172
  relationship :medium_attachments, :MediumAttachment
175
173
  relationship :shared_folders, :SharedFolder
@@ -378,7 +376,7 @@ module VirtualBox
378
376
  # be modified with an open session on a machine. An open session is similar
379
377
  # to a write-lock. Once the session is completed, it must be closed, which
380
378
  # this method does as well.
381
- def with_open_session
379
+ def with_open_session(mode=:write)
382
380
  # Set the session up
383
381
  session = Lib.lib.session
384
382
 
@@ -386,23 +384,23 @@ module VirtualBox
386
384
 
387
385
  if session.state != :open
388
386
  # Open up a session for this virtual machine
389
- interface.parent.open_session(session, uuid)
387
+ interface.lock_machine(session, mode)
390
388
 
391
389
  # Mark the session to be closed
392
390
  close_session = true
393
391
  end
394
392
 
395
393
  # Yield the block with the session
396
- yield session
394
+ yield session if block_given?
397
395
 
398
396
  # Close the session
399
397
  if close_session
400
398
  # Save these settings only if we're closing and only if the state
401
399
  # is not saved, since that doesn't allow the machine to be saved.
402
- session.machine.save_settings if session.machine.state != :saved
400
+ session.machine.save_settings if mode == :write && session.machine.state != :saved
403
401
 
404
402
  # Close the session
405
- session.close
403
+ session.unlock_machine
406
404
  end
407
405
  rescue Exception
408
406
  # Close the session so we don't get locked out. We use a rescue block
@@ -410,7 +408,7 @@ module VirtualBox
410
408
  # exception is raised. Otherwise, we may or may not close the session,
411
409
  # depending how deeply nested this call to `with_open_session` is.
412
410
  # (see close_session boolean above)
413
- session.close if session.state == :open
411
+ session.unlock_machine if session.state == :open
414
412
 
415
413
  # Reraise the exception, we're not actually catching it to handle it
416
414
  raise
@@ -473,11 +471,8 @@ module VirtualBox
473
471
  # Open a new remote session, this will automatically start the machine
474
472
  # as well
475
473
  session = Lib.lib.session
476
- interface.parent.open_remote_session(session, uuid, mode.to_s, "").wait_for_completion(-1)
474
+ interface.launch_vm_process(session, mode.to_s, "").wait
477
475
  true
478
- ensure
479
- # Be sure to close that session!
480
- session.close if session && session.state == :open
481
476
  end
482
477
 
483
478
  # Shuts down the VM by directly calling "acpipowerbutton". Depending on the
@@ -543,16 +538,10 @@ module VirtualBox
543
538
  # @param [String] command The command to run on controlvm
544
539
  # @return [Boolean] True if command was successful, false otherwise.
545
540
  def control(command, *args)
546
- # Grab the session using an existing session
547
- session = Lib.lib.session
548
- interface.parent.open_existing_session(session, uuid)
549
-
550
- # Send the proper command, waiting if we have to
551
- result = session.console.send(command, *args)
552
- result.wait_for_completion(-1) if result.is_a?(COM::Util.versioned_interface(:Progress))
553
- ensure
554
- # Close the session
555
- session.close if session && session.state == :open
541
+ with_open_session(:shared) do |session|
542
+ result = session.console.send(command, *args)
543
+ result.wait if result.is_a?(COM::Util.versioned_interface(:Progress))
544
+ end
556
545
  end
557
546
 
558
547
  # Destroys the virtual machine. This method also removes all attached
@@ -567,30 +556,17 @@ module VirtualBox
567
556
  # not only unregister attached media, but will also physically
568
557
  # remove their respective data.
569
558
  def destroy(*args)
570
- # Destroy all snapshots first (by destroying the root, all children
571
- # are automatically destroyed)
572
- if root_snapshot
573
- destroy_snapshot = lambda do |snapshot|
574
- return if snapshot.nil?
575
-
576
- snapshot.children.each { |c| destroy_snapshot.call(c) }
577
- snapshot.destroy
578
- end
559
+ # Do a full cleanup on the machine, then delete all the media attached
560
+ media = interface.unregister(:full)
579
561
 
580
- destroy_snapshot.call(root_snapshot)
562
+ if !media.empty?
563
+ interface.delete(media)
581
564
 
582
- # Reload ourselves before continuing since snapshots do some
583
- # crazy things.
584
- reload
565
+ # TODO: This sleep is silly. The progress object returned by the media
566
+ # delete always fails to "wait" for some reason, so I do this. I hope
567
+ # to solve this issue soon.
568
+ sleep 1
585
569
  end
586
-
587
- # Call super first so destroy is propogated through to relationships
588
- # first
589
- super
590
-
591
- # Finally, destroy this machine and remove the settings file
592
- interface.parent.unregister_machine(uuid)
593
- interface.delete_settings
594
570
  end
595
571
 
596
572
  # Returns true if the virtual machine state is starting
@@ -1,23 +1,23 @@
1
1
  module VirtualBox
2
2
  # Represents the VRDP Server settings of a {VM}.
3
- class VRDPServer < AbstractModel
3
+ class VRDEServer < AbstractModel
4
4
  attribute :parent, :readonly => true, :property => false
5
5
  attribute :enabled, :boolean => true
6
- attribute :ports
7
- attribute :net_address
8
6
  attribute :auth_type
9
7
  attribute :auth_timeout
10
8
  attribute :allow_multi_connection, :boolean => true
11
9
  attribute :reuse_single_connection, :boolean => true
10
+ attribute :vrde_ext_pack
11
+ attribute :auth_library
12
12
 
13
13
  class << self
14
14
  # Populates a relationship with another model.
15
15
  #
16
16
  # **This method typically won't be used except internally.**
17
17
  #
18
- # @return [VRDPServer]
18
+ # @return [VRDEServer]
19
19
  def populate_relationship(caller, imachine)
20
- data = new(caller, imachine.vrdp_server)
20
+ data = new(caller, imachine.vrde_server)
21
21
  end
22
22
 
23
23
  # Saves the relationship.
@@ -28,11 +28,11 @@ module VirtualBox
28
28
  end
29
29
  end
30
30
 
31
- def initialize(parent, vrdp_settings)
31
+ def initialize(parent, vrde_settings)
32
32
  write_attribute(:parent, parent)
33
33
 
34
34
  # Load the attributes and mark the whole thing as existing
35
- load_interface_attributes(vrdp_settings)
35
+ load_interface_attributes(vrde_settings)
36
36
  clear_dirty!
37
37
  existing_record!
38
38
  end
@@ -41,9 +41,7 @@ module VirtualBox
41
41
  super
42
42
 
43
43
  validates_inclusion_of :enabled, :allow_multi_connection, :reuse_single_connection, :in => [true, false]
44
- validates_format_of :ports, :with => /^[\d\s\-\.]+$/, :message => "must only contain numbers, spaces, dashes or periods."
45
- validates_format_of :net_address, :with => /^[\w\d\-\.]+$/, :message => "must only contain latters, numbers, dashes or periods."
46
- validates_inclusion_of :auth_type, :in => COM::Util.versioned_interface(:VRDPAuthType).map
44
+ validates_inclusion_of :auth_type, :in => COM::Util.versioned_interface(:AuthType).map
47
45
  validates_numericality_of :auth_timeout
48
46
  end
49
47
 
@@ -52,7 +50,7 @@ module VirtualBox
52
50
  machine = session.machine
53
51
 
54
52
  # Save them
55
- save_changed_interface_attributes(machine.vrdp_server)
53
+ save_changed_interface_attributes(machine.vrde_server)
56
54
  end
57
55
  end
58
56
  end
@@ -109,6 +109,7 @@ class HostNetworkInterfaceTest < Test::Unit::TestCase
109
109
 
110
110
  interfaces.each do |name|
111
111
  adapter = mock("adapter")
112
+ adapter.stubs(:enabled?).returns(true)
112
113
  adapter.stubs(:host_interface).returns(name)
113
114
  adapters << adapter
114
115
  end