velir_virtualbox 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (350) 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 +37 -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 +63 -0
  56. data/lib/virtualbox/com/ffi/util.rb +121 -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 +381 -0
  61. data/lib/virtualbox/com/implementer/mscom.rb +189 -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/interface/4.0.x/access_mode.rb +11 -0
  190. data/lib/virtualbox/com/interface/4.0.x/appliance.rb +23 -0
  191. data/lib/virtualbox/com/interface/4.0.x/audio_adapter.rb +15 -0
  192. data/lib/virtualbox/com/interface/4.0.x/audio_controller_type.rb +11 -0
  193. data/lib/virtualbox/com/interface/4.0.x/audio_driver_type.rb +11 -0
  194. data/lib/virtualbox/com/interface/4.0.x/auth_type.rb +11 -0
  195. data/lib/virtualbox/com/interface/4.0.x/bios_boot_menu_mode.rb +11 -0
  196. data/lib/virtualbox/com/interface/4.0.x/bios_settings.rb +21 -0
  197. data/lib/virtualbox/com/interface/4.0.x/cleanup_mode.rb +12 -0
  198. data/lib/virtualbox/com/interface/4.0.x/clipboard_mode.rb +11 -0
  199. data/lib/virtualbox/com/interface/4.0.x/console.rb +50 -0
  200. data/lib/virtualbox/com/interface/4.0.x/cpu_property_type.rb +11 -0
  201. data/lib/virtualbox/com/interface/4.0.x/device_type.rb +11 -0
  202. data/lib/virtualbox/com/interface/4.0.x/dhcp_server.rb +22 -0
  203. data/lib/virtualbox/com/interface/4.0.x/event_source.rb +13 -0
  204. data/lib/virtualbox/com/interface/4.0.x/fault_tolerance_state.rb +11 -0
  205. data/lib/virtualbox/com/interface/4.0.x/firmware_type.rb +11 -0
  206. data/lib/virtualbox/com/interface/4.0.x/guest.rb +13 -0
  207. data/lib/virtualbox/com/interface/4.0.x/guest_os_type.rb +33 -0
  208. data/lib/virtualbox/com/interface/4.0.x/host.rb +43 -0
  209. data/lib/virtualbox/com/interface/4.0.x/host_network_interface.rb +30 -0
  210. data/lib/virtualbox/com/interface/4.0.x/host_network_interface_medium_type.rb +11 -0
  211. data/lib/virtualbox/com/interface/4.0.x/host_network_interface_status.rb +11 -0
  212. data/lib/virtualbox/com/interface/4.0.x/host_network_interface_type.rb +11 -0
  213. data/lib/virtualbox/com/interface/4.0.x/host_usb_device.rb +13 -0
  214. data/lib/virtualbox/com/interface/4.0.x/host_usb_device_filter.rb +13 -0
  215. data/lib/virtualbox/com/interface/4.0.x/hw_virt_ex_property_type.rb +12 -0
  216. data/lib/virtualbox/com/interface/4.0.x/keyboard_hid_type.rb +11 -0
  217. data/lib/virtualbox/com/interface/4.0.x/lock_type.rb +11 -0
  218. data/lib/virtualbox/com/interface/4.0.x/machine.rb +132 -0
  219. data/lib/virtualbox/com/interface/4.0.x/machine_state.rb +14 -0
  220. data/lib/virtualbox/com/interface/4.0.x/medium.rb +53 -0
  221. data/lib/virtualbox/com/interface/4.0.x/medium_attachment.rb +18 -0
  222. data/lib/virtualbox/com/interface/4.0.x/medium_format.rb +18 -0
  223. data/lib/virtualbox/com/interface/4.0.x/medium_state.rb +11 -0
  224. data/lib/virtualbox/com/interface/4.0.x/medium_type.rb +11 -0
  225. data/lib/virtualbox/com/interface/4.0.x/medium_variant.rb +11 -0
  226. data/lib/virtualbox/com/interface/4.0.x/nat_alias_mode.rb +11 -0
  227. data/lib/virtualbox/com/interface/4.0.x/nat_engine.rb +27 -0
  228. data/lib/virtualbox/com/interface/4.0.x/nat_protocol.rb +11 -0
  229. data/lib/virtualbox/com/interface/4.0.x/network_adapter.rb +35 -0
  230. data/lib/virtualbox/com/interface/4.0.x/network_adapter_type.rb +11 -0
  231. data/lib/virtualbox/com/interface/4.0.x/network_attachment_type.rb +11 -0
  232. data/lib/virtualbox/com/interface/4.0.x/nsiexception.rb +23 -0
  233. data/lib/virtualbox/com/interface/4.0.x/nsisupports.rb +15 -0
  234. data/lib/virtualbox/com/interface/4.0.x/parallel_port.rb +17 -0
  235. data/lib/virtualbox/com/interface/4.0.x/pointing_hid_type.rb +11 -0
  236. data/lib/virtualbox/com/interface/4.0.x/port_mode.rb +11 -0
  237. data/lib/virtualbox/com/interface/4.0.x/progress.rb +64 -0
  238. data/lib/virtualbox/com/interface/4.0.x/serial_port.rb +19 -0
  239. data/lib/virtualbox/com/interface/4.0.x/session.rb +18 -0
  240. data/lib/virtualbox/com/interface/4.0.x/session_state.rb +11 -0
  241. data/lib/virtualbox/com/interface/4.0.x/session_type.rb +11 -0
  242. data/lib/virtualbox/com/interface/4.0.x/shared_folder.rb +17 -0
  243. data/lib/virtualbox/com/interface/4.0.x/snapshot.rb +20 -0
  244. data/lib/virtualbox/com/interface/4.0.x/storage_bus.rb +11 -0
  245. data/lib/virtualbox/com/interface/4.0.x/storage_controller.rb +24 -0
  246. data/lib/virtualbox/com/interface/4.0.x/storage_controller_type.rb +11 -0
  247. data/lib/virtualbox/com/interface/4.0.x/system_properties.rb +42 -0
  248. data/lib/virtualbox/com/interface/4.0.x/usb_controller.rb +21 -0
  249. data/lib/virtualbox/com/interface/4.0.x/usb_device.rb +24 -0
  250. data/lib/virtualbox/com/interface/4.0.x/usb_device_filter.rb +23 -0
  251. data/lib/virtualbox/com/interface/4.0.x/usb_device_filter_action.rb +11 -0
  252. data/lib/virtualbox/com/interface/4.0.x/usb_device_state.rb +11 -0
  253. data/lib/virtualbox/com/interface/4.0.x/virtual_box_error_info.rb +17 -0
  254. data/lib/virtualbox/com/interface/4.0.x/virtual_system_description.rb +19 -0
  255. data/lib/virtualbox/com/interface/4.0.x/virtual_system_description_type.rb +14 -0
  256. data/lib/virtualbox/com/interface/4.0.x/virtual_system_description_value_type.rb +11 -0
  257. data/lib/virtualbox/com/interface/4.0.x/virtualbox.rb +50 -0
  258. data/lib/virtualbox/com/interface/4.0.x/vrde_server.rb +23 -0
  259. data/lib/virtualbox/com/mscom_interface.rb +44 -0
  260. data/lib/virtualbox/com/nil_interface.rb +7 -0
  261. data/lib/virtualbox/com/util.rb +32 -0
  262. data/lib/virtualbox/cpu.rb +61 -0
  263. data/lib/virtualbox/dhcp_server.rb +89 -0
  264. data/lib/virtualbox/dvd.rb +27 -0
  265. data/lib/virtualbox/exceptions.rb +39 -0
  266. data/lib/virtualbox/ext/byte_normalizer.rb +17 -0
  267. data/lib/virtualbox/ext/glob_loader.rb +35 -0
  268. data/lib/virtualbox/ext/logger.rb +38 -0
  269. data/lib/virtualbox/ext/platform.rb +31 -0
  270. data/lib/virtualbox/ext/subclass_listing.rb +24 -0
  271. data/lib/virtualbox/extra_data.rb +127 -0
  272. data/lib/virtualbox/forwarded_port.rb +222 -0
  273. data/lib/virtualbox/global.rb +96 -0
  274. data/lib/virtualbox/hard_drive.rb +246 -0
  275. data/lib/virtualbox/host.rb +71 -0
  276. data/lib/virtualbox/host_network_interface.rb +137 -0
  277. data/lib/virtualbox/hw_virtualization.rb +64 -0
  278. data/lib/virtualbox/lib.rb +84 -0
  279. data/lib/virtualbox/media.rb +20 -0
  280. data/lib/virtualbox/medium.rb +145 -0
  281. data/lib/virtualbox/medium_attachment.rb +61 -0
  282. data/lib/virtualbox/nat_engine.rb +71 -0
  283. data/lib/virtualbox/nat_forwarded_port.rb +171 -0
  284. data/lib/virtualbox/network_adapter.rb +166 -0
  285. data/lib/virtualbox/proxies/collection.rb +57 -0
  286. data/lib/virtualbox/shared_folder.rb +220 -0
  287. data/lib/virtualbox/snapshot.rb +185 -0
  288. data/lib/virtualbox/storage_controller.rb +160 -0
  289. data/lib/virtualbox/system_properties.rb +73 -0
  290. data/lib/virtualbox/usb_controller.rb +59 -0
  291. data/lib/virtualbox/usb_device_filter.rb +74 -0
  292. data/lib/virtualbox/version.rb +36 -0
  293. data/lib/virtualbox/virtual_system_description.rb +47 -0
  294. data/lib/virtualbox/vm.rb +649 -0
  295. data/lib/virtualbox/vrde_server.rb +57 -0
  296. data/test/test_helper.rb +18 -0
  297. data/test/virtualbox/abstract_model/attributable_test.rb +269 -0
  298. data/test/virtualbox/abstract_model/dirty_test.rb +83 -0
  299. data/test/virtualbox/abstract_model/interface_attributes_test.rb +194 -0
  300. data/test/virtualbox/abstract_model/relatable_test.rb +348 -0
  301. data/test/virtualbox/abstract_model/validatable_test.rb +308 -0
  302. data/test/virtualbox/abstract_model/version_matcher_test.rb +41 -0
  303. data/test/virtualbox/abstract_model_test.rb +462 -0
  304. data/test/virtualbox/appliance_test.rb +159 -0
  305. data/test/virtualbox/audio_adapter_test.rb +83 -0
  306. data/test/virtualbox/bios_test.rb +83 -0
  307. data/test/virtualbox/com/abstract_enum_test.rb +49 -0
  308. data/test/virtualbox/com/abstract_implementer_test.rb +40 -0
  309. data/test/virtualbox/com/abstract_interface_test.rb +140 -0
  310. data/test/virtualbox/com/ffi/interface_test.rb +249 -0
  311. data/test/virtualbox/com/ffi/util_test.rb +108 -0
  312. data/test/virtualbox/com/ffi_interface_test.rb +42 -0
  313. data/test/virtualbox/com/implementer/base_test.rb +38 -0
  314. data/test/virtualbox/com/implementer/ffi_test.rb +527 -0
  315. data/test/virtualbox/com/implementer/mscom_test.rb +247 -0
  316. data/test/virtualbox/com/mscom_interface_test.rb +17 -0
  317. data/test/virtualbox/com/util_test.rb +17 -0
  318. data/test/virtualbox/cpu_test.rb +103 -0
  319. data/test/virtualbox/dhcp_server_test.rb +165 -0
  320. data/test/virtualbox/dvd_test.rb +28 -0
  321. data/test/virtualbox/ext/byte_normalizer_test.rb +34 -0
  322. data/test/virtualbox/ext/platform_test.rb +50 -0
  323. data/test/virtualbox/ext/subclass_listing_test.rb +25 -0
  324. data/test/virtualbox/extra_data_test.rb +155 -0
  325. data/test/virtualbox/forwarded_port_test.rb +286 -0
  326. data/test/virtualbox/global_test.rb +46 -0
  327. data/test/virtualbox/hard_drive_test.rb +141 -0
  328. data/test/virtualbox/host_network_interface_test.rb +255 -0
  329. data/test/virtualbox/host_test.rb +94 -0
  330. data/test/virtualbox/hw_virtualization_test.rb +103 -0
  331. data/test/virtualbox/lib_test.rb +93 -0
  332. data/test/virtualbox/medium_attachment_test.rb +147 -0
  333. data/test/virtualbox/medium_test.rb +192 -0
  334. data/test/virtualbox/nat_engine_test.rb +106 -0
  335. data/test/virtualbox/nat_forwarded_port_test.rb +222 -0
  336. data/test/virtualbox/network_adapter_test.rb +191 -0
  337. data/test/virtualbox/proxies/collection_test.rb +102 -0
  338. data/test/virtualbox/shared_folder_test.rb +219 -0
  339. data/test/virtualbox/snapshot_test.rb +231 -0
  340. data/test/virtualbox/storage_controller_test.rb +197 -0
  341. data/test/virtualbox/system_properties_test.rb +87 -0
  342. data/test/virtualbox/usb_controller_test.rb +112 -0
  343. data/test/virtualbox/usb_device_filter_test.rb +93 -0
  344. data/test/virtualbox/version_test.rb +59 -0
  345. data/test/virtualbox/virtual_system_description_test.rb +61 -0
  346. data/test/virtualbox/vm_test.rb +633 -0
  347. data/test/virtualbox/vrde_server_test.rb +83 -0
  348. data/test/virtualbox_test.rb +11 -0
  349. data/virtualbox.gemspec +24 -0
  350. metadata +464 -0
@@ -0,0 +1,17 @@
1
+ module VirtualBox::ByteNormalizer
2
+ # So that this is only defined once (suppress warnings)
3
+ if !defined?(THOUSAND)
4
+ THOUSAND = 1024.0
5
+ BYTE = 1.0
6
+ KILOBYTE = BYTE * THOUSAND
7
+ MEGABYTE = KILOBYTE * THOUSAND
8
+ end
9
+
10
+ def bytes_to_megabytes(b)
11
+ b / MEGABYTE
12
+ end
13
+
14
+ def megabytes_to_bytes(mb)
15
+ mb * MEGABYTE
16
+ end
17
+ end
@@ -0,0 +1,35 @@
1
+ require 'virtualbox/ext/platform'
2
+
3
+ module VirtualBox
4
+ # Eases the processes of loading specific files then globbing
5
+ # the rest from a specified directory.
6
+ module GlobLoader
7
+ # Glob requires all ruby files in a directory, optionally loading select
8
+ # files initially (since others may depend on them).
9
+ #
10
+ # @param [String] dir The directory to glob
11
+ # @param [Array<String>] initial_files Initial files (relative to `dir`)
12
+ # to load
13
+ def self.glob_require(dir, initial_files=[])
14
+ # Note: The paths below both are "downcased" because on Windows, some
15
+ # expand to "c:\" and some expand to "C:\" and cause the same file to
16
+ # be loaded twice. Uck.
17
+
18
+ require_files = []
19
+ initial_files.each do |file|
20
+ require_files << File.expand_path(file, dir)
21
+ end
22
+
23
+ # Glob require the rest
24
+ Dir[File.join(dir, "**", "*.rb")].each do |f|
25
+ require_files << File.expand_path(f)
26
+ end
27
+
28
+ # Iterate over the files to require, manipulating them if necessary
29
+ require_files.each do |file|
30
+ file = file.downcase if Platform.windows?
31
+ require file
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,38 @@
1
+ require 'logger'
2
+
3
+ module VirtualBox
4
+ # Provides logger functionality for VirtualBox. This class is available on most
5
+ # VirtualBox classes through mixins. To access the logger, simply call the {logger}
6
+ # method. This returns a standard Ruby logger which can be modified.
7
+ module Logger
8
+ @@logger = nil
9
+ @@logger_output = nil
10
+
11
+ # Make the logger available both on a class and instance level
12
+ # once included.
13
+ def self.included(base)
14
+ base.extend self
15
+ end
16
+
17
+ # Sets up the output stream for the logger. This should be called before any
18
+ # calls to {logger}. If the logger has already been instantiated, then a new
19
+ # logger will be created on the next call with the new output setup.
20
+ def logger_output=(value)
21
+ @@logger_output = value
22
+ @@logger = nil
23
+ end
24
+
25
+ # Accesses the logger. If logger output is specified and this is the first load,
26
+ # then the logger will be properly setup to point to that output. Logging
27
+ # levels should also be set once the logger is created. The logger is a standard
28
+ # Ruby `Logger`.
29
+ #
30
+ # The VirtualBox gem can get very verybose very quickly, so choose a log level
31
+ # which suits the granularity needed.
32
+ #
33
+ # @return [Logger]
34
+ def logger
35
+ @@logger ||= ::Logger.new(@@logger_output)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,31 @@
1
+ require "rbconfig"
2
+
3
+ module VirtualBox
4
+ class Platform
5
+ class << self
6
+ def mac?
7
+ platform.include?("darwin")
8
+ end
9
+
10
+ def windows?
11
+ platform.include?("mswin") || platform.include?("mingw") || platform.include?("cygwin")
12
+ end
13
+
14
+ def linux?
15
+ platform.include?("linux")
16
+ end
17
+
18
+ def solaris?
19
+ platform.include?("solaris")
20
+ end
21
+
22
+ def jruby?
23
+ RbConfig::CONFIG["ruby_install_name"] == "jruby"
24
+ end
25
+
26
+ def platform
27
+ RbConfig::CONFIG["host_os"].downcase
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,24 @@
1
+ # From: http://snippets.dzone.com/posts/show/2992
2
+ module VirtualBox::SubclassListing
3
+ def self.included(base)
4
+ base.extend ClassMethods
5
+ end
6
+
7
+ module ClassMethods
8
+ def subclasses(direct = false)
9
+ classes = []
10
+ if direct
11
+ ObjectSpace.each_object(Class) do |c|
12
+ next unless c.superclass == self
13
+ classes << c
14
+ end
15
+ else
16
+ ObjectSpace.each_object(Class) do |c|
17
+ next unless c.ancestors.include?(self) and (c != self)
18
+ classes << c
19
+ end
20
+ end
21
+ classes
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,127 @@
1
+ module VirtualBox
2
+ # Represents "extra data" which can be set on a specific
3
+ # virtual machine or on VirtualBox as a whole. Extra data is persistent
4
+ # key-value storage which is available as a way to store any information
5
+ # wanted. VirtualBox uses it for storing statistics and settings. You can
6
+ # use it for anything!
7
+ #
8
+ # # Extra Data on a Virtual Machine
9
+ #
10
+ # Setting extra data on a virtual machine is easy. All {VM} objects have a
11
+ # `extra_data` relationship which is just a simple ruby hash, so you can treat
12
+ # it like one! Once the data is set, simply saving the VM will save the
13
+ # extra data. An example below:
14
+ #
15
+ # vm = VirtualBox::VM.find("FooVM")
16
+ # vm.extra_data["ruby-accessed"] = "yes, yes it was"
17
+ # vm.save
18
+ #
19
+ # Now, let's say you open up the VM again some other time:
20
+ #
21
+ # vm = VirtualBox::VM.find("FooVM")
22
+ # puts vm.extra_data["ruby-accessed"]
23
+ #
24
+ # It acts just like a hash!
25
+ #
26
+ # # Global Extra Data
27
+ #
28
+ # Extra data doesn't need to be tied to a specific virtual machine. It can also
29
+ # exist globally. Setting global extra-data is just as easy:
30
+ #
31
+ # VirtualBox::ExtraData.global["some-key"] = "some value"
32
+ # VirtualBox::ExtraData.global.save
33
+ #
34
+ class ExtraData < Hash
35
+ include AbstractModel::Dirty
36
+
37
+ attr_accessor :parent
38
+ attr_reader :interface
39
+
40
+ @@global_data = nil
41
+
42
+ class << self
43
+ # Gets the global extra data. This will "cache" the data for
44
+ # future use unless you set the `reload` paramter to true.
45
+ #
46
+ # @param [Boolean] reload If true, will reload new global data.
47
+ # @return [Array<ExtraData>]
48
+ def global(reload=false)
49
+ if !@@global_data || reload
50
+ @@global_data = Global.global.extra_data
51
+ end
52
+
53
+ @@global_data
54
+ end
55
+
56
+ # Populates a relationship with another model.
57
+ #
58
+ # **This method typically won't be used except internally.**
59
+ #
60
+ # @return [Array<ExtraData>]
61
+ def populate_relationship(caller, interface)
62
+ data = new(caller, interface)
63
+
64
+ interface.get_extra_data_keys.each do |key|
65
+ data[key] = interface.get_extra_data(key)
66
+ end
67
+
68
+ data.clear_dirty!
69
+ data
70
+ end
71
+
72
+ # Saves the relationship. This simply calls {#save} on every
73
+ # member of the relationship.
74
+ #
75
+ # **This method typically won't be used except internally.**
76
+ def save_relationship(caller, data)
77
+ data.save
78
+ end
79
+ end
80
+
81
+ # Initializes an extra data object.
82
+ #
83
+ # @param [Hash] data Initial attributes to populate.
84
+ def initialize(parent, interface)
85
+ @parent = parent
86
+ @interface = interface
87
+ end
88
+
89
+ # Set an extradata key-value pair. Overrides ruby hash implementation
90
+ # to set dirty state. Otherwise that, behaves the same way.
91
+ def []=(key,value)
92
+ set_dirty!(key, self[key], value)
93
+ super
94
+ end
95
+
96
+ # Saves extra data. This method does the same thing for both new
97
+ # and existing extra data, since virtualbox will overwrite old data or
98
+ # create it if it doesn't exist.
99
+ #
100
+ # @param [Boolean] raise_errors If true, {Exceptions::CommandFailedException}
101
+ # will be raised if the command failed.
102
+ # @return [Boolean] True if command was successful, false otherwise.
103
+ def save
104
+ changes.each do |key, value|
105
+ interface.set_extra_data(key.to_s, value[1].to_s)
106
+
107
+ clear_dirty!(key)
108
+
109
+ if value[1].nil?
110
+ # Remove the key from the hash altogether
111
+ hash_delete(key.to_s)
112
+ end
113
+ end
114
+ end
115
+
116
+ # Alias away the old delete method so its still accessible somehow
117
+ alias :hash_delete :delete
118
+
119
+ # Deletes the specified extra data.
120
+ #
121
+ # @param [String] key The extra data key to delete
122
+ def delete(key)
123
+ interface.set_extra_data(key.to_s, nil)
124
+ hash_delete(key.to_s)
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,222 @@
1
+ module VirtualBox
2
+ # When a VM uses NAT as its NIC type, VirtualBox acts like its
3
+ # own private router for all virtual machines. Because of this,
4
+ # the host machine can't access services within the guest machine.
5
+ # To get around this, NAT supports port forwarding, which allows the
6
+ # guest machine services to be forwarded to some port on the host
7
+ # machine. Port forwarding is done completely through {ExtraData}, but
8
+ # is a complicated enough procedure that this class was made to
9
+ # faciliate it.
10
+ #
11
+ # **Note:** After changing any forwarded ports, the entire VirtualBox
12
+ # process must be restarted completely for them to take effect. When
13
+ # working with the ruby library, this isn't so much of an issue, but
14
+ # if you have any VMs running, they must all be shut down and restarted.
15
+ #
16
+ # # Adding a new Forwarded Port
17
+ #
18
+ # Since forwarded ports rely on being part of a {VM}, we're going to
19
+ # assume that `vm` points to a {VM} which has already been found.
20
+ #
21
+ # port = VirtualBox::ForwardedPort.new
22
+ # port.name = "apache" # This can be anything
23
+ # port.guestport = 80
24
+ # port.hostport = 8080
25
+ # vm.forwarded_ports << port
26
+ # port.save # Or vm.save
27
+ #
28
+ # # Modifying an Existing Forwarded Port
29
+ #
30
+ # This is assuming that `vm` is a local variable storing a {VM} object
31
+ # which has already been found.
32
+ #
33
+ # vm.forwarded_ports.first.hostport = 1919
34
+ # vm.save
35
+ #
36
+ # # Deleting a Forwarded Port
37
+ #
38
+ # To delete a forwarded port, you simply destroy it like any other model:
39
+ #
40
+ # vm.forwarded_ports.first.destroy
41
+ #
42
+ # # Attributes and Relationships
43
+ #
44
+ # Properties of the model are exposed using standard ruby instance
45
+ # methods which are generated on the fly. Because of this, they are not listed
46
+ # below as available instance methods.
47
+ #
48
+ # These attributes can be accessed and modified via standard ruby-style
49
+ # `instance.attribute` and `instance.attribute=` methods. The attributes are
50
+ # listed below.
51
+ #
52
+ # Relationships are also accessed like attributes but can't be set. Instead,
53
+ # they are typically references to other objects such as an {AttachedDevice} which
54
+ # in turn have their own attributes which can be modified.
55
+ #
56
+ # ## Attributes
57
+ #
58
+ # This is copied directly from the class header, but lists all available
59
+ # attributes. If you don't understand what this means, read {Attributable}.
60
+ #
61
+ # attribute :parent, :readonly => true
62
+ # attribute :name
63
+ # attribute :instance, :default => "0"
64
+ # attribute :device, :default => "pcnet"
65
+ # attribute :protocol, :default => "TCP"
66
+ # attribute :guestport
67
+ # attribute :hostport
68
+ #
69
+ class ForwardedPort < AbstractModel
70
+ attribute :parent, :readonly => true, :property => false
71
+ attribute :parent_collection, :readonly => true, :property => false
72
+ attribute :name
73
+ attribute :instance, :default => "0"
74
+ attribute :device, :default => "pcnet"
75
+ attribute :protocol, :default => "TCP"
76
+ attribute :guestport
77
+ attribute :hostport
78
+
79
+ class << self
80
+ # Populates a relationship with another model.
81
+ #
82
+ # **This method typically won't be used except internally.**
83
+ #
84
+ # @return [Array<ForwardedPort>]
85
+ def populate_relationship(caller, data)
86
+ relation = Proxies::Collection.new(caller)
87
+
88
+ caller.extra_data.each do |key, value|
89
+ next unless key =~ /^(VBoxInternal\/Devices\/(.+?)\/(.+?)\/LUN#0\/Config\/(.+?)\/)Protocol$/i
90
+
91
+ port = new({
92
+ :parent => caller,
93
+ :parent_collection => relation,
94
+ :name => $4.to_s,
95
+ :instance => $3.to_s,
96
+ :device => $2.to_s,
97
+ :protocol => value,
98
+ :guestport => caller.extra_data["#{$1.to_s}GuestPort"],
99
+ :hostport => caller.extra_data["#{$1.to_s}HostPort"]
100
+ })
101
+
102
+ port.existing_record!
103
+
104
+ relation.push(port)
105
+ end
106
+
107
+ relation
108
+ end
109
+
110
+ # Saves the relationship. This simply calls {#save} on every
111
+ # member of the relationship.
112
+ #
113
+ # **This method typically won't be used except internally.**
114
+ def save_relationship(caller, data)
115
+ data.dup.each do |fp|
116
+ fp.save
117
+ end
118
+ end
119
+ end
120
+
121
+ # @param [Hash] data The initial attributes to populate.
122
+ def initialize(data={})
123
+ super()
124
+ populate_attributes(data) if !data.empty?
125
+ end
126
+
127
+ # Validates a forwarded port.
128
+ def validate
129
+ super
130
+
131
+ validates_presence_of :parent
132
+ validates_presence_of :name
133
+ validates_presence_of :guestport
134
+ validates_presence_of :hostport
135
+ end
136
+
137
+ # Retrieves the device for the forwarded port. This tries to "do the
138
+ # right thing" depending on the first NIC of the VM parent by either
139
+ # setting the forwarded port type to "pcnet" or "e1000." If the device
140
+ # was already set manually, this method will simply return that value
141
+ # instead.
142
+ #
143
+ # @return [String] Device type for the forwarded port
144
+ def device
145
+ # Return the current or default value if it is:
146
+ # * an existing record, since it was already mucked with, no need to
147
+ # modify it again
148
+ # * device setting changed, since we should return what the user set
149
+ # it to
150
+ # * If the parent is nil, since we can't infer the type without a parent
151
+ return read_attribute(:device) if !new_record? || device_changed? || parent.nil?
152
+
153
+ device_map = {
154
+ :Am79C970A => "pcnet",
155
+ :Am79C973 => "pcnet",
156
+ :I82540EM => "e1000",
157
+ :I82543GC => "e1000",
158
+ :I82545EM => "e1000"
159
+ }
160
+
161
+ return device_map[parent.network_adapters[0].adapter_type]
162
+ end
163
+
164
+ # Saves the forwarded port.
165
+ #
166
+ # @return [Boolean] True if command was successful, false otherwise.
167
+ def save
168
+ return true if !new_record? && !changed?
169
+ raise Exceptions::ValidationFailedException.new(errors) if !valid?
170
+
171
+ destroy if !new_record? && name_changed?
172
+
173
+ parent.extra_data["#{key_prefix}Protocol"] = protocol
174
+ parent.extra_data["#{key_prefix}GuestPort"] = guestport
175
+ parent.extra_data["#{key_prefix}HostPort"] = hostport
176
+ result = parent.extra_data.save
177
+
178
+ clear_dirty!
179
+ existing_record!
180
+
181
+ result
182
+ end
183
+
184
+ # Destroys the port forwarding mapping.
185
+ #
186
+ # @return [Boolean] True if command was successful, false otherwise.
187
+ def destroy
188
+ results = []
189
+
190
+ if !new_record?
191
+ results << parent.extra_data.delete("#{key_prefix(true)}Protocol")
192
+ results << parent.extra_data.delete("#{key_prefix(true)}GuestPort")
193
+ results << parent.extra_data.delete("#{key_prefix(true)}HostPort")
194
+
195
+ # Remove it from any collection
196
+ parent_collection.delete(self, true) if parent_collection
197
+
198
+ new_record!
199
+ end
200
+
201
+ results.empty? || results.all? { |o| o == true }
202
+ end
203
+
204
+ # Relationship callback when added to a collection. This is automatically
205
+ # called by any relationship collection when this object is added.
206
+ def added_to_relationship(proxy)
207
+ write_attribute(:parent, proxy.parent)
208
+ write_attribute(:parent_collection, proxy)
209
+ end
210
+
211
+ # Returns the prefix to be used for the extra data key. Forwarded ports
212
+ # are created by simply setting {ExtraData} on a {VM}. This class hides most
213
+ # of the inner workings of it, but it requires a common prefix. This method
214
+ # generates that.
215
+ #
216
+ # @return [String]
217
+ def key_prefix(old_name=false)
218
+ name_value = old_name && name_changed? ? name_was : name
219
+ "VBoxInternal\/Devices\/#{device}\/#{instance}\/LUN#0\/Config\/#{name_value}\/"
220
+ end
221
+ end
222
+ end