vagrantup 1.0.7 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (623) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +91 -0
  3. data/LICENSE +2 -2
  4. data/README.md +11 -13
  5. data/bin/vagrant +29 -5
  6. data/config/default.rb +14 -9
  7. data/contrib/bash/completion.sh +3 -0
  8. data/keys/README.md +3 -3
  9. data/lib/vagrant.rb +156 -102
  10. data/lib/vagrant/action.rb +26 -47
  11. data/lib/vagrant/action/builder.rb +49 -23
  12. data/lib/vagrant/action/builtin/box_add.rb +85 -0
  13. data/lib/vagrant/action/builtin/call.rb +67 -0
  14. data/lib/vagrant/action/builtin/config_validate.rb +30 -0
  15. data/lib/vagrant/action/builtin/confirm.rb +38 -0
  16. data/lib/vagrant/action/builtin/env_set.rb +24 -0
  17. data/lib/vagrant/action/builtin/graceful_halt.rb +73 -0
  18. data/lib/vagrant/action/builtin/handle_box_url.rb +43 -0
  19. data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +117 -0
  20. data/lib/vagrant/action/builtin/lock.rb +57 -0
  21. data/lib/vagrant/action/builtin/nfs.rb +117 -0
  22. data/lib/vagrant/action/builtin/provision.rb +70 -0
  23. data/lib/vagrant/action/builtin/set_hostname.rb +27 -0
  24. data/lib/vagrant/action/builtin/ssh_exec.rb +42 -0
  25. data/lib/vagrant/action/builtin/ssh_run.rb +43 -0
  26. data/lib/vagrant/action/general/package.rb +19 -18
  27. data/lib/vagrant/action/hook.rb +103 -0
  28. data/lib/vagrant/action/runner.rb +21 -5
  29. data/lib/vagrant/action/warden.rb +20 -9
  30. data/lib/vagrant/box.rb +75 -26
  31. data/lib/vagrant/box_collection.rb +301 -35
  32. data/lib/vagrant/cli.rb +20 -14
  33. data/lib/vagrant/config.rb +23 -9
  34. data/lib/vagrant/config/loader.rb +131 -36
  35. data/lib/vagrant/config/v1.rb +9 -0
  36. data/lib/vagrant/config/v1/dummy_config.rb +13 -0
  37. data/lib/vagrant/config/v1/loader.rb +105 -0
  38. data/lib/vagrant/config/v1/root.rb +60 -0
  39. data/lib/vagrant/config/v2.rb +9 -0
  40. data/lib/vagrant/config/v2/dummy_config.rb +13 -0
  41. data/lib/vagrant/config/v2/loader.rb +141 -0
  42. data/lib/vagrant/config/v2/root.rb +105 -0
  43. data/lib/vagrant/config/v2/util.rb +21 -0
  44. data/lib/vagrant/config/version_base.rb +80 -0
  45. data/lib/vagrant/downloaders/base.rb +0 -3
  46. data/lib/vagrant/downloaders/file.rb +10 -4
  47. data/lib/vagrant/downloaders/http.rb +29 -10
  48. data/lib/vagrant/environment.rb +447 -240
  49. data/lib/vagrant/errors.rb +138 -97
  50. data/lib/vagrant/hosts.rb +3 -12
  51. data/lib/vagrant/machine.rb +325 -0
  52. data/lib/vagrant/machine_state.rb +45 -0
  53. data/lib/vagrant/plugin.rb +3 -78
  54. data/lib/vagrant/plugin/v1.rb +19 -0
  55. data/lib/vagrant/plugin/v1/command.rb +169 -0
  56. data/lib/vagrant/plugin/v1/communicator.rb +98 -0
  57. data/lib/vagrant/plugin/v1/config.rb +112 -0
  58. data/lib/vagrant/plugin/v1/errors.rb +15 -0
  59. data/lib/vagrant/plugin/v1/guest.rb +92 -0
  60. data/lib/vagrant/plugin/v1/host.rb +66 -0
  61. data/lib/vagrant/plugin/v1/manager.rb +131 -0
  62. data/lib/vagrant/plugin/v1/plugin.rb +229 -0
  63. data/lib/vagrant/plugin/v1/provider.rb +68 -0
  64. data/lib/vagrant/plugin/v1/provisioner.rb +50 -0
  65. data/lib/vagrant/plugin/v2.rb +22 -0
  66. data/lib/vagrant/plugin/v2/command.rb +234 -0
  67. data/lib/vagrant/plugin/v2/communicator.rb +98 -0
  68. data/lib/vagrant/plugin/v2/components.rb +29 -0
  69. data/lib/vagrant/plugin/v2/config.rb +101 -0
  70. data/lib/vagrant/plugin/v2/errors.rb +15 -0
  71. data/lib/vagrant/plugin/v2/guest.rb +92 -0
  72. data/lib/vagrant/plugin/v2/host.rb +66 -0
  73. data/lib/vagrant/plugin/v2/manager.rb +158 -0
  74. data/lib/vagrant/plugin/v2/plugin.rb +217 -0
  75. data/lib/vagrant/plugin/v2/provider.rb +69 -0
  76. data/lib/vagrant/plugin/v2/provisioner.rb +47 -0
  77. data/lib/vagrant/registry.rb +43 -17
  78. data/lib/vagrant/ssh.rb +15 -9
  79. data/lib/vagrant/ui.rb +7 -5
  80. data/lib/vagrant/util/is_port_open.rb +1 -1
  81. data/lib/vagrant/util/platform.rb +19 -0
  82. data/lib/vagrant/util/retryable.rb +8 -2
  83. data/lib/vagrant/util/safe_exec.rb +2 -2
  84. data/lib/vagrant/util/scoped_hash_override.rb +45 -0
  85. data/lib/vagrant/util/ssh.rb +126 -0
  86. data/lib/vagrant/util/string_block_editor.rb +75 -0
  87. data/lib/vagrant/util/subprocess.rb +33 -10
  88. data/lib/vagrant/util/which.rb +43 -0
  89. data/lib/vagrant/version.rb +1 -1
  90. data/plugins/README.md +5 -0
  91. data/plugins/commands/box/command/add.rb +46 -0
  92. data/plugins/commands/box/command/list.rb +41 -0
  93. data/plugins/commands/box/command/remove.rb +37 -0
  94. data/plugins/commands/box/command/repackage.rb +43 -0
  95. data/plugins/commands/box/command/root.rb +75 -0
  96. data/plugins/commands/box/plugin.rb +15 -0
  97. data/plugins/commands/destroy/command.rb +31 -0
  98. data/plugins/commands/destroy/plugin.rb +18 -0
  99. data/plugins/commands/halt/command.rb +33 -0
  100. data/plugins/commands/halt/plugin.rb +18 -0
  101. data/{lib/vagrant/command/init.rb → plugins/commands/init/command.rb} +4 -4
  102. data/plugins/commands/init/plugin.rb +18 -0
  103. data/plugins/commands/package/command.rb +83 -0
  104. data/plugins/commands/package/plugin.rb +18 -0
  105. data/plugins/commands/plugin/action.rb +52 -0
  106. data/plugins/commands/plugin/action/bundler_check.rb +25 -0
  107. data/plugins/commands/plugin/action/install_gem.rb +70 -0
  108. data/plugins/commands/plugin/action/license_plugin.rb +54 -0
  109. data/plugins/commands/plugin/action/list_plugins.rb +54 -0
  110. data/plugins/commands/plugin/action/prune_gems.rb +149 -0
  111. data/plugins/commands/plugin/action/uninstall_plugin.rb +23 -0
  112. data/plugins/commands/plugin/command/base.rb +22 -0
  113. data/plugins/commands/plugin/command/install.rb +39 -0
  114. data/plugins/commands/plugin/command/license.rb +31 -0
  115. data/plugins/commands/plugin/command/list.rb +28 -0
  116. data/plugins/commands/plugin/command/root.rb +75 -0
  117. data/plugins/commands/plugin/command/uninstall.rb +28 -0
  118. data/plugins/commands/plugin/gem_helper.rb +74 -0
  119. data/plugins/commands/plugin/plugin.rb +22 -0
  120. data/plugins/commands/plugin/state_file.rb +57 -0
  121. data/plugins/commands/provision/command.rb +34 -0
  122. data/plugins/commands/provision/plugin.rb +18 -0
  123. data/plugins/commands/reload/command.rb +37 -0
  124. data/plugins/commands/reload/plugin.rb +18 -0
  125. data/plugins/commands/resume/command.rb +25 -0
  126. data/plugins/commands/resume/plugin.rb +17 -0
  127. data/{lib/vagrant/command/ssh.rb → plugins/commands/ssh/command.rb} +17 -41
  128. data/plugins/commands/ssh/plugin.rb +17 -0
  129. data/{lib/vagrant/command/ssh_config.rb → plugins/commands/ssh_config/command.rb} +14 -16
  130. data/plugins/commands/ssh_config/plugin.rb +18 -0
  131. data/plugins/commands/status/command.rb +39 -0
  132. data/plugins/commands/status/plugin.rb +18 -0
  133. data/plugins/commands/suspend/command.rb +25 -0
  134. data/plugins/commands/suspend/plugin.rb +18 -0
  135. data/plugins/commands/up/command.rb +45 -0
  136. data/plugins/commands/up/plugin.rb +17 -0
  137. data/{lib/vagrant/command → plugins/commands/up}/start_mixins.rb +6 -6
  138. data/{lib/vagrant/communication/ssh.rb → plugins/communicators/ssh/communicator.rb} +139 -52
  139. data/plugins/communicators/ssh/plugin.rb +19 -0
  140. data/plugins/guests/arch/guest.rb +41 -0
  141. data/plugins/guests/arch/plugin.rb +15 -0
  142. data/{lib/vagrant/guest/debian.rb → plugins/guests/debian/guest.rb} +21 -13
  143. data/plugins/guests/debian/plugin.rb +15 -0
  144. data/{lib/vagrant/guest/fedora.rb → plugins/guests/fedora/guest.rb} +19 -14
  145. data/plugins/guests/fedora/plugin.rb +15 -0
  146. data/plugins/guests/freebsd/config.rb +13 -0
  147. data/plugins/guests/freebsd/guest.rb +70 -0
  148. data/plugins/guests/freebsd/plugin.rb +20 -0
  149. data/plugins/guests/gentoo/guest.rb +51 -0
  150. data/plugins/guests/gentoo/plugin.rb +15 -0
  151. data/plugins/guests/linux/config.rb +13 -0
  152. data/{lib/vagrant/guest/linux.rb → plugins/guests/linux/guest.rb} +35 -34
  153. data/plugins/guests/linux/plugin.rb +20 -0
  154. data/plugins/guests/openbsd/guest.rb +13 -0
  155. data/plugins/guests/openbsd/plugin.rb +15 -0
  156. data/{lib/vagrant/guest/redhat.rb → plugins/guests/redhat/guest.rb} +22 -15
  157. data/plugins/guests/redhat/plugin.rb +15 -0
  158. data/plugins/guests/solaris/config.rb +18 -0
  159. data/plugins/guests/solaris/guest.rb +73 -0
  160. data/plugins/guests/solaris/plugin.rb +20 -0
  161. data/plugins/guests/suse/guest.rb +24 -0
  162. data/plugins/guests/suse/plugin.rb +15 -0
  163. data/plugins/guests/ubuntu/guest.rb +44 -0
  164. data/plugins/guests/ubuntu/plugin.rb +15 -0
  165. data/{lib/vagrant/hosts/arch.rb → plugins/hosts/arch/host.rb} +18 -5
  166. data/plugins/hosts/arch/plugin.rb +15 -0
  167. data/{lib/vagrant/hosts/bsd.rb → plugins/hosts/bsd/host.rb} +16 -11
  168. data/plugins/hosts/bsd/plugin.rb +15 -0
  169. data/{lib/vagrant/hosts/fedora.rb → plugins/hosts/fedora/host.rb} +8 -4
  170. data/plugins/hosts/fedora/plugin.rb +15 -0
  171. data/{lib/vagrant/hosts/freebsd.rb → plugins/hosts/freebsd/host.rb} +10 -8
  172. data/plugins/hosts/freebsd/plugin.rb +15 -0
  173. data/{lib/vagrant/hosts/gentoo.rb → plugins/hosts/gentoo/host.rb} +7 -3
  174. data/plugins/hosts/gentoo/plugin.rb +15 -0
  175. data/{lib/vagrant/hosts/linux.rb → plugins/hosts/linux/host.rb} +12 -11
  176. data/plugins/hosts/linux/plugin.rb +15 -0
  177. data/{lib/vagrant/hosts/opensuse.rb → plugins/hosts/opensuse/host.rb} +8 -4
  178. data/plugins/hosts/opensuse/plugin.rb +15 -0
  179. data/{lib/vagrant/hosts/windows.rb → plugins/hosts/windows/host.rb} +5 -4
  180. data/plugins/hosts/windows/plugin.rb +15 -0
  181. data/plugins/kernel_v1/config/nfs.rb +20 -0
  182. data/plugins/kernel_v1/config/package.rb +17 -0
  183. data/plugins/kernel_v1/config/ssh.rb +46 -0
  184. data/plugins/kernel_v1/config/vagrant.rb +31 -0
  185. data/plugins/kernel_v1/config/vm.rb +184 -0
  186. data/plugins/kernel_v1/plugin.rb +44 -0
  187. data/plugins/kernel_v2/config/nfs.rb +10 -0
  188. data/plugins/kernel_v2/config/package.rb +9 -0
  189. data/plugins/kernel_v2/config/ssh.rb +35 -0
  190. data/plugins/kernel_v2/config/vagrant.rb +9 -0
  191. data/plugins/kernel_v2/config/vm.rb +314 -0
  192. data/plugins/kernel_v2/config/vm_provisioner.rb +40 -0
  193. data/plugins/kernel_v2/config/vm_subvm.rb +30 -0
  194. data/plugins/kernel_v2/plugin.rb +44 -0
  195. data/plugins/providers/virtualbox/action.rb +308 -0
  196. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/boot.rb +12 -16
  197. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/check_accessible.rb +5 -5
  198. data/plugins/providers/virtualbox/action/check_created.rb +21 -0
  199. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/check_guest_additions.rb +18 -11
  200. data/plugins/providers/virtualbox/action/check_running.rb +21 -0
  201. data/plugins/providers/virtualbox/action/check_virtualbox.rb +22 -0
  202. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/clean_machine_folder.rb +5 -5
  203. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/clear_forwarded_ports.rb +4 -4
  204. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/clear_network_interfaces.rb +4 -4
  205. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/clear_shared_folders.rb +4 -5
  206. data/plugins/providers/virtualbox/action/created.rb +20 -0
  207. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/customize.rb +7 -7
  208. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/destroy.rb +5 -5
  209. data/plugins/providers/virtualbox/action/destroy_confirm.rb +17 -0
  210. data/plugins/providers/virtualbox/action/destroy_unused_network_interfaces.rb +16 -0
  211. data/plugins/providers/virtualbox/action/discard_state.rb +20 -0
  212. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/export.rb +7 -7
  213. data/plugins/providers/virtualbox/action/forced_halt.rb +25 -0
  214. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/forward_ports.rb +29 -42
  215. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/import.rb +15 -12
  216. data/plugins/providers/virtualbox/action/is_paused.rb +20 -0
  217. data/plugins/providers/virtualbox/action/is_running.rb +20 -0
  218. data/plugins/providers/virtualbox/action/is_saved.rb +20 -0
  219. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/match_mac_address.rb +5 -5
  220. data/plugins/providers/virtualbox/action/message_not_created.rb +16 -0
  221. data/plugins/providers/virtualbox/action/message_not_running.rb +16 -0
  222. data/plugins/providers/virtualbox/action/message_will_not_destroy.rb +17 -0
  223. data/plugins/providers/virtualbox/action/network.rb +366 -0
  224. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/package.rb +4 -7
  225. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/package_vagrantfile.rb +5 -8
  226. data/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb +35 -0
  227. data/plugins/providers/virtualbox/action/prepare_nfs_settings.rb +51 -0
  228. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/prune_nfs_exports.rb +5 -5
  229. data/plugins/providers/virtualbox/action/resume.rb +25 -0
  230. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/sane_defaults.rb +41 -32
  231. data/plugins/providers/virtualbox/action/set_name.rb +40 -0
  232. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/setup_package_files.rb +5 -8
  233. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/share_folders.rb +24 -25
  234. data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/suspend.rb +5 -5
  235. data/plugins/providers/virtualbox/config.rb +82 -0
  236. data/plugins/providers/virtualbox/driver/base.rb +344 -0
  237. data/plugins/providers/virtualbox/driver/meta.rb +142 -0
  238. data/plugins/providers/virtualbox/driver/version_4_0.rb +485 -0
  239. data/plugins/providers/virtualbox/driver/version_4_1.rb +485 -0
  240. data/plugins/providers/virtualbox/driver/version_4_2.rb +475 -0
  241. data/plugins/providers/virtualbox/model/forwarded_port.rb +58 -0
  242. data/plugins/providers/virtualbox/plugin.rb +42 -0
  243. data/plugins/providers/virtualbox/provider.rb +92 -0
  244. data/plugins/providers/virtualbox/util/compile_forwarded_ports.rb +31 -0
  245. data/plugins/provisioners/chef/config/base.rb +65 -0
  246. data/plugins/provisioners/chef/config/chef_client.rb +39 -0
  247. data/plugins/provisioners/chef/config/chef_solo.rb +87 -0
  248. data/plugins/provisioners/chef/plugin.rb +33 -0
  249. data/plugins/provisioners/chef/provisioner/base.rb +91 -0
  250. data/plugins/provisioners/chef/provisioner/chef_client.rb +103 -0
  251. data/plugins/provisioners/chef/provisioner/chef_solo.rb +182 -0
  252. data/plugins/provisioners/puppet/config/puppet.rb +70 -0
  253. data/plugins/provisioners/puppet/config/puppet_server.rb +16 -0
  254. data/plugins/provisioners/puppet/plugin.rb +33 -0
  255. data/plugins/provisioners/puppet/provisioner/puppet.rb +110 -0
  256. data/plugins/provisioners/puppet/provisioner/puppet_server.rb +67 -0
  257. data/plugins/provisioners/shell/config.rb +46 -0
  258. data/plugins/provisioners/shell/plugin.rb +23 -0
  259. data/plugins/provisioners/shell/provisioner.rb +66 -0
  260. data/templates/commands/init/Vagrantfile.erb +33 -21
  261. data/templates/commands/ssh_config/config.erb +1 -0
  262. data/templates/config/messages.erb +14 -0
  263. data/templates/config/validation_failed.erb +3 -3
  264. data/templates/guests/arch/network_dhcp.erb +4 -7
  265. data/templates/guests/arch/network_static.erb +6 -7
  266. data/templates/guests/debian/network_dhcp.erb +5 -0
  267. data/templates/locales/en.yml +336 -100
  268. data/templates/rgloader.rb +9 -0
  269. data/test/acceptance/support/isolated_environment.rb +3 -2
  270. data/test/support/tempdir.rb +13 -4
  271. data/test/unit/base.rb +6 -0
  272. data/test/unit/support/dummy_provider.rb +16 -0
  273. data/test/unit/support/isolated_environment.rb +132 -0
  274. data/test/unit/support/shared/base_context.rb +74 -0
  275. data/test/unit/vagrant/action/builder_test.rb +88 -48
  276. data/test/unit/vagrant/action/builtin/call_test.rb +145 -0
  277. data/test/unit/vagrant/action/builtin/confirm_test.rb +36 -0
  278. data/test/unit/vagrant/action/builtin/env_set_test.rb +20 -0
  279. data/test/unit/vagrant/action/builtin/graceful_halt_test.rb +61 -0
  280. data/test/unit/vagrant/action/builtin/lock_test.rb +98 -0
  281. data/test/unit/vagrant/action/builtin/ssh_exec_test.rb +57 -0
  282. data/test/unit/vagrant/action/hook_test.rb +101 -0
  283. data/test/unit/vagrant/action/runner_test.rb +15 -9
  284. data/test/unit/vagrant/box_collection_test.rb +219 -38
  285. data/test/unit/vagrant/box_test.rb +94 -19
  286. data/test/unit/vagrant/cli_test.rb +27 -0
  287. data/test/unit/vagrant/config/loader_test.rb +154 -49
  288. data/test/unit/vagrant/config/v1/dummy_config_test.rb +24 -0
  289. data/test/unit/vagrant/config/v1/loader_test.rb +145 -0
  290. data/test/unit/vagrant/config/v1/root_test.rb +40 -0
  291. data/test/unit/vagrant/config/v2/dummy_config_test.rb +24 -0
  292. data/test/unit/vagrant/config/v2/loader_test.rb +151 -0
  293. data/test/unit/vagrant/config/v2/root_test.rb +97 -0
  294. data/test/unit/vagrant/config/v2/util_test.rb +21 -0
  295. data/test/unit/vagrant/config_test.rb +40 -1
  296. data/test/unit/vagrant/downloaders/base_test.rb +0 -4
  297. data/test/unit/vagrant/downloaders/file_test.rb +21 -9
  298. data/test/unit/vagrant/downloaders/http_test.rb +4 -0
  299. data/test/unit/vagrant/environment_test.rb +414 -63
  300. data/test/unit/vagrant/hosts_test.rb +10 -9
  301. data/test/unit/vagrant/machine_state_test.rb +26 -0
  302. data/test/unit/vagrant/machine_test.rb +418 -0
  303. data/test/unit/vagrant/{command/base_test.rb → plugin/v1/command_test.rb} +2 -9
  304. data/test/unit/vagrant/plugin/v1/communicator_test.rb +9 -0
  305. data/test/unit/vagrant/plugin/v1/config_test.rb +50 -0
  306. data/test/unit/vagrant/plugin/v1/host_test.rb +5 -0
  307. data/test/unit/vagrant/plugin/v1/manager_test.rb +114 -0
  308. data/test/unit/vagrant/plugin/v1/plugin_test.rb +267 -0
  309. data/test/unit/vagrant/plugin/v1/provider_test.rb +18 -0
  310. data/test/unit/vagrant/plugin/v2/command_test.rb +238 -0
  311. data/test/unit/vagrant/plugin/v2/communicator_test.rb +9 -0
  312. data/test/unit/vagrant/plugin/v2/components_test.rb +17 -0
  313. data/test/unit/vagrant/plugin/v2/config_test.rb +60 -0
  314. data/test/unit/vagrant/plugin/v2/host_test.rb +5 -0
  315. data/test/unit/vagrant/plugin/v2/manager_test.rb +157 -0
  316. data/test/unit/vagrant/plugin/v2/plugin_test.rb +287 -0
  317. data/test/unit/vagrant/plugin/v2/provider_test.rb +18 -0
  318. data/test/unit/vagrant/registry_test.rb +59 -5
  319. data/test/unit/vagrant/util/scoped_hash_override_test.rb +48 -0
  320. data/test/unit/vagrant/util/ssh_test.rb +30 -0
  321. data/test/unit/vagrant/util/string_block_editor_test.rb +98 -0
  322. data/test/unit/vagrant/util/which_test.rb +43 -0
  323. data/test/unit/vagrant_test.rb +42 -13
  324. data/vagrant.gemspec +6 -7
  325. data/vagrant.gemspecbak +6 -7
  326. metadata +273 -358
  327. data/lib/vagrant/action/box/destroy.rb +0 -25
  328. data/lib/vagrant/action/box/download.rb +0 -84
  329. data/lib/vagrant/action/box/package.rb +0 -19
  330. data/lib/vagrant/action/box/unpackage.rb +0 -61
  331. data/lib/vagrant/action/box/verify.rb +0 -23
  332. data/lib/vagrant/action/builtin.rb +0 -171
  333. data/lib/vagrant/action/env/set.rb +0 -21
  334. data/lib/vagrant/action/environment.rb +0 -12
  335. data/lib/vagrant/action/general/check_virtualbox.rb +0 -28
  336. data/lib/vagrant/action/general/validate.rb +0 -18
  337. data/lib/vagrant/action/vm/check_box.rb +0 -33
  338. data/lib/vagrant/action/vm/check_port_collisions.rb +0 -89
  339. data/lib/vagrant/action/vm/default_name.rb +0 -22
  340. data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +0 -20
  341. data/lib/vagrant/action/vm/discard_state.rb +0 -22
  342. data/lib/vagrant/action/vm/halt.rb +0 -32
  343. data/lib/vagrant/action/vm/host_name.rb +0 -21
  344. data/lib/vagrant/action/vm/network.rb +0 -403
  345. data/lib/vagrant/action/vm/nfs.rb +0 -196
  346. data/lib/vagrant/action/vm/provision.rb +0 -61
  347. data/lib/vagrant/action/vm/provisioner_cleanup.rb +0 -26
  348. data/lib/vagrant/action/vm/resume.rb +0 -20
  349. data/lib/vagrant/command.rb +0 -24
  350. data/lib/vagrant/command/base.rb +0 -167
  351. data/lib/vagrant/command/box.rb +0 -58
  352. data/lib/vagrant/command/box_add.rb +0 -37
  353. data/lib/vagrant/command/box_list.rb +0 -28
  354. data/lib/vagrant/command/box_remove.rb +0 -27
  355. data/lib/vagrant/command/box_repackage.rb +0 -27
  356. data/lib/vagrant/command/destroy.rb +0 -64
  357. data/lib/vagrant/command/gem.rb +0 -39
  358. data/lib/vagrant/command/halt.rb +0 -39
  359. data/lib/vagrant/command/package.rb +0 -75
  360. data/lib/vagrant/command/provision.rb +0 -40
  361. data/lib/vagrant/command/reload.rb +0 -39
  362. data/lib/vagrant/command/resume.rb +0 -33
  363. data/lib/vagrant/command/status.rb +0 -36
  364. data/lib/vagrant/command/suspend.rb +0 -33
  365. data/lib/vagrant/command/up.rb +0 -40
  366. data/lib/vagrant/communication.rb +0 -7
  367. data/lib/vagrant/communication/base.rb +0 -56
  368. data/lib/vagrant/config/base.rb +0 -82
  369. data/lib/vagrant/config/error_recorder.rb +0 -19
  370. data/lib/vagrant/config/nfs.rb +0 -8
  371. data/lib/vagrant/config/package.rb +0 -7
  372. data/lib/vagrant/config/ssh.rb +0 -27
  373. data/lib/vagrant/config/top.rb +0 -72
  374. data/lib/vagrant/config/vagrant.rb +0 -14
  375. data/lib/vagrant/config/vm.rb +0 -168
  376. data/lib/vagrant/config/vm/provisioner.rb +0 -52
  377. data/lib/vagrant/config/vm/sub_vm.rb +0 -17
  378. data/lib/vagrant/data_store.rb +0 -92
  379. data/lib/vagrant/driver.rb +0 -8
  380. data/lib/vagrant/driver/virtualbox.rb +0 -134
  381. data/lib/vagrant/driver/virtualbox_4_0.rb +0 -459
  382. data/lib/vagrant/driver/virtualbox_4_1.rb +0 -459
  383. data/lib/vagrant/driver/virtualbox_4_2.rb +0 -606
  384. data/lib/vagrant/driver/virtualbox_base.rb +0 -326
  385. data/lib/vagrant/guest.rb +0 -18
  386. data/lib/vagrant/guest/arch.rb +0 -56
  387. data/lib/vagrant/guest/base.rb +0 -99
  388. data/lib/vagrant/guest/freebsd.rb +0 -86
  389. data/lib/vagrant/guest/gentoo.rb +0 -46
  390. data/lib/vagrant/guest/linux/config.rb +0 -19
  391. data/lib/vagrant/guest/linux/error.rb +0 -9
  392. data/lib/vagrant/guest/openbsd.rb +0 -20
  393. data/lib/vagrant/guest/solaris.rb +0 -118
  394. data/lib/vagrant/guest/suse.rb +0 -17
  395. data/lib/vagrant/guest/ubuntu.rb +0 -23
  396. data/lib/vagrant/hosts/base.rb +0 -66
  397. data/lib/vagrant/provisioners.rb +0 -12
  398. data/lib/vagrant/provisioners/base.rb +0 -44
  399. data/lib/vagrant/provisioners/chef.rb +0 -168
  400. data/lib/vagrant/provisioners/chef_client.rb +0 -132
  401. data/lib/vagrant/provisioners/chef_solo.rb +0 -234
  402. data/lib/vagrant/provisioners/puppet.rb +0 -176
  403. data/lib/vagrant/provisioners/puppet_server.rb +0 -78
  404. data/lib/vagrant/provisioners/shell.rb +0 -103
  405. data/lib/vagrant/vm.rb +0 -195
  406. data/test/buildbot/README.md +0 -72
  407. data/test/buildbot/buildbot_config/__init__.py +0 -0
  408. data/test/buildbot/buildbot_config/config/__init__.py +0 -0
  409. data/test/buildbot/buildbot_config/config/loader.py +0 -24
  410. data/test/buildbot/buildbot_config/config/master.py +0 -24
  411. data/test/buildbot/buildbot_config/config/slave.py +0 -22
  412. data/test/buildbot/buildbot_config/master/__init__.py +0 -6
  413. data/test/buildbot/buildbot_config/master/builders.py +0 -78
  414. data/test/buildbot/buildbot_config/master/buildsteps.py +0 -100
  415. data/test/buildbot/buildbot_config/master/change_sources.py +0 -8
  416. data/test/buildbot/buildbot_config/master/schedulers.py +0 -32
  417. data/test/buildbot/buildbot_config/master/slaves.py +0 -60
  418. data/test/buildbot/buildbot_config/master/status.py +0 -52
  419. data/test/buildbot/master/Makefile.sample +0 -28
  420. data/test/buildbot/master/buildbot.tac +0 -36
  421. data/test/buildbot/master/master.cfg +0 -67
  422. data/test/buildbot/master/public_html/bg_gradient.jpg +0 -0
  423. data/test/buildbot/master/public_html/default.css +0 -545
  424. data/test/buildbot/master/public_html/favicon.ico +0 -0
  425. data/test/buildbot/master/public_html/robots.txt +0 -10
  426. data/test/buildbot/master/public_html/static/css/bootstrap-1.4.0.min.css +0 -356
  427. data/test/buildbot/master/public_html/static/css/prettify.css +0 -97
  428. data/test/buildbot/master/public_html/static/css/syntax.css +0 -60
  429. data/test/buildbot/master/public_html/static/css/vagrant.base.css +0 -205
  430. data/test/buildbot/master/public_html/static/images/base_box_mac.jpg +0 -0
  431. data/test/buildbot/master/public_html/static/images/getting-started/success.jpg +0 -0
  432. data/test/buildbot/master/public_html/static/images/icons/error.png +0 -0
  433. data/test/buildbot/master/public_html/static/images/vagrant_chilling.png +0 -0
  434. data/test/buildbot/master/public_html/static/images/vagrant_holding.png +0 -0
  435. data/test/buildbot/master/public_html/static/images/vagrant_looking.png +0 -0
  436. data/test/buildbot/master/public_html/static/images/windows/alter_path.jpg +0 -0
  437. data/test/buildbot/master/public_html/static/images/windows/edit_path.jpg +0 -0
  438. data/test/buildbot/master/public_html/static/images/windows/environment_variables_button.jpg +0 -0
  439. data/test/buildbot/master/public_html/static/images/windows/port_and_ppk_path.jpg +0 -0
  440. data/test/buildbot/master/public_html/static/images/windows/ppk_selection.jpg +0 -0
  441. data/test/buildbot/master/public_html/static/images/windows/putty_first_screen.jpg +0 -0
  442. data/test/buildbot/master/public_html/static/images/windows/save_result.jpg +0 -0
  443. data/test/buildbot/master/public_html/static/images/windows/vbox_manage_default_location.jpg +0 -0
  444. data/test/buildbot/master/public_html/static/js/bootstrap-tabs.js +0 -80
  445. data/test/buildbot/master/public_html/static/js/jquery-1.7.min.js +0 -4
  446. data/test/buildbot/master/templates/authfail.html +0 -9
  447. data/test/buildbot/master/templates/build.html +0 -205
  448. data/test/buildbot/master/templates/builder.html +0 -118
  449. data/test/buildbot/master/templates/builders.html +0 -33
  450. data/test/buildbot/master/templates/buildslave.html +0 -72
  451. data/test/buildbot/master/templates/buildslaves.html +0 -70
  452. data/test/buildbot/master/templates/change.html +0 -15
  453. data/test/buildbot/master/templates/layouts/base.html +0 -58
  454. data/test/buildbot/master/templates/macros/box.html +0 -37
  455. data/test/buildbot/master/templates/macros/build_line.html +0 -50
  456. data/test/buildbot/master/templates/macros/change.html +0 -81
  457. data/test/buildbot/master/templates/macros/forms.html +0 -300
  458. data/test/buildbot/master/templates/root.html +0 -42
  459. data/test/buildbot/master/templates/waterfall.html +0 -53
  460. data/test/buildbot/requirements.txt +0 -4
  461. data/test/buildbot/scripts/deploy.sh +0 -38
  462. data/test/buildbot/scripts/setup.sh +0 -107
  463. data/test/buildbot/slave/buildbot.tac +0 -43
  464. data/test/buildbot/slave/info/admin +0 -1
  465. data/test/buildbot/slave/info/host +0 -1
  466. data/test/buildbot/tests/__init__.py +0 -0
  467. data/test/buildbot/tests/master/__init__.py +0 -0
  468. data/test/buildbot/tests/master/test_slaves.py +0 -41
  469. data/test/buildbot/vendor/choices-0.4.0.tar.gz +0 -0
  470. data/test/unit/vagrant/action/environment_test.rb +0 -16
  471. data/test/unit/vagrant/config/base_test.rb +0 -48
  472. data/test/unit/vagrant/config/ssh_test.rb +0 -17
  473. data/test/unit/vagrant/config/top_test.rb +0 -69
  474. data/test/unit/vagrant/config/vm_test.rb +0 -71
  475. data/test/unit/vagrant/data_store_test.rb +0 -79
  476. data/test/unit_legacy/locales/en.yml +0 -8
  477. data/test/unit_legacy/test_helper.rb +0 -32
  478. data/test/unit_legacy/vagrant/action/box/destroy_test.rb +0 -18
  479. data/test/unit_legacy/vagrant/action/box/download_test.rb +0 -125
  480. data/test/unit_legacy/vagrant/action/box/package_test.rb +0 -25
  481. data/test/unit_legacy/vagrant/action/box/unpackage_test.rb +0 -84
  482. data/test/unit_legacy/vagrant/action/box/verify_test.rb +0 -30
  483. data/test/unit_legacy/vagrant/action/env/set_test.rb +0 -24
  484. data/test/unit_legacy/vagrant/action/general/package_test.rb +0 -268
  485. data/test/unit_legacy/vagrant/action/general/validate_test.rb +0 -31
  486. data/test/unit_legacy/vagrant/action/vm/boot_test.rb +0 -66
  487. data/test/unit_legacy/vagrant/action/vm/check_accessible_test.rb +0 -61
  488. data/test/unit_legacy/vagrant/action/vm/check_box_test.rb +0 -61
  489. data/test/unit_legacy/vagrant/action/vm/check_guest_additions_test.rb +0 -9
  490. data/test/unit_legacy/vagrant/action/vm/clean_machine_folder_test.rb +0 -84
  491. data/test/unit_legacy/vagrant/action/vm/clear_forwarded_ports_test.rb +0 -52
  492. data/test/unit_legacy/vagrant/action/vm/clear_nfs_exports_test.rb +0 -22
  493. data/test/unit_legacy/vagrant/action/vm/clear_shared_folders_test.rb +0 -40
  494. data/test/unit_legacy/vagrant/action/vm/customize_test.rb +0 -37
  495. data/test/unit_legacy/vagrant/action/vm/destroy_test.rb +0 -25
  496. data/test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +0 -49
  497. data/test/unit_legacy/vagrant/action/vm/discard_state_test.rb +0 -45
  498. data/test/unit_legacy/vagrant/action/vm/export_test.rb +0 -107
  499. data/test/unit_legacy/vagrant/action/vm/forward_ports_helpers_test.rb +0 -77
  500. data/test/unit_legacy/vagrant/action/vm/forward_ports_test.rb +0 -197
  501. data/test/unit_legacy/vagrant/action/vm/halt_test.rb +0 -79
  502. data/test/unit_legacy/vagrant/action/vm/host_name_test.rb +0 -36
  503. data/test/unit_legacy/vagrant/action/vm/import_test.rb +0 -66
  504. data/test/unit_legacy/vagrant/action/vm/match_mac_address_test.rb +0 -40
  505. data/test/unit_legacy/vagrant/action/vm/modify_test.rb +0 -38
  506. data/test/unit_legacy/vagrant/action/vm/network_test.rb +0 -286
  507. data/test/unit_legacy/vagrant/action/vm/nfs_helpers_test.rb +0 -26
  508. data/test/unit_legacy/vagrant/action/vm/nfs_test.rb +0 -260
  509. data/test/unit_legacy/vagrant/action/vm/package_test.rb +0 -25
  510. data/test/unit_legacy/vagrant/action/vm/package_vagrantfile_test.rb +0 -46
  511. data/test/unit_legacy/vagrant/action/vm/provision_test.rb +0 -65
  512. data/test/unit_legacy/vagrant/action/vm/provisioner_cleanup_test.rb +0 -56
  513. data/test/unit_legacy/vagrant/action/vm/resume_test.rb +0 -35
  514. data/test/unit_legacy/vagrant/action/vm/share_folders_test.rb +0 -144
  515. data/test/unit_legacy/vagrant/action/vm/suspend_test.rb +0 -35
  516. data/test/unit_legacy/vagrant/action_test.rb +0 -89
  517. data/test/unit_legacy/vagrant/box_collection_test.rb +0 -45
  518. data/test/unit_legacy/vagrant/box_test.rb +0 -74
  519. data/test/unit_legacy/vagrant/cli_test.rb +0 -35
  520. data/test/unit_legacy/vagrant/command/base_test.rb +0 -23
  521. data/test/unit_legacy/vagrant/command/group_base_test.rb +0 -15
  522. data/test/unit_legacy/vagrant/command/helpers_test.rb +0 -88
  523. data/test/unit_legacy/vagrant/command/init_test.rb +0 -10
  524. data/test/unit_legacy/vagrant/command/package_test.rb +0 -27
  525. data/test/unit_legacy/vagrant/config/base_test.rb +0 -52
  526. data/test/unit_legacy/vagrant/config/error_recorder_test.rb +0 -18
  527. data/test/unit_legacy/vagrant/config/ssh_test.rb +0 -12
  528. data/test/unit_legacy/vagrant/config/vagrant_test.rb +0 -35
  529. data/test/unit_legacy/vagrant/config/vm/provisioner_test.rb +0 -92
  530. data/test/unit_legacy/vagrant/config/vm_test.rb +0 -47
  531. data/test/unit_legacy/vagrant/config_test.rb +0 -148
  532. data/test/unit_legacy/vagrant/downloaders/http_test.rb +0 -93
  533. data/test/unit_legacy/vagrant/environment_test.rb +0 -539
  534. data/test/unit_legacy/vagrant/errors_test.rb +0 -42
  535. data/test/unit_legacy/vagrant/hosts/base_test.rb +0 -46
  536. data/test/unit_legacy/vagrant/hosts/bsd_test.rb +0 -53
  537. data/test/unit_legacy/vagrant/hosts/linux_test.rb +0 -54
  538. data/test/unit_legacy/vagrant/plugin_test.rb +0 -9
  539. data/test/unit_legacy/vagrant/provisioners/base_test.rb +0 -63
  540. data/test/unit_legacy/vagrant/provisioners/chef_client_test.rb +0 -190
  541. data/test/unit_legacy/vagrant/provisioners/chef_solo_test.rb +0 -115
  542. data/test/unit_legacy/vagrant/provisioners/chef_test.rb +0 -209
  543. data/test/unit_legacy/vagrant/provisioners/puppet_server_test.rb +0 -68
  544. data/test/unit_legacy/vagrant/provisioners/puppet_test.rb +0 -182
  545. data/test/unit_legacy/vagrant/provisioners/shell_test.rb +0 -79
  546. data/test/unit_legacy/vagrant/ssh/session_test.rb +0 -40
  547. data/test/unit_legacy/vagrant/ssh_test.rb +0 -304
  548. data/test/unit_legacy/vagrant/systems/base_test.rb +0 -18
  549. data/test/unit_legacy/vagrant/systems/linux_test.rb +0 -104
  550. data/test/unit_legacy/vagrant/util/busy_test.rb +0 -106
  551. data/test/unit_legacy/vagrant/util/counter_test.rb +0 -29
  552. data/test/unit_legacy/vagrant/util/platform_test.rb +0 -18
  553. data/test/unit_legacy/vagrant/util/stacked_proc_runner_test.rb +0 -43
  554. data/test/unit_legacy/vagrant/util/template_renderer_test.rb +0 -145
  555. data/test/unit_legacy/vagrant/vm_test.rb +0 -300
  556. data/vagrant-1.1.4.gem +0 -0
  557. data/vagrantup-0.1.0.gem +0 -0
  558. data/vagrantup-0.1.1.gem +0 -0
  559. data/vagrantup-0.1.2.gem +0 -0
  560. data/vagrantup-0.1.3.gem +0 -0
  561. data/vagrantup-0.1.4.gem +0 -0
  562. data/vagrantup-0.2.0.gem +0 -0
  563. data/vagrantup-0.3.0.gem +0 -0
  564. data/vagrantup-0.3.1.gem +0 -0
  565. data/vagrantup-0.3.2.gem +0 -0
  566. data/vagrantup-0.3.3.gem +0 -0
  567. data/vagrantup-0.3.4.gem +0 -0
  568. data/vagrantup-0.4.0.gem +0 -0
  569. data/vagrantup-0.4.1.gem +0 -0
  570. data/vagrantup-0.4.3.dev.gem +0 -0
  571. data/vagrantup-0.5.0.gem +0 -0
  572. data/vagrantup-0.5.1.gem +0 -0
  573. data/vagrantup-0.5.2.gem +0 -0
  574. data/vagrantup-0.5.3.gem +0 -0
  575. data/vagrantup-0.5.4.gem +0 -0
  576. data/vagrantup-0.6.0.gem +0 -0
  577. data/vagrantup-0.6.1.gem +0 -0
  578. data/vagrantup-0.6.2.gem +0 -0
  579. data/vagrantup-0.6.3.gem +0 -0
  580. data/vagrantup-0.6.4.gem +0 -0
  581. data/vagrantup-0.6.5.gem +0 -0
  582. data/vagrantup-0.6.6.gem +0 -0
  583. data/vagrantup-0.6.7.gem +0 -0
  584. data/vagrantup-0.6.8.gem +0 -0
  585. data/vagrantup-0.6.9.gem +0 -0
  586. data/vagrantup-0.7.0.gem +0 -0
  587. data/vagrantup-0.7.1.gem +0 -0
  588. data/vagrantup-0.7.2.gem +0 -0
  589. data/vagrantup-0.7.3.gem +0 -0
  590. data/vagrantup-0.7.4.gem +0 -0
  591. data/vagrantup-0.7.5.gem +0 -0
  592. data/vagrantup-0.7.6.gem +0 -0
  593. data/vagrantup-0.7.7.gem +0 -0
  594. data/vagrantup-0.7.8.gem +0 -0
  595. data/vagrantup-0.8.0.gem +0 -0
  596. data/vagrantup-0.8.1.gem +0 -0
  597. data/vagrantup-0.8.10.gem +0 -0
  598. data/vagrantup-0.8.2.gem +0 -0
  599. data/vagrantup-0.8.3.gem +0 -0
  600. data/vagrantup-0.8.4.gem +0 -0
  601. data/vagrantup-0.8.5.gem +0 -0
  602. data/vagrantup-0.8.6.gem +0 -0
  603. data/vagrantup-0.8.7.gem +0 -0
  604. data/vagrantup-0.8.8.gem +0 -0
  605. data/vagrantup-0.8.9.gem +0 -0
  606. data/vagrantup-0.9.0.gem +0 -0
  607. data/vagrantup-0.9.1.gem +0 -0
  608. data/vagrantup-0.9.2.gem +0 -0
  609. data/vagrantup-0.9.3.gem +0 -0
  610. data/vagrantup-0.9.4.gem +0 -0
  611. data/vagrantup-0.9.5.gem +0 -0
  612. data/vagrantup-0.9.6.gem +0 -0
  613. data/vagrantup-0.9.7.gem +0 -0
  614. data/vagrantup-0.9.99.1.gem +0 -0
  615. data/vagrantup-0.9.99.2.gem +0 -0
  616. data/vagrantup-1.0.0.gem +0 -0
  617. data/vagrantup-1.0.1.gem +0 -0
  618. data/vagrantup-1.0.2.gem +0 -0
  619. data/vagrantup-1.0.3.gem +0 -0
  620. data/vagrantup-1.0.4.gem +0 -0
  621. data/vagrantup-1.0.5.gem +0 -0
  622. data/vagrantup-1.0.6.gem +0 -0
  623. data/vagrantup-1.1.4.gem +0 -0
@@ -0,0 +1,105 @@
1
+ require "set"
2
+
3
+ require "vagrant/config/v2/util"
4
+
5
+ module Vagrant
6
+ module Config
7
+ module V2
8
+ # This is the root configuration class. An instance of this is what
9
+ # is passed into version 1 Vagrant configuration blocks.
10
+ class Root
11
+ # Initializes a root object that maps the given keys to specific
12
+ # configuration classes.
13
+ #
14
+ # @param [Hash] config_map Map of key to config class.
15
+ def initialize(config_map, keys=nil)
16
+ @keys = keys || {}
17
+ @config_map = config_map
18
+ @missing_key_calls = Set.new
19
+ end
20
+
21
+ # We use method_missing as a way to get the configuration that is
22
+ # used for Vagrant and load the proper configuration classes for
23
+ # each.
24
+ def method_missing(name, *args)
25
+ return @keys[name] if @keys.has_key?(name)
26
+
27
+ config_klass = @config_map[name.to_sym]
28
+ if config_klass
29
+ # Instantiate the class and return the instance
30
+ @keys[name] = config_klass.new
31
+ return @keys[name]
32
+ else
33
+ # Record access to a missing key as an error
34
+ @missing_key_calls.add(name.to_s)
35
+ return DummyConfig.new
36
+ end
37
+ end
38
+
39
+ # Called to finalize this object just prior to it being used by
40
+ # the Vagrant system. The "!" signifies that this is expected to
41
+ # mutate itself.
42
+ def finalize!
43
+ @keys.each do |_key, instance|
44
+ instance.finalize!
45
+ end
46
+ end
47
+
48
+ # This validates the configuration and returns a hash of error
49
+ # messages by section. If there are no errors, an empty hash
50
+ # is returned.
51
+ #
52
+ # @param [Environment] env
53
+ # @return [Hash]
54
+ def validate(machine)
55
+ # Go through each of the configuration keys and validate
56
+ errors = {}
57
+ @keys.each do |_key, instance|
58
+ if instance.respond_to?(:validate)
59
+ # Validate this single item, and if we have errors then
60
+ # we merge them into our total errors list.
61
+ result = instance.validate(machine)
62
+ if result && !result.empty?
63
+ errors = Util.merge_errors(errors, result)
64
+ end
65
+ end
66
+ end
67
+
68
+ # Go through and delete empty keys
69
+ errors.keys.each do |key|
70
+ errors.delete(key) if errors[key].empty?
71
+ end
72
+
73
+ # If we have missing keys, record those as errors
74
+ if !@missing_key_calls.empty?
75
+ errors["Vagrant"] = @missing_key_calls.to_a.sort.map do |key|
76
+ I18n.t("vagrant.config.root.bad_key", :key => key)
77
+ end
78
+ end
79
+
80
+ errors
81
+ end
82
+
83
+ # Returns the internal state of the root object. This is used
84
+ # by outside classes when merging, and shouldn't be called directly.
85
+ # Note the strange method name is to attempt to avoid any name
86
+ # clashes with potential configuration keys.
87
+ def __internal_state
88
+ {
89
+ "config_map" => @config_map,
90
+ "keys" => @keys,
91
+ "missing_key_calls" => @missing_key_calls
92
+ }
93
+ end
94
+
95
+ # This sets the internal state. This is used by the core to do some
96
+ # merging logic and shouldn't be used by the general public.
97
+ def __set_internal_state(state)
98
+ @config_map = state["config_map"] if state.has_key?("config_map")
99
+ @keys = state["keys"] if state.has_key?("keys")
100
+ @missing_key_calls = state["missing_key_calls"] if state.has_key?("missing_key_calls")
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,21 @@
1
+ module Vagrant
2
+ module Config
3
+ module V2
4
+ class Util
5
+ # This merges two error hashes from validate methods.
6
+ #
7
+ # @param [Hash] first
8
+ # @param [Hash] second
9
+ # @return [Hash] Merged result
10
+ def self.merge_errors(first, second)
11
+ first.dup.tap do |result|
12
+ second.each do |key, value|
13
+ result[key] ||= []
14
+ result[key] += value
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,80 @@
1
+ module Vagrant
2
+ module Config
3
+ # This is the base class for any configuration versions, and includes
4
+ # the stub methods that configuaration versions must implement. Vagrant
5
+ # supports configuration versioning so that backwards compatibility can be
6
+ # maintained for past Vagrantfiles while newer configurations are added.
7
+ # Vagrant only introduces new configuration versions for major versions
8
+ # of Vagrant.
9
+ class VersionBase
10
+ # Returns an empty configuration object. This can be any kind of object,
11
+ # since it is treated as an opaque value on the other side, used only
12
+ # for things like calling into {merge}.
13
+ #
14
+ # @return [Object]
15
+ def self.init
16
+ raise NotImplementedError
17
+ end
18
+
19
+ # This is called just before configuration loading is complete of
20
+ # a potentially completely-merged value to perform final touch-ups
21
+ # to the configuration, if required.
22
+ #
23
+ # This is an optional method to implement. The default implementation
24
+ # will simply return the same object.
25
+ #
26
+ # This will ONLY be called if this is the version that is being
27
+ # used. In the case that an `upgrade` is called, this will never
28
+ # be called.
29
+ #
30
+ # @param [Object] obj Final configuration object.
31
+ # @param [Object] Finalized configuration object.
32
+ def self.finalize(obj)
33
+ obj
34
+ end
35
+
36
+ # Loads the configuration for the given proc and returns a configuration
37
+ # object. The return value is treated as an opaque object, so it can be
38
+ # anything you'd like. The return value is the object that is passed
39
+ # into methods like {merge}, so it should be something you expect.
40
+ #
41
+ # @param [Proc] proc The proc that is to be configured.
42
+ # @return [Object]
43
+ def self.load(proc)
44
+ raise NotImplementedError
45
+ end
46
+
47
+ # Merges two configuration objects, returning the merged object.
48
+ # The values of `old` and `new` are the opaque objects returned by
49
+ # {load} or {init}.
50
+ #
51
+ # Once again, the return object is treated as an opaque value by
52
+ # the Vagrant configuration loader, so it can be anything you'd like.
53
+ #
54
+ # @param [Object] old Old configuration object.
55
+ # @param [Object] new New configuration object.
56
+ # @return [Object] The merged configuration object.
57
+ def self.merge(old, new)
58
+ raise NotImplementedError
59
+ end
60
+
61
+ # This is called if a previous version of configuration needs to be
62
+ # upgraded to this version. Each version of configuration should know
63
+ # how to upgrade the version immediately prior to it. This should be
64
+ # a best effort upgrade that makes many assumptions. The goal is for
65
+ # this to work in almost every case, but perhaps with some warnings.
66
+ # The return value for this is a 3-tuple: `[object, warnings, errors]`,
67
+ # where `object` is the upgraded configuration object, `warnings` is
68
+ # an array of warning messages, and `errors` is an array of error
69
+ # messages.
70
+ #
71
+ # @param [Object] old The version of the configuration object just
72
+ # prior to this one.
73
+ # @return [Array] The 3-tuple result. Please see the above documentation
74
+ # for more information on the exact structure of this object.
75
+ def self.upgrade(old)
76
+ raise NotImplementedError
77
+ end
78
+ end
79
+ end
80
+ end
@@ -14,9 +14,6 @@ module Vagrant
14
14
  # handle.
15
15
  def self.match?(url); false; end
16
16
 
17
- # Called prior to execution so any error checks can be done
18
- def prepare(source_url); end
19
-
20
17
  # Downloads the source file to the destination file. It is up to
21
18
  # implementors of this class to handle the logic.
22
19
  def download!(source_url, destination_file); end
@@ -1,4 +1,5 @@
1
1
  require 'fileutils'
2
+ require 'uri'
2
3
 
3
4
  module Vagrant
4
5
  module Downloaders
@@ -6,14 +7,19 @@ module Vagrant
6
7
  # simply does a file copy.
7
8
  class File < Base
8
9
  def self.match?(uri)
9
- ::File.file?(::File.expand_path(uri))
10
- end
10
+ extracted = URI.extract(uri, "file")
11
11
 
12
- def prepare(source_url)
13
- raise Errors::DownloaderFileDoesntExist if !::File.file?(::File.expand_path(source_url))
12
+ # We match if we got a file URI. It doesn't matter here if the file
13
+ # doesn't exist because we check again later as well.
14
+ return true if extracted && extracted.include?(uri)
15
+
16
+ # Otherwise we match if the file exists
17
+ return ::File.file?(::File.expand_path(uri))
14
18
  end
15
19
 
16
20
  def download!(source_url, destination_file)
21
+ raise Errors::DownloaderFileDoesntExist if !::File.file?(::File.expand_path(source_url))
22
+
17
23
  @ui.info I18n.t("vagrant.downloaders.file.download")
18
24
  FileUtils.cp(::File.expand_path(source_url), destination_file.path)
19
25
  end
@@ -10,7 +10,7 @@ module Vagrant
10
10
  class HTTP < Base
11
11
  def self.match?(uri)
12
12
  # URI.parse barfs on '<drive letter>:\\files \on\ windows'
13
- extracted = URI.extract(uri).first
13
+ extracted = URI.extract(uri, ['http', 'https']).first
14
14
  extracted && extracted.include?(uri)
15
15
  end
16
16
 
@@ -69,6 +69,10 @@ module Vagrant
69
69
  @ui.clear_line
70
70
  end
71
71
  end
72
+ rescue Errno::ECONNRESET
73
+ raise Errors::DownloaderHTTPConnectReset
74
+ rescue Errno::ETIMEDOUT
75
+ raise Errors::DownloaderHTTPConnectTimeout
72
76
  rescue SocketError
73
77
  raise Errors::DownloaderHTTPSocketError
74
78
  end
@@ -78,19 +82,34 @@ module Vagrant
78
82
  # This method respects the "http_proxy" and "no_proxy" environmental
79
83
  # variables so that HTTP proxies can properly be used with Vagrant.
80
84
  def resolve_proxy(source_uri)
81
- proxy_string = ENV["http_proxy"] || ""
82
- if !proxy_string.empty? && ENV.has_key?("no_proxy")
83
- # Respect the "no_proxy" environmental variable which contains a list
84
- # of hosts that a proxy should not be used for.
85
- ENV["no_proxy"].split(",").each do |host|
86
- if source_uri.host =~ /#{Regexp.quote(host.strip)}$/
87
- proxy_string = ""
88
- break
85
+ # Get the proper proxy key depending on the scheme of the box URL
86
+ proxy_key = "#{source_uri.scheme}_proxy".downcase
87
+ proxy_string = ENV[proxy_key] || ENV[proxy_key.upcase] || ""
88
+
89
+ if !proxy_string.empty?
90
+ # Make sure the proxy string starts with a protocol so that
91
+ # URI.parse works properly below.
92
+ proxy_string = "http://#{proxy_string}" if !proxy_string.include?("://")
93
+
94
+ if ENV.has_key?("no_proxy")
95
+ # Respect the "no_proxy" environmental variable which contains a list
96
+ # of hosts that a proxy should not be used for.
97
+ ENV["no_proxy"].split(",").each do |host|
98
+ if source_uri.host =~ /#{Regexp.quote(host.strip)}$/
99
+ proxy_string = ""
100
+ break
101
+ end
89
102
  end
90
103
  end
91
104
  end
92
105
 
93
- URI.parse(proxy_string)
106
+ begin
107
+ URI.parse(proxy_string)
108
+ rescue URI::InvalidURIError
109
+ # If we have an invalid URI, we assume the proxy is invalid,
110
+ # so we don't use a proxy.
111
+ URI.parse("")
112
+ end
94
113
  end
95
114
  end
96
115
  end
@@ -1,8 +1,9 @@
1
- require 'pathname'
2
1
  require 'fileutils'
2
+ require 'json'
3
+ require 'pathname'
4
+ require 'set'
3
5
 
4
6
  require 'log4r'
5
- require 'rubygems' # This is needed for plugin loading below.
6
7
 
7
8
  require 'vagrant/util/file_mode'
8
9
  require 'vagrant/util/platform'
@@ -12,23 +13,36 @@ module Vagrant
12
13
  # defined as basically a folder with a "Vagrantfile." This class allows
13
14
  # access to the VMs, CLI, etc. all in the scope of this environment.
14
15
  class Environment
15
- HOME_SUBDIRS = ["tmp", "boxes", "gems"]
16
- DEFAULT_VM = :default
17
16
  DEFAULT_HOME = "~/.vagrant.d"
17
+ DEFAULT_LOCAL_DATA = ".vagrant"
18
18
 
19
19
  # The `cwd` that this environment represents
20
20
  attr_reader :cwd
21
21
 
22
+ # The persistent data directory where global data can be stored. It
23
+ # is up to the creator of the data in this directory to properly
24
+ # remove it when it is no longer needed.
25
+ #
26
+ # @return [Pathname]
27
+ attr_reader :data_dir
28
+
22
29
  # The valid name for a Vagrantfile for this environment.
23
30
  attr_reader :vagrantfile_name
24
31
 
25
32
  # The {UI} object to communicate with the outside world.
26
33
  attr_reader :ui
27
34
 
35
+ # This is the UI class to use when creating new UIs.
36
+ attr_reader :ui_class
37
+
28
38
  # The directory to the "home" folder that Vagrant will use to store
29
39
  # global state.
30
40
  attr_reader :home_path
31
41
 
42
+ # The directory to the directory where local, environment-specific
43
+ # data is stored.
44
+ attr_reader :local_data_path
45
+
32
46
  # The directory where temporary files for Vagrant go.
33
47
  attr_reader :tmp_path
34
48
 
@@ -49,10 +63,11 @@ module Vagrant
49
63
  def initialize(opts=nil)
50
64
  opts = {
51
65
  :cwd => nil,
52
- :vagrantfile_name => nil,
66
+ :home_path => nil,
67
+ :local_data_path => nil,
53
68
  :lock_path => nil,
54
69
  :ui_class => nil,
55
- :home_path => nil
70
+ :vagrantfile_name => nil
56
71
  }.merge(opts || {})
57
72
 
58
73
  # Set the default working directory to look for the vagrantfile
@@ -61,22 +76,25 @@ module Vagrant
61
76
  opts[:cwd] = Pathname.new(opts[:cwd])
62
77
  raise Errors::EnvironmentNonExistentCWD if !opts[:cwd].directory?
63
78
 
79
+ # Set the default ui class
80
+ opts[:ui_class] ||= UI::Silent
81
+
64
82
  # Set the Vagrantfile name up. We append "Vagrantfile" and "vagrantfile" so that
65
83
  # those continue to work as well, but anything custom will take precedence.
66
- opts[:vagrantfile_name] ||= []
67
- opts[:vagrantfile_name] = [opts[:vagrantfile_name]] if !opts[:vagrantfile_name].is_a?(Array)
68
- opts[:vagrantfile_name] += ["Vagrantfile", "vagrantfile"]
84
+ opts[:vagrantfile_name] ||= ENV["VAGRANT_VAGRANTFILE"] if \
85
+ ENV.has_key?("VAGRANT_VAGRANTFILE")
86
+ opts[:vagrantfile_name] ||= ["Vagrantfile", "vagrantfile"]
87
+ opts[:vagrantfile_name] = [opts[:vagrantfile_name]] if \
88
+ !opts[:vagrantfile_name].is_a?(Array)
69
89
 
70
90
  # Set instance variables for all the configuration parameters.
71
- @cwd = opts[:cwd]
91
+ @cwd = opts[:cwd]
92
+ @home_path = opts[:home_path]
93
+ @lock_path = opts[:lock_path]
72
94
  @vagrantfile_name = opts[:vagrantfile_name]
73
- @lock_path = opts[:lock_path]
74
- @home_path = opts[:home_path]
75
-
76
- ui_class = opts[:ui_class] || UI::Silent
77
- @ui = ui_class.new("vagrant")
95
+ @ui = opts[:ui_class].new
96
+ @ui_class = opts[:ui_class]
78
97
 
79
- @loaded = false
80
98
  @lock_acquired = false
81
99
 
82
100
  @logger = Log4r::Logger.new("vagrant::environment")
@@ -85,9 +103,22 @@ module Vagrant
85
103
 
86
104
  # Setup the home directory
87
105
  setup_home_path
88
- @tmp_path = @home_path.join("tmp")
89
106
  @boxes_path = @home_path.join("boxes")
107
+ @data_dir = @home_path.join("data")
90
108
  @gems_path = @home_path.join("gems")
109
+ @tmp_path = @home_path.join("tmp")
110
+
111
+ # Setup the local data directory. If a configuration path is given,
112
+ # then it is expanded relative to the working directory. Otherwise,
113
+ # we use the default which is expanded relative to the root path.
114
+ @local_data_path = nil
115
+ if opts[:local_data_path]
116
+ @local_data_path = Pathname.new(File.expand_path(opts[:local_data_path], @cwd))
117
+ elsif !root_path.nil?
118
+ @local_data_path = root_path.join(DEFAULT_LOCAL_DATA)
119
+ end
120
+
121
+ setup_local_data_path
91
122
 
92
123
  # Setup the default private key
93
124
  @default_private_key_path = @home_path.join("insecure_private_key")
@@ -95,67 +126,275 @@ module Vagrant
95
126
 
96
127
  # Load the plugins
97
128
  load_plugins
129
+
130
+ # Call the environment load hooks
131
+ hook(:environment_load)
132
+ end
133
+
134
+ # Return a human-friendly string for pretty printed or inspected
135
+ # instances.
136
+ #
137
+ # @return [String]
138
+ def inspect
139
+ "#<#{self.class}: #{@cwd}>"
98
140
  end
99
141
 
100
142
  #---------------------------------------------------------------
101
143
  # Helpers
102
144
  #---------------------------------------------------------------
103
145
 
104
- # The path to the `dotfile`, which contains the persisted UUID of
105
- # the VM if it exists.
146
+ # Returns a list of machines that this environment is currently
147
+ # managing that physically have been created.
106
148
  #
107
- # @return [Pathname]
108
- def dotfile_path
109
- return nil if !root_path
110
- root_path.join(config.global.vagrant.dotfile_name)
149
+ # An "active" machine is a machine that Vagrant manages that has
150
+ # been created. The machine itself may be in any state such as running,
151
+ # suspended, etc. but if a machine is "active" then it exists.
152
+ #
153
+ # Note that the machines in this array may no longer be present in
154
+ # the Vagrantfile of this environment. In this case the machine can
155
+ # be considered an "orphan." Determining which machines are orphan
156
+ # and which aren't is not currently a supported feature, but will
157
+ # be in a future version.
158
+ #
159
+ # @return [Array<String, Symbol>]
160
+ def active_machines
161
+ machine_folder = @local_data_path.join("machines")
162
+
163
+ # If the machine folder is not a directory then we just return
164
+ # an empty array since no active machines exist.
165
+ return [] if !machine_folder.directory?
166
+
167
+ # Traverse the machines folder accumulate a result
168
+ result = []
169
+
170
+ machine_folder.children(true).each do |name_folder|
171
+ # If this isn't a directory then it isn't a machine
172
+ next if !name_folder.directory?
173
+
174
+ name = name_folder.basename.to_s.to_sym
175
+ name_folder.children(true).each do |provider_folder|
176
+ # If this isn't a directory then it isn't a provider
177
+ next if !provider_folder.directory?
178
+
179
+ # If this machine doesn't have an ID, then ignore
180
+ next if !provider_folder.join("id").file?
181
+
182
+ provider = provider_folder.basename.to_s.to_sym
183
+ result << [name, provider]
184
+ end
185
+ end
186
+
187
+ # Return the results
188
+ result
189
+ end
190
+
191
+ # This returns the provider name for the default provider for this
192
+ # environment. The provider returned is currently hardcoded to "virtualbox"
193
+ # but one day should be a detected valid, best-case provider for this
194
+ # environment.
195
+ #
196
+ # @return [Symbol] Name of the default provider.
197
+ def default_provider
198
+ :virtualbox
111
199
  end
112
200
 
113
201
  # Returns the collection of boxes for the environment.
114
202
  #
115
203
  # @return [BoxCollection]
116
204
  def boxes
117
- @_boxes ||= BoxCollection.new(boxes_path, action_runner)
205
+ @_boxes ||= BoxCollection.new(boxes_path)
118
206
  end
119
207
 
120
- # Returns the VMs associated with this environment.
208
+ # This is the global config, comprised of loading configuration from
209
+ # the default, home, and root Vagrantfiles. This configuration is only
210
+ # really useful for reading the list of virtual machines, since each
211
+ # individual VM can override _most_ settings.
121
212
  #
122
- # @return [Hash<Symbol,VM>]
123
- def vms
124
- load! if !loaded?
125
- @vms ||= load_vms!
213
+ # This is lazy-loaded upon first use.
214
+ #
215
+ # @return [Object]
216
+ def config_global
217
+ return @config_global if @config_global
218
+
219
+ @logger.info("Initializing config...")
220
+
221
+ home_vagrantfile = nil
222
+ root_vagrantfile = nil
223
+ home_vagrantfile = find_vagrantfile(home_path) if home_path
224
+ root_vagrantfile = find_vagrantfile(root_path) if root_path
225
+
226
+ # Create the configuration loader and set the sources that are global.
227
+ # We use this to load the configuration, and the list of machines we are
228
+ # managing. Then, the actual individual configuration is loaded for
229
+ # each {#machine} call.
230
+ @config_loader = Config::Loader.new(Config::VERSIONS, Config::VERSIONS_ORDER)
231
+ @config_loader.set(:default, File.expand_path("config/default.rb", Vagrant.source_root))
232
+ @config_loader.set(:home, home_vagrantfile) if home_vagrantfile
233
+ @config_loader.set(:root, root_vagrantfile) if root_vagrantfile
234
+
235
+ # Make the initial call to get the "global" config. This is mostly
236
+ # only useful to get the list of machines that we are managing.
237
+ # Because of this, we ignore any warnings or errors.
238
+ @config_global, _ = @config_loader.load([:default, :home, :root])
239
+
240
+ # Return the config
241
+ @config_global
126
242
  end
127
243
 
128
- # Returns the VMs associated with this environment, in the order
129
- # that they were defined.
244
+ # This defines a hook point where plugin action hooks that are registered
245
+ # against the given name will be run in the context of this environment.
130
246
  #
131
- # @return [Array<VM>]
132
- def vms_ordered
133
- return @vms.values if !multivm?
134
- @vms_enum ||= config.global.vm.defined_vm_keys.map { |name| @vms[name] }
247
+ # @param [Symbol] name Name of the hook.
248
+ def hook(name)
249
+ @logger.info("Running hook: #{name}")
250
+ callable = Action::Builder.new
251
+ action_runner.run(
252
+ callable,
253
+ :action_name => name,
254
+ :env => self)
135
255
  end
136
256
 
137
- # Returns the primary VM associated with this environment. This
138
- # method is only applicable for multi-VM environments. This can
139
- # potentially be nil if no primary VM is specified.
257
+ # This returns a machine with the proper provider for this environment.
258
+ # The machine named by `name` must be in this environment.
140
259
  #
141
- # @return [VM]
142
- def primary_vm
143
- return vms.values.first if !multivm?
260
+ # @param [Symbol] name Name of the machine (as configured in the
261
+ # Vagrantfile).
262
+ # @param [Symbol] provider The provider that this machine should be
263
+ # backed by.
264
+ # @param [Boolean] refresh If true, then if there is a cached version
265
+ # it is reloaded.
266
+ # @return [Machine]
267
+ def machine(name, provider, refresh=false)
268
+ @logger.info("Getting machine: #{name} (#{provider})")
269
+
270
+ # Compose the cache key of the name and provider, and return from
271
+ # the cache if we have that.
272
+ cache_key = [name, provider]
273
+ @machines ||= {}
274
+ if refresh
275
+ @logger.info("Refreshing machine (busting cache): #{name} (#{provider})")
276
+ @machines.delete(cache_key)
277
+ end
278
+
279
+ if @machines.has_key?(cache_key)
280
+ @logger.info("Returning cached machine: #{name} (#{provider})")
281
+ return @machines[cache_key]
282
+ end
144
283
 
145
- config.global.vm.defined_vms.each do |name, subvm|
146
- return vms[name] if subvm.options[:primary]
284
+ @logger.info("Uncached load of machine.")
285
+ sub_vm = config_global.vm.defined_vms[name]
286
+ if !sub_vm
287
+ raise Errors::MachineNotFound, :name => name, :provider => provider
147
288
  end
148
289
 
290
+ provider_cls = Vagrant.plugin("2").manager.providers[provider]
291
+ if !provider_cls
292
+ raise Errors::ProviderNotFound, :machine => name, :provider => provider
293
+ end
294
+
295
+ # Build the machine configuration. This requires two passes: The first pass
296
+ # loads in the machine sub-configuration. Since this can potentially
297
+ # define a new box to base the machine from, we then make a second pass
298
+ # with the box Vagrantfile (if it has one).
299
+ vm_config_key = "vm_#{name}".to_sym
300
+ @config_loader.set(vm_config_key, sub_vm.config_procs)
301
+ config, config_warnings, config_errors = \
302
+ @config_loader.load([:default, :home, :root, vm_config_key])
303
+
304
+ box = nil
305
+ begin
306
+ box = boxes.find(config.vm.box, provider)
307
+ rescue Errors::BoxUpgradeRequired
308
+ # Upgrade the box if we must
309
+ @logger.info("Upgrading box during config load: #{config.vm.box}")
310
+ boxes.upgrade(config.vm.box)
311
+ retry
312
+ end
313
+
314
+ # If a box was found, then we attempt to load the Vagrantfile for
315
+ # that box. We don't require a box since we allow providers to download
316
+ # boxes and so on.
317
+ if box
318
+ box_vagrantfile = find_vagrantfile(box.directory)
319
+ if box_vagrantfile
320
+ # The box has a custom Vagrantfile, so we load that into the config
321
+ # as well.
322
+ @logger.info("Box exists with Vagrantfile. Reloading machine config.")
323
+ box_config_key = "box_#{box.name}_#{box.provider}".to_sym
324
+ @config_loader.set(box_config_key, box_vagrantfile)
325
+ config, config_warnings, config_errors = \
326
+ @config_loader.load([:default, box_config_key, :home, :root, vm_config_key])
327
+ end
328
+ end
329
+
330
+ # Get the provider configuration from the final loaded configuration
331
+ provider_config = config.vm.get_provider_config(provider)
332
+
333
+ # Determine the machine data directory and pass it to the machine.
334
+ # XXX: Permissions error here.
335
+ machine_data_path = @local_data_path.join("machines/#{name}/#{provider}")
336
+ FileUtils.mkdir_p(machine_data_path)
337
+
338
+ # If there were warnings or errors we want to output them
339
+ if !config_warnings.empty? || !config_errors.empty?
340
+ # The color of the output depends on whether we have warnings
341
+ # or errors...
342
+ level = config_errors.empty? ? :warn : :error
343
+ output = Util::TemplateRenderer.render(
344
+ "config/messages",
345
+ :warnings => config_warnings,
346
+ :errors => config_errors).chomp
347
+ @ui.send(level, I18n.t("vagrant.general.config_upgrade_messages",
348
+ :output => output))
349
+
350
+ # If we had errors, then we bail
351
+ raise Errors::ConfigUpgradeErrors if !config_errors.empty?
352
+ end
353
+
354
+ # Create the machine and cache it for future calls. This will also
355
+ # return the machine from this method.
356
+ @machines[cache_key] = Machine.new(name, provider, provider_cls, provider_config,
357
+ config, machine_data_path, box, self)
358
+ end
359
+
360
+ # This returns a list of the configured machines for this environment.
361
+ # Each of the names returned by this method is valid to be used with
362
+ # the {#machine} method.
363
+ #
364
+ # @return [Array<Symbol>] Configured machine names.
365
+ def machine_names
366
+ config_global.vm.defined_vm_keys.dup
367
+ end
368
+
369
+ # This returns the name of the machine that is the "primary." In the
370
+ # case of a single-machine environment, this is just the single machine
371
+ # name. In the case of a multi-machine environment, then this can
372
+ # potentially be nil if no primary machine is specified.
373
+ #
374
+ # @return [Symbol]
375
+ def primary_machine_name
376
+ # If it is a single machine environment, then return the name
377
+ return machine_names.first if machine_names.length == 1
378
+
379
+ # If it is a multi-machine environment, then return the primary
380
+ config_global.vm.defined_vms.each do |name, subvm|
381
+ return name if subvm.options[:primary]
382
+ end
383
+
384
+ # If no primary was specified, nil it is
149
385
  nil
150
386
  end
151
387
 
152
- # Returns a boolean whether this environment represents a multi-VM
153
- # environment or not. This will work even when called on child
154
- # environments.
388
+ # Unload the environment, running completion hooks. The environment
389
+ # should not be used after this (but CAN be, technically). It is
390
+ # recommended to always immediately set the variable to `nil` after
391
+ # running this so you can't accidentally run any more methods. Example:
392
+ #
393
+ # env.unload
394
+ # env = nil
155
395
  #
156
- # @return [Bool]
157
- def multivm?
158
- vms.length > 1 || vms.keys.first != DEFAULT_VM
396
+ def unload
397
+ hook(:environment_unload)
159
398
  end
160
399
 
161
400
  # Makes a call to the CLI with the given arguments as if they
@@ -169,7 +408,7 @@ module Vagrant
169
408
 
170
409
  # Returns the host object associated with this environment.
171
410
  #
172
- # @return [Hosts::Base]
411
+ # @return [Class]
173
412
  def host
174
413
  return @host if defined?(@host)
175
414
 
@@ -177,12 +416,16 @@ module Vagrant
177
416
  # matters here, so please don't touch. Specifically: The symbol
178
417
  # check is done after the detect check because the symbol check
179
418
  # will return nil, and we don't want to trigger a detect load.
180
- host_klass = config.global.vagrant.host
181
- host_klass = Hosts.detect(Vagrant.hosts) if host_klass.nil? || host_klass == :detect
182
- host_klass = Vagrant.hosts.get(host_klass) if host_klass.is_a?(Symbol)
419
+ host_klass = config_global.vagrant.host
420
+ if host_klass.nil? || host_klass == :detect
421
+ hosts = Vagrant.plugin("2").manager.hosts.to_hash
422
+
423
+ # Get the flattened list of available hosts
424
+ host_klass = Hosts.detect(hosts)
425
+ end
183
426
 
184
427
  # If no host class is detected, we use the base class.
185
- host_klass ||= Hosts::Base
428
+ host_klass ||= Vagrant.plugin("2", :host)
186
429
 
187
430
  @host ||= host_klass.new(@ui)
188
431
  end
@@ -191,12 +434,14 @@ module Vagrant
191
434
  #
192
435
  # @return [Action::Runner]
193
436
  def action_runner
194
- @action_runner ||= Action::Runner.new(action_registry) do
437
+ @action_runner ||= Action::Runner.new do
195
438
  {
196
439
  :action_runner => action_runner,
197
440
  :box_collection => boxes,
198
- :global_config => config.global,
441
+ :global_config => config_global,
199
442
  :host => host,
443
+ :gems_path => gems_path,
444
+ :home_path => home_path,
200
445
  :root_path => root_path,
201
446
  :tmp_path => tmp_path,
202
447
  :ui => @ui
@@ -204,37 +449,6 @@ module Vagrant
204
449
  end
205
450
  end
206
451
 
207
- # Action registry for registering new actions with this environment.
208
- #
209
- # @return [Registry]
210
- def action_registry
211
- # For now we return the global built-in actions registry. In the future
212
- # we may want to create an isolated registry that inherits from this
213
- # global one, but for now there isn't a use case that calls for it.
214
- Vagrant.actions
215
- end
216
-
217
- # Loads on initial access and reads data from the global data store.
218
- # The global data store is global to Vagrant everywhere (in every environment),
219
- # so it can be used to store system-wide information. Note that "system-wide"
220
- # typically means "for this user" since the location of the global data
221
- # store is in the home directory.
222
- #
223
- # @return [DataStore]
224
- def global_data
225
- @global_data ||= DataStore.new(File.expand_path("global_data.json", home_path))
226
- end
227
-
228
- # Loads (on initial access) and reads data from the local data
229
- # store. This file is always at the root path as the file "~/.vagrant"
230
- # and contains a JSON dump of a hash. See {DataStore} for more
231
- # information.
232
- #
233
- # @return [DataStore]
234
- def local_data
235
- @local_data ||= DataStore.new(dotfile_path)
236
- end
237
-
238
452
  # The root path is the path where the top-most (loaded last)
239
453
  # Vagrantfile resides. It can be considered the project root for
240
454
  # this environment.
@@ -291,152 +505,10 @@ module Vagrant
291
505
  end
292
506
  end
293
507
 
294
- #---------------------------------------------------------------
295
- # Config Methods
296
- #---------------------------------------------------------------
297
-
298
- # The configuration object represented by this environment. This
299
- # will trigger the environment to load if it hasn't loaded yet (see
300
- # {#load!}).
301
- #
302
- # @return [Config::Container]
303
- def config
304
- load! if !loaded?
305
- @config
306
- end
307
-
308
508
  #---------------------------------------------------------------
309
509
  # Load Methods
310
510
  #---------------------------------------------------------------
311
511
 
312
- # Returns a boolean representing if the environment has been
313
- # loaded or not.
314
- #
315
- # @return [Bool]
316
- def loaded?
317
- !!@loaded
318
- end
319
-
320
- # Loads this entire environment, setting up the instance variables
321
- # such as `vm`, `config`, etc. on this environment. The order this
322
- # method calls its other methods is very particular.
323
- def load!
324
- if !loaded?
325
- @loaded = true
326
- @logger.info("Loading configuration...")
327
- load_config!
328
- end
329
-
330
- self
331
- end
332
-
333
- # Reloads the configuration of this environment.
334
- def reload!
335
- # Reload the configuration
336
- load_config!
337
-
338
- # Clear the VMs because this can now be diferent due to configuration
339
- @vms = nil
340
- end
341
-
342
- # Loads this environment's configuration and stores it in the {#config}
343
- # variable. The configuration loaded by this method is specified to
344
- # this environment, meaning that it will use the given root directory
345
- # to load the Vagrantfile into that context.
346
- def load_config!
347
- # Initialize the config loader
348
- config_loader = Config::Loader.new
349
- config_loader.load_order = [:default, :box, :home, :root, :vm]
350
-
351
- inner_load = lambda do |*args|
352
- # This is for Ruby 1.8.7 compatibility. Ruby 1.8.7 doesn't allow
353
- # default arguments for lambdas, so we get around by doing a *args
354
- # and setting the args here.
355
- subvm = args[0]
356
- box = args[1]
357
-
358
- # Default Vagrantfile first. This is the Vagrantfile that ships
359
- # with Vagrant.
360
- config_loader.set(:default, File.expand_path("config/default.rb", Vagrant.source_root))
361
-
362
- if box
363
- # We load the box Vagrantfile
364
- box_vagrantfile = find_vagrantfile(box.directory)
365
- config_loader.set(:box, box_vagrantfile) if box_vagrantfile
366
- end
367
-
368
- if home_path
369
- # Load the home Vagrantfile
370
- home_vagrantfile = find_vagrantfile(home_path)
371
- config_loader.set(:home, home_vagrantfile) if home_vagrantfile
372
- end
373
-
374
- if root_path
375
- # Load the Vagrantfile in this directory
376
- root_vagrantfile = find_vagrantfile(root_path)
377
- config_loader.set(:root, root_vagrantfile) if root_vagrantfile
378
- end
379
-
380
- if subvm
381
- # We have subvm configuration, so set that up as well.
382
- config_loader.set(:vm, subvm.proc_stack)
383
- end
384
-
385
- # Execute the configuration stack and store the result as the final
386
- # value in the config ivar.
387
- config_loader.load
388
- end
389
-
390
- # For the global configuration, we only need to load the configuration
391
- # in a single pass, since nothing is conditional on the configuration.
392
- global = inner_load.call
393
-
394
- # For each virtual machine represented by this environment, we have
395
- # to load the configuration in two-passes. We do this because the
396
- # first pass is used to determine the box for the VM. The second pass
397
- # is used to also load the box Vagrantfile.
398
- defined_vm_keys = global.vm.defined_vm_keys.dup
399
- defined_vms = global.vm.defined_vms.dup
400
-
401
- # If this isn't a multi-VM environment, then setup the default VM
402
- # to simply be our configuration.
403
- if defined_vm_keys.empty?
404
- defined_vm_keys << DEFAULT_VM
405
- defined_vms[DEFAULT_VM] = Config::VMConfig::SubVM.new
406
- end
407
-
408
- vm_configs = defined_vm_keys.map do |vm_name|
409
- @logger.debug("Loading configuration for VM: #{vm_name}")
410
-
411
- subvm = defined_vms[vm_name]
412
-
413
- # First pass, first run.
414
- config = inner_load[subvm]
415
-
416
- # Second pass, with the box
417
- config = inner_load[subvm, boxes.find(config.vm.box)]
418
- config.vm.name = vm_name
419
-
420
- # Return the final configuration for this VM
421
- config
422
- end
423
-
424
- # Finally, we have our configuration. Set it and forget it.
425
- @config = Config::Container.new(global, vm_configs)
426
- end
427
-
428
- # Loads the persisted VM (if it exists) for this environment.
429
- def load_vms!
430
- result = {}
431
-
432
- # Load all the virtual machine instances.
433
- config.vms.each do |name|
434
- result[name] = Vagrant::VM.new(name, self, config.for_vm(name))
435
- end
436
-
437
- result
438
- end
439
-
440
512
  # This sets the `@home_path` variable properly.
441
513
  #
442
514
  # @return [Pathname]
@@ -446,14 +518,11 @@ module Vagrant
446
518
  DEFAULT_HOME))
447
519
  @logger.info("Home path: #{@home_path}")
448
520
 
449
- # If the setup_version file exists, then we can't load because we're
450
- # not forward compatible. It means they ran a future version of Vagrant.
451
- raise Errors::IncompatibleWithFutureVersion, :path => @home_path.to_s if \
452
- @home_path.join("setup_version").file?
453
-
454
- # Setup the array of necessary home directories
455
- dirs = [@home_path]
456
- dirs += HOME_SUBDIRS.collect { |subdir| @home_path.join(subdir) }
521
+ # Setup the list of child directories that need to be created if they
522
+ # don't already exist.
523
+ dirs = [@home_path]
524
+ subdirs = ["boxes", "data", "gems", "rgloader", "tmp"]
525
+ dirs += subdirs.collect { |subdir| @home_path.join(subdir) }
457
526
 
458
527
  # Go through each required directory, creating it if it doesn't exist
459
528
  dirs.each do |dir|
@@ -466,6 +535,49 @@ module Vagrant
466
535
  raise Errors::HomeDirectoryNotAccessible, :home_path => @home_path.to_s
467
536
  end
468
537
  end
538
+
539
+ # Create the version file to mark the version of the home directory
540
+ # we're using.
541
+ version_file = @home_path.join("setup_version")
542
+ if !version_file.file?
543
+ @logger.debug("Setting up the version file.")
544
+ version_file.open("w") do |f|
545
+ f.write("1.1")
546
+ end
547
+ end
548
+
549
+ # Create the rgloader/loader file so we can use encoded files.
550
+ loader_file = @home_path.join("rgloader", "loader.rb")
551
+ if !loader_file.file?
552
+ source_loader = Vagrant.source_root.join("templates/rgloader.rb")
553
+ FileUtils.cp(source_loader.to_s, loader_file.to_s)
554
+ end
555
+ end
556
+
557
+ # This creates the local data directory and show an error if it
558
+ # couldn't properly be created.
559
+ def setup_local_data_path
560
+ if @local_data_path.nil?
561
+ @logger.warn("No local data path is set. Local data cannot be stored.")
562
+ return
563
+ end
564
+
565
+ @logger.info("Local data path: #{@local_data_path}")
566
+
567
+ # If the local data path is a file, then we are probably seeing an
568
+ # old (V1) "dotfile." In this case, we upgrade it. The upgrade process
569
+ # will remove the old data file if it is successful.
570
+ if @local_data_path.file?
571
+ upgrade_v1_dotfile(@local_data_path)
572
+ end
573
+
574
+ begin
575
+ @logger.debug("Creating: #{@local_data_path}")
576
+ FileUtils.mkdir_p(@local_data_path)
577
+ rescue Errno::EACCES
578
+ raise Errors::LocalDataDirectoryNotAccessible,
579
+ :local_data_path => @local_data_path.to_s
580
+ end
469
581
  end
470
582
 
471
583
  protected
@@ -480,8 +592,17 @@ module Vagrant
480
592
  def copy_insecure_private_key
481
593
  if !@default_private_key_path.exist?
482
594
  @logger.info("Copying private key to home directory")
483
- FileUtils.cp(File.expand_path("keys/vagrant", Vagrant.source_root),
484
- @default_private_key_path)
595
+
596
+ source = File.expand_path("keys/vagrant", Vagrant.source_root)
597
+ destination = @default_private_key_path
598
+
599
+ begin
600
+ FileUtils.cp(source, destination)
601
+ rescue Errno::EACCES
602
+ raise Errors::CopyPrivateKeyFailed,
603
+ :source => source,
604
+ :destination => destination
605
+ end
485
606
  end
486
607
 
487
608
  if !Util::Platform.windows?
@@ -510,13 +631,99 @@ module Vagrant
510
631
  # Loads the Vagrant plugins by properly setting up RubyGems so that
511
632
  # our private gem repository is on the path.
512
633
  def load_plugins
634
+ if ENV["VAGRANT_NO_PLUGINS"]
635
+ # If this key exists, then we don't load any plugins. It is a "safe
636
+ # mode" of sorts.
637
+ @logger.warn("VAGRANT_NO_PLUGINS is set. Not loading 3rd party plugins.")
638
+ return
639
+ end
640
+
513
641
  # Add our private gem path to the gem path and reset the paths
514
642
  # that Rubygems knows about.
515
643
  ENV["GEM_PATH"] = "#{@gems_path}#{::File::PATH_SEPARATOR}#{ENV["GEM_PATH"]}"
516
644
  ::Gem.clear_paths
517
645
 
518
646
  # Load the plugins
519
- Plugin.load!
647
+ plugins_json_file = @home_path.join("plugins.json")
648
+ @logger.debug("Loading plugins from: #{plugins_json_file}")
649
+ if plugins_json_file.file?
650
+ data = JSON.parse(plugins_json_file.read)
651
+ data["installed"].each do |plugin|
652
+ @logger.info("Loading plugin from JSON: #{plugin}")
653
+ begin
654
+ Vagrant.require_plugin(plugin)
655
+ rescue Errors::PluginLoadError => e
656
+ @ui.error(e.message + "\n")
657
+ rescue Errors::PluginLoadFailed => e
658
+ @ui.error(e.message + "\n")
659
+ end
660
+ end
661
+ end
662
+ end
663
+
664
+ # This upgrades a Vagrant 1.0.x "dotfile" to the new V2 format.
665
+ #
666
+ # This is a destructive process. Once the upgrade is complete, the
667
+ # old dotfile is removed, and the environment becomes incompatible for
668
+ # Vagrant 1.0 environments.
669
+ #
670
+ # @param [Pathname] path The path to the dotfile
671
+ def upgrade_v1_dotfile(path)
672
+ @logger.info("Upgrading V1 dotfile to V2 directory structure...")
673
+
674
+ # First, verify the file isn't empty. If it is an empty file, we
675
+ # just delete it and go on with life.
676
+ contents = path.read.strip
677
+ if contents.strip == ""
678
+ @logger.info("V1 dotfile was empty. Removing and moving on.")
679
+ path.delete
680
+ return
681
+ end
682
+
683
+ # Otherwise, verify there is valid JSON in here since a Vagrant
684
+ # environment would always ensure valid JSON. This is a sanity check
685
+ # to make sure we don't nuke a dotfile that is not ours...
686
+ @logger.debug("Attempting to parse JSON of V1 file")
687
+ json_data = nil
688
+ begin
689
+ json_data = JSON.parse(contents)
690
+ @logger.debug("JSON parsed successfully. Things are okay.")
691
+ rescue JSON::ParserError
692
+ # The file could've been tampered with since Vagrant 1.0.x is
693
+ # supposed to ensure that the contents are valid JSON. Show an error.
694
+ raise Errors::DotfileUpgradeJSONError,
695
+ :state_file => path.to_s
696
+ end
697
+
698
+ # Alright, let's upgrade this guy to the new structure. Start by
699
+ # backing up the old dotfile.
700
+ backup_file = path.dirname.join(".vagrant.v1.#{Time.now.to_i}")
701
+ @logger.info("Renaming old dotfile to: #{backup_file}")
702
+ path.rename(backup_file)
703
+
704
+ # Now, we create the actual local data directory. This should succeed
705
+ # this time since we renamed the old conflicting V1.
706
+ setup_local_data_path
707
+
708
+ if json_data["active"]
709
+ @logger.debug("Upgrading to V2 style for each active VM")
710
+ json_data["active"].each do |name, id|
711
+ @logger.info("Upgrading dotfile: #{name} (#{id})")
712
+
713
+ # Create the machine configuration directory
714
+ directory = @local_data_path.join("machines/#{name}/virtualbox")
715
+ FileUtils.mkdir_p(directory)
716
+
717
+ # Write the ID file
718
+ directory.join("id").open("w+") do |f|
719
+ f.write(id)
720
+ end
721
+ end
722
+ end
723
+
724
+ # Upgrade complete! Let the user know
725
+ @ui.info(I18n.t("vagrant.general.upgraded_v1_dotfile",
726
+ :backup_path => backup_file.to_s))
520
727
  end
521
728
  end
522
729
  end