vagrant 0.8.10 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (324) hide show
  1. data/CHANGELOG.md +77 -1
  2. data/Gemfile +0 -14
  3. data/LICENSE +1 -1
  4. data/bin/vagrant +47 -20
  5. data/config/default.rb +6 -14
  6. data/lib/vagrant.rb +132 -5
  7. data/lib/vagrant/action.rb +45 -123
  8. data/lib/vagrant/action/box/destroy.rb +7 -3
  9. data/lib/vagrant/action/box/download.rb +8 -8
  10. data/lib/vagrant/action/box/package.rb +2 -2
  11. data/lib/vagrant/action/box/unpackage.rb +13 -7
  12. data/lib/vagrant/action/box/verify.rb +5 -5
  13. data/lib/vagrant/action/builder.rb +23 -19
  14. data/lib/vagrant/action/builtin.rb +117 -79
  15. data/lib/vagrant/action/env/set.rb +7 -4
  16. data/lib/vagrant/action/environment.rb +3 -41
  17. data/lib/vagrant/action/general/package.rb +14 -29
  18. data/lib/vagrant/action/general/validate.rb +2 -2
  19. data/lib/vagrant/action/runner.rb +53 -0
  20. data/lib/vagrant/action/vm/boot.rb +9 -9
  21. data/lib/vagrant/action/vm/check_accessible.rb +2 -2
  22. data/lib/vagrant/action/vm/check_box.rb +10 -12
  23. data/lib/vagrant/action/vm/check_guest_additions.rb +8 -8
  24. data/lib/vagrant/action/vm/check_port_collisions.rb +85 -0
  25. data/lib/vagrant/action/vm/clean_machine_folder.rb +4 -4
  26. data/lib/vagrant/action/vm/clear_forwarded_ports.rb +3 -11
  27. data/lib/vagrant/action/vm/clear_network_interfaces.rb +31 -0
  28. data/lib/vagrant/action/vm/clear_shared_folders.rb +2 -11
  29. data/lib/vagrant/action/vm/customize.rb +19 -9
  30. data/lib/vagrant/action/vm/destroy.rb +4 -4
  31. data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +2 -12
  32. data/lib/vagrant/action/vm/discard_state.rb +4 -4
  33. data/lib/vagrant/action/vm/export.rb +13 -8
  34. data/lib/vagrant/action/vm/forward_ports.rb +55 -102
  35. data/lib/vagrant/action/vm/halt.rb +9 -6
  36. data/lib/vagrant/action/vm/host_name.rb +4 -4
  37. data/lib/vagrant/action/vm/import.rb +19 -10
  38. data/lib/vagrant/action/vm/match_mac_address.rb +4 -9
  39. data/lib/vagrant/action/vm/network.rb +300 -94
  40. data/lib/vagrant/action/vm/nfs.rb +41 -26
  41. data/lib/vagrant/action/vm/package.rb +1 -1
  42. data/lib/vagrant/action/vm/package_vagrantfile.rb +5 -2
  43. data/lib/vagrant/action/vm/provision.rb +42 -13
  44. data/lib/vagrant/action/vm/provisioner_cleanup.rb +2 -2
  45. data/lib/vagrant/action/vm/{clear_nfs_exports.rb → prune_nfs_exports.rb} +7 -7
  46. data/lib/vagrant/action/vm/resume.rb +4 -4
  47. data/lib/vagrant/action/vm/setup_package_files.rb +54 -0
  48. data/lib/vagrant/action/vm/share_folders.rb +63 -39
  49. data/lib/vagrant/action/vm/suspend.rb +4 -4
  50. data/lib/vagrant/action/warden.rb +13 -6
  51. data/lib/vagrant/box.rb +9 -55
  52. data/lib/vagrant/box_collection.rb +22 -17
  53. data/lib/vagrant/cli.rb +62 -47
  54. data/lib/vagrant/command.rb +18 -20
  55. data/lib/vagrant/command/base.rb +135 -90
  56. data/lib/vagrant/command/box.rb +46 -21
  57. data/lib/vagrant/command/box_add.rb +33 -0
  58. data/lib/vagrant/command/box_list.rb +25 -0
  59. data/lib/vagrant/command/box_remove.rb +23 -0
  60. data/lib/vagrant/command/box_repackage.rb +23 -0
  61. data/lib/vagrant/command/destroy.rb +16 -5
  62. data/lib/vagrant/command/halt.rb +25 -7
  63. data/lib/vagrant/command/init.rb +30 -7
  64. data/lib/vagrant/command/package.rb +49 -18
  65. data/lib/vagrant/command/provision.rb +22 -9
  66. data/lib/vagrant/command/reload.rb +18 -5
  67. data/lib/vagrant/command/resume.rb +18 -5
  68. data/lib/vagrant/command/ssh.rb +69 -31
  69. data/lib/vagrant/command/ssh_config.rb +37 -22
  70. data/lib/vagrant/command/status.rb +22 -20
  71. data/lib/vagrant/command/suspend.rb +18 -5
  72. data/lib/vagrant/command/up.rb +41 -8
  73. data/lib/vagrant/communication.rb +7 -0
  74. data/lib/vagrant/communication/base.rb +56 -0
  75. data/lib/vagrant/communication/ssh.rb +200 -0
  76. data/lib/vagrant/config.rb +29 -103
  77. data/lib/vagrant/config/base.rb +18 -26
  78. data/lib/vagrant/config/container.rb +37 -0
  79. data/lib/vagrant/config/error_recorder.rb +1 -1
  80. data/lib/vagrant/config/loader.rb +125 -0
  81. data/lib/vagrant/config/nfs.rb +1 -3
  82. data/lib/vagrant/config/package.rb +1 -3
  83. data/lib/vagrant/config/ssh.rb +31 -16
  84. data/lib/vagrant/config/top.rb +36 -25
  85. data/lib/vagrant/config/vagrant.rb +2 -5
  86. data/lib/vagrant/config/vm.rb +115 -56
  87. data/lib/vagrant/config/vm/provisioner.rb +16 -20
  88. data/lib/vagrant/config/vm/sub_vm.rb +1 -1
  89. data/lib/vagrant/data_store.rb +23 -15
  90. data/lib/vagrant/downloaders/base.rb +7 -5
  91. data/lib/vagrant/downloaders/file.rb +4 -4
  92. data/lib/vagrant/downloaders/http.rb +4 -5
  93. data/lib/vagrant/driver.rb +7 -0
  94. data/lib/vagrant/driver/virtualbox.rb +121 -0
  95. data/lib/vagrant/driver/virtualbox_4_0.rb +411 -0
  96. data/lib/vagrant/driver/virtualbox_4_1.rb +411 -0
  97. data/lib/vagrant/driver/virtualbox_base.rb +284 -0
  98. data/lib/vagrant/environment.rb +221 -240
  99. data/lib/vagrant/errors.rb +74 -25
  100. data/lib/vagrant/guest.rb +16 -0
  101. data/lib/vagrant/guest/arch.rb +48 -0
  102. data/lib/vagrant/{systems → guest}/base.rb +30 -18
  103. data/lib/vagrant/guest/debian.rb +61 -0
  104. data/lib/vagrant/{systems → guest}/freebsd.rb +11 -18
  105. data/lib/vagrant/guest/gentoo.rb +32 -0
  106. data/lib/vagrant/guest/linux.rb +78 -0
  107. data/lib/vagrant/{systems → guest}/linux/config.rb +2 -4
  108. data/lib/vagrant/guest/linux/error.rb +9 -0
  109. data/lib/vagrant/guest/redhat.rb +66 -0
  110. data/lib/vagrant/guest/solaris.rb +114 -0
  111. data/lib/vagrant/{systems → guest}/suse.rb +2 -2
  112. data/lib/vagrant/guest/ubuntu.rb +23 -0
  113. data/lib/vagrant/hosts.rb +23 -6
  114. data/lib/vagrant/hosts/arch.rb +7 -3
  115. data/lib/vagrant/hosts/base.rb +36 -46
  116. data/lib/vagrant/hosts/bsd.rb +53 -16
  117. data/lib/vagrant/hosts/fedora.rb +14 -0
  118. data/lib/vagrant/hosts/freebsd.rb +6 -36
  119. data/lib/vagrant/hosts/linux.rb +45 -20
  120. data/lib/vagrant/hosts/windows.rb +16 -0
  121. data/lib/vagrant/provisioners.rb +10 -7
  122. data/lib/vagrant/provisioners/base.rb +11 -34
  123. data/lib/vagrant/provisioners/chef.rb +30 -26
  124. data/lib/vagrant/provisioners/chef_client.rb +37 -23
  125. data/lib/vagrant/provisioners/chef_solo.rb +61 -16
  126. data/lib/vagrant/provisioners/puppet.rb +70 -38
  127. data/lib/vagrant/provisioners/puppet_server.rb +12 -13
  128. data/lib/vagrant/provisioners/shell.rb +24 -24
  129. data/lib/vagrant/registry.rb +49 -0
  130. data/lib/vagrant/ssh.rb +82 -153
  131. data/lib/vagrant/ui.rb +118 -50
  132. data/lib/vagrant/util/busy.rb +1 -1
  133. data/lib/vagrant/util/file_mode.rb +12 -0
  134. data/lib/vagrant/util/network_ip.rb +28 -0
  135. data/lib/vagrant/util/platform.rb +1 -0
  136. data/lib/vagrant/util/subprocess.rb +227 -0
  137. data/lib/vagrant/version.rb +1 -1
  138. data/lib/vagrant/vm.rb +111 -97
  139. data/tasks/acceptance.rake +3 -3
  140. data/tasks/test.rake +7 -2
  141. data/templates/commands/init/Vagrantfile.erb +11 -4
  142. data/templates/{ssh_config.erb → commands/ssh_config/config.erb} +0 -0
  143. data/templates/guests/arch/network_dhcp.erb +7 -0
  144. data/templates/guests/arch/network_static.erb +7 -0
  145. data/templates/guests/debian/network_dhcp.erb +6 -0
  146. data/templates/guests/debian/network_static.erb +7 -0
  147. data/templates/guests/gentoo/network_dhcp.erb +4 -0
  148. data/templates/guests/gentoo/network_static.erb +4 -0
  149. data/templates/guests/redhat/network_dhcp.erb +6 -0
  150. data/templates/guests/redhat/network_static.erb +7 -0
  151. data/templates/locales/en.yml +241 -122
  152. data/templates/{chef_server_client.erb → provisioners/chef_client/client.erb} +0 -0
  153. data/templates/{chef_solo_solo.erb → provisioners/chef_solo/solo.erb} +0 -0
  154. data/test/acceptance/base.rb +10 -10
  155. data/test/acceptance/box_test.rb +28 -6
  156. data/test/acceptance/destroy_test.rb +1 -1
  157. data/test/acceptance/halt_test.rb +4 -4
  158. data/test/acceptance/init_test.rb +3 -3
  159. data/test/acceptance/networking/host_only_test.rb +37 -0
  160. data/test/acceptance/networking/port_forward_test.rb +125 -0
  161. data/test/acceptance/package_test.rb +46 -0
  162. data/test/acceptance/provisioning/basic_test.rb +61 -0
  163. data/test/acceptance/provisioning/chef_solo_test.rb +37 -0
  164. data/test/acceptance/provisioning/shell_test.rb +53 -0
  165. data/test/acceptance/resume_test.rb +1 -1
  166. data/test/acceptance/skeletons/chef_solo_basic/README.md +3 -0
  167. data/test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb +5 -0
  168. data/test/acceptance/skeletons/chef_solo_json/README.md +3 -0
  169. data/test/acceptance/skeletons/chef_solo_json/cookbooks/basic/recipes/default.rb +6 -0
  170. data/test/acceptance/skeletons/provisioner_multi/README.md +3 -0
  171. data/test/acceptance/skeletons/provisioner_multi/cookbooks/basic/recipes/default.rb +5 -0
  172. data/test/acceptance/ssh_test.rb +7 -2
  173. data/test/acceptance/support/config.rb +1 -1
  174. data/test/acceptance/support/isolated_environment.rb +41 -150
  175. data/test/acceptance/support/matchers/match_output.rb +1 -1
  176. data/test/acceptance/support/matchers/succeed.rb +14 -0
  177. data/test/acceptance/support/network_tests.rb +29 -0
  178. data/test/acceptance/support/output.rb +9 -1
  179. data/test/acceptance/support/shared/base_context.rb +16 -9
  180. data/test/acceptance/support/shared/command_examples.rb +4 -4
  181. data/test/acceptance/suspend_test.rb +1 -1
  182. data/test/acceptance/up_basic_test.rb +26 -7
  183. data/test/acceptance/up_with_box_url.rb +1 -1
  184. data/test/acceptance/vagrant_test.rb +1 -1
  185. data/test/acceptance/version_test.rb +0 -5
  186. data/test/support/isolated_environment.rb +46 -0
  187. data/test/{acceptance/support → support}/tempdir.rb +0 -0
  188. data/test/unit/base.rb +21 -0
  189. data/test/unit/support/isolated_environment.rb +39 -0
  190. data/test/unit/support/shared/base_context.rb +30 -0
  191. data/test/unit/vagrant/action/builder_test.rb +126 -177
  192. data/test/unit/vagrant/action/environment_test.rb +10 -21
  193. data/test/unit/vagrant/action/runner_test.rb +65 -0
  194. data/test/unit/vagrant/action/warden_test.rb +64 -97
  195. data/test/unit/vagrant/box_collection_test.rb +44 -33
  196. data/test/unit/vagrant/box_test.rb +25 -65
  197. data/test/unit/vagrant/command/base_test.rb +141 -14
  198. data/test/unit/vagrant/config/base_test.rb +16 -43
  199. data/test/unit/vagrant/config/loader_test.rb +79 -0
  200. data/test/unit/vagrant/config/top_test.rb +69 -0
  201. data/test/unit/vagrant/config/vm_test.rb +62 -47
  202. data/test/unit/vagrant/config_test.rb +16 -151
  203. data/test/unit/vagrant/data_store_test.rb +43 -61
  204. data/test/unit/vagrant/downloaders/base_test.rb +12 -22
  205. data/test/unit/vagrant/downloaders/file_test.rb +58 -31
  206. data/test/unit/vagrant/downloaders/http_test.rb +12 -86
  207. data/test/unit/vagrant/environment_test.rb +107 -536
  208. data/test/unit/vagrant/hosts_test.rb +36 -0
  209. data/test/unit/vagrant/registry_test.rb +56 -0
  210. data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
  211. data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +23 -24
  212. data/test/unit/vagrant/util/network_ip_test.rb +17 -0
  213. data/test/unit/vagrant/util/retryable_test.rb +90 -34
  214. data/test/unit/vagrant_test.rb +27 -0
  215. data/test/{unit → unit_legacy}/locales/en.yml +0 -0
  216. data/test/{unit → unit_legacy}/test_helper.rb +0 -0
  217. data/test/{unit → unit_legacy}/vagrant/action/box/destroy_test.rb +0 -0
  218. data/test/{unit → unit_legacy}/vagrant/action/box/download_test.rb +0 -0
  219. data/test/{unit → unit_legacy}/vagrant/action/box/package_test.rb +0 -0
  220. data/test/{unit → unit_legacy}/vagrant/action/box/unpackage_test.rb +0 -0
  221. data/test/{unit → unit_legacy}/vagrant/action/box/verify_test.rb +0 -0
  222. data/test/{unit → unit_legacy}/vagrant/action/env/set_test.rb +0 -0
  223. data/test/{unit → unit_legacy}/vagrant/action/general/package_test.rb +0 -0
  224. data/test/{unit → unit_legacy}/vagrant/action/general/validate_test.rb +0 -0
  225. data/test/{unit → unit_legacy}/vagrant/action/vm/boot_test.rb +0 -0
  226. data/test/{unit → unit_legacy}/vagrant/action/vm/check_accessible_test.rb +0 -0
  227. data/test/{unit → unit_legacy}/vagrant/action/vm/check_box_test.rb +0 -0
  228. data/test/{unit → unit_legacy}/vagrant/action/vm/check_guest_additions_test.rb +0 -0
  229. data/test/{unit → unit_legacy}/vagrant/action/vm/clean_machine_folder_test.rb +0 -0
  230. data/test/{unit → unit_legacy}/vagrant/action/vm/clear_forwarded_ports_test.rb +0 -0
  231. data/test/{unit → unit_legacy}/vagrant/action/vm/clear_nfs_exports_test.rb +0 -0
  232. data/test/{unit → unit_legacy}/vagrant/action/vm/clear_shared_folders_test.rb +0 -0
  233. data/test/{unit → unit_legacy}/vagrant/action/vm/customize_test.rb +0 -0
  234. data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_test.rb +0 -0
  235. data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +0 -0
  236. data/test/{unit → unit_legacy}/vagrant/action/vm/discard_state_test.rb +0 -0
  237. data/test/{unit → unit_legacy}/vagrant/action/vm/export_test.rb +0 -0
  238. data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_helpers_test.rb +0 -0
  239. data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_test.rb +0 -0
  240. data/test/{unit → unit_legacy}/vagrant/action/vm/halt_test.rb +0 -0
  241. data/test/{unit → unit_legacy}/vagrant/action/vm/host_name_test.rb +0 -0
  242. data/test/{unit → unit_legacy}/vagrant/action/vm/import_test.rb +0 -0
  243. data/test/{unit → unit_legacy}/vagrant/action/vm/match_mac_address_test.rb +0 -0
  244. data/test/{unit → unit_legacy}/vagrant/action/vm/modify_test.rb +0 -0
  245. data/test/{unit → unit_legacy}/vagrant/action/vm/network_test.rb +0 -0
  246. data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_helpers_test.rb +0 -0
  247. data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_test.rb +0 -0
  248. data/test/{unit → unit_legacy}/vagrant/action/vm/package_test.rb +0 -0
  249. data/test/{unit → unit_legacy}/vagrant/action/vm/package_vagrantfile_test.rb +0 -0
  250. data/test/{unit → unit_legacy}/vagrant/action/vm/provision_test.rb +0 -0
  251. data/test/{unit → unit_legacy}/vagrant/action/vm/provisioner_cleanup_test.rb +0 -0
  252. data/test/{unit → unit_legacy}/vagrant/action/vm/resume_test.rb +0 -0
  253. data/test/{unit → unit_legacy}/vagrant/action/vm/share_folders_test.rb +0 -0
  254. data/test/{unit → unit_legacy}/vagrant/action/vm/suspend_test.rb +0 -0
  255. data/test/{unit → unit_legacy}/vagrant/action_test.rb +0 -0
  256. data/test/unit_legacy/vagrant/box_collection_test.rb +45 -0
  257. data/test/unit_legacy/vagrant/box_test.rb +74 -0
  258. data/test/{unit → unit_legacy}/vagrant/cli_test.rb +0 -0
  259. data/test/unit_legacy/vagrant/command/base_test.rb +23 -0
  260. data/test/{unit → unit_legacy}/vagrant/command/group_base_test.rb +0 -0
  261. data/test/{unit → unit_legacy}/vagrant/command/helpers_test.rb +0 -0
  262. data/test/{unit → unit_legacy}/vagrant/command/init_test.rb +0 -0
  263. data/test/{unit → unit_legacy}/vagrant/command/package_test.rb +0 -0
  264. data/test/unit_legacy/vagrant/config/base_test.rb +52 -0
  265. data/test/{unit → unit_legacy}/vagrant/config/error_recorder_test.rb +0 -0
  266. data/test/{unit → unit_legacy}/vagrant/config/ssh_test.rb +0 -0
  267. data/test/{unit → unit_legacy}/vagrant/config/vagrant_test.rb +0 -0
  268. data/test/{unit → unit_legacy}/vagrant/config/vm/provisioner_test.rb +0 -0
  269. data/test/unit_legacy/vagrant/config/vm_test.rb +47 -0
  270. data/test/unit_legacy/vagrant/config_test.rb +148 -0
  271. data/test/unit_legacy/vagrant/downloaders/http_test.rb +93 -0
  272. data/test/unit_legacy/vagrant/environment_test.rb +539 -0
  273. data/test/{unit → unit_legacy}/vagrant/errors_test.rb +0 -0
  274. data/test/{unit → unit_legacy}/vagrant/hosts/base_test.rb +0 -0
  275. data/test/{unit → unit_legacy}/vagrant/hosts/bsd_test.rb +0 -0
  276. data/test/{unit → unit_legacy}/vagrant/hosts/linux_test.rb +0 -0
  277. data/test/{unit → unit_legacy}/vagrant/plugin_test.rb +0 -0
  278. data/test/{unit → unit_legacy}/vagrant/provisioners/base_test.rb +0 -0
  279. data/test/{unit → unit_legacy}/vagrant/provisioners/chef_client_test.rb +0 -0
  280. data/test/{unit → unit_legacy}/vagrant/provisioners/chef_solo_test.rb +0 -0
  281. data/test/{unit → unit_legacy}/vagrant/provisioners/chef_test.rb +0 -0
  282. data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_server_test.rb +0 -0
  283. data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_test.rb +0 -0
  284. data/test/{unit → unit_legacy}/vagrant/provisioners/shell_test.rb +0 -0
  285. data/test/{unit → unit_legacy}/vagrant/ssh/session_test.rb +0 -0
  286. data/test/{unit → unit_legacy}/vagrant/ssh_test.rb +0 -0
  287. data/test/{unit → unit_legacy}/vagrant/systems/base_test.rb +0 -0
  288. data/test/{unit → unit_legacy}/vagrant/systems/linux_test.rb +0 -0
  289. data/test/{unit → unit_legacy}/vagrant/util/busy_test.rb +0 -0
  290. data/test/{unit → unit_legacy}/vagrant/util/counter_test.rb +0 -0
  291. data/test/{unit → unit_legacy}/vagrant/util/platform_test.rb +0 -0
  292. data/test/{unit → unit_legacy}/vagrant/util/stacked_proc_runner_test.rb +0 -0
  293. data/test/{unit → unit_legacy}/vagrant/util/template_renderer_test.rb +0 -0
  294. data/test/{unit → unit_legacy}/vagrant/vm_test.rb +0 -0
  295. data/vagrant.gemspec +7 -9
  296. metadata +214 -216
  297. data/keys/vagrant.ppk +0 -26
  298. data/lib/vagrant/action/box.rb +0 -11
  299. data/lib/vagrant/action/env.rb +0 -7
  300. data/lib/vagrant/action/general.rb +0 -8
  301. data/lib/vagrant/action/vm.rb +0 -34
  302. data/lib/vagrant/action/vm/forward_ports_helpers.rb +0 -28
  303. data/lib/vagrant/action/vm/modify.rb +0 -37
  304. data/lib/vagrant/action/vm/nfs_helpers.rb +0 -11
  305. data/lib/vagrant/command/group_base.rb +0 -107
  306. data/lib/vagrant/command/helpers.rb +0 -33
  307. data/lib/vagrant/command/named_base.rb +0 -14
  308. data/lib/vagrant/command/upgrade_to_060.rb +0 -45
  309. data/lib/vagrant/command/version.rb +0 -13
  310. data/lib/vagrant/ssh/session.rb +0 -136
  311. data/lib/vagrant/systems.rb +0 -13
  312. data/lib/vagrant/systems/arch.rb +0 -34
  313. data/lib/vagrant/systems/debian.rb +0 -36
  314. data/lib/vagrant/systems/gentoo.rb +0 -27
  315. data/lib/vagrant/systems/linux.rb +0 -82
  316. data/lib/vagrant/systems/linux/error.rb +0 -9
  317. data/lib/vagrant/systems/redhat.rb +0 -48
  318. data/lib/vagrant/systems/solaris.rb +0 -113
  319. data/lib/vagrant/systems/ubuntu.rb +0 -17
  320. data/templates/network_entry_arch.erb +0 -9
  321. data/templates/network_entry_debian.erb +0 -8
  322. data/templates/network_entry_gentoo.erb +0 -5
  323. data/templates/network_entry_redhat.erb +0 -9
  324. data/test/unit/vagrant/ui_test.rb +0 -29
@@ -1,46 +1,18 @@
1
- require 'vagrant/config/base'
2
- require 'vagrant/config/error_recorder'
3
- require 'vagrant/config/top'
1
+ module Vagrant
2
+ module Config
3
+ autoload :Base, 'vagrant/config/base'
4
+ autoload :Container, 'vagrant/config/container'
5
+ autoload :ErrorRecorder, 'vagrant/config/error_recorder'
6
+ autoload :Loader, 'vagrant/config/loader'
7
+ autoload :Top, 'vagrant/config/top'
4
8
 
5
- # The built-in configuration classes
6
- require 'vagrant/config/vagrant'
7
- require 'vagrant/config/ssh'
8
- require 'vagrant/config/nfs'
9
- require 'vagrant/config/vm'
10
- require 'vagrant/config/package'
9
+ autoload :NFSConfig, 'vagrant/config/nfs'
10
+ autoload :PackageConfig, 'vagrant/config/package'
11
+ autoload :SSHConfig, 'vagrant/config/ssh'
12
+ autoload :VagrantConfig, 'vagrant/config/vagrant'
13
+ autoload :VMConfig, 'vagrant/config/vm'
11
14
 
12
- module Vagrant
13
- # The config class is responsible for loading Vagrant configurations, which
14
- # are usually found in Vagrantfiles but may also be procs. The loading is done
15
- # by specifying a queue of files or procs that are for configuration, and then
16
- # executing them. The config loader will run each item in the queue, so that
17
- # configuration from later items overwrite that from earlier items. This is how
18
- # Vagrant "scoping" of Vagranfiles is implemented.
19
- #
20
- # If you're looking to create your own configuration classes, see {Base}.
21
- #
22
- # # Loading Configuration Files
23
- #
24
- # If you are in fact looking to load configuration files, then this is the
25
- # class you are looking for. Loading configuration is quite easy. The following
26
- # example assumes `env` is already a loaded instance of {Environment}:
27
- #
28
- # config = Vagrant::Config.new
29
- # config.set(:first, "/path/to/some/Vagrantfile")
30
- # config.set(:second, "/path/to/another/Vagrantfile")
31
- # config.load_order = [:first, :second]
32
- # result = config.load(env)
33
- #
34
- # p "Your box is: #{result.vm.box}"
35
- #
36
- # The load order determines what order the config files specified are loaded.
37
- # If a key is not mentioned (for example if above the load order was set to
38
- # `[:first]`, therefore `:second` was not mentioned), then that config file
39
- # won't be loaded.
40
- class Config
41
- # An array of symbols specifying the load order for the procs.
42
- attr_accessor :load_order
43
- attr_reader :procs
15
+ CONFIGURE_MUTEX = Mutex.new
44
16
 
45
17
  # This is the method which is called by all Vagrantfiles to configure Vagrant.
46
18
  # This method expects a block which accepts a single argument representing
@@ -54,69 +26,23 @@ module Vagrant
54
26
  @last_procs << block
55
27
  end
56
28
 
57
- # Returns the last proc which was activated for the class via {run}. This
58
- # also sets the last proc to `nil` so that calling this method multiple times
59
- # will not return duplicates.
60
- #
61
- # @return [Proc]
62
- def self.last_proc
63
- value = @last_procs
64
- @last_procs = nil
65
- value
66
- end
67
-
68
- def initialize(parent=nil)
69
- @procs = {}
70
- @load_order = []
71
-
72
- if parent
73
- # Shallow copy the procs and load order from parent if given
74
- @procs = parent.procs.dup
75
- @load_order = parent.load_order.dup
76
- end
77
- end
78
-
79
- # Adds a Vagrantfile to be loaded to the queue of config procs. Note
80
- # that this causes the Vagrantfile file to be loaded at this point,
81
- # and it will never be loaded again.
82
- def set(key, path)
83
- return if @procs.has_key?(key)
84
- @procs[key] = [path].flatten.map(&method(:proc_for)).flatten
85
- end
86
-
87
- # Loads the added procs using the set `load_order` attribute and returns
88
- # the {Config::Top} object result. The configuration is loaded for the
89
- # given {Environment} object.
29
+ # This is a method which will yield to a block and will capture all
30
+ # ``Vagrant.configure`` calls, returning an array of `Proc`s.
90
31
  #
91
- # @param [Environment] env
92
- def load(env)
93
- config = Top.new(env)
94
-
95
- # Only run the procs specified in the load order, in the order
96
- # specified.
97
- load_order.each do |key|
98
- if @procs[key]
99
- @procs[key].each do |proc|
100
- proc.call(config) if proc
101
- end
102
- end
103
- end
104
-
105
- config
106
- end
107
-
108
- protected
109
-
110
- def proc_for(path)
111
- return nil if !path
112
- return path if path.is_a?(Proc)
113
-
114
- begin
115
- Kernel.load path if File.exist?(path)
116
- return self.class.last_proc
117
- rescue SyntaxError => e
118
- # Report syntax errors in a nice way for Vagrantfiles
119
- raise Errors::VagrantfileSyntaxError, :file => e.message
32
+ # Wrapping this around anytime you call code which loads configurations
33
+ # will force a mutex so that procs never get mixed up. This keeps
34
+ # the configuration loading part of Vagrant thread-safe.
35
+ def self.capture_configures
36
+ CONFIGURE_MUTEX.synchronize do
37
+ # Reset the last procs so that we start fresh
38
+ @last_procs = []
39
+
40
+ # Yield to allow the caller to do whatever loading needed
41
+ yield
42
+
43
+ # Return the last procs we've seen while still in the mutex,
44
+ # knowing we're safe.
45
+ return @last_procs
120
46
  end
121
47
  end
122
48
  end
@@ -1,22 +1,9 @@
1
1
  module Vagrant
2
- class Config
2
+ module Config
3
3
  # The base class for all configuration classes. This implements
4
4
  # basic things such as the environment instance variable which all
5
5
  # config classes need as well as a basic `to_json` implementation.
6
6
  class Base
7
- # {Top} of this configuration stack
8
- attr_accessor :top
9
-
10
- # Registers a subclass with the Vagrant configuration system so
11
- # that it can then be used in Vagrantfiles.
12
- #
13
- # @param [Symbol] accessor The accessor on the main config object
14
- # that is used to access the configuration class.
15
- #
16
- def self.configures(accessor, klass=self)
17
- Top.configures(accessor, klass)
18
- end
19
-
20
7
  # Loads configuration values from JSON back into the proper
21
8
  # configuration classes. By default, this is done by simply
22
9
  # iterating over all values in the JSON hash and assigning them
@@ -29,14 +16,6 @@ module Vagrant
29
16
  end
30
17
  end
31
18
 
32
- # A helper to access the environment that this configuration is for.
33
- # This is obtained by getting the env from the {Top}.
34
- #
35
- # @return [Vagrant::Envrionment]
36
- def env
37
- top.env
38
- end
39
-
40
19
  # Allows setting options from a hash. By default this simply calls
41
20
  # the `#{key}=` method on the config class with the value, which is
42
21
  # the expected behavior most of the time.
@@ -46,12 +25,26 @@ module Vagrant
46
25
  end
47
26
  end
48
27
 
28
+ # Merge another configuration object into this one.
29
+ #
30
+ # @param [Object] other The other configuration object to merge from,
31
+ # this must be the same type of object as this one.
32
+ # @return [Object] The merged object.
33
+ def merge(other)
34
+ result = self.class.new
35
+ instance_variables_hash.merge(other.instance_variables_hash).each do |key, value|
36
+ result.instance_variable_set("@#{key}".to_sym, value)
37
+ end
38
+
39
+ result
40
+ end
41
+
49
42
  # Called by {Top} after the configuration is loaded to validate
50
43
  # the configuaration objects. Subclasses should implement this
51
44
  # method and add any errors to the `errors` object given.
52
45
  #
53
46
  # @param [ErrorRecorder] errors
54
- def validate(errors); end
47
+ def validate(env, errors); end
55
48
 
56
49
  # Converts the configuration to a raw hash by calling `#to_hash`
57
50
  # on all instance variables (if it can) and putting them into
@@ -69,14 +62,13 @@ module Vagrant
69
62
  # the JSON is parsed back, it can be loaded back into the proper class.
70
63
  # See {json_create}.
71
64
  def to_json(*a)
72
- result = { 'json_class' => self.class.name }
73
- result.merge(instance_variables_hash).to_json(*a)
65
+ instance_variables_hash.to_json(*a)
74
66
  end
75
67
 
76
68
  # Returns the instance variables as a hash of key-value pairs.
77
69
  def instance_variables_hash
78
70
  instance_variables.inject({}) do |acc, iv|
79
- acc[iv.to_s[1..-1]] = instance_variable_get(iv) unless [:@env, :@top].include?(iv.to_sym)
71
+ acc[iv.to_s[1..-1]] = instance_variable_get(iv)
80
72
  acc
81
73
  end
82
74
  end
@@ -0,0 +1,37 @@
1
+ module Vagrant
2
+ module Config
3
+ # Contains loaded configuration values and provides access to those
4
+ # values.
5
+ #
6
+ # This is the class returned when loading configuration and stores
7
+ # the completely loaded configuration values. This class is meant to
8
+ # be immutable.
9
+ class Container
10
+ attr_reader :global
11
+ attr_reader :vms
12
+
13
+ # Initializes the configuration container.
14
+ #
15
+ # @param [Top] global Top-level configuration for the global
16
+ # applicatoin.
17
+ # @param [Array] vms Array of VM configurations.
18
+ def initialize(global, vms)
19
+ @global = global
20
+ @vms = []
21
+ @vm_configs = {}
22
+
23
+ vms.each do |vm_config|
24
+ @vms << vm_config.vm.name
25
+ @vm_configs[vm_config.vm.name] = vm_config
26
+ end
27
+ end
28
+
29
+ # This returns the configuration for a specific virtual machine.
30
+ # The values for this configuration are usually pertinent to a
31
+ # single virtual machine and do not affect the system globally.
32
+ def for_vm(name)
33
+ @vm_configs[name]
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
- class Config
2
+ module Config
3
3
  # A class which is passed into the various {Base#validate} methods and
4
4
  # can be used as a helper to add error messages about a single config
5
5
  # class.
@@ -0,0 +1,125 @@
1
+ require "pathname"
2
+
3
+ require "log4r"
4
+
5
+ module Vagrant
6
+ module Config
7
+ # This class is responsible for loading Vagrant configuration,
8
+ # usually in the form of Vagrantfiles.
9
+ #
10
+ # Loading works by specifying the sources for the configuration
11
+ # as well as the order the sources should be loaded. Configuration
12
+ # set later always overrides those set earlier; this is how
13
+ # configuration "scoping" is implemented.
14
+ class Loader
15
+ # This is an array of symbols specifying the order in which
16
+ # configuration is loaded. For examples, see the class documentation.
17
+ attr_accessor :load_order
18
+
19
+ def initialize
20
+ @logger = Log4r::Logger.new("vagrant::config::loader")
21
+ @sources = {}
22
+ @proc_cache = {}
23
+ @config_cache = {}
24
+ end
25
+
26
+ # Set the configuration data for the given name.
27
+ #
28
+ # The `name` should be a symbol and must uniquely identify the data
29
+ # being given.
30
+ #
31
+ # `data` can either be a path to a Ruby Vagrantfile or a `Proc` directly.
32
+ # `data` can also be an array of such values.
33
+ #
34
+ # At this point, no configuration is actually loaded. Note that calling
35
+ # `set` multiple times with the same name will override any previously
36
+ # set values. In this way, the last set data for a given name wins.
37
+ def set(name, sources)
38
+ @logger.debug("Set #{name.inspect} = #{sources.inspect}")
39
+
40
+ # Sources should be an array
41
+ sources = [sources] if !sources.kind_of?(Array)
42
+
43
+ # Gather the procs for every source, since that is what we care about.
44
+ procs = []
45
+ sources.each do |source|
46
+ if !@proc_cache.has_key?(source)
47
+ # Load the procs for this source and cache them. This caching
48
+ # avoids the issue where a file may have side effects when loading
49
+ # and loading it multiple times causes unexpected behavior.
50
+ @logger.debug("Populating proc cache for #{source.inspect}")
51
+ @proc_cache[source] = procs_for_source(source)
52
+ end
53
+
54
+ # Add on to the array of procs we're going to use
55
+ procs.concat(@proc_cache[source])
56
+ end
57
+
58
+ # Set this source by name.
59
+ @sources[name] = procs
60
+ end
61
+
62
+ # This loads the configured sources in the configured order and returns
63
+ # an actual configuration object that is ready to be used.
64
+ def load
65
+ @logger.debug("Loading configuration in order: #{@load_order.inspect}")
66
+
67
+ unknown_sources = @sources.keys - @load_order
68
+ if !unknown_sources.empty?
69
+ # TODO: Raise exception here perhaps.
70
+ @logger.error("Unknown config sources: #{unknown_sources.inspect}")
71
+ end
72
+
73
+ # Create the top-level configuration which will hold all the config.
74
+ result = Top.new
75
+
76
+ @load_order.each do |key|
77
+ next if !@sources.has_key?(key)
78
+
79
+ @sources[key].each do |proc|
80
+ if !@config_cache.has_key?(proc)
81
+ @logger.debug("Loading from: #{key} (evaluating)")
82
+ current = Top.new
83
+ proc.call(current)
84
+ @config_cache[proc] = current
85
+ end
86
+
87
+ # Merge in the results of this proc's configuration
88
+ result = result.merge(@config_cache[proc])
89
+ end
90
+ end
91
+
92
+ @logger.debug("Configuration loaded successfully")
93
+ result
94
+ end
95
+
96
+ protected
97
+
98
+ # This returns an array of `Proc` objects for the given source.
99
+ # The `Proc` objects returned will expect a single argument for
100
+ # the configuration object and are expected to mutate this
101
+ # configuration object.
102
+ def procs_for_source(source)
103
+ return [source] if source.is_a?(Proc)
104
+
105
+ # Assume all string sources are actually pathnames
106
+ source = Pathname.new(source) if source.is_a?(String)
107
+
108
+ if source.is_a?(Pathname)
109
+ @logger.debug("Load procs for pathname: #{source.inspect}")
110
+
111
+ begin
112
+ return Config.capture_configures do
113
+ Kernel.load source
114
+ end
115
+ rescue SyntaxError => e
116
+ # Report syntax errors in a nice way.
117
+ raise Errors::VagrantfileSyntaxError, :file => e.message
118
+ end
119
+ end
120
+
121
+ raise Exception, "Unknown configuration source: #{source.inspect}"
122
+ end
123
+ end
124
+ end
125
+ end
@@ -1,8 +1,6 @@
1
1
  module Vagrant
2
- class Config
2
+ module Config
3
3
  class NFSConfig < Base
4
- configures :nfs
5
-
6
4
  attr_accessor :map_uid
7
5
  attr_accessor :map_gid
8
6
  end
@@ -1,8 +1,6 @@
1
1
  module Vagrant
2
- class Config
2
+ module Config
3
3
  class PackageConfig < Base
4
- configures :package
5
-
6
4
  attr_accessor :name
7
5
  end
8
6
  end
@@ -1,37 +1,52 @@
1
1
  module Vagrant
2
- class Config
2
+ module Config
3
3
  class SSHConfig < Base
4
- configures :ssh
5
-
6
4
  attr_accessor :username
5
+ attr_accessor :password
7
6
  attr_accessor :host
8
- attr_accessor :forwarded_port_key
9
- attr_accessor :forwarded_port_destination
7
+ attr_accessor :port
8
+ attr_accessor :guest_port
10
9
  attr_accessor :max_tries
11
10
  attr_accessor :timeout
12
- attr_writer :private_key_path
11
+ attr_accessor :private_key_path
13
12
  attr_accessor :forward_agent
14
13
  attr_accessor :forward_x11
15
14
  attr_accessor :shell
16
- attr_accessor :port
17
15
 
18
16
  def initialize
19
- @shell = "bash"
20
- @port = nil
21
- @forward_agent = false
22
- @forward_x11 = false
17
+ @shell = "bash"
18
+ @forward_agent = false
19
+ @forward_x11 = false
23
20
  end
24
21
 
25
- def private_key_path
26
- File.expand_path(@private_key_path, env.root_path)
22
+ def forwarded_port_key=(value)
23
+ raise Errors::DeprecationError, :message => <<-MESSAGE
24
+ `config.ssh.forwarded_port_key` is now gone. You must now use
25
+ `config.ssh.guest_port` which is expected to be the port on the
26
+ guest that SSH is listening on. Vagrant will automatically scan
27
+ the forwarded ports to look for a forwarded port from this port
28
+ and use it.
29
+ MESSAGE
27
30
  end
28
31
 
29
- def validate(errors)
30
- [:username, :host, :forwarded_port_key, :max_tries, :timeout, :private_key_path].each do |field|
32
+ def forwarded_port_destination=(value)
33
+ raise Errors::DeprecationError, :message => <<-MESSAGE
34
+ `config.ssh.forwarded_port_destination` is now gone. You must now use
35
+ `config.ssh.guest_port` which is expected to be the port on the
36
+ guest that SSH is listening on. Vagrant will automatically scan
37
+ the forwarded ports to look for a forwarded port from this port
38
+ and use it.
39
+ MESSAGE
40
+ end
41
+
42
+ def validate(env, errors)
43
+ [:username, :host, :max_tries, :timeout].each do |field|
31
44
  errors.add(I18n.t("vagrant.config.common.error_empty", :field => field)) if !instance_variable_get("@#{field}".to_sym)
32
45
  end
33
46
 
34
- errors.add(I18n.t("vagrant.config.ssh.private_key_missing", :path => private_key_path)) if !File.file?(private_key_path)
47
+ if private_key_path && !File.file?(private_key_path)
48
+ errors.add(I18n.t("vagrant.config.ssh.private_key_missing", :path => private_key_path))
49
+ end
35
50
  end
36
51
  end
37
52
  end