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.
Files changed (281) hide show
  1. data/.gitignore +8 -0
  2. data/.yardopts +3 -0
  3. data/Gemfile +16 -0
  4. data/LICENSE +19 -0
  5. data/Rakefile +33 -0
  6. data/Readme.md +70 -0
  7. data/docs/GettingStarted.md +196 -0
  8. data/docs/WhatsNew.md +12 -0
  9. data/features/README.md +33 -0
  10. data/features/global.feature +19 -0
  11. data/features/global_extra_data.feature +27 -0
  12. data/features/step_definitions/abstract_model_steps.rb +39 -0
  13. data/features/step_definitions/extra_data_steps.rb +36 -0
  14. data/features/step_definitions/global_steps.rb +29 -0
  15. data/features/step_definitions/nat_engine_steps.rb +76 -0
  16. data/features/step_definitions/network_adapter_steps.rb +38 -0
  17. data/features/step_definitions/shared_folder_steps.rb +76 -0
  18. data/features/step_definitions/snapshot_steps.rb +74 -0
  19. data/features/step_definitions/storage_controller_steps.rb +16 -0
  20. data/features/step_definitions/virtualbox_steps.rb +17 -0
  21. data/features/step_definitions/vm_steps.rb +50 -0
  22. data/features/support/env.rb +61 -0
  23. data/features/support/helpers.rb +38 -0
  24. data/features/support/hooks.rb +30 -0
  25. data/features/support/ordered_hash.rb +49 -0
  26. data/features/support/vboxmanage.rb +191 -0
  27. data/features/version.feature +16 -0
  28. data/features/vm.feature +13 -0
  29. data/features/vm_bios.feature +29 -0
  30. data/features/vm_cpu.feature +29 -0
  31. data/features/vm_extra_data.feature +35 -0
  32. data/features/vm_hw_virt.feature +29 -0
  33. data/features/vm_nat_engine.feature +57 -0
  34. data/features/vm_network_adapters.feature +27 -0
  35. data/features/vm_shared_folders.feature +42 -0
  36. data/features/vm_snapshots.feature +29 -0
  37. data/features/vm_storage_controllers.feature +11 -0
  38. data/lib/virtualbox.rb +11 -0
  39. data/lib/virtualbox/abstract_model.rb +281 -0
  40. data/lib/virtualbox/abstract_model/attributable.rb +290 -0
  41. data/lib/virtualbox/abstract_model/dirty.rb +177 -0
  42. data/lib/virtualbox/abstract_model/interface_attributes.rb +98 -0
  43. data/lib/virtualbox/abstract_model/relatable.rb +332 -0
  44. data/lib/virtualbox/abstract_model/validatable.rb +167 -0
  45. data/lib/virtualbox/abstract_model/version_matcher.rb +35 -0
  46. data/lib/virtualbox/appliance.rb +62 -0
  47. data/lib/virtualbox/audio_adapter.rb +52 -0
  48. data/lib/virtualbox/bios.rb +50 -0
  49. data/lib/virtualbox/com.rb +23 -0
  50. data/lib/virtualbox/com/abstract_enum.rb +43 -0
  51. data/lib/virtualbox/com/abstract_implementer.rb +45 -0
  52. data/lib/virtualbox/com/abstract_interface.rb +167 -0
  53. data/lib/virtualbox/com/base_interface.rb +38 -0
  54. data/lib/virtualbox/com/ffi/interface.rb +150 -0
  55. data/lib/virtualbox/com/ffi/interfaces.rb +54 -0
  56. data/lib/virtualbox/com/ffi/util.rb +119 -0
  57. data/lib/virtualbox/com/ffi/vboxxpcomc.rb +31 -0
  58. data/lib/virtualbox/com/ffi_interface.rb +96 -0
  59. data/lib/virtualbox/com/implementer/base.rb +59 -0
  60. data/lib/virtualbox/com/implementer/ffi.rb +361 -0
  61. data/lib/virtualbox/com/implementer/mscom.rb +175 -0
  62. data/lib/virtualbox/com/implementer/nil.rb +10 -0
  63. data/lib/virtualbox/com/interface/3.1.x/access_mode.rb +11 -0
  64. data/lib/virtualbox/com/interface/3.1.x/appliance.rb +22 -0
  65. data/lib/virtualbox/com/interface/3.1.x/audio_adapter.rb +15 -0
  66. data/lib/virtualbox/com/interface/3.1.x/audio_controller_type.rb +11 -0
  67. data/lib/virtualbox/com/interface/3.1.x/audio_driver_type.rb +11 -0
  68. data/lib/virtualbox/com/interface/3.1.x/bios_boot_menu_mode.rb +11 -0
  69. data/lib/virtualbox/com/interface/3.1.x/bios_settings.rb +21 -0
  70. data/lib/virtualbox/com/interface/3.1.x/clipboard_mode.rb +11 -0
  71. data/lib/virtualbox/com/interface/3.1.x/console.rb +50 -0
  72. data/lib/virtualbox/com/interface/3.1.x/cpu_property_type.rb +11 -0
  73. data/lib/virtualbox/com/interface/3.1.x/device_type.rb +11 -0
  74. data/lib/virtualbox/com/interface/3.1.x/dhcp_server.rb +22 -0
  75. data/lib/virtualbox/com/interface/3.1.x/firmware_type.rb +11 -0
  76. data/lib/virtualbox/com/interface/3.1.x/guest_os_type.rb +23 -0
  77. data/lib/virtualbox/com/interface/3.1.x/host.rb +42 -0
  78. data/lib/virtualbox/com/interface/3.1.x/host_network_interface.rb +30 -0
  79. data/lib/virtualbox/com/interface/3.1.x/host_network_interface_medium_type.rb +11 -0
  80. data/lib/virtualbox/com/interface/3.1.x/host_network_interface_status.rb +11 -0
  81. data/lib/virtualbox/com/interface/3.1.x/host_network_interface_type.rb +11 -0
  82. data/lib/virtualbox/com/interface/3.1.x/host_usb_device.rb +13 -0
  83. data/lib/virtualbox/com/interface/3.1.x/host_usb_device_filter.rb +13 -0
  84. data/lib/virtualbox/com/interface/3.1.x/hw_virt_ex_property_type.rb +11 -0
  85. data/lib/virtualbox/com/interface/3.1.x/machine.rb +105 -0
  86. data/lib/virtualbox/com/interface/3.1.x/machine_state.rb +14 -0
  87. data/lib/virtualbox/com/interface/3.1.x/medium.rb +50 -0
  88. data/lib/virtualbox/com/interface/3.1.x/medium_attachment.rb +18 -0
  89. data/lib/virtualbox/com/interface/3.1.x/medium_format.rb +18 -0
  90. data/lib/virtualbox/com/interface/3.1.x/medium_state.rb +11 -0
  91. data/lib/virtualbox/com/interface/3.1.x/medium_type.rb +11 -0
  92. data/lib/virtualbox/com/interface/3.1.x/medium_variant.rb +11 -0
  93. data/lib/virtualbox/com/interface/3.1.x/network_adapter.rb +30 -0
  94. data/lib/virtualbox/com/interface/3.1.x/network_adapter_type.rb +11 -0
  95. data/lib/virtualbox/com/interface/3.1.x/network_attachment_type.rb +11 -0
  96. data/lib/virtualbox/com/interface/3.1.x/nsiexception.rb +23 -0
  97. data/lib/virtualbox/com/interface/3.1.x/nsisupports.rb +15 -0
  98. data/lib/virtualbox/com/interface/3.1.x/parallel_port.rb +17 -0
  99. data/lib/virtualbox/com/interface/3.1.x/port_mode.rb +11 -0
  100. data/lib/virtualbox/com/interface/3.1.x/progress.rb +63 -0
  101. data/lib/virtualbox/com/interface/3.1.x/serial_port.rb +19 -0
  102. data/lib/virtualbox/com/interface/3.1.x/session.rb +18 -0
  103. data/lib/virtualbox/com/interface/3.1.x/session_state.rb +11 -0
  104. data/lib/virtualbox/com/interface/3.1.x/session_type.rb +11 -0
  105. data/lib/virtualbox/com/interface/3.1.x/shared_folder.rb +17 -0
  106. data/lib/virtualbox/com/interface/3.1.x/snapshot.rb +20 -0
  107. data/lib/virtualbox/com/interface/3.1.x/storage_bus.rb +11 -0
  108. data/lib/virtualbox/com/interface/3.1.x/storage_controller.rb +23 -0
  109. data/lib/virtualbox/com/interface/3.1.x/storage_controller_type.rb +11 -0
  110. data/lib/virtualbox/com/interface/3.1.x/system_properties.rb +37 -0
  111. data/lib/virtualbox/com/interface/3.1.x/usb_controller.rb +20 -0
  112. data/lib/virtualbox/com/interface/3.1.x/usb_device.rb +24 -0
  113. data/lib/virtualbox/com/interface/3.1.x/usb_device_filter.rb +23 -0
  114. data/lib/virtualbox/com/interface/3.1.x/usb_device_filter_action.rb +11 -0
  115. data/lib/virtualbox/com/interface/3.1.x/usb_device_state.rb +11 -0
  116. data/lib/virtualbox/com/interface/3.1.x/virtual_box_error_info.rb +17 -0
  117. data/lib/virtualbox/com/interface/3.1.x/virtual_system_description.rb +19 -0
  118. data/lib/virtualbox/com/interface/3.1.x/virtual_system_description_type.rb +14 -0
  119. data/lib/virtualbox/com/interface/3.1.x/virtual_system_description_value_type.rb +11 -0
  120. data/lib/virtualbox/com/interface/3.1.x/virtualbox.rb +67 -0
  121. data/lib/virtualbox/com/interface/3.1.x/vrdp_auth_type.rb +11 -0
  122. data/lib/virtualbox/com/interface/3.1.x/vrdp_server.rb +19 -0
  123. data/lib/virtualbox/com/interface/3.2.x/access_mode.rb +11 -0
  124. data/lib/virtualbox/com/interface/3.2.x/appliance.rb +22 -0
  125. data/lib/virtualbox/com/interface/3.2.x/audio_adapter.rb +15 -0
  126. data/lib/virtualbox/com/interface/3.2.x/audio_controller_type.rb +11 -0
  127. data/lib/virtualbox/com/interface/3.2.x/audio_driver_type.rb +11 -0
  128. data/lib/virtualbox/com/interface/3.2.x/bios_boot_menu_mode.rb +11 -0
  129. data/lib/virtualbox/com/interface/3.2.x/bios_settings.rb +21 -0
  130. data/lib/virtualbox/com/interface/3.2.x/clipboard_mode.rb +11 -0
  131. data/lib/virtualbox/com/interface/3.2.x/console.rb +50 -0
  132. data/lib/virtualbox/com/interface/3.2.x/cpu_property_type.rb +11 -0
  133. data/lib/virtualbox/com/interface/3.2.x/device_type.rb +11 -0
  134. data/lib/virtualbox/com/interface/3.2.x/dhcp_server.rb +22 -0
  135. data/lib/virtualbox/com/interface/3.2.x/firmware_type.rb +11 -0
  136. data/lib/virtualbox/com/interface/3.2.x/guest.rb +13 -0
  137. data/lib/virtualbox/com/interface/3.2.x/guest_os_type.rb +33 -0
  138. data/lib/virtualbox/com/interface/3.2.x/host.rb +43 -0
  139. data/lib/virtualbox/com/interface/3.2.x/host_network_interface.rb +30 -0
  140. data/lib/virtualbox/com/interface/3.2.x/host_network_interface_medium_type.rb +11 -0
  141. data/lib/virtualbox/com/interface/3.2.x/host_network_interface_status.rb +11 -0
  142. data/lib/virtualbox/com/interface/3.2.x/host_network_interface_type.rb +11 -0
  143. data/lib/virtualbox/com/interface/3.2.x/host_usb_device.rb +13 -0
  144. data/lib/virtualbox/com/interface/3.2.x/host_usb_device_filter.rb +13 -0
  145. data/lib/virtualbox/com/interface/3.2.x/hw_virt_ex_property_type.rb +11 -0
  146. data/lib/virtualbox/com/interface/3.2.x/keyboard_hid_type.rb +11 -0
  147. data/lib/virtualbox/com/interface/3.2.x/machine.rb +118 -0
  148. data/lib/virtualbox/com/interface/3.2.x/machine_state.rb +14 -0
  149. data/lib/virtualbox/com/interface/3.2.x/medium.rb +51 -0
  150. data/lib/virtualbox/com/interface/3.2.x/medium_attachment.rb +18 -0
  151. data/lib/virtualbox/com/interface/3.2.x/medium_format.rb +18 -0
  152. data/lib/virtualbox/com/interface/3.2.x/medium_state.rb +11 -0
  153. data/lib/virtualbox/com/interface/3.2.x/medium_type.rb +11 -0
  154. data/lib/virtualbox/com/interface/3.2.x/medium_variant.rb +11 -0
  155. data/lib/virtualbox/com/interface/3.2.x/nat_alias_mode.rb +11 -0
  156. data/lib/virtualbox/com/interface/3.2.x/nat_engine.rb +27 -0
  157. data/lib/virtualbox/com/interface/3.2.x/nat_protocol.rb +11 -0
  158. data/lib/virtualbox/com/interface/3.2.x/network_adapter.rb +34 -0
  159. data/lib/virtualbox/com/interface/3.2.x/network_adapter_type.rb +11 -0
  160. data/lib/virtualbox/com/interface/3.2.x/network_attachment_type.rb +11 -0
  161. data/lib/virtualbox/com/interface/3.2.x/nsiexception.rb +23 -0
  162. data/lib/virtualbox/com/interface/3.2.x/nsisupports.rb +15 -0
  163. data/lib/virtualbox/com/interface/3.2.x/parallel_port.rb +17 -0
  164. data/lib/virtualbox/com/interface/3.2.x/pointing_hid_type.rb +11 -0
  165. data/lib/virtualbox/com/interface/3.2.x/port_mode.rb +11 -0
  166. data/lib/virtualbox/com/interface/3.2.x/progress.rb +63 -0
  167. data/lib/virtualbox/com/interface/3.2.x/serial_port.rb +19 -0
  168. data/lib/virtualbox/com/interface/3.2.x/session.rb +18 -0
  169. data/lib/virtualbox/com/interface/3.2.x/session_state.rb +11 -0
  170. data/lib/virtualbox/com/interface/3.2.x/session_type.rb +11 -0
  171. data/lib/virtualbox/com/interface/3.2.x/shared_folder.rb +17 -0
  172. data/lib/virtualbox/com/interface/3.2.x/snapshot.rb +20 -0
  173. data/lib/virtualbox/com/interface/3.2.x/storage_bus.rb +11 -0
  174. data/lib/virtualbox/com/interface/3.2.x/storage_controller.rb +24 -0
  175. data/lib/virtualbox/com/interface/3.2.x/storage_controller_type.rb +11 -0
  176. data/lib/virtualbox/com/interface/3.2.x/system_properties.rb +42 -0
  177. data/lib/virtualbox/com/interface/3.2.x/usb_controller.rb +21 -0
  178. data/lib/virtualbox/com/interface/3.2.x/usb_device.rb +24 -0
  179. data/lib/virtualbox/com/interface/3.2.x/usb_device_filter.rb +23 -0
  180. data/lib/virtualbox/com/interface/3.2.x/usb_device_filter_action.rb +11 -0
  181. data/lib/virtualbox/com/interface/3.2.x/usb_device_state.rb +11 -0
  182. data/lib/virtualbox/com/interface/3.2.x/virtual_box_error_info.rb +17 -0
  183. data/lib/virtualbox/com/interface/3.2.x/virtual_system_description.rb +19 -0
  184. data/lib/virtualbox/com/interface/3.2.x/virtual_system_description_type.rb +14 -0
  185. data/lib/virtualbox/com/interface/3.2.x/virtual_system_description_value_type.rb +11 -0
  186. data/lib/virtualbox/com/interface/3.2.x/virtualbox.rb +67 -0
  187. data/lib/virtualbox/com/interface/3.2.x/vrdp_auth_type.rb +11 -0
  188. data/lib/virtualbox/com/interface/3.2.x/vrdp_server.rb +21 -0
  189. data/lib/virtualbox/com/mscom_interface.rb +44 -0
  190. data/lib/virtualbox/com/nil_interface.rb +7 -0
  191. data/lib/virtualbox/com/util.rb +32 -0
  192. data/lib/virtualbox/cpu.rb +61 -0
  193. data/lib/virtualbox/dhcp_server.rb +89 -0
  194. data/lib/virtualbox/dvd.rb +27 -0
  195. data/lib/virtualbox/exceptions.rb +39 -0
  196. data/lib/virtualbox/ext/byte_normalizer.rb +17 -0
  197. data/lib/virtualbox/ext/glob_loader.rb +22 -0
  198. data/lib/virtualbox/ext/logger.rb +38 -0
  199. data/lib/virtualbox/ext/platform.rb +27 -0
  200. data/lib/virtualbox/ext/subclass_listing.rb +24 -0
  201. data/lib/virtualbox/extra_data.rb +127 -0
  202. data/lib/virtualbox/forwarded_port.rb +222 -0
  203. data/lib/virtualbox/global.rb +102 -0
  204. data/lib/virtualbox/guest_property.rb +116 -0
  205. data/lib/virtualbox/hard_drive.rb +246 -0
  206. data/lib/virtualbox/host.rb +71 -0
  207. data/lib/virtualbox/host_network_interface.rb +137 -0
  208. data/lib/virtualbox/hw_virtualization.rb +63 -0
  209. data/lib/virtualbox/lib.rb +84 -0
  210. data/lib/virtualbox/media.rb +20 -0
  211. data/lib/virtualbox/medium.rb +145 -0
  212. data/lib/virtualbox/medium_attachment.rb +61 -0
  213. data/lib/virtualbox/nat_engine.rb +71 -0
  214. data/lib/virtualbox/nat_forwarded_port.rb +171 -0
  215. data/lib/virtualbox/network_adapter.rb +166 -0
  216. data/lib/virtualbox/proxies/collection.rb +57 -0
  217. data/lib/virtualbox/shared_folder.rb +220 -0
  218. data/lib/virtualbox/snapshot.rb +185 -0
  219. data/lib/virtualbox/storage_controller.rb +160 -0
  220. data/lib/virtualbox/system_properties.rb +74 -0
  221. data/lib/virtualbox/usb_controller.rb +59 -0
  222. data/lib/virtualbox/usb_device_filter.rb +74 -0
  223. data/lib/virtualbox/version.rb +36 -0
  224. data/lib/virtualbox/virtual_system_description.rb +47 -0
  225. data/lib/virtualbox/vm.rb +684 -0
  226. data/lib/virtualbox/vrdp_server.rb +59 -0
  227. data/test/test_helper.rb +18 -0
  228. data/test/virtualbox/abstract_model/attributable_test.rb +269 -0
  229. data/test/virtualbox/abstract_model/dirty_test.rb +83 -0
  230. data/test/virtualbox/abstract_model/interface_attributes_test.rb +194 -0
  231. data/test/virtualbox/abstract_model/relatable_test.rb +348 -0
  232. data/test/virtualbox/abstract_model/validatable_test.rb +308 -0
  233. data/test/virtualbox/abstract_model/version_matcher_test.rb +41 -0
  234. data/test/virtualbox/abstract_model_test.rb +462 -0
  235. data/test/virtualbox/appliance_test.rb +159 -0
  236. data/test/virtualbox/audio_adapter_test.rb +83 -0
  237. data/test/virtualbox/bios_test.rb +83 -0
  238. data/test/virtualbox/com/abstract_enum_test.rb +49 -0
  239. data/test/virtualbox/com/abstract_implementer_test.rb +40 -0
  240. data/test/virtualbox/com/abstract_interface_test.rb +140 -0
  241. data/test/virtualbox/com/ffi/interface_test.rb +249 -0
  242. data/test/virtualbox/com/ffi/util_test.rb +108 -0
  243. data/test/virtualbox/com/ffi_interface_test.rb +42 -0
  244. data/test/virtualbox/com/implementer/base_test.rb +38 -0
  245. data/test/virtualbox/com/implementer/ffi_test.rb +527 -0
  246. data/test/virtualbox/com/implementer/mscom_test.rb +247 -0
  247. data/test/virtualbox/com/mscom_interface_test.rb +17 -0
  248. data/test/virtualbox/com/util_test.rb +17 -0
  249. data/test/virtualbox/cpu_test.rb +103 -0
  250. data/test/virtualbox/dhcp_server_test.rb +165 -0
  251. data/test/virtualbox/dvd_test.rb +28 -0
  252. data/test/virtualbox/ext/byte_normalizer_test.rb +34 -0
  253. data/test/virtualbox/ext/platform_test.rb +50 -0
  254. data/test/virtualbox/ext/subclass_listing_test.rb +25 -0
  255. data/test/virtualbox/extra_data_test.rb +155 -0
  256. data/test/virtualbox/forwarded_port_test.rb +286 -0
  257. data/test/virtualbox/global_test.rb +46 -0
  258. data/test/virtualbox/hard_drive_test.rb +141 -0
  259. data/test/virtualbox/host_network_interface_test.rb +254 -0
  260. data/test/virtualbox/host_test.rb +94 -0
  261. data/test/virtualbox/hw_virtualization_test.rb +103 -0
  262. data/test/virtualbox/lib_test.rb +93 -0
  263. data/test/virtualbox/medium_attachment_test.rb +147 -0
  264. data/test/virtualbox/medium_test.rb +192 -0
  265. data/test/virtualbox/nat_engine_test.rb +106 -0
  266. data/test/virtualbox/nat_forwarded_port_test.rb +222 -0
  267. data/test/virtualbox/network_adapter_test.rb +191 -0
  268. data/test/virtualbox/proxies/collection_test.rb +102 -0
  269. data/test/virtualbox/shared_folder_test.rb +219 -0
  270. data/test/virtualbox/snapshot_test.rb +231 -0
  271. data/test/virtualbox/storage_controller_test.rb +197 -0
  272. data/test/virtualbox/system_properties_test.rb +87 -0
  273. data/test/virtualbox/usb_controller_test.rb +112 -0
  274. data/test/virtualbox/usb_device_filter_test.rb +93 -0
  275. data/test/virtualbox/version_test.rb +59 -0
  276. data/test/virtualbox/virtual_system_description_test.rb +61 -0
  277. data/test/virtualbox/vm_test.rb +637 -0
  278. data/test/virtualbox/vrdp_server_test.rb +83 -0
  279. data/test/virtualbox_test.rb +11 -0
  280. data/virtualbox.gemspec +25 -0
  281. metadata +397 -0
@@ -0,0 +1,8 @@
1
+ doc/*
2
+ .yardoc/*
3
+ pkg/*
4
+ test/coverage/*
5
+ .bundle/*
6
+ Gemfile.lock
7
+ test.rb
8
+ *.rbc
@@ -0,0 +1,3 @@
1
+ -
2
+ docs/GettingStarted.md
3
+ docs/WhatsNew.md
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ # Gems required for development only.
6
+ group :development do
7
+ # Docs
8
+ gem "yard"
9
+
10
+ # Unit tests
11
+ gem "rcov"
12
+
13
+ # Integration tests
14
+ gem "cucumber", "~> 0.8.0"
15
+ gem "rspec"
16
+ end
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010 Mitchell Hashimoto.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ require "rake/testtask"
4
+ require "rcov/rcovtask"
5
+ require "cucumber"
6
+ require "cucumber/rake/task"
7
+ require "yard"
8
+ Bundler::GemHelper.install_tasks
9
+
10
+ task :default => "test:units"
11
+
12
+ namespace :test do
13
+ Rake::TestTask.new(:units) do |t|
14
+ t.libs << "test"
15
+ t.pattern = 'test/**/*_test.rb'
16
+ end
17
+
18
+ Cucumber::Rake::Task.new(:integration) do |t|
19
+ t.cucumber_opts = "features --format pretty"
20
+ end
21
+
22
+ Rcov::RcovTask.new do |t|
23
+ t.libs << "test"
24
+ t.test_files = FileList["test/**/*_test.rb"]
25
+ t.output_dir = "test/coverage"
26
+ t.verbose = true
27
+ end
28
+ end
29
+
30
+ YARD::Rake::YardocTask.new do |t|
31
+ t.options = ['--main', 'Readme.md', '--markup', 'markdown']
32
+ t.options += ['--title', 'VirtualBox Ruby Library Documentation']
33
+ end
@@ -0,0 +1,70 @@
1
+ # VirtualBox Ruby Gem
2
+
3
+ The VirtualBox ruby gem is a library which allows anyone to control VirtualBox
4
+ from ruby code! Create, destroy, start, stop, suspend, and resume virtual machines.
5
+ Also list virtual machines, list hard drives, network devices, etc.
6
+
7
+ ## Installation and Requirements
8
+
9
+ First you need to install [VirtualBox](http://www.virtualbox.org/) which is available for
10
+ Windows, Linux, and OS X. After installation, install the gem:
11
+
12
+ sudo gem install virtualbox
13
+
14
+ The gem uses the native COM interface with VirtualBox provides to communicate with
15
+ VirtualBox. On Windows, this is globally available. On Linux-based machines, the gem
16
+ uses Ruby-FFI to talk to a dynamic library. No configuration should be necessary.
17
+
18
+ ## Basic Usage
19
+
20
+ The virtualbox gem is modeled after ActiveRecord. If you've used ActiveRecord, you'll
21
+ feel very comfortable using the virtualbox gem.
22
+
23
+ There is a [quick getting started guide](http://mitchellh.github.com/virtualbox/file.GettingStarted.html) to
24
+ get you acquainted with the conventions of the virtualbox gem.
25
+
26
+ Complete documentation can be found at [http://mitchellh.github.com/virtualbox](http://mitchellh.github.com/virtualbox).
27
+
28
+ Below are some examples:
29
+
30
+ require 'virtualbox'
31
+
32
+ vm = VirtualBox::VM.find("my-vm")
33
+
34
+ # Let's first print out some basic info about the VM
35
+ puts "Memory: #{vm.memory_size}"
36
+
37
+ # Let's modify the memory and name...
38
+ vm.memory_size = 360
39
+ vm.name = "my-renamed-vm"
40
+
41
+ # Save it!
42
+ vm.save
43
+
44
+ ## Known Issues or Uncompleted Features
45
+
46
+ VirtualBox has a _ton_ of features! As such, this gem is still not totally complete.
47
+ You can see the features that are still left to do in the TODO file.
48
+
49
+ ## Reporting Bugs or Feature Requests
50
+
51
+ Please use the [issue tracker](https://github.com/mitchellh/virtualbox/issues).
52
+
53
+ ## Contributing
54
+
55
+ If you'd like to contribute to VirtualBox, the first step to developing is to
56
+ clone this repo, get [bundler](http://github.com/carlhuda/bundler) if you
57
+ don't have it already, and do the following:
58
+
59
+ bundle install --relock
60
+ rake
61
+
62
+ This will run the test suite, which should come back all green! Then you're good to go!
63
+
64
+ ## Special Thanks
65
+
66
+ These folks went above and beyond with contributions to the virtualbox gem, and
67
+ for that, I have to say "thanks!"
68
+
69
+ * [Kieran Pilkington](http://github.com/KieranP)
70
+ * [Aleksey Palazhchenko](http://github.com/AlekSi)
@@ -0,0 +1,196 @@
1
+ # Getting Started with the VirtualBox Gem
2
+
3
+ * [Basic Conventions](#basic-conventions)
4
+ * [Finding Models](#bc-finding-models)
5
+ * [Accessing Models](#bc-accessing-models)
6
+ * [Modifying Models](#bc-modifying-models)
7
+ * [Saving Models](#bc-saving-models)
8
+
9
+ <a name="basic-conventions"></a>
10
+ # Basic Conventions
11
+
12
+ The entire virtualbox library follows a few conventions to make sure
13
+ things work uniformly across the entire codebase, and so that nothing
14
+ should surprise any developers once they understand these conventions.
15
+
16
+ When browsing the documentation, you'll probably notice that a lot of the
17
+ classes inherit from {VirtualBox::AbstractModel}. This just means that all
18
+ these classes act the same way! Every {VirtualBox::AbstractModel AbstractModel}
19
+ shares the following behaviors:
20
+
21
+ * Finding
22
+ * Accessing
23
+ * Modifying
24
+ * Saving
25
+
26
+ These behaviors should be similar if not the exact same across all
27
+ virtualbox models. Each of these behaviors is covered below.
28
+
29
+ <a name="bc-finding-models"></a>
30
+ ## Finding Models
31
+
32
+ All data models have a `find` or `all` method (or sometimes both!) These
33
+ methods do what you expect them to: `all` will return an array of all instances
34
+ of that model which is typically unordered. `find` will allow you to find a
35
+ specific instance of that model, typically by name or UUID. Below are a couple
36
+ examples of this.
37
+
38
+ ### All
39
+
40
+ This example uses {VirtualBox::HardDrive}. As you can see, its just an
41
+ unmodified ruby `Array` which is returned by `all`. This can be used find,
42
+ sort, enumerate, etc.
43
+
44
+ drives = VirtualBox::HardDrive.all
45
+ puts "You have #{drives.length} hard drives!"
46
+
47
+ drives.each do |drive|
48
+ puts "Drive: #{drive.uuid}"
49
+ end
50
+
51
+ In the case that `all` returns an empty array, this simply means that none
52
+ of that model exist.
53
+
54
+ ### Find
55
+
56
+ This example uses {VirtualBox::VM}, which will probably be the most common
57
+ model you search for.
58
+
59
+ vm = VirtualBox::VM.find("MyVM")
60
+ puts "This VM has #{vm.memory} MB of RAM allocated to it."
61
+
62
+ Find can also be used with UUIDs:
63
+
64
+ vm = VirtualBox::VM.find("3d0f87b4-50f7-4fc5-ad89-93375b1b32a3")
65
+ puts "This VM's name is: #{vm.name}"
66
+
67
+ When a find fails, it will return `nil`.
68
+
69
+ <a name="bc-accessing-models"></a>
70
+ ## Accessing Models
71
+
72
+ Every model has an _attribute list_ associated with it. These attributes are
73
+ what can be accessed on the model via the typical ruby attribute accessing
74
+ syntax with the `.` (dot) operator. Because these methods are generated
75
+ dynamically, they don't show up as methods in the documentation. Because of this,
76
+ attributes are listed for every model in their overviews. For examples, see the
77
+ overviews of {VirtualBox::VM}, {VirtualBox::HardDrive}, etc.
78
+
79
+ In addition to an attribute list, many models also have _relationships_.
80
+ Relationships are, for our purposes, similar enough to attributes that they
81
+ can be treated the same. Relationship accessing methods are also dynamically
82
+ generated, so they are listed within the overviews of the models as well (if they
83
+ have any). Relationships allow two models to show that they are connected in some
84
+ way, and can therefore be accessed through each other.
85
+
86
+ ### Attributes
87
+
88
+ Reading attributes is simple. Let's use a {VirtualBox::VM} as an example:
89
+
90
+ vm = VirtualBox::VM.find("FooVM")
91
+
92
+ # Accessing attributes:
93
+ vm.memory
94
+ vm.name
95
+ vm.boot1
96
+ vm.ioapic
97
+
98
+ ### Relationships
99
+
100
+ Relationships are read the exact same way as attributes. Again using a
101
+ {VirtualBox::VM} as an example:
102
+
103
+ vm = VirtualBox::VM.find("FooVM")
104
+
105
+ # storage_controllers is a relationship containing an array of all the
106
+ # storage controllers on this VM
107
+ vm.storage_controllers.each do |sc|
108
+ puts "Storage Controller: #{sc.uuid}"
109
+ end
110
+
111
+ The difference from an attribute is that while attributes are typically ruby
112
+ primitives such as `String` or `Boolean`, relationship objects are always other
113
+ virtualbox models such as {VirtualBox::StorageController}.
114
+
115
+ <a name="bc-modifying-models"></a>
116
+ ## Modifying Models
117
+
118
+ In addition to simply reading attributes and relationships, most can be modified
119
+ as well. I say "most" because some attributes are `readonly` and some relationships
120
+ simply don't support being directly modified (though their objects may, I'll get to
121
+ this in a moment). By looking at the attribute list it is easy to spot a readonly
122
+ attribute, which will have the `:readonly` option set to `true`. Below is an example
123
+ of what you might see in the overview of some model:
124
+
125
+ attribute :uuid, :readonly => true
126
+
127
+ In the above case, you could read the `uuid` attribute as normal, but it wouldn't support
128
+ modification (and you'll simply get a `NoMethodError` if you try to set it).
129
+
130
+ Relationships are a little bit trickier, since when discussing modifying a relationship,
131
+ it could either be taken to mean the items _in_ the relationship, or the relationship
132
+ itself. A good rule of thumb, assuming there exists a relationship `foos`,is if you ever
133
+ want to do `object.foos =` something, then you're _modifying the relationship_ and _not_
134
+ the objects. But if you ever do `object.foos[0].destroy`, then you're _modifying the
135
+ relationship objects_ and _not_ the relationship itself.
136
+
137
+ ### Attributes
138
+
139
+ Attributes which support modification are modified like standard ruby attributes. The
140
+ following example uses {VirtualBox::HardDrive}:
141
+
142
+ hd = VirtualBox::HardDrive.new
143
+ hd.size = 2000 # megabytes
144
+ hd.format = "VMDK"
145
+
146
+ As you can see, there is nothing sneaky going on here, and does what you expect.
147
+
148
+ ### Relationships
149
+
150
+ Modifying relationships, on the other hand, is a little different. If the model supports
151
+ modifying the relationship (which it'll note in its respective documentation), then
152
+ you can set it just like an attribute. Below, we use {VirtualBox::AttachedDevice} as
153
+ an example:
154
+
155
+ ad = VirtualBox::AttachedDevice.new
156
+
157
+ # Attached devices have an image relationship
158
+ ad.image = VirtualBox::DVD.empty_drive
159
+
160
+ If a relationship doesn't support setting it, it will raise a {VirtualBox::Exceptions::NonSettableRelationshipException}.
161
+
162
+ **Note**: Below is an example of modifying a relationship object, rather than a
163
+ relationship itself. The example below uses {VirtualBox::VM}.
164
+
165
+ vm = VirtualBox::VM.find("FooVM")
166
+ vm.storage_controllers[0].name = "Foo Controller"
167
+
168
+ <a name="bc-saving-models"></a>
169
+ ## Saving Models
170
+
171
+ Saving models is _really_ easy: you simply call `save`. That's all! Well, there are
172
+ some subtleties, but that's the basic idea. `save` will typically **also save relationships**
173
+ so if you modify a relationship object or relationship itself, calling `save` on the
174
+ parent object will typically save the relationships as well. `save` always returns
175
+ `true` or `false` depending on whether the operation was a success or not. If you'd like
176
+ instead to know why a `save` failed, you can call the method with a `true` parameter
177
+ which sets `raise_errors` to `true` and will raise a {VirtualBox::Exceptions::CommandFailedException}
178
+ if there is a failure. The message on this object contains the reason.
179
+
180
+ Below is an example of saving a simple {VirtualBox::VM} object:
181
+
182
+ vm = VirtualBox::VM.find("FooVM")
183
+
184
+ # Double the memory
185
+ vm.memory = vm.memory.to_i * 2
186
+
187
+ # This will return true/false depending on success
188
+ vm.save
189
+
190
+ Below is an example where an exception will be raised if an error occurs:
191
+
192
+ vm = VirtualBox::VM.find("FooVM")
193
+ vm.memory = "INVALID"
194
+
195
+ # This will raise an exception, since the memory is invalid
196
+ vm.save(true)
@@ -0,0 +1,12 @@
1
+ # What's New in 0.6.x?
2
+
3
+ ## Native Interface
4
+
5
+ The VirtualBox gem no longer piggy-backs on top of `VBoxManage` or XML configuration files.
6
+ The gem now uses the native interface provided by VirtualBox to communicate. The result of
7
+ this is a _huge_ speed increase which simply would not have been possible otherwise, and
8
+ stability across versions. In addition to that, the entire VirtualBox API is now at your
9
+ disposal. While the gem itself doesn't yet support creating VMs and so on, the API is available
10
+ for you to do it manually (if you really wanted to!).
11
+
12
+ Future versions will support more and more of the API.
@@ -0,0 +1,33 @@
1
+ # VirtualBox Gem Feature Tests
2
+
3
+ **Warning: These tests actually hit the real VirtualBox software!**
4
+
5
+ The tests in this directory are _not_ meant as a replacement
6
+ for the unit tests in the `test/` directory. Instead, these
7
+ features are meant to test the actual integration of the
8
+ virtualbox gem with an actual VirtualBox installation.
9
+
10
+ Whereas the unit tests try to test every branch of the code in a
11
+ very prescribed, isolated environment, the feature tests do not
12
+ test specific branches of code, but test behavior of the gem.
13
+ The reasoning for both tests is that the unit tests test proper
14
+ behavior _within the library itself_ whereas these feature tests
15
+ test proper behavior _with the outside world_.
16
+
17
+ ## Running Feature Tests
18
+
19
+ The easiest way to run these feature tests is via `rake` or the
20
+ `cucumber` binary. `rake` shown below:
21
+
22
+ rake test:integration
23
+
24
+ ## Feature Coverage
25
+
26
+ The test coverage of the features are purposefully not trying to
27
+ reach 100% branch coverage. They test the basic functionality (and
28
+ as much as the functionality as possible) to verify the library is
29
+ functional. If a bug is found, then a feature should be added to
30
+ reproduce and verify the bug no longer exists, but I'm not concerned
31
+ with getting 100% branch coverage right away.
32
+
33
+ For 100% branch coverage, see the unit tests, which do this.
@@ -0,0 +1,19 @@
1
+ Feature: Global Data
2
+ As a virtualbox library user
3
+ I want to access information about the global state of VirtualBox
4
+ In order to get information about my environment
5
+
6
+ Scenario: Reading the VMs
7
+ Given the global object
8
+ When I read the "vms"
9
+ Then I should get a matching length for "vms"
10
+
11
+ Scenario: Reading the hard drives
12
+ Given the global object
13
+ When I read the media "hard drives"
14
+ Then I should get a matching length of media items
15
+
16
+ Scenario: Reading the dvds
17
+ Given the global object
18
+ When I read the media "dvds"
19
+ Then I should get a matching length of media items
@@ -0,0 +1,27 @@
1
+ Feature: Global Extra Data
2
+ As a virtualbox library user
3
+ I want to access and update global extra data
4
+
5
+ Background:
6
+ Given the global object
7
+ And I delete the "global" extra data "VirtualBoxGemTest/Key"
8
+ And the "extra_data" relationship
9
+
10
+ Scenario: Reading extra data
11
+ When I get the extra data of "global"
12
+ Then all the extra data should match
13
+
14
+ @unsafe
15
+ Scenario: Writing extra data
16
+ When I set the extra data "VirtualBoxGemTest/Key" to "Value"
17
+ And I save the relationship
18
+ And I get the extra data of "global"
19
+ Then the extra data should include "VirtualBoxGemTest/Key" as "Value"
20
+
21
+ @unsafe
22
+ Scenario: Deleting extra data
23
+ When I set the extra data "VirtualBoxGemTest/Key" to "Value"
24
+ And I save the relationship
25
+ And I delete the extra data "VirtualBoxGemTest/Key"
26
+ And I get the extra data of "global"
27
+ Then the extra data should not include "VirtualBoxGemTest/Key"