vagrant 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. data/.gitignore +1 -0
  2. data/.yardopts +1 -0
  3. data/CHANGELOG.md +56 -0
  4. data/Gemfile +14 -3
  5. data/Gemfile.lock +38 -11
  6. data/README.md +1 -1
  7. data/bin/vagrant +20 -5
  8. data/config/default.rb +6 -8
  9. data/lib/vagrant.rb +40 -13
  10. data/lib/vagrant/action.rb +56 -16
  11. data/lib/vagrant/action/box/destroy.rb +3 -1
  12. data/lib/vagrant/action/box/download.rb +8 -13
  13. data/lib/vagrant/action/box/unpackage.rb +8 -11
  14. data/lib/vagrant/action/box/verify.rb +3 -3
  15. data/lib/vagrant/action/builder.rb +3 -30
  16. data/lib/vagrant/action/builtin.rb +6 -1
  17. data/lib/vagrant/action/environment.rb +14 -62
  18. data/lib/vagrant/action/general/package.rb +29 -22
  19. data/lib/vagrant/action/vm/boot.rb +5 -12
  20. data/lib/vagrant/action/vm/check_box.rb +4 -4
  21. data/lib/vagrant/action/vm/check_guest_additions.rb +4 -6
  22. data/lib/vagrant/action/vm/clear_forwarded_ports.rb +2 -2
  23. data/lib/vagrant/action/vm/clear_nfs_exports.rb +1 -1
  24. data/lib/vagrant/action/vm/clear_shared_folders.rb +1 -1
  25. data/lib/vagrant/action/vm/customize.rb +1 -1
  26. data/lib/vagrant/action/vm/destroy.rb +1 -2
  27. data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +1 -1
  28. data/lib/vagrant/action/vm/disable_networks.rb +11 -9
  29. data/lib/vagrant/action/vm/discard_state.rb +2 -2
  30. data/lib/vagrant/action/vm/export.rb +10 -11
  31. data/lib/vagrant/action/vm/forward_ports.rb +21 -9
  32. data/lib/vagrant/action/vm/halt.rb +3 -8
  33. data/lib/vagrant/action/vm/import.rb +16 -14
  34. data/lib/vagrant/action/vm/match_mac_address.rb +1 -1
  35. data/lib/vagrant/action/vm/network.rb +9 -16
  36. data/lib/vagrant/action/vm/nfs.rb +14 -18
  37. data/lib/vagrant/action/vm/provision.rb +5 -5
  38. data/lib/vagrant/action/vm/resume.rb +1 -1
  39. data/lib/vagrant/action/vm/share_folders.rb +6 -44
  40. data/lib/vagrant/action/vm/suspend.rb +1 -1
  41. data/lib/vagrant/action/warden.rb +74 -0
  42. data/lib/vagrant/box.rb +18 -82
  43. data/lib/vagrant/box_collection.rb +47 -0
  44. data/lib/vagrant/cli.rb +55 -0
  45. data/lib/vagrant/command/base.rb +106 -0
  46. data/lib/vagrant/command/box.rb +33 -0
  47. data/lib/vagrant/command/destroy.rb +17 -0
  48. data/lib/vagrant/command/group_base.rb +99 -0
  49. data/lib/vagrant/command/halt.rb +18 -0
  50. data/lib/vagrant/command/helpers.rb +33 -0
  51. data/lib/vagrant/command/init.rb +14 -0
  52. data/lib/vagrant/command/named_base.rb +14 -0
  53. data/lib/vagrant/command/package.rb +41 -0
  54. data/lib/vagrant/command/provision.rb +17 -0
  55. data/lib/vagrant/command/reload.rb +17 -0
  56. data/lib/vagrant/command/resume.rb +17 -0
  57. data/lib/vagrant/command/ssh.rb +41 -0
  58. data/lib/vagrant/command/ssh_config.rb +21 -0
  59. data/lib/vagrant/command/status.rb +23 -0
  60. data/lib/vagrant/command/suspend.rb +17 -0
  61. data/lib/vagrant/command/up.rb +20 -0
  62. data/lib/vagrant/command/upgrade_to_060.rb +45 -0
  63. data/lib/vagrant/command/version.rb +13 -0
  64. data/lib/vagrant/config.rb +107 -189
  65. data/lib/vagrant/config/base.rb +67 -0
  66. data/lib/vagrant/config/error_recorder.rb +19 -0
  67. data/lib/vagrant/config/nfs.rb +10 -0
  68. data/lib/vagrant/config/package.rb +9 -0
  69. data/lib/vagrant/config/ssh.rb +28 -0
  70. data/lib/vagrant/config/vagrant.rb +21 -0
  71. data/lib/vagrant/config/vm.rb +111 -0
  72. data/lib/vagrant/data_store.rb +68 -0
  73. data/lib/vagrant/downloaders/file.rb +3 -3
  74. data/lib/vagrant/downloaders/http.rb +5 -5
  75. data/lib/vagrant/environment.rb +246 -243
  76. data/lib/vagrant/errors.rb +306 -0
  77. data/lib/vagrant/hosts/base.rb +1 -1
  78. data/lib/vagrant/hosts/bsd.rb +3 -9
  79. data/lib/vagrant/hosts/linux.rb +3 -9
  80. data/lib/vagrant/plugin.rb +50 -0
  81. data/lib/vagrant/provisioners/base.rb +0 -6
  82. data/lib/vagrant/provisioners/chef.rb +63 -58
  83. data/lib/vagrant/provisioners/chef_server.rb +9 -11
  84. data/lib/vagrant/provisioners/chef_solo.rb +2 -2
  85. data/lib/vagrant/ssh.rb +34 -37
  86. data/lib/vagrant/systems/base.rb +0 -13
  87. data/lib/vagrant/systems/linux.rb +10 -33
  88. data/lib/vagrant/systems/solaris.rb +59 -0
  89. data/lib/vagrant/test_helpers.rb +109 -0
  90. data/lib/vagrant/ui.rb +65 -0
  91. data/lib/vagrant/util.rb +9 -19
  92. data/lib/vagrant/util/glob_loader.rb +19 -17
  93. data/lib/vagrant/util/hash_with_indifferent_access.rb +63 -0
  94. data/lib/vagrant/util/plain_logger.rb +2 -0
  95. data/lib/vagrant/util/platform.rb +2 -0
  96. data/lib/vagrant/util/resource_logger.rb +5 -70
  97. data/lib/vagrant/util/retryable.rb +25 -0
  98. data/lib/vagrant/util/template_renderer.rb +1 -1
  99. data/lib/vagrant/version.rb +1 -1
  100. data/lib/vagrant/vm.rb +27 -13
  101. data/templates/commands/init/Vagrantfile.erb +13 -0
  102. data/templates/config/validation_failed.erb +7 -0
  103. data/templates/locales/en.yml +402 -0
  104. data/templates/package_Vagrantfile.erb +1 -1
  105. data/test/locales/en.yml +8 -0
  106. data/test/test_helper.rb +19 -103
  107. data/test/vagrant/action/box/destroy_test.rb +7 -19
  108. data/test/vagrant/action/box/download_test.rb +9 -25
  109. data/test/vagrant/action/box/package_test.rb +2 -2
  110. data/test/vagrant/action/box/unpackage_test.rb +8 -34
  111. data/test/vagrant/action/box/verify_test.rb +10 -19
  112. data/test/vagrant/action/builder_test.rb +0 -15
  113. data/test/vagrant/action/env/set_test.rb +1 -1
  114. data/test/vagrant/action/environment_test.rb +8 -26
  115. data/test/vagrant/action/general/package_test.rb +53 -53
  116. data/test/vagrant/action/vm/boot_test.rb +5 -22
  117. data/test/vagrant/action/vm/check_box_test.rb +35 -25
  118. data/test/vagrant/action/vm/clean_machine_folder_test.rb +1 -1
  119. data/test/vagrant/action/vm/clear_forwarded_ports_test.rb +1 -1
  120. data/test/vagrant/action/vm/clear_nfs_exports_test.rb +1 -1
  121. data/test/vagrant/action/vm/clear_shared_folders_test.rb +1 -1
  122. data/test/vagrant/action/vm/customize_test.rb +2 -1
  123. data/test/vagrant/action/vm/destroy_test.rb +1 -2
  124. data/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +1 -1
  125. data/test/vagrant/action/vm/disable_networks_test.rb +10 -1
  126. data/test/vagrant/action/vm/discard_state_test.rb +10 -1
  127. data/test/vagrant/action/vm/export_test.rb +9 -37
  128. data/test/vagrant/action/vm/forward_ports_helpers_test.rb +2 -2
  129. data/test/vagrant/action/vm/forward_ports_test.rb +19 -16
  130. data/test/vagrant/action/vm/halt_test.rb +11 -1
  131. data/test/vagrant/action/vm/import_test.rb +37 -21
  132. data/test/vagrant/action/vm/match_mac_address_test.rb +1 -1
  133. data/test/vagrant/action/vm/network_test.rb +8 -7
  134. data/test/vagrant/action/vm/nfs_helpers_test.rb +6 -3
  135. data/test/vagrant/action/vm/nfs_test.rb +20 -45
  136. data/test/vagrant/action/vm/package_test.rb +1 -1
  137. data/test/vagrant/action/vm/package_vagrantfile_test.rb +1 -1
  138. data/test/vagrant/action/vm/provision_test.rb +10 -17
  139. data/test/vagrant/action/vm/resume_test.rb +1 -1
  140. data/test/vagrant/action/vm/share_folders_test.rb +25 -106
  141. data/test/vagrant/action/vm/suspend_test.rb +1 -1
  142. data/test/vagrant/action/warden_test.rb +105 -0
  143. data/test/vagrant/action_test.rb +5 -27
  144. data/test/vagrant/box_collection_test.rb +44 -0
  145. data/test/vagrant/box_test.rb +5 -105
  146. data/test/vagrant/cli_test.rb +35 -0
  147. data/test/vagrant/command/base_test.rb +23 -0
  148. data/test/vagrant/command/group_base_test.rb +15 -0
  149. data/test/vagrant/command/helpers_test.rb +88 -0
  150. data/test/vagrant/config/base_test.rb +52 -0
  151. data/test/vagrant/config/error_recorder_test.rb +18 -0
  152. data/test/vagrant/config/ssh_test.rb +12 -0
  153. data/test/vagrant/config/vagrant_test.rb +11 -0
  154. data/test/vagrant/config/vm_test.rb +70 -0
  155. data/test/vagrant/config_test.rb +113 -206
  156. data/test/vagrant/data_store_test.rb +68 -0
  157. data/test/vagrant/downloaders/base_test.rb +1 -1
  158. data/test/vagrant/downloaders/file_test.rb +4 -3
  159. data/test/vagrant/downloaders/http_test.rb +14 -4
  160. data/test/vagrant/environment_test.rb +290 -590
  161. data/test/vagrant/errors_test.rb +42 -0
  162. data/test/vagrant/hosts/base_test.rb +1 -1
  163. data/test/vagrant/hosts/bsd_test.rb +3 -6
  164. data/test/vagrant/hosts/linux_test.rb +3 -5
  165. data/test/vagrant/plugin_test.rb +9 -0
  166. data/test/vagrant/provisioners/base_test.rb +1 -1
  167. data/test/vagrant/provisioners/chef_server_test.rb +31 -35
  168. data/test/vagrant/provisioners/chef_solo_test.rb +1 -1
  169. data/test/vagrant/provisioners/chef_test.rb +7 -7
  170. data/test/vagrant/ssh_session_test.rb +3 -10
  171. data/test/vagrant/ssh_test.rb +25 -33
  172. data/test/vagrant/systems/linux_test.rb +6 -71
  173. data/test/vagrant/ui_test.rb +29 -0
  174. data/test/vagrant/util/hash_with_indifferent_access_test.rb +39 -0
  175. data/test/vagrant/util/resource_logger_test.rb +14 -81
  176. data/test/vagrant/util/retryable_test.rb +38 -0
  177. data/test/vagrant/util/template_renderer_test.rb +4 -4
  178. data/test/vagrant/vm_test.rb +47 -26
  179. data/vagrant.gemspec +14 -12
  180. metadata +142 -108
  181. data/bin/.gitignore +0 -0
  182. data/lib/vagrant/action/action_exception.rb +0 -16
  183. data/lib/vagrant/action/env/error_halt.rb +0 -16
  184. data/lib/vagrant/action/exception_catcher.rb +0 -14
  185. data/lib/vagrant/action/vm/persist.rb +0 -22
  186. data/lib/vagrant/active_list.rb +0 -83
  187. data/lib/vagrant/command.rb +0 -27
  188. data/lib/vagrant/commands/base.rb +0 -181
  189. data/lib/vagrant/commands/box.rb +0 -16
  190. data/lib/vagrant/commands/box/add.rb +0 -30
  191. data/lib/vagrant/commands/box/list.rb +0 -30
  192. data/lib/vagrant/commands/box/remove.rb +0 -30
  193. data/lib/vagrant/commands/box/repackage.rb +0 -35
  194. data/lib/vagrant/commands/destroy.rb +0 -37
  195. data/lib/vagrant/commands/halt.rb +0 -43
  196. data/lib/vagrant/commands/init.rb +0 -36
  197. data/lib/vagrant/commands/package.rb +0 -81
  198. data/lib/vagrant/commands/provision.rb +0 -31
  199. data/lib/vagrant/commands/reload.rb +0 -36
  200. data/lib/vagrant/commands/resume.rb +0 -35
  201. data/lib/vagrant/commands/ssh.rb +0 -78
  202. data/lib/vagrant/commands/ssh_config.rb +0 -45
  203. data/lib/vagrant/commands/status.rb +0 -125
  204. data/lib/vagrant/commands/suspend.rb +0 -36
  205. data/lib/vagrant/commands/up.rb +0 -44
  206. data/lib/vagrant/exceptions/uncallable_action.rb +0 -17
  207. data/lib/vagrant/util/translator.rb +0 -35
  208. data/templates/strings.yml +0 -341
  209. data/templates/unison/crontab_entry.erb +0 -1
  210. data/templates/unison/script.erb +0 -71
  211. data/test/vagrant/action/env/error_halt_test.rb +0 -21
  212. data/test/vagrant/action/exception_catcher_test.rb +0 -30
  213. data/test/vagrant/action/vm/persist_test.rb +0 -50
  214. data/test/vagrant/active_list_test.rb +0 -173
  215. data/test/vagrant/command_test.rb +0 -53
  216. data/test/vagrant/commands/base_test.rb +0 -139
  217. data/test/vagrant/commands/box/add_test.rb +0 -34
  218. data/test/vagrant/commands/box/list_test.rb +0 -32
  219. data/test/vagrant/commands/box/remove_test.rb +0 -41
  220. data/test/vagrant/commands/box/repackage_test.rb +0 -52
  221. data/test/vagrant/commands/destroy_test.rb +0 -44
  222. data/test/vagrant/commands/halt_test.rb +0 -50
  223. data/test/vagrant/commands/init_test.rb +0 -71
  224. data/test/vagrant/commands/package_test.rb +0 -97
  225. data/test/vagrant/commands/provision_test.rb +0 -60
  226. data/test/vagrant/commands/reload_test.rb +0 -47
  227. data/test/vagrant/commands/resume_test.rb +0 -44
  228. data/test/vagrant/commands/ssh_config_test.rb +0 -77
  229. data/test/vagrant/commands/ssh_test.rb +0 -129
  230. data/test/vagrant/commands/status_test.rb +0 -40
  231. data/test/vagrant/commands/suspend_test.rb +0 -44
  232. data/test/vagrant/commands/up_test.rb +0 -49
  233. data/test/vagrant/util/translator_test.rb +0 -61
  234. data/test/vagrant/util_test.rb +0 -27
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .DS_Store
1
2
  pkg/*
2
3
  Vagrantfile
3
4
  .vagrant
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ -m markdown
data/CHANGELOG.md CHANGED
@@ -1,3 +1,59 @@
1
+ ## 0.6.0 (unreleased)
2
+
3
+ - VM name now defaults to the name of the containing folder, plus a timestamp.
4
+ This should make it easier to identify VMs in the VirtualBox GUI.
5
+ - Exposed Vagrant test helpers in `Vagrant::TestHelpers` for plugins to easily
6
+ test themselves against Vagrant environments.
7
+ - **Plugins** have landed. Plugins are simply gems which have a `vagrant_init.rb`
8
+ file somewhere in their load path. Please read the documentation on
9
+ vagrantup.com before attempting to create a plugin (which is very easy)
10
+ for more information on how it all works and also some guidelines.
11
+ - `vagrant package` now takes a `--vagrantfile` option to specify a
12
+ Vagrantfile to package. The `--include` approach for including a Vagrantfile
13
+ no longer works (previously built boxes will continue to work).
14
+ - `vagrant package` has new logic with regards to the `--include` option
15
+ depending on if the file path is relative or absolute (they can be
16
+ intermixed):
17
+ * _Relative_ paths are copied directly into the box, preserving
18
+ their path. So `--include lib/foo` would be in the box as "lib/foo"
19
+ * _Absolute_ paths are simply copied files into the root of the
20
+ box. So `--include /lib/foo` would be in the box as "foo"
21
+ - "vagrant_main" is no longer the default run list. Instead, chef
22
+ run list starts empty. It is up to you to specify all recipes in
23
+ the Vagrantfile now.
24
+ - Fixed various issues with certain action middleware not working if
25
+ the VM was not created.
26
+ - SSH connection is retried 5 times if there is a connection refused.
27
+ Related to GH-140.
28
+ - If `http_proxy` environmental variable is set, it will be used as the proxy
29
+ box adding via http.
30
+ - Remove `config.ssh.password`. It hasn't been used for a few versions
31
+ now and was only kept around to avoid exceptions in Vagrantfiles.
32
+ - Configuration is now validated so improper input can be found in
33
+ Vagrantfiles.
34
+ - Fixed issue with not detecting Vagrantfile at root directory ("/").
35
+ - Vagrant now gives a nice error message if there is a syntax error
36
+ in any Vagrantfile. [GH-154]
37
+ - The format of the ".vagrant" file which stores persisted VMs has
38
+ changed. This is **backwards incompatible**. Will provide an upgrade
39
+ utility prior to 0.6 launch.
40
+ - Every [expected] Vagrant error now exits with a clean error message
41
+ and a unique exit status, and raises a unique exception (if you're
42
+ scripting Vagrant).
43
+ - Added I18n gem dependency for pulling strings into clean YML files.
44
+ Vagrant is now localizable as a side effect! Translations welcome.
45
+ - Fixed issue with "Waiting for cleanup" message appearing twice in
46
+ some cases. [GH-145]
47
+ - Converted CLI to use Thor. As a tradeoff, there are some backwards
48
+ incompatibilities:
49
+ * `vagrant package` - The `--include` flag now separates filenames
50
+ by spaces, instead of by commas. e.g. `vagrant package --include x y z`
51
+ * `vagrant ssh` - If you specify a command to execute using the `--execute`
52
+ flag, you may now only specify one command (before you were able to
53
+ specify an arbitrary amount). e.g. `vagrant ssh -e "echo hello"`
54
+ * `vagrant ssh-config` has become `vagrant ssh_config` due to a limitation
55
+ in Thor.
56
+
1
57
  ## 0.5.4 (September 7, 2010)
2
58
 
3
59
  - Fix issue with the "exec failed" by running on Tiger as well.
data/Gemfile CHANGED
@@ -2,7 +2,8 @@ source "http://rubygems.org"
2
2
 
3
3
  gem "vagrant", :path => '.'
4
4
 
5
- # Use the version of virtualbox off of github
5
+ # Use the following gems straight from git, since Vagrant dev
6
+ # typically coincides with it
6
7
  gem "virtualbox", :git => "git://github.com/mitchellh/virtualbox.git"
7
8
 
8
9
  # Gems required for testing only. To install run
@@ -11,6 +12,16 @@ group :test do
11
12
  gem "rake"
12
13
  gem "contest", ">= 0.1.2"
13
14
  gem "mocha"
14
- gem "yard"
15
- gem "ruby-debug", ">= 0.10.3" if RUBY_VERSION < '1.9'
15
+
16
+ # For documentation
17
+ gem "yard", "~> 0.6.1"
18
+ gem "bluecloth"
19
+
20
+ platforms :mri_18 do
21
+ gem "ruby-debug"
22
+ end
23
+
24
+ platforms :mri_19 do
25
+ gem "ruby-debug19"
26
+ end
16
27
  end
data/Gemfile.lock CHANGED
@@ -1,20 +1,22 @@
1
1
  GIT
2
2
  remote: git://github.com/mitchellh/virtualbox.git
3
- revision: 69db76b
3
+ revision: 041996145591d20acf3e04fef3d4709f826d878a
4
4
  specs:
5
- virtualbox (0.7.5)
6
- ffi (>= 0.6.3)
5
+ virtualbox (0.7.6.dev)
6
+ ffi (~> 0.6.3)
7
7
 
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- vagrant (0.5.4)
11
+ vagrant (0.6.0)
12
12
  archive-tar-minitar (= 0.5.2)
13
- erubis (>= 2.6.6)
14
- json (>= 1.4.3)
13
+ erubis (~> 2.6.6)
14
+ i18n (~> 0.4.1)
15
+ json (~> 1.4.6)
15
16
  mario (~> 0.0.6)
16
- net-scp (>= 1.0.2)
17
- net-ssh (>= 2.0.19)
17
+ net-scp (~> 1.0.3)
18
+ net-ssh (~> 2.0.23)
19
+ thor (~> 0.14.2)
18
20
  virtualbox (~> 0.7.3)
19
21
 
20
22
  GEM
@@ -22,28 +24,53 @@ GEM
22
24
  specs:
23
25
  abstract (1.0.0)
24
26
  archive-tar-minitar (0.5.2)
27
+ bluecloth (2.0.9)
28
+ columnize (0.3.1)
25
29
  contest (0.1.2)
26
30
  erubis (2.6.6)
27
31
  abstract (>= 1.0.0)
28
32
  ffi (0.6.3)
29
33
  rake (>= 0.8.7)
34
+ i18n (0.4.1)
30
35
  json (1.4.6)
36
+ linecache (0.43)
37
+ linecache19 (0.5.11)
38
+ ruby_core_source (>= 0.1.4)
31
39
  mario (0.0.6)
32
40
  mocha (0.9.8)
33
41
  rake
34
- net-scp (1.0.3)
42
+ net-scp (1.0.4)
35
43
  net-ssh (>= 1.99.1)
36
44
  net-ssh (2.0.23)
37
45
  rake (0.8.7)
38
- yard (0.5.8)
46
+ ruby-debug (0.10.3)
47
+ columnize (>= 0.1)
48
+ ruby-debug-base (~> 0.10.3.0)
49
+ ruby-debug-base (0.10.3)
50
+ linecache (>= 0.3)
51
+ ruby-debug-base19 (0.11.24)
52
+ columnize (>= 0.3.1)
53
+ linecache19 (>= 0.5.11)
54
+ ruby_core_source (>= 0.1.4)
55
+ ruby-debug19 (0.11.6)
56
+ columnize (>= 0.3.1)
57
+ linecache19 (>= 0.5.11)
58
+ ruby-debug-base19 (>= 0.11.19)
59
+ ruby_core_source (0.1.4)
60
+ archive-tar-minitar (>= 0.5.2)
61
+ thor (0.14.2)
62
+ yard (0.6.1)
39
63
 
40
64
  PLATFORMS
41
65
  ruby
42
66
 
43
67
  DEPENDENCIES
68
+ bluecloth
44
69
  contest (>= 0.1.2)
45
70
  mocha
46
71
  rake
72
+ ruby-debug
73
+ ruby-debug19
47
74
  vagrant!
48
75
  virtualbox!
49
- yard
76
+ yard (~> 0.6.1)
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  * Website: [http://vagrantup.com](http://vagrantup.com)
4
4
  * Source: [http://github.com/mitchellh/vagrant](http://github.com/mitchellh/vagrant)
5
5
  * IRC: `#vagrant` on Freenode
6
- * Mailng list: [Google Groups](http://groups.google.com/group/vagrant-up)
6
+ * Mailing list: [Google Groups](http://groups.google.com/group/vagrant-up)
7
7
 
8
8
  Vagrant is a tool for building and distributing virtualized development environments.
9
9
 
data/bin/vagrant CHANGED
@@ -1,7 +1,22 @@
1
1
  #!/usr/bin/env ruby
2
- # Get library
3
- libdir = File.join(File.dirname(__FILE__), '..', 'lib')
4
- require File.expand_path('vagrant', libdir)
2
+ require 'vagrant'
3
+ require 'vagrant/cli'
5
4
 
6
- # Call the command
7
- Vagrant::Command.execute(*ARGV)
5
+ env = Vagrant::Environment.new
6
+
7
+ begin
8
+ # Set the UI early in case any errors are raised, and load
9
+ # the config immediately, so we gather any new commands from
10
+ # plugins
11
+ env.ui = Vagrant::UI::Shell.new(env, Thor::Base.shell.new)
12
+ env.load!
13
+
14
+ # Kick start the CLI
15
+ Vagrant::CLI.start(ARGV, :env => env)
16
+ rescue Vagrant::Errors::VagrantError => e
17
+ opts = { :prefix => false }
18
+ env.ui.error e.message, opts if e.message
19
+ env.ui.error e.backtrace.join("\n"), opts if ENV["VAGRANT_DEBUG"]
20
+ exit e.status_code if e.respond_to?(:status_code)
21
+ exit 999 # An error occurred with no status code defined
22
+ end
data/config/default.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  Vagrant::Config.run do |config|
2
2
  # default config goes here
3
- config.vagrant.log_output = STDOUT
4
3
  config.vagrant.dotfile_name = ".vagrant"
5
4
  config.vagrant.home = "~/.vagrant"
6
5
  config.vagrant.host = :detect
@@ -11,7 +10,7 @@ Vagrant::Config.run do |config|
11
10
  config.ssh.forwarded_port_key = "ssh"
12
11
  config.ssh.max_tries = 10
13
12
  config.ssh.timeout = 30
14
- config.ssh.private_key_path = File.join(PROJECT_ROOT, 'keys', 'vagrant')
13
+ config.ssh.private_key_path = File.expand_path("keys/vagrant", Vagrant.source_root)
15
14
  config.ssh.forward_agent = false
16
15
 
17
16
  config.vm.auto_port_range = (2200..2250)
@@ -26,16 +25,15 @@ Vagrant::Config.run do |config|
26
25
  config.vm.boot_mode = "vrdp"
27
26
  config.vm.system = :linux
28
27
 
28
+ config.vm.customize do |vm|
29
+ # Make VM name the name of the containing folder by default
30
+ vm.name = File.basename(File.expand_path("../", Vagrant.source_root)) + "_#{Time.now.to_i}"
31
+ end
32
+
29
33
  # Share the root folder. This can then be overridden by
30
34
  # other Vagrantfiles, if they wish.
31
35
  config.vm.share_folder("v-root", "/vagrant", ".")
32
36
 
33
- config.unison.folder_suffix = ".sync"
34
- config.unison.script = "/tmp/vagrant-unison"
35
- config.unison.options = "-terse -owner -group -batch"
36
- config.unison.crontab_entry_file = "/tmp/vagrant-unison-crontab"
37
- config.unison.log_file = "/tmp/v-unison-log-%s"
38
-
39
37
  config.nfs.map_uid = :auto
40
38
  config.nfs.map_gid = :auto
41
39
 
data/lib/vagrant.rb CHANGED
@@ -1,19 +1,46 @@
1
- libdir = File.join(File.dirname(__FILE__), "vagrant")
2
- PROJECT_ROOT = File.join(libdir, '..', "..") unless defined?(PROJECT_ROOT)
1
+ require 'pathname'
2
+ require 'json'
3
+ require 'i18n'
4
+ require 'virtualbox'
3
5
 
4
- # First, load the various libs which Vagrant requires
5
- %w{tempfile json pathname logger virtualbox net/ssh archive/tar/minitar
6
- net/scp fileutils mario}.each do |lib|
7
- require lib
6
+ module Vagrant
7
+ # TODO: Move more classes over to the autoload model. We'll
8
+ # start small, but slowly move everything over.
9
+
10
+ autoload :Box, 'vagrant/box'
11
+ autoload :BoxCollection, 'vagrant/box_collection'
12
+ autoload :CLI, 'vagrant/cli'
13
+ autoload :Config, 'vagrant/config'
14
+ autoload :DataStore, 'vagrant/data_store'
15
+ autoload :Errors, 'vagrant/errors'
16
+ autoload :Plugin, 'vagrant/plugin'
17
+ autoload :TestHelpers, 'vagrant/test_helpers'
18
+ autoload :Util, 'vagrant/util'
19
+
20
+ module Command
21
+ autoload :Base, 'vagrant/command/base'
22
+ autoload :GroupBase, 'vagrant/command/group_base'
23
+ autoload :Helpers, 'vagrant/command/helpers'
24
+ autoload :NamedBase, 'vagrant/command/named_base'
25
+ end
26
+
27
+ # The source root is the path to the root directory of
28
+ # the Vagrant gem.
29
+ def self.source_root
30
+ @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
31
+ end
8
32
  end
9
33
 
10
- # Then load the glob loader, which will handle loading everything else
11
- require File.expand_path("util/glob_loader", libdir)
34
+ # Default I18n to load the en locale
35
+ I18n.load_path << File.expand_path("templates/locales/en.yml", Vagrant.source_root)
12
36
 
13
- # Load them up
14
- Vagrant::GlobLoader.glob_require(libdir, %w{util util/stacked_proc_runner
15
- downloaders/base config provisioners/base provisioners/chef systems/base
16
- commands/base commands/box action/exception_catcher hosts/base})
37
+ # Load them up. One day we'll convert this to autoloads. Today
38
+ # is not that day. Low hanging fruit for anyone wishing to do it.
39
+ libdir = File.expand_path("lib/vagrant", Vagrant.source_root)
40
+ Vagrant::Util::GlobLoader.glob_require(libdir, %w{
41
+ downloaders/base provisioners/base provisioners/chef systems/base
42
+ hosts/base})
17
43
 
18
- # Initialize the built-in actions
44
+ # Initialize the built-in actions and load the plugins.
19
45
  Vagrant::Action.builtin!
46
+ Vagrant::Plugin.load!
@@ -1,12 +1,56 @@
1
1
  module Vagrant
2
2
  # Manages action running and registration. Every Vagrant environment
3
3
  # has an instance of {Action} to allow for running in the context of
4
- # the environment.
4
+ # the environment, which is accessible at {Environment#actions}. Actions
5
+ # are the foundation of most functionality in Vagrant, and are implemented
6
+ # architecturally as "middleware."
7
+ #
8
+ # # Registering an Action
9
+ #
10
+ # The main benefits of registering an action is the ability to retrieve and
11
+ # modify that registered action, as well as easily run the action. An example
12
+ # of registering an action is shown below, with a simple middleware which just
13
+ # outputs to `STDOUT`:
14
+ #
15
+ # class StdoutMiddleware
16
+ # def initialize(app, env)
17
+ # @app = app
18
+ # end
19
+ #
20
+ # def call(env)
21
+ # puts "HI!"
22
+ # @app.call(env)
23
+ # end
24
+ # end
25
+ #
26
+ # Vagrant::Action.register(:stdout, StdoutMiddleware)
27
+ #
28
+ # Then to run a registered action, assuming `env` is a loaded {Environment}:
29
+ #
30
+ # env.actions.run(:stdout)
31
+ #
32
+ # Or to retrieve the action class for any reason:
33
+ #
34
+ # Vagrant::Action[:stdout]
35
+ #
36
+ # # Running an Action
37
+ #
38
+ # There are various built-in registered actions such as `start`, `stop`, `up`,
39
+ # etc. Actions are built to be run in the context of an environment, so use
40
+ # {Environment#actions} to run all actions. Then simply call {#run}:
41
+ #
42
+ # env.actions.run(:name)
43
+ #
44
+ # Where `:name` is the name of the registered action.
45
+ #
5
46
  class Action
6
47
  include Util
48
+ @@reported_interrupt = false
7
49
 
8
50
  class << self
9
51
  # Returns the list of registered actions.
52
+ #
53
+ # @return [Array]
10
54
  def actions
11
55
  @actions ||= {}
12
56
  end
@@ -17,12 +61,14 @@ module Vagrant
17
61
  #
18
62
  # @param [Symbol] key
19
63
  def register(key, callable)
20
- actions[key] = callable
64
+ actions[key.to_sym] = callable
21
65
  end
22
66
 
23
67
  # Retrieves a registered action by key.
68
+ #
69
+ # @param [Symbol] key
24
70
  def [](key)
25
- actions[key]
71
+ actions[key.to_sym]
26
72
  end
27
73
  end
28
74
 
@@ -41,11 +87,13 @@ module Vagrant
41
87
  # If a symbol is given as the `callable` parameter, then it is looked
42
88
  # up in the registered actions list which are registered with {register}.
43
89
  #
90
+ # Any options given are injected into the environment hash.
91
+ #
44
92
  # @param [Object] callable An object which responds to `call`.
45
93
  def run(callable, options=nil)
46
94
  callable = Builder.new.use(callable) if callable.kind_of?(Class)
47
95
  callable = self.class.actions[callable] if callable.kind_of?(Symbol)
48
- raise Exceptions::UncallableAction.new(callable) if !callable
96
+ raise ArgumentError.new("Argument to run must be a callable object or registered action.") if !callable
49
97
 
50
98
  action_environment = Action::Environment.new(env)
51
99
  action_environment.merge!(options || {})
@@ -55,24 +103,16 @@ module Vagrant
55
103
  # chain has been run.
56
104
  int_callback = lambda do
57
105
  if action_environment.interrupted?
58
- env.logger.info "Exiting immediately!"
106
+ env.ui.error I18n.t("vagrant.actions.runner.exit_immediately")
59
107
  abort
60
108
  end
61
109
 
62
- env.logger.info "Waiting for cleanup before exiting..."
63
- action_environment.error!(:interrupt)
110
+ env.ui.warn I18n.t("vagrant.actions.runner.waiting_cleanup") if !@@reported_interrupt
111
+ action_environment.interrupt!
112
+ @@reported_interrupt = true
64
113
  end
65
114
 
66
115
  Busy.busy(int_callback) { callable.call(action_environment) }
67
- exit if action_environment.interrupted?
68
-
69
- if action_environment.error?
70
- # Erroneous environment resulted. Properly display error
71
- # message.
72
- key, options = action_environment.error
73
- error_and_exit(key, options)
74
- return false
75
- end
76
116
  end
77
117
  end
78
118
  end
@@ -1,3 +1,5 @@
1
+ require 'fileutils'
2
+
1
3
  module Vagrant
2
4
  class Action
3
5
  module Box
@@ -8,7 +10,7 @@ module Vagrant
8
10
  end
9
11
 
10
12
  def call(env)
11
- env.logger.info "Deleting box directory..."
13
+ env.ui.info I18n.t("vagrant.actions.box.destroy.destroying", :name => env["box"].name)
12
14
  FileUtils.rm_rf(env["box"].directory)
13
15
 
14
16
  @app.call(env)