vagrant 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 (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,15 +1,18 @@
1
1
  module Vagrant
2
- class Action
2
+ module Action
3
3
  module Env
4
4
  # A middleware which just sets up the environment with some
5
5
  # options which are passed to it.
6
6
  class Set
7
- def initialize(app,env,options=nil)
8
- @app = app
9
- env.merge!(options || {})
7
+ def initialize(app, env, options=nil)
8
+ @app = app
9
+ @options = options || {}
10
10
  end
11
11
 
12
12
  def call(env)
13
+ # Merge the options that were given to us
14
+ env.merge!(@options)
15
+
13
16
  @app.call(env)
14
17
  end
15
18
  end
@@ -1,50 +1,12 @@
1
+ require 'vagrant/util/hash_with_indifferent_access'
2
+
1
3
  module Vagrant
2
- class Action
4
+ module Action
3
5
  # Represents an action environment which is what is passed
4
6
  # to the `call` method of each action. This environment contains
5
7
  # some helper methods for accessing the environment as well
6
8
  # as being a hash, to store any additional options.
7
9
  class Environment < Util::HashWithIndifferentAccess
8
- # The {Vagrant::Environment} object represented by this
9
- # action environment.
10
- attr_reader :env
11
-
12
- def initialize(env)
13
- super() do |h,k|
14
- # By default, try to find the key as a method on the
15
- # environment. Gross eval use here.
16
- begin
17
- value = eval("h.env.#{k}")
18
- h[k] = value
19
- rescue Exception
20
- nil
21
- end
22
- end
23
-
24
- @env = env
25
- @interrupted = false
26
- end
27
-
28
- # Returns a UI object from the environment
29
- def ui
30
- env.ui
31
- end
32
-
33
- # Marks an environment as interrupted (by an outside signal or
34
- # anything). This will trigger any middleware sequences using this
35
- # environment to halt. This is automatically set by {Action} when
36
- # a SIGINT is captured.
37
- def interrupt!
38
- @interrupted = true
39
- end
40
-
41
- # Returns a boolean denoting if environment has been interrupted
42
- # with a SIGINT.
43
- #
44
- # @return [Bool]
45
- def interrupted?
46
- !!@interrupted
47
- end
48
10
  end
49
11
  end
50
12
  end
@@ -2,7 +2,7 @@ require 'fileutils'
2
2
  require 'archive/tar/minitar'
3
3
 
4
4
  module Vagrant
5
- class Action
5
+ module Action
6
6
  module General
7
7
  # A general packaging (tar) middleware. Given the following options,
8
8
  # it will do the right thing:
@@ -19,19 +19,18 @@ module Vagrant
19
19
 
20
20
  def initialize(app, env)
21
21
  @app = app
22
- @env = env
23
- @env["package.output"] ||= env["config"].package.name
24
- @env["package.include"] ||= []
25
- @env["package.vagrantfile"] ||= nil
22
+
23
+ env["package.files"] ||= {}
24
+ env["package.output"] ||= env["global_config"].package.name
26
25
  end
27
26
 
28
27
  def call(env)
29
28
  @env = env
30
29
 
31
30
  raise Errors::PackageOutputExists if File.exist?(tar_path)
32
- raise Errors::PackageRequiresDirectory if !@env["package.directory"] || !File.directory?(@env["package.directory"])
31
+ raise Errors::PackageRequiresDirectory if !env["package.directory"] ||
32
+ !File.directory?(env["package.directory"])
33
33
 
34
- verify_files_to_copy
35
34
  compress
36
35
 
37
36
  @app.call(env)
@@ -46,31 +45,17 @@ module Vagrant
46
45
  end
47
46
  end
48
47
 
49
- def files_to_copy
50
- package_dir = Pathname.new(@env["package.directory"]).join("include")
51
-
52
- files = @env["package.include"].inject({}) do |acc, file|
53
- source = Pathname.new(file)
54
- acc[file] = source.relative? ? package_dir.join(source) : package_dir.join(source.basename)
55
- acc
56
- end
57
-
58
- files[@env["package.vagrantfile"]] = package_dir.join("_Vagrantfile") if @env["package.vagrantfile"]
59
- files
60
- end
61
-
62
- def verify_files_to_copy
63
- files_to_copy.each do |file, _|
64
- raise Errors::PackageIncludeMissing, :file => file if !File.exist?(file)
65
- end
66
- end
67
-
68
48
  # This method copies the include files (passed in via command line)
69
49
  # to the temporary directory so they are included in a sub-folder within
70
50
  # the actual box
71
51
  def copy_include_files
72
- files_to_copy.each do |from, to|
73
- @env.ui.info I18n.t("vagrant.actions.general.package.packaging", :file => from)
52
+ include_directory = Pathname.new(@env["package.directory"]).join("include")
53
+
54
+ @env["package.files"].each do |from, dest|
55
+ # We place the file in the include directory
56
+ to = include_directory.join(dest)
57
+
58
+ @env[:ui].info I18n.t("vagrant.actions.general.package.packaging", :file => from)
74
59
  FileUtils.mkdir_p(to.parent)
75
60
 
76
61
  # Copy direcotry contents recursively.
@@ -84,7 +69,7 @@ module Vagrant
84
69
 
85
70
  # Compress the exported file into a package
86
71
  def compress
87
- @env.ui.info I18n.t("vagrant.actions.general.package.compressing", :tar_path => tar_path)
72
+ @env[:ui].info I18n.t("vagrant.actions.general.package.compressing", :tar_path => tar_path)
88
73
  File.open(tar_path, Platform.tar_file_options) do |tar|
89
74
  Archive::Tar::Minitar::Output.open(tar) do |output|
90
75
  begin
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
- class Action
2
+ module Action
3
3
  module General
4
4
  # Simply validates the configuration of the current Vagrant
5
5
  # environment.
@@ -10,7 +10,7 @@ module Vagrant
10
10
  end
11
11
 
12
12
  def call(env)
13
- @env["config"].validate! if !@env.has_key?("validate") || @env["validate"]
13
+ @env[:vm].config.validate!(@env[:vm].env) if !@env.has_key?("validate") || @env["validate"]
14
14
  @app.call(@env)
15
15
  end
16
16
  end
@@ -0,0 +1,53 @@
1
+ require 'log4r'
2
+
3
+ require 'vagrant/util/busy'
4
+
5
+ # TODO:
6
+ # * env.lock
7
+
8
+ module Vagrant
9
+ module Action
10
+ class Runner
11
+ @@reported_interrupt = false
12
+
13
+ def initialize(registry, globals=nil, &block)
14
+ @registry = registry
15
+ @globals = globals || {}
16
+ @lazy_globals = block
17
+ @logger = Log4r::Logger.new("vagrant::action::runner")
18
+ end
19
+
20
+ def run(callable_id, options=nil)
21
+ callable = callable_id
22
+ callable = Builder.new.use(callable_id) if callable_id.kind_of?(Class)
23
+ callable = @registry.get(callable_id) if callable_id.kind_of?(Symbol)
24
+ raise ArgumentError, "Argument to run must be a callable object or registered action." if !callable || !callable.respond_to?(:call)
25
+
26
+ # Create the initial environment with the options given
27
+ environment = Environment.new
28
+ environment.merge!(@globals)
29
+ environment.merge!(@lazy_globals.call) if @lazy_globals
30
+ environment.merge!(options || {})
31
+
32
+ # Run the action chain in a busy block, marking the environment as
33
+ # interrupted if a SIGINT occurs, and exiting cleanly once the
34
+ # chain has been run.
35
+ ui = environment[:ui] if environment.has_key?(:ui)
36
+ int_callback = lambda do
37
+ if environment[:interrupted]
38
+ ui.error I18n.t("vagrant.actions.runner.exit_immediately") if ui
39
+ abort
40
+ end
41
+
42
+ ui.warn I18n.t("vagrant.actions.runner.waiting_cleanup") if ui && !@@reported_interrupt
43
+ environment[:interrupted] = true
44
+ @@reported_interrupt = true
45
+ end
46
+
47
+ # We place a process lock around every action that is called
48
+ @logger.info("Running action: #{callable_id}")
49
+ Util::Busy.busy(int_callback) { callable.call(environment) }
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
- class Action
2
+ module Action
3
3
  module VM
4
4
  class Boot
5
5
  def initialize(app, env)
@@ -18,27 +18,27 @@ module Vagrant
18
18
  end
19
19
 
20
20
  def boot
21
- @env.ui.info I18n.t("vagrant.actions.vm.boot.booting")
22
- @env["vm"].vm.start(@env.env.config.vm.boot_mode)
21
+ @env[:ui].info I18n.t("vagrant.actions.vm.boot.booting")
22
+ @env[:vm].driver.start(@env[:vm].config.vm.boot_mode)
23
23
  end
24
24
 
25
25
  def wait_for_boot
26
- @env.ui.info I18n.t("vagrant.actions.vm.boot.waiting")
26
+ @env[:ui].info I18n.t("vagrant.actions.vm.boot.waiting")
27
27
 
28
- @env["config"].ssh.max_tries.to_i.times do |i|
29
- if @env["vm"].ssh.up?
30
- @env.ui.info I18n.t("vagrant.actions.vm.boot.ready")
28
+ @env[:vm].config.ssh.max_tries.to_i.times do |i|
29
+ if @env[:vm].channel.ready?
30
+ @env[:ui].info I18n.t("vagrant.actions.vm.boot.ready")
31
31
  return true
32
32
  end
33
33
 
34
34
  # Return true so that the vm_failed_to_boot error doesn't
35
35
  # get shown
36
- return true if @env.interrupted?
36
+ return true if @env[:interrupted]
37
37
 
38
38
  sleep 2 if !@env["vagrant.test"]
39
39
  end
40
40
 
41
- @env.ui.error I18n.t("vagrant.actions.vm.boot.failed")
41
+ @env[:ui].error I18n.t("vagrant.actions.vm.boot.failed")
42
42
  false
43
43
  end
44
44
  end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
- class Action
2
+ module Action
3
3
  module VM
4
4
  class CheckAccessible
5
5
  def initialize(app, env)
@@ -7,7 +7,7 @@ module Vagrant
7
7
  end
8
8
 
9
9
  def call(env)
10
- if env["vm"] && env["vm"].created? && !env["vm"].vm.accessible?
10
+ if env[:vm].state == :inaccessible
11
11
  # The VM we are attempting to manipulate is inaccessible. This
12
12
  # is a very bad situation and can only be fixed by the user. It
13
13
  # also prohibits us from actually doing anything with the virtual
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
- class Action
2
+ module Action
3
3
  module VM
4
4
  class CheckBox
5
5
  def initialize(app, env)
@@ -7,24 +7,22 @@ module Vagrant
7
7
  end
8
8
 
9
9
  def call(env)
10
- box_name = env["config"].vm.box
10
+ box_name = env[:vm].config.vm.box
11
11
  raise Errors::BoxNotSpecified if !box_name
12
12
 
13
- if !env.env.boxes.find(box_name)
14
- box_url = env["config"].vm.box_url
13
+ if !env[:box_collection].find(box_name)
14
+ box_url = env[:vm].config.vm.box_url
15
15
  raise Errors::BoxSpecifiedDoesntExist, :name => box_name if !box_url
16
16
 
17
17
  # Add the box then reload the box collection so that it becomes
18
18
  # aware of it.
19
- env.ui.info I18n.t("vagrant.actions.vm.check_box.not_found", :name => box_name)
20
- Vagrant::Box.add(env.env, box_name, box_url)
21
- env["boxes"].reload!
19
+ env[:ui].info I18n.t("vagrant.actions.vm.check_box.not_found", :name => box_name)
20
+ env[:box_collection].add(box_name, box_url)
21
+ env[:box_collection].reload!
22
22
 
23
- # Reload the configuration for all our VMs, since this box
24
- # may be used for other VMs.
25
- env.env.vms.each do |name, vm|
26
- vm.env.reload_config!
27
- end
23
+ # Reload the environment and set the VM to be the new loaded VM.
24
+ env[:vm].env.reload!
25
+ env[:vm] = env[:vm].env.vms[env[:vm].name]
28
26
  end
29
27
 
30
28
  @app.call(env)
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
- class Action
2
+ module Action
3
3
  module VM
4
4
  # Middleware which verifies that the VM has the proper guest additions
5
5
  # installed and prints a warning if they're not detected or if the
@@ -12,20 +12,20 @@ module Vagrant
12
12
  def call(env)
13
13
  # Use the raw interface for now, while the virtualbox gem
14
14
  # doesn't support guest properties (due to cross platform issues)
15
- version = env["vm"].vm.interface.get_guest_property_value("/VirtualBox/GuestAdd/Version")
16
- if version.empty?
17
- env.ui.warn I18n.t("vagrant.actions.vm.check_guest_additions.not_detected")
15
+ version = env[:vm].driver.read_guest_additions_version
16
+ if !version
17
+ env[:ui].warn I18n.t("vagrant.actions.vm.check_guest_additions.not_detected")
18
18
  else
19
19
  # Strip the -OSE/_OSE off from the guest additions and the virtual box
20
20
  # version since all the matters are that the version _numbers_ match up.
21
- guest_version, vb_version = [version, VirtualBox.version].map do |v|
21
+ guest_version, vb_version = [version, env[:vm].driver.version].map do |v|
22
22
  v.gsub(/[-_]ose/i, '')
23
23
  end
24
24
 
25
25
  if guest_version != vb_version
26
- env.ui.warn(I18n.t("vagrant.actions.vm.check_guest_additions.version_mismatch",
27
- :guest_version => version,
28
- :virtualbox_version => VirtualBox.version))
26
+ env[:ui].warn(I18n.t("vagrant.actions.vm.check_guest_additions.version_mismatch",
27
+ :guest_version => version,
28
+ :virtualbox_version => vb_version))
29
29
  end
30
30
  end
31
31
 
@@ -0,0 +1,85 @@
1
+ module Vagrant
2
+ module Action
3
+ module VM
4
+ # Action that checks to make sure there are no forwarded port collisions,
5
+ # and raises an exception if there is.
6
+ class CheckPortCollisions
7
+ def initialize(app, env)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ # For the handlers...
13
+ @env = env
14
+
15
+ # Figure out how we handle port collisions. By default we error.
16
+ handler = env[:port_collision_handler] || :error
17
+
18
+ # Read our forwarded ports, if we have any, to override what
19
+ # we have configured.
20
+ current = {}
21
+ env[:vm].driver.read_forwarded_ports.each do |nic, name, hostport, guestport|
22
+ current[name] = hostport.to_i
23
+ end
24
+
25
+ existing = env[:vm].driver.read_used_ports
26
+ env[:vm].config.vm.forwarded_ports.each do |options|
27
+ # Use the proper port, whether that be the configured port or the
28
+ # port that is currently on use of the VM.
29
+ hostport = options[:hostport].to_i
30
+ hostport = current[options[:name]] if current.has_key?(options[:name])
31
+
32
+ if existing.include?(hostport)
33
+ # We have a collision! Handle it
34
+ send("handle_#{handler}".to_sym, options, existing)
35
+ end
36
+ end
37
+
38
+ @app.call(env)
39
+ end
40
+
41
+ # Handles a port collision by raising an exception.
42
+ def handle_error(options, existing_ports)
43
+ raise Errors::ForwardPortCollisionResume
44
+ end
45
+
46
+ # Handles a port collision by attempting to fix it.
47
+ def handle_correct(options, existing_ports)
48
+ # We need to keep this for messaging purposes
49
+ original_hostport = options[:hostport]
50
+
51
+ if !options[:auto]
52
+ # Auto fixing is disabled for this port forward, so we
53
+ # must throw an error so the user can fix it.
54
+ raise Errors::ForwardPortCollision, :host_port => options[:hostport].to_s,
55
+ :guest_port => options[:guestport].to_s
56
+ end
57
+
58
+ # Get the auto port range and get rid of the used ports and
59
+ # ports which are being used in other forwards so we're just
60
+ # left with available ports.
61
+ range = @env[:vm].config.vm.auto_port_range.to_a
62
+ range -= @env[:vm].config.vm.forwarded_ports.collect { |opts| opts[:hostport].to_i }
63
+ range -= existing_ports
64
+
65
+ if range.empty?
66
+ raise Errors::ForwardPortAutolistEmpty, :vm_name => @env[:vm].name,
67
+ :host_port => options[:hostport].to_s,
68
+ :guest_port => options[:guestport].to_s
69
+ end
70
+
71
+ # Set the port up to be the first one and add that port to
72
+ # the used list.
73
+ options[:hostport] = range.shift
74
+ existing_ports << options[:hostport]
75
+
76
+ # Notify the user
77
+ @env[:ui].info(I18n.t("vagrant.actions.vm.forward_ports.fixed_collision",
78
+ :host_port => original_hostport.to_s,
79
+ :guest_port => options[:guestport].to_s,
80
+ :new_port => options[:hostport]))
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end