vagrantup 0.8.10 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (325) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +77 -1
  3. data/Gemfile +0 -14
  4. data/LICENSE +1 -1
  5. data/bin/vagrant +47 -20
  6. data/config/default.rb +6 -14
  7. data/lib/vagrant/action/box/destroy.rb +7 -3
  8. data/lib/vagrant/action/box/download.rb +8 -8
  9. data/lib/vagrant/action/box/package.rb +2 -2
  10. data/lib/vagrant/action/box/unpackage.rb +13 -7
  11. data/lib/vagrant/action/box/verify.rb +5 -5
  12. data/lib/vagrant/action/builder.rb +23 -19
  13. data/lib/vagrant/action/builtin.rb +117 -79
  14. data/lib/vagrant/action/env/set.rb +7 -4
  15. data/lib/vagrant/action/environment.rb +3 -41
  16. data/lib/vagrant/action/general/package.rb +14 -29
  17. data/lib/vagrant/action/general/validate.rb +2 -2
  18. data/lib/vagrant/action/runner.rb +53 -0
  19. data/lib/vagrant/action/vm/boot.rb +9 -9
  20. data/lib/vagrant/action/vm/check_accessible.rb +2 -2
  21. data/lib/vagrant/action/vm/check_box.rb +10 -12
  22. data/lib/vagrant/action/vm/check_guest_additions.rb +8 -8
  23. data/lib/vagrant/action/vm/check_port_collisions.rb +85 -0
  24. data/lib/vagrant/action/vm/clean_machine_folder.rb +4 -4
  25. data/lib/vagrant/action/vm/clear_forwarded_ports.rb +3 -11
  26. data/lib/vagrant/action/vm/clear_network_interfaces.rb +31 -0
  27. data/lib/vagrant/action/vm/clear_shared_folders.rb +2 -11
  28. data/lib/vagrant/action/vm/customize.rb +19 -9
  29. data/lib/vagrant/action/vm/destroy.rb +4 -4
  30. data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +2 -12
  31. data/lib/vagrant/action/vm/discard_state.rb +4 -4
  32. data/lib/vagrant/action/vm/export.rb +13 -8
  33. data/lib/vagrant/action/vm/forward_ports.rb +55 -102
  34. data/lib/vagrant/action/vm/halt.rb +9 -6
  35. data/lib/vagrant/action/vm/host_name.rb +4 -4
  36. data/lib/vagrant/action/vm/import.rb +19 -10
  37. data/lib/vagrant/action/vm/match_mac_address.rb +4 -9
  38. data/lib/vagrant/action/vm/network.rb +300 -94
  39. data/lib/vagrant/action/vm/nfs.rb +41 -26
  40. data/lib/vagrant/action/vm/package.rb +1 -1
  41. data/lib/vagrant/action/vm/package_vagrantfile.rb +5 -2
  42. data/lib/vagrant/action/vm/provision.rb +42 -13
  43. data/lib/vagrant/action/vm/provisioner_cleanup.rb +2 -2
  44. data/lib/vagrant/action/vm/{clear_nfs_exports.rb → prune_nfs_exports.rb} +7 -7
  45. data/lib/vagrant/action/vm/resume.rb +4 -4
  46. data/lib/vagrant/action/vm/setup_package_files.rb +54 -0
  47. data/lib/vagrant/action/vm/share_folders.rb +63 -39
  48. data/lib/vagrant/action/vm/suspend.rb +4 -4
  49. data/lib/vagrant/action/warden.rb +13 -6
  50. data/lib/vagrant/action.rb +45 -123
  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/base.rb +135 -90
  55. data/lib/vagrant/command/box.rb +46 -21
  56. data/lib/vagrant/command/box_add.rb +33 -0
  57. data/lib/vagrant/command/box_list.rb +25 -0
  58. data/lib/vagrant/command/box_remove.rb +23 -0
  59. data/lib/vagrant/command/box_repackage.rb +23 -0
  60. data/lib/vagrant/command/destroy.rb +16 -5
  61. data/lib/vagrant/command/halt.rb +25 -7
  62. data/lib/vagrant/command/init.rb +30 -7
  63. data/lib/vagrant/command/package.rb +49 -18
  64. data/lib/vagrant/command/provision.rb +22 -9
  65. data/lib/vagrant/command/reload.rb +18 -5
  66. data/lib/vagrant/command/resume.rb +18 -5
  67. data/lib/vagrant/command/ssh.rb +69 -31
  68. data/lib/vagrant/command/ssh_config.rb +37 -22
  69. data/lib/vagrant/command/status.rb +22 -20
  70. data/lib/vagrant/command/suspend.rb +18 -5
  71. data/lib/vagrant/command/up.rb +41 -8
  72. data/lib/vagrant/command.rb +18 -20
  73. data/lib/vagrant/communication/base.rb +56 -0
  74. data/lib/vagrant/communication/ssh.rb +200 -0
  75. data/lib/vagrant/communication.rb +7 -0
  76. data/lib/vagrant/config/base.rb +18 -26
  77. data/lib/vagrant/config/container.rb +37 -0
  78. data/lib/vagrant/config/error_recorder.rb +1 -1
  79. data/lib/vagrant/config/loader.rb +125 -0
  80. data/lib/vagrant/config/nfs.rb +1 -3
  81. data/lib/vagrant/config/package.rb +1 -3
  82. data/lib/vagrant/config/ssh.rb +31 -16
  83. data/lib/vagrant/config/top.rb +36 -25
  84. data/lib/vagrant/config/vagrant.rb +2 -5
  85. data/lib/vagrant/config/vm/provisioner.rb +16 -20
  86. data/lib/vagrant/config/vm/sub_vm.rb +1 -1
  87. data/lib/vagrant/config/vm.rb +115 -56
  88. data/lib/vagrant/config.rb +29 -103
  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/virtualbox.rb +121 -0
  94. data/lib/vagrant/driver/virtualbox_4_0.rb +411 -0
  95. data/lib/vagrant/driver/virtualbox_4_1.rb +411 -0
  96. data/lib/vagrant/driver/virtualbox_base.rb +284 -0
  97. data/lib/vagrant/driver.rb +7 -0
  98. data/lib/vagrant/environment.rb +221 -240
  99. data/lib/vagrant/errors.rb +74 -25
  100. data/lib/vagrant/guest/arch.rb +48 -0
  101. data/lib/vagrant/{systems → guest}/base.rb +30 -18
  102. data/lib/vagrant/guest/debian.rb +61 -0
  103. data/lib/vagrant/{systems → guest}/freebsd.rb +11 -18
  104. data/lib/vagrant/guest/gentoo.rb +32 -0
  105. data/lib/vagrant/{systems → guest}/linux/config.rb +2 -4
  106. data/lib/vagrant/guest/linux/error.rb +9 -0
  107. data/lib/vagrant/guest/linux.rb +78 -0
  108. data/lib/vagrant/guest/redhat.rb +66 -0
  109. data/lib/vagrant/guest/solaris.rb +114 -0
  110. data/lib/vagrant/{systems → guest}/suse.rb +2 -2
  111. data/lib/vagrant/guest/ubuntu.rb +23 -0
  112. data/lib/vagrant/guest.rb +16 -0
  113. data/lib/vagrant/hosts/arch.rb +7 -3
  114. data/lib/vagrant/hosts/base.rb +36 -46
  115. data/lib/vagrant/hosts/bsd.rb +53 -16
  116. data/lib/vagrant/hosts/fedora.rb +14 -0
  117. data/lib/vagrant/hosts/freebsd.rb +6 -36
  118. data/lib/vagrant/hosts/linux.rb +45 -20
  119. data/lib/vagrant/hosts/windows.rb +16 -0
  120. data/lib/vagrant/hosts.rb +23 -6
  121. data/lib/vagrant/provisioners/base.rb +11 -34
  122. data/lib/vagrant/provisioners/chef.rb +30 -26
  123. data/lib/vagrant/provisioners/chef_client.rb +37 -23
  124. data/lib/vagrant/provisioners/chef_solo.rb +61 -16
  125. data/lib/vagrant/provisioners/puppet.rb +70 -38
  126. data/lib/vagrant/provisioners/puppet_server.rb +12 -13
  127. data/lib/vagrant/provisioners/shell.rb +24 -24
  128. data/lib/vagrant/provisioners.rb +10 -7
  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/lib/vagrant.rb +132 -5
  140. data/tasks/acceptance.rake +3 -3
  141. data/tasks/test.rake +7 -2
  142. data/templates/commands/init/Vagrantfile.erb +11 -4
  143. data/templates/{ssh_config.erb → commands/ssh_config/config.erb} +0 -0
  144. data/templates/guests/arch/network_dhcp.erb +7 -0
  145. data/templates/guests/arch/network_static.erb +7 -0
  146. data/templates/guests/debian/network_dhcp.erb +6 -0
  147. data/templates/guests/debian/network_static.erb +7 -0
  148. data/templates/guests/gentoo/network_dhcp.erb +4 -0
  149. data/templates/guests/gentoo/network_static.erb +4 -0
  150. data/templates/guests/redhat/network_dhcp.erb +6 -0
  151. data/templates/guests/redhat/network_static.erb +7 -0
  152. data/templates/locales/en.yml +241 -122
  153. data/templates/{chef_server_client.erb → provisioners/chef_client/client.erb} +0 -0
  154. data/templates/{chef_solo_solo.erb → provisioners/chef_solo/solo.erb} +0 -0
  155. data/test/acceptance/base.rb +10 -10
  156. data/test/acceptance/box_test.rb +28 -6
  157. data/test/acceptance/destroy_test.rb +1 -1
  158. data/test/acceptance/halt_test.rb +4 -4
  159. data/test/acceptance/init_test.rb +3 -3
  160. data/test/acceptance/networking/host_only_test.rb +37 -0
  161. data/test/acceptance/networking/port_forward_test.rb +125 -0
  162. data/test/acceptance/package_test.rb +46 -0
  163. data/test/acceptance/provisioning/basic_test.rb +61 -0
  164. data/test/acceptance/provisioning/chef_solo_test.rb +37 -0
  165. data/test/acceptance/provisioning/shell_test.rb +53 -0
  166. data/test/acceptance/resume_test.rb +1 -1
  167. data/test/acceptance/skeletons/chef_solo_basic/README.md +3 -0
  168. data/test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb +5 -0
  169. data/test/acceptance/skeletons/chef_solo_json/README.md +3 -0
  170. data/test/acceptance/skeletons/chef_solo_json/cookbooks/basic/recipes/default.rb +6 -0
  171. data/test/acceptance/skeletons/provisioner_multi/README.md +3 -0
  172. data/test/acceptance/skeletons/provisioner_multi/cookbooks/basic/recipes/default.rb +5 -0
  173. data/test/acceptance/ssh_test.rb +7 -2
  174. data/test/acceptance/support/config.rb +1 -1
  175. data/test/acceptance/support/isolated_environment.rb +41 -150
  176. data/test/acceptance/support/matchers/match_output.rb +1 -1
  177. data/test/acceptance/support/matchers/succeed.rb +14 -0
  178. data/test/acceptance/support/network_tests.rb +29 -0
  179. data/test/acceptance/support/output.rb +9 -1
  180. data/test/acceptance/support/shared/base_context.rb +16 -9
  181. data/test/acceptance/support/shared/command_examples.rb +4 -4
  182. data/test/acceptance/suspend_test.rb +1 -1
  183. data/test/acceptance/up_basic_test.rb +26 -7
  184. data/test/acceptance/up_with_box_url.rb +1 -1
  185. data/test/acceptance/vagrant_test.rb +1 -1
  186. data/test/acceptance/version_test.rb +0 -5
  187. data/test/support/isolated_environment.rb +46 -0
  188. data/test/{acceptance/support → support}/tempdir.rb +0 -0
  189. data/test/unit/base.rb +21 -0
  190. data/test/unit/support/isolated_environment.rb +39 -0
  191. data/test/unit/support/shared/base_context.rb +30 -0
  192. data/test/unit/vagrant/action/builder_test.rb +126 -177
  193. data/test/unit/vagrant/action/environment_test.rb +10 -21
  194. data/test/unit/vagrant/action/runner_test.rb +65 -0
  195. data/test/unit/vagrant/action/warden_test.rb +64 -97
  196. data/test/unit/vagrant/box_collection_test.rb +44 -33
  197. data/test/unit/vagrant/box_test.rb +25 -65
  198. data/test/unit/vagrant/command/base_test.rb +141 -14
  199. data/test/unit/vagrant/config/base_test.rb +16 -43
  200. data/test/unit/vagrant/config/loader_test.rb +79 -0
  201. data/test/unit/vagrant/config/top_test.rb +69 -0
  202. data/test/unit/vagrant/config/vm_test.rb +62 -47
  203. data/test/unit/vagrant/config_test.rb +16 -151
  204. data/test/unit/vagrant/data_store_test.rb +43 -61
  205. data/test/unit/vagrant/downloaders/base_test.rb +12 -22
  206. data/test/unit/vagrant/downloaders/file_test.rb +58 -31
  207. data/test/unit/vagrant/downloaders/http_test.rb +12 -86
  208. data/test/unit/vagrant/environment_test.rb +107 -536
  209. data/test/unit/vagrant/hosts_test.rb +36 -0
  210. data/test/unit/vagrant/registry_test.rb +56 -0
  211. data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
  212. data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +23 -24
  213. data/test/unit/vagrant/util/network_ip_test.rb +17 -0
  214. data/test/unit/vagrant/util/retryable_test.rb +90 -34
  215. data/test/unit/vagrant_test.rb +27 -0
  216. data/test/{unit → unit_legacy}/locales/en.yml +0 -0
  217. data/test/{unit → unit_legacy}/test_helper.rb +0 -0
  218. data/test/{unit → unit_legacy}/vagrant/action/box/destroy_test.rb +0 -0
  219. data/test/{unit → unit_legacy}/vagrant/action/box/download_test.rb +0 -0
  220. data/test/{unit → unit_legacy}/vagrant/action/box/package_test.rb +0 -0
  221. data/test/{unit → unit_legacy}/vagrant/action/box/unpackage_test.rb +0 -0
  222. data/test/{unit → unit_legacy}/vagrant/action/box/verify_test.rb +0 -0
  223. data/test/{unit → unit_legacy}/vagrant/action/env/set_test.rb +0 -0
  224. data/test/{unit → unit_legacy}/vagrant/action/general/package_test.rb +0 -0
  225. data/test/{unit → unit_legacy}/vagrant/action/general/validate_test.rb +0 -0
  226. data/test/{unit → unit_legacy}/vagrant/action/vm/boot_test.rb +0 -0
  227. data/test/{unit → unit_legacy}/vagrant/action/vm/check_accessible_test.rb +0 -0
  228. data/test/{unit → unit_legacy}/vagrant/action/vm/check_box_test.rb +0 -0
  229. data/test/{unit → unit_legacy}/vagrant/action/vm/check_guest_additions_test.rb +0 -0
  230. data/test/{unit → unit_legacy}/vagrant/action/vm/clean_machine_folder_test.rb +0 -0
  231. data/test/{unit → unit_legacy}/vagrant/action/vm/clear_forwarded_ports_test.rb +0 -0
  232. data/test/{unit → unit_legacy}/vagrant/action/vm/clear_nfs_exports_test.rb +0 -0
  233. data/test/{unit → unit_legacy}/vagrant/action/vm/clear_shared_folders_test.rb +0 -0
  234. data/test/{unit → unit_legacy}/vagrant/action/vm/customize_test.rb +0 -0
  235. data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_test.rb +0 -0
  236. data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +0 -0
  237. data/test/{unit → unit_legacy}/vagrant/action/vm/discard_state_test.rb +0 -0
  238. data/test/{unit → unit_legacy}/vagrant/action/vm/export_test.rb +0 -0
  239. data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_helpers_test.rb +0 -0
  240. data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_test.rb +0 -0
  241. data/test/{unit → unit_legacy}/vagrant/action/vm/halt_test.rb +0 -0
  242. data/test/{unit → unit_legacy}/vagrant/action/vm/host_name_test.rb +0 -0
  243. data/test/{unit → unit_legacy}/vagrant/action/vm/import_test.rb +0 -0
  244. data/test/{unit → unit_legacy}/vagrant/action/vm/match_mac_address_test.rb +0 -0
  245. data/test/{unit → unit_legacy}/vagrant/action/vm/modify_test.rb +0 -0
  246. data/test/{unit → unit_legacy}/vagrant/action/vm/network_test.rb +0 -0
  247. data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_helpers_test.rb +0 -0
  248. data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_test.rb +0 -0
  249. data/test/{unit → unit_legacy}/vagrant/action/vm/package_test.rb +0 -0
  250. data/test/{unit → unit_legacy}/vagrant/action/vm/package_vagrantfile_test.rb +0 -0
  251. data/test/{unit → unit_legacy}/vagrant/action/vm/provision_test.rb +0 -0
  252. data/test/{unit → unit_legacy}/vagrant/action/vm/provisioner_cleanup_test.rb +0 -0
  253. data/test/{unit → unit_legacy}/vagrant/action/vm/resume_test.rb +0 -0
  254. data/test/{unit → unit_legacy}/vagrant/action/vm/share_folders_test.rb +0 -0
  255. data/test/{unit → unit_legacy}/vagrant/action/vm/suspend_test.rb +0 -0
  256. data/test/{unit → unit_legacy}/vagrant/action_test.rb +0 -0
  257. data/test/unit_legacy/vagrant/box_collection_test.rb +45 -0
  258. data/test/unit_legacy/vagrant/box_test.rb +74 -0
  259. data/test/{unit → unit_legacy}/vagrant/cli_test.rb +0 -0
  260. data/test/unit_legacy/vagrant/command/base_test.rb +23 -0
  261. data/test/{unit → unit_legacy}/vagrant/command/group_base_test.rb +0 -0
  262. data/test/{unit → unit_legacy}/vagrant/command/helpers_test.rb +0 -0
  263. data/test/{unit → unit_legacy}/vagrant/command/init_test.rb +0 -0
  264. data/test/{unit → unit_legacy}/vagrant/command/package_test.rb +0 -0
  265. data/test/unit_legacy/vagrant/config/base_test.rb +52 -0
  266. data/test/{unit → unit_legacy}/vagrant/config/error_recorder_test.rb +0 -0
  267. data/test/{unit → unit_legacy}/vagrant/config/ssh_test.rb +0 -0
  268. data/test/{unit → unit_legacy}/vagrant/config/vagrant_test.rb +0 -0
  269. data/test/{unit → unit_legacy}/vagrant/config/vm/provisioner_test.rb +0 -0
  270. data/test/unit_legacy/vagrant/config/vm_test.rb +47 -0
  271. data/test/unit_legacy/vagrant/config_test.rb +148 -0
  272. data/test/unit_legacy/vagrant/downloaders/http_test.rb +93 -0
  273. data/test/unit_legacy/vagrant/environment_test.rb +539 -0
  274. data/test/{unit → unit_legacy}/vagrant/errors_test.rb +0 -0
  275. data/test/{unit → unit_legacy}/vagrant/hosts/base_test.rb +0 -0
  276. data/test/{unit → unit_legacy}/vagrant/hosts/bsd_test.rb +0 -0
  277. data/test/{unit → unit_legacy}/vagrant/hosts/linux_test.rb +0 -0
  278. data/test/{unit → unit_legacy}/vagrant/plugin_test.rb +0 -0
  279. data/test/{unit → unit_legacy}/vagrant/provisioners/base_test.rb +0 -0
  280. data/test/{unit → unit_legacy}/vagrant/provisioners/chef_client_test.rb +0 -0
  281. data/test/{unit → unit_legacy}/vagrant/provisioners/chef_solo_test.rb +0 -0
  282. data/test/{unit → unit_legacy}/vagrant/provisioners/chef_test.rb +0 -0
  283. data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_server_test.rb +0 -0
  284. data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_test.rb +0 -0
  285. data/test/{unit → unit_legacy}/vagrant/provisioners/shell_test.rb +0 -0
  286. data/test/{unit → unit_legacy}/vagrant/ssh/session_test.rb +0 -0
  287. data/test/{unit → unit_legacy}/vagrant/ssh_test.rb +0 -0
  288. data/test/{unit → unit_legacy}/vagrant/systems/base_test.rb +0 -0
  289. data/test/{unit → unit_legacy}/vagrant/systems/linux_test.rb +0 -0
  290. data/test/{unit → unit_legacy}/vagrant/util/busy_test.rb +0 -0
  291. data/test/{unit → unit_legacy}/vagrant/util/counter_test.rb +0 -0
  292. data/test/{unit → unit_legacy}/vagrant/util/platform_test.rb +0 -0
  293. data/test/{unit → unit_legacy}/vagrant/util/stacked_proc_runner_test.rb +0 -0
  294. data/test/{unit → unit_legacy}/vagrant/util/template_renderer_test.rb +0 -0
  295. data/test/{unit → unit_legacy}/vagrant/vm_test.rb +0 -0
  296. data/vagrant.gemspec +7 -9
  297. metadata +183 -179
  298. data/keys/vagrant.ppk +0 -26
  299. data/lib/vagrant/action/box.rb +0 -11
  300. data/lib/vagrant/action/env.rb +0 -7
  301. data/lib/vagrant/action/general.rb +0 -8
  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/action/vm.rb +0 -34
  306. data/lib/vagrant/command/group_base.rb +0 -107
  307. data/lib/vagrant/command/helpers.rb +0 -33
  308. data/lib/vagrant/command/named_base.rb +0 -14
  309. data/lib/vagrant/command/upgrade_to_060.rb +0 -45
  310. data/lib/vagrant/command/version.rb +0 -13
  311. data/lib/vagrant/ssh/session.rb +0 -136
  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/error.rb +0 -9
  316. data/lib/vagrant/systems/linux.rb +0 -82
  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/lib/vagrant/systems.rb +0 -13
  321. data/templates/network_entry_arch.erb +0 -9
  322. data/templates/network_entry_debian.erb +0 -8
  323. data/templates/network_entry_gentoo.erb +0 -5
  324. data/templates/network_entry_redhat.erb +0 -9
  325. data/test/unit/vagrant/ui_test.rb +0 -29
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
- class Config
2
+ module Config
3
3
  # This class is the "top" configure class, which handles registering
4
4
  # other configuration classes as well as validation of all configured
5
5
  # classes. This is the object which is returned by {Environment#config}
@@ -7,34 +7,45 @@ module Vagrant
7
7
  #
8
8
  # If you're looking to create your own configuration class, see {Base}.
9
9
  class Top < Base
10
- @@configures = {} if !defined?(@@configures)
10
+ attr_reader :keys
11
11
 
12
- # The environment that this configuration is for.
13
- attr_reader :env
12
+ def initialize(registry=nil)
13
+ @keys = {}
14
+ @registry = registry || Vagrant.config_keys
15
+ end
14
16
 
15
- class << self
16
- # The list of registered configuration classes as well as the key
17
- # they're registered under.
18
- def configures_list
19
- @@configures ||= {}
20
- end
17
+ # We use method_missing as a way to get the configuration that is used
18
+ # for Vagrant and load the proper configuration classes for each.
19
+ def method_missing(name, *args)
20
+ return @keys[name] if @keys.has_key?(name)
21
21
 
22
- # Registers a configuration class with the given key. This method shouldn't
23
- # be called. Instead, inherit from {Base} and call {Base.configures}.
24
- def configures(key, klass)
25
- configures_list[key] = klass
26
- attr_reader key.to_sym
22
+ config_klass = @registry.get(name.to_sym)
23
+ if config_klass
24
+ # Instantiate the class and return the instance
25
+ @keys[name] = config_klass.new
26
+ return @keys[name]
27
+ else
28
+ # Super it up to probably raise a NoMethodError
29
+ super
27
30
  end
28
31
  end
29
32
 
30
- def initialize(env=nil)
31
- self.class.configures_list.each do |key, klass|
32
- config = klass.new
33
- config.top = self
34
- instance_variable_set("@#{key}".to_sym, config)
33
+ # Custom implementation to merge each key separately.
34
+ def merge(other)
35
+ result = self.class.new
36
+ @keys.each do |key, value|
37
+ result.keys[key] = value.merge(other.send(key))
38
+ end
39
+
40
+ other.keys.each do |key, value|
41
+ if !@keys.has_key?(key)
42
+ # This is a key that the other configuration class has
43
+ # that we don't, so just copy it in.
44
+ result.keys[key] = value.dup
45
+ end
35
46
  end
36
47
 
37
- @env = env
48
+ result
38
49
  end
39
50
 
40
51
  # Validates the configuration classes of this instance and raises an
@@ -42,13 +53,13 @@ module Vagrant
42
53
  # class, the method you want to implement is {Base#validate}. This is
43
54
  # the method that checks all the validation, not one which defines
44
55
  # validation rules.
45
- def validate!
56
+ def validate!(env)
46
57
  # Validate each of the configured classes and store the results into
47
58
  # a hash.
48
- errors = self.class.configures_list.inject({}) do |container, data|
49
- key, _ = data
59
+ errors = @keys.inject({}) do |container, data|
60
+ key, instance = data
50
61
  recorder = ErrorRecorder.new
51
- send(key.to_sym).validate(recorder)
62
+ instance.validate(env, recorder)
52
63
  container[key.to_sym] = recorder if !recorder.errors.empty?
53
64
  container
54
65
  end
@@ -1,13 +1,10 @@
1
1
  module Vagrant
2
- class Config
2
+ module Config
3
3
  class VagrantConfig < Base
4
- configures :vagrant
5
-
6
4
  attr_accessor :dotfile_name
7
5
  attr_accessor :host
8
- attr_accessor :ssh_session_cache
9
6
 
10
- def validate(errors)
7
+ def validate(env, errors)
11
8
  [:dotfile_name, :host].each do |field|
12
9
  errors.add(I18n.t("vagrant.config.common.error_empty", :field => field)) if !instance_variable_get("@#{field}".to_sym)
13
10
  end
@@ -1,42 +1,38 @@
1
+ require 'log4r'
2
+
1
3
  module Vagrant
2
- class Config
4
+ module Config
3
5
  class VMConfig < Base
4
6
  # Represents a single configured provisioner for a VM.
5
7
  class Provisioner
6
- attr_reader :top
7
8
  attr_reader :shortcut
8
9
  attr_reader :provisioner
9
10
  attr_reader :config
10
11
 
11
- def initialize(top, shortcut, options=nil, &block)
12
- @top = top
12
+ def initialize(shortcut, options=nil, &block)
13
+ @logger = Log4r::Logger.new("vagrant::config::vm::provisioner")
14
+ @logger.debug("Provisioner config: #{shortcut}")
13
15
  @shortcut = shortcut
14
16
  @provisioner = shortcut
15
- @provisioner = Provisioners::Base.registered[shortcut] if shortcut.is_a?(Symbol)
17
+ @provisioner = Vagrant.provisioners.get(shortcut) if shortcut.is_a?(Symbol)
16
18
  @config = nil
17
19
 
18
- configure(options, &block)
20
+ @logger.info("Provisioner class: #{provisioner}")
21
+ configure(options, &block) if @provisioner
19
22
  end
20
23
 
21
24
  # Configures the provisioner if it can (if it is valid).
22
25
  def configure(options=nil, &block)
23
- # We don't want ancestors to be searched. This is the default in 1.8,
24
- # but not in 1.9, hence this hackery.
25
- const_args = ["Config"]
26
- const_args << false if RUBY_VERSION >= "1.9"
27
-
28
- # We assume that every provisioner has a `Config` class beneath
29
- # it for configuring.
30
- return if !@provisioner || !@provisioner.const_defined?(*const_args)
31
-
32
- # Instantiate the config class and configure it
33
- @config = @provisioner.const_get(*const_args).new
34
- @config.top = top
26
+ config_class = @provisioner.config_class
27
+ return if !config_class
28
+
29
+ @logger.debug("Configuring provisioner with: #{config_class}")
30
+ @config = config_class.new
35
31
  @config.set_options(options) if options
36
32
  block.call(@config) if block
37
33
  end
38
34
 
39
- def validate(errors)
35
+ def validate(env, errors)
40
36
  if !provisioner
41
37
  # If we don't have a provisioner then the whole thing is invalid.
42
38
  errors.add(I18n.t("vagrant.config.vm.provisioner_not_found", :shortcut => shortcut))
@@ -48,7 +44,7 @@ module Vagrant
48
44
  end
49
45
 
50
46
  # Pass on validation to the provisioner config
51
- config.validate(errors) if config
47
+ config.validate(env, errors) if config
52
48
  end
53
49
  end
54
50
  end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
- class Config
2
+ module Config
3
3
  class VMConfig < Base
4
4
  # Represents a single sub-VM in a multi-VM environment.
5
5
  class SubVM
@@ -1,77 +1,120 @@
1
+ require 'pathname'
2
+
1
3
  require 'vagrant/config/vm/sub_vm'
2
4
  require 'vagrant/config/vm/provisioner'
3
5
 
4
6
  module Vagrant
5
- class Config
7
+ module Config
6
8
  class VMConfig < Base
7
- configures :vm
8
-
9
- include Util::StackedProcRunner
10
-
9
+ attr_accessor :name
11
10
  attr_accessor :auto_port_range
12
11
  attr_accessor :box
13
12
  attr_accessor :box_url
14
- attr_accessor :box_ovf
15
13
  attr_accessor :base_mac
16
14
  attr_accessor :boot_mode
17
15
  attr_accessor :host_name
18
16
  attr_reader :forwarded_ports
19
17
  attr_reader :shared_folders
20
- attr_reader :network_options
18
+ attr_reader :networks
21
19
  attr_reader :provisioners
22
- attr_accessor :system
20
+ attr_reader :customizations
21
+ attr_accessor :guest
23
22
 
24
23
  def initialize
25
- @forwarded_ports = {}
24
+ @forwarded_ports = []
26
25
  @shared_folders = {}
27
- @network_options = []
26
+ @networks = []
28
27
  @provisioners = []
28
+ @customizations = []
29
29
  end
30
30
 
31
- def forward_port(name, guestport, hostport, options=nil)
32
- options = {
31
+ # Custom merge method since some keys here are merged differently.
32
+ def merge(other)
33
+ result = super
34
+ result.instance_variable_set(:@forwarded_ports, @forwarded_ports + other.forwarded_ports)
35
+ result.instance_variable_set(:@shared_folders, @shared_folders.merge(other.shared_folders))
36
+ result.instance_variable_set(:@networks, @networks + other.networks)
37
+ result.instance_variable_set(:@provisioners, @provisioners + other.provisioners)
38
+ result.instance_variable_set(:@customizations, @customizations + other.customizations)
39
+ result
40
+ end
41
+
42
+ def forward_port(guestport, hostport, options=nil)
43
+ if !guestport.kind_of?(Integer)
44
+ raise Errors::DeprecationError, :message => <<-MESSAGE
45
+ `config.vm.forward_port` changed in 0.9.0 where the required name
46
+ argument is now removed. Vagrant will now automatically generate
47
+ a unique name for your forwarded port. For example, to forward
48
+ port 80 to port 8080 you now do the following:
49
+
50
+ config.vm.forward_port 80, 8080
51
+
52
+ Please change your configurations to match this new syntax.
53
+ MESSAGE
54
+ end
55
+
56
+ @forwarded_ports << {
57
+ :name => "#{guestport.to_s(32)}-#{hostport.to_s(32)}",
33
58
  :guestport => guestport,
34
59
  :hostport => hostport,
35
60
  :protocol => :tcp,
36
- :adapter => 0,
61
+ :adapter => 1,
37
62
  :auto => false
38
63
  }.merge(options || {})
39
-
40
- forwarded_ports[name] = options
41
64
  end
42
65
 
43
66
  def share_folder(name, guestpath, hostpath, opts=nil)
44
67
  @shared_folders[name] = {
45
- :guestpath => guestpath,
46
- :hostpath => hostpath,
68
+ :guestpath => guestpath.to_s,
69
+ :hostpath => hostpath.to_s,
70
+ :create => false,
47
71
  :owner => nil,
48
72
  :group => nil,
49
- :nfs => false
73
+ :nfs => false,
74
+ :extra => nil
50
75
  }.merge(opts || {})
51
76
  end
52
77
 
53
- def network(ip, options=nil)
54
- options = {
55
- :ip => ip,
56
- :netmask => "255.255.255.0",
57
- :adapter => 1,
58
- :mac => nil,
59
- :name => nil
60
- }.merge(options || {})
78
+ def network(type, *args)
79
+ if !type.kind_of?(Symbol)
80
+ raise Errors::DeprecationError, :message => <<-MESSAGE
81
+ `config.vm.network` changed in 0.9.0 where the first argument is
82
+ now the type of network and the remaining arguments are options for
83
+ that type. For example, host only networks are now configured like
84
+ so:
61
85
 
62
- @network_options[options[:adapter]] = options
86
+ config.vm.network :hostonly, "172.24.24.24"
87
+
88
+ Please change your configurations to match this new syntax.
89
+ MESSAGE
90
+ end
91
+
92
+ @networks << [type, args]
63
93
  end
64
94
 
65
95
  def provision(name, options=nil, &block)
66
- @provisioners << Provisioner.new(top, name, options, &block)
96
+ @provisioners << Provisioner.new(name, options, &block)
67
97
  end
68
98
 
69
- def customize(&block)
70
- push_proc(&block)
71
- end
99
+ # TODO: This argument should not be `nil` in the future.
100
+ # It is only defaulted to nil so that the deprecation error
101
+ # can be properly shown.
102
+ def customize(command=nil)
103
+ if block_given?
104
+ raise Errors::DeprecationError, :message => <<-MESSAGE
105
+ `config.vm.customize` now takes an array of arguments to send to
106
+ `VBoxManage` instead of having a block which gets a virtual machine
107
+ object. Example of the new usage:
108
+
109
+ config.vm.customize ["modifyvm", :id, "--memory", "1024"]
110
+
111
+ The above will run `VBoxManage modifyvm 1234 --memory 1024` where
112
+ "1234" is the ID of your current virtual machine. Anything you could
113
+ do before is certainly still possible with `VBoxManage` as well.
114
+ MESSAGE
115
+ end
72
116
 
73
- def has_multi_vms?
74
- !defined_vms.empty?
117
+ @customizations << command if command
75
118
  end
76
119
 
77
120
  def defined_vms
@@ -95,17 +138,19 @@ module Vagrant
95
138
  # Add the SubVM to the hash of defined VMs
96
139
  defined_vms[name] ||= SubVM.new
97
140
  defined_vms[name].options.merge!(options)
98
- defined_vms[name].push_proc(&block)
141
+ defined_vms[name].push_proc(&block) if block
99
142
  end
100
143
 
101
- def validate(errors)
144
+ def validate(env, errors)
102
145
  errors.add(I18n.t("vagrant.config.vm.box_missing")) if !box
103
- errors.add(I18n.t("vagrant.config.vm.box_not_found", :name => box)) if box && !box_url && !env.box
104
- errors.add(I18n.t("vagrant.config.vm.boot_mode_invalid")) if ![:vrdp, :gui].include?(boot_mode.to_sym)
105
- errors.add(I18n.t("vagrant.config.vm.base_mac_invalid")) if env.box && !base_mac
146
+ errors.add(I18n.t("vagrant.config.vm.box_not_found", :name => box)) if box && !box_url && !env.boxes.find(box)
147
+ errors.add(I18n.t("vagrant.config.vm.boot_mode_invalid")) if ![:headless, :gui].include?(boot_mode.to_sym)
148
+ errors.add(I18n.t("vagrant.config.vm.base_mac_invalid")) if env.boxes.find(box) && !base_mac
106
149
 
107
150
  shared_folders.each do |name, options|
108
- if !File.directory?(File.expand_path(options[:hostpath].to_s, env.root_path))
151
+ hostpath = Pathname.new(options[:hostpath]).expand_path(env.root_path)
152
+
153
+ if !hostpath.directory? && !options[:create]
109
154
  errors.add(I18n.t("vagrant.config.vm.shared_folder_hostpath_missing",
110
155
  :name => name,
111
156
  :path => options[:hostpath]))
@@ -119,28 +164,42 @@ module Vagrant
119
164
  end
120
165
 
121
166
  # Validate some basic networking
122
- network_options.each do |options|
123
- next if !options
124
-
125
- ip = options[:ip].split(".")
126
-
127
- if ip.length != 4
128
- errors.add(I18n.t("vagrant.config.vm.network_ip_invalid",
129
- :ip => options[:ip]))
130
- elsif ip.last == "1"
131
- errors.add(I18n.t("vagrant.config.vm.network_ip_ends_one",
132
- :ip => options[:ip]))
167
+ #
168
+ # TODO: One day we need to abstract this out, since in the future
169
+ # providers other than VirtualBox will not be able to satisfy
170
+ # all types of networks.
171
+ networks.each do |type, args|
172
+ if type == :hostonly && args[0] == :dhcp
173
+ # Valid. There is no real way this can be invalid at the moment.
174
+ elsif type == :hostonly
175
+ # Validate the host-only network
176
+ ip = args[0]
177
+ options = args[1] || {}
178
+
179
+ if !ip
180
+ errors.add(I18n.t("vagrant.config.vm.network_ip_required"))
181
+ else
182
+ ip_parts = ip.split(".")
183
+
184
+ if ip_parts.length != 4
185
+ errors.add(I18n.t("vagrant.config.vm.network_ip_invalid",
186
+ :ip => ip))
187
+ elsif ip_parts.last == "1"
188
+ errors.add(I18n.t("vagrant.config.vm.network_ip_ends_one",
189
+ :ip => ip))
190
+ end
191
+ end
192
+ elsif type == :bridged
193
+ else
194
+ # Invalid network type
195
+ errors.add(I18n.t("vagrant.config.vm.network_invalid",
196
+ :type => type.to_s))
133
197
  end
134
198
  end
135
199
 
136
200
  # Each provisioner can validate itself
137
201
  provisioners.each do |prov|
138
- # TODO: Remove at some point
139
- if prov.shortcut == :chef_server
140
- errors.add(I18n.t("vagrant.config.vm.provisioner_chef_server_changed"))
141
- else
142
- prov.validate(errors)
143
- end
202
+ prov.validate(env, errors)
144
203
  end
145
204
  end
146
205
  end
@@ -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