vagrantup 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 (235) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.yardopts +1 -0
  4. data/CHANGELOG.md +56 -0
  5. data/Gemfile +14 -3
  6. data/Gemfile.lock +38 -11
  7. data/README.md +1 -1
  8. data/bin/vagrant +20 -5
  9. data/config/default.rb +6 -8
  10. data/lib/vagrant.rb +40 -13
  11. data/lib/vagrant/action.rb +56 -16
  12. data/lib/vagrant/action/box/destroy.rb +3 -1
  13. data/lib/vagrant/action/box/download.rb +8 -13
  14. data/lib/vagrant/action/box/unpackage.rb +8 -11
  15. data/lib/vagrant/action/box/verify.rb +3 -3
  16. data/lib/vagrant/action/builder.rb +3 -30
  17. data/lib/vagrant/action/builtin.rb +6 -1
  18. data/lib/vagrant/action/environment.rb +14 -62
  19. data/lib/vagrant/action/general/package.rb +29 -22
  20. data/lib/vagrant/action/vm/boot.rb +5 -12
  21. data/lib/vagrant/action/vm/check_box.rb +4 -4
  22. data/lib/vagrant/action/vm/check_guest_additions.rb +4 -6
  23. data/lib/vagrant/action/vm/clear_forwarded_ports.rb +2 -2
  24. data/lib/vagrant/action/vm/clear_nfs_exports.rb +1 -1
  25. data/lib/vagrant/action/vm/clear_shared_folders.rb +1 -1
  26. data/lib/vagrant/action/vm/customize.rb +1 -1
  27. data/lib/vagrant/action/vm/destroy.rb +1 -2
  28. data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +1 -1
  29. data/lib/vagrant/action/vm/disable_networks.rb +11 -9
  30. data/lib/vagrant/action/vm/discard_state.rb +2 -2
  31. data/lib/vagrant/action/vm/export.rb +10 -11
  32. data/lib/vagrant/action/vm/forward_ports.rb +21 -9
  33. data/lib/vagrant/action/vm/halt.rb +3 -8
  34. data/lib/vagrant/action/vm/import.rb +16 -14
  35. data/lib/vagrant/action/vm/match_mac_address.rb +1 -1
  36. data/lib/vagrant/action/vm/network.rb +9 -16
  37. data/lib/vagrant/action/vm/nfs.rb +14 -18
  38. data/lib/vagrant/action/vm/provision.rb +5 -5
  39. data/lib/vagrant/action/vm/resume.rb +1 -1
  40. data/lib/vagrant/action/vm/share_folders.rb +6 -44
  41. data/lib/vagrant/action/vm/suspend.rb +1 -1
  42. data/lib/vagrant/action/warden.rb +74 -0
  43. data/lib/vagrant/box.rb +18 -82
  44. data/lib/vagrant/box_collection.rb +47 -0
  45. data/lib/vagrant/cli.rb +55 -0
  46. data/lib/vagrant/command/base.rb +106 -0
  47. data/lib/vagrant/command/box.rb +33 -0
  48. data/lib/vagrant/command/destroy.rb +17 -0
  49. data/lib/vagrant/command/group_base.rb +99 -0
  50. data/lib/vagrant/command/halt.rb +18 -0
  51. data/lib/vagrant/command/helpers.rb +33 -0
  52. data/lib/vagrant/command/init.rb +14 -0
  53. data/lib/vagrant/command/named_base.rb +14 -0
  54. data/lib/vagrant/command/package.rb +41 -0
  55. data/lib/vagrant/command/provision.rb +17 -0
  56. data/lib/vagrant/command/reload.rb +17 -0
  57. data/lib/vagrant/command/resume.rb +17 -0
  58. data/lib/vagrant/command/ssh.rb +41 -0
  59. data/lib/vagrant/command/ssh_config.rb +21 -0
  60. data/lib/vagrant/command/status.rb +23 -0
  61. data/lib/vagrant/command/suspend.rb +17 -0
  62. data/lib/vagrant/command/up.rb +20 -0
  63. data/lib/vagrant/command/upgrade_to_060.rb +45 -0
  64. data/lib/vagrant/command/version.rb +13 -0
  65. data/lib/vagrant/config.rb +107 -189
  66. data/lib/vagrant/config/base.rb +67 -0
  67. data/lib/vagrant/config/error_recorder.rb +19 -0
  68. data/lib/vagrant/config/nfs.rb +10 -0
  69. data/lib/vagrant/config/package.rb +9 -0
  70. data/lib/vagrant/config/ssh.rb +28 -0
  71. data/lib/vagrant/config/vagrant.rb +21 -0
  72. data/lib/vagrant/config/vm.rb +111 -0
  73. data/lib/vagrant/data_store.rb +68 -0
  74. data/lib/vagrant/downloaders/file.rb +3 -3
  75. data/lib/vagrant/downloaders/http.rb +5 -5
  76. data/lib/vagrant/environment.rb +246 -243
  77. data/lib/vagrant/errors.rb +306 -0
  78. data/lib/vagrant/hosts/base.rb +1 -1
  79. data/lib/vagrant/hosts/bsd.rb +3 -9
  80. data/lib/vagrant/hosts/linux.rb +3 -9
  81. data/lib/vagrant/plugin.rb +50 -0
  82. data/lib/vagrant/provisioners/base.rb +0 -6
  83. data/lib/vagrant/provisioners/chef.rb +63 -58
  84. data/lib/vagrant/provisioners/chef_server.rb +9 -11
  85. data/lib/vagrant/provisioners/chef_solo.rb +2 -2
  86. data/lib/vagrant/ssh.rb +34 -37
  87. data/lib/vagrant/systems/base.rb +0 -13
  88. data/lib/vagrant/systems/linux.rb +10 -33
  89. data/lib/vagrant/systems/solaris.rb +59 -0
  90. data/lib/vagrant/test_helpers.rb +109 -0
  91. data/lib/vagrant/ui.rb +65 -0
  92. data/lib/vagrant/util.rb +9 -19
  93. data/lib/vagrant/util/glob_loader.rb +19 -17
  94. data/lib/vagrant/util/hash_with_indifferent_access.rb +63 -0
  95. data/lib/vagrant/util/plain_logger.rb +2 -0
  96. data/lib/vagrant/util/platform.rb +2 -0
  97. data/lib/vagrant/util/resource_logger.rb +5 -70
  98. data/lib/vagrant/util/retryable.rb +25 -0
  99. data/lib/vagrant/util/template_renderer.rb +1 -1
  100. data/lib/vagrant/version.rb +1 -1
  101. data/lib/vagrant/vm.rb +27 -13
  102. data/templates/commands/init/Vagrantfile.erb +13 -0
  103. data/templates/config/validation_failed.erb +7 -0
  104. data/templates/locales/en.yml +402 -0
  105. data/templates/package_Vagrantfile.erb +1 -1
  106. data/test/locales/en.yml +8 -0
  107. data/test/test_helper.rb +19 -103
  108. data/test/vagrant/action/box/destroy_test.rb +7 -19
  109. data/test/vagrant/action/box/download_test.rb +9 -25
  110. data/test/vagrant/action/box/package_test.rb +2 -2
  111. data/test/vagrant/action/box/unpackage_test.rb +8 -34
  112. data/test/vagrant/action/box/verify_test.rb +10 -19
  113. data/test/vagrant/action/builder_test.rb +0 -15
  114. data/test/vagrant/action/env/set_test.rb +1 -1
  115. data/test/vagrant/action/environment_test.rb +8 -26
  116. data/test/vagrant/action/general/package_test.rb +53 -53
  117. data/test/vagrant/action/vm/boot_test.rb +5 -22
  118. data/test/vagrant/action/vm/check_box_test.rb +35 -25
  119. data/test/vagrant/action/vm/clean_machine_folder_test.rb +1 -1
  120. data/test/vagrant/action/vm/clear_forwarded_ports_test.rb +1 -1
  121. data/test/vagrant/action/vm/clear_nfs_exports_test.rb +1 -1
  122. data/test/vagrant/action/vm/clear_shared_folders_test.rb +1 -1
  123. data/test/vagrant/action/vm/customize_test.rb +2 -1
  124. data/test/vagrant/action/vm/destroy_test.rb +1 -2
  125. data/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +1 -1
  126. data/test/vagrant/action/vm/disable_networks_test.rb +10 -1
  127. data/test/vagrant/action/vm/discard_state_test.rb +10 -1
  128. data/test/vagrant/action/vm/export_test.rb +9 -37
  129. data/test/vagrant/action/vm/forward_ports_helpers_test.rb +2 -2
  130. data/test/vagrant/action/vm/forward_ports_test.rb +19 -16
  131. data/test/vagrant/action/vm/halt_test.rb +11 -1
  132. data/test/vagrant/action/vm/import_test.rb +37 -21
  133. data/test/vagrant/action/vm/match_mac_address_test.rb +1 -1
  134. data/test/vagrant/action/vm/network_test.rb +8 -7
  135. data/test/vagrant/action/vm/nfs_helpers_test.rb +6 -3
  136. data/test/vagrant/action/vm/nfs_test.rb +20 -45
  137. data/test/vagrant/action/vm/package_test.rb +1 -1
  138. data/test/vagrant/action/vm/package_vagrantfile_test.rb +1 -1
  139. data/test/vagrant/action/vm/provision_test.rb +10 -17
  140. data/test/vagrant/action/vm/resume_test.rb +1 -1
  141. data/test/vagrant/action/vm/share_folders_test.rb +25 -106
  142. data/test/vagrant/action/vm/suspend_test.rb +1 -1
  143. data/test/vagrant/action/warden_test.rb +105 -0
  144. data/test/vagrant/action_test.rb +5 -27
  145. data/test/vagrant/box_collection_test.rb +44 -0
  146. data/test/vagrant/box_test.rb +5 -105
  147. data/test/vagrant/cli_test.rb +35 -0
  148. data/test/vagrant/command/base_test.rb +23 -0
  149. data/test/vagrant/command/group_base_test.rb +15 -0
  150. data/test/vagrant/command/helpers_test.rb +88 -0
  151. data/test/vagrant/config/base_test.rb +52 -0
  152. data/test/vagrant/config/error_recorder_test.rb +18 -0
  153. data/test/vagrant/config/ssh_test.rb +12 -0
  154. data/test/vagrant/config/vagrant_test.rb +11 -0
  155. data/test/vagrant/config/vm_test.rb +70 -0
  156. data/test/vagrant/config_test.rb +113 -206
  157. data/test/vagrant/data_store_test.rb +68 -0
  158. data/test/vagrant/downloaders/base_test.rb +1 -1
  159. data/test/vagrant/downloaders/file_test.rb +4 -3
  160. data/test/vagrant/downloaders/http_test.rb +14 -4
  161. data/test/vagrant/environment_test.rb +290 -590
  162. data/test/vagrant/errors_test.rb +42 -0
  163. data/test/vagrant/hosts/base_test.rb +1 -1
  164. data/test/vagrant/hosts/bsd_test.rb +3 -6
  165. data/test/vagrant/hosts/linux_test.rb +3 -5
  166. data/test/vagrant/plugin_test.rb +9 -0
  167. data/test/vagrant/provisioners/base_test.rb +1 -1
  168. data/test/vagrant/provisioners/chef_server_test.rb +31 -35
  169. data/test/vagrant/provisioners/chef_solo_test.rb +1 -1
  170. data/test/vagrant/provisioners/chef_test.rb +7 -7
  171. data/test/vagrant/ssh_session_test.rb +3 -10
  172. data/test/vagrant/ssh_test.rb +25 -33
  173. data/test/vagrant/systems/linux_test.rb +6 -71
  174. data/test/vagrant/ui_test.rb +29 -0
  175. data/test/vagrant/util/hash_with_indifferent_access_test.rb +39 -0
  176. data/test/vagrant/util/resource_logger_test.rb +14 -81
  177. data/test/vagrant/util/retryable_test.rb +38 -0
  178. data/test/vagrant/util/template_renderer_test.rb +4 -4
  179. data/test/vagrant/vm_test.rb +47 -26
  180. data/vagrant.gemspec +14 -12
  181. metadata +121 -89
  182. data/bin/.gitignore +0 -0
  183. data/lib/vagrant/action/action_exception.rb +0 -16
  184. data/lib/vagrant/action/env/error_halt.rb +0 -16
  185. data/lib/vagrant/action/exception_catcher.rb +0 -14
  186. data/lib/vagrant/action/vm/persist.rb +0 -22
  187. data/lib/vagrant/active_list.rb +0 -83
  188. data/lib/vagrant/command.rb +0 -27
  189. data/lib/vagrant/commands/base.rb +0 -181
  190. data/lib/vagrant/commands/box.rb +0 -16
  191. data/lib/vagrant/commands/box/add.rb +0 -30
  192. data/lib/vagrant/commands/box/list.rb +0 -30
  193. data/lib/vagrant/commands/box/remove.rb +0 -30
  194. data/lib/vagrant/commands/box/repackage.rb +0 -35
  195. data/lib/vagrant/commands/destroy.rb +0 -37
  196. data/lib/vagrant/commands/halt.rb +0 -43
  197. data/lib/vagrant/commands/init.rb +0 -36
  198. data/lib/vagrant/commands/package.rb +0 -81
  199. data/lib/vagrant/commands/provision.rb +0 -31
  200. data/lib/vagrant/commands/reload.rb +0 -36
  201. data/lib/vagrant/commands/resume.rb +0 -35
  202. data/lib/vagrant/commands/ssh.rb +0 -78
  203. data/lib/vagrant/commands/ssh_config.rb +0 -45
  204. data/lib/vagrant/commands/status.rb +0 -125
  205. data/lib/vagrant/commands/suspend.rb +0 -36
  206. data/lib/vagrant/commands/up.rb +0 -44
  207. data/lib/vagrant/exceptions/uncallable_action.rb +0 -17
  208. data/lib/vagrant/util/translator.rb +0 -35
  209. data/templates/strings.yml +0 -341
  210. data/templates/unison/crontab_entry.erb +0 -1
  211. data/templates/unison/script.erb +0 -71
  212. data/test/vagrant/action/env/error_halt_test.rb +0 -21
  213. data/test/vagrant/action/exception_catcher_test.rb +0 -30
  214. data/test/vagrant/action/vm/persist_test.rb +0 -50
  215. data/test/vagrant/active_list_test.rb +0 -173
  216. data/test/vagrant/command_test.rb +0 -53
  217. data/test/vagrant/commands/base_test.rb +0 -139
  218. data/test/vagrant/commands/box/add_test.rb +0 -34
  219. data/test/vagrant/commands/box/list_test.rb +0 -32
  220. data/test/vagrant/commands/box/remove_test.rb +0 -41
  221. data/test/vagrant/commands/box/repackage_test.rb +0 -52
  222. data/test/vagrant/commands/destroy_test.rb +0 -44
  223. data/test/vagrant/commands/halt_test.rb +0 -50
  224. data/test/vagrant/commands/init_test.rb +0 -71
  225. data/test/vagrant/commands/package_test.rb +0 -97
  226. data/test/vagrant/commands/provision_test.rb +0 -60
  227. data/test/vagrant/commands/reload_test.rb +0 -47
  228. data/test/vagrant/commands/resume_test.rb +0 -44
  229. data/test/vagrant/commands/ssh_config_test.rb +0 -77
  230. data/test/vagrant/commands/ssh_test.rb +0 -129
  231. data/test/vagrant/commands/status_test.rb +0 -40
  232. data/test/vagrant/commands/suspend_test.rb +0 -44
  233. data/test/vagrant/commands/up_test.rb +0 -49
  234. data/test/vagrant/util/translator_test.rb +0 -61
  235. data/test/vagrant/util_test.rb +0 -27
@@ -5,8 +5,6 @@ module Vagrant
5
5
  # installed and prints a warning if they're not detected or if the
6
6
  # version does not match the installed VirtualBox version.
7
7
  class CheckGuestAdditions
8
- include Util
9
-
10
8
  def initialize(app, env)
11
9
  @app = app
12
10
  end
@@ -16,11 +14,11 @@ module Vagrant
16
14
  # doesn't support guest properties (due to cross platform issues)
17
15
  version = env["vm"].vm.interface.get_guest_property_value("/VirtualBox/GuestAdd/Version")
18
16
  if version.empty?
19
- env.logger.error Translator.t(:vm_additions_not_detected)
17
+ env.ui.warn I18n.t("vagrant.actions.vm.check_guest_additions.not_detected")
20
18
  elsif version != VirtualBox.version
21
- env.logger.error Translator.t(:vm_additions_version_mismatch,
22
- :guest_additions_version => version,
23
- :virtualbox_version => VirtualBox.version)
19
+ env.ui.warn(I18n.t("vagrant.actions.vm.check_guest_additions.version_mismatch",
20
+ :guest_version => version,
21
+ :virtualbox_version => VirtualBox.version))
24
22
  end
25
23
 
26
24
  # Continue
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'forward_ports_helpers')
1
+ require File.expand_path("../forward_ports_helpers", __FILE__)
2
2
 
3
3
  module Vagrant
4
4
  class Action
@@ -19,7 +19,7 @@ module Vagrant
19
19
 
20
20
  def clear
21
21
  if used_ports.length > 0
22
- @env.logger.info "Deleting any previously set forwarded ports..."
22
+ @env.ui.info I18n.t("vagrant.actions.vm.clear_forward_ports.deleting")
23
23
  clear_ports
24
24
  @env["vm"].reload!
25
25
  end
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'nfs_helpers')
1
+ require File.expand_path("../nfs_helpers", __FILE__)
2
2
 
3
3
  module Vagrant
4
4
  class Action
@@ -16,7 +16,7 @@ module Vagrant
16
16
 
17
17
  def clear_shared_folders
18
18
  if @env["vm"].vm.shared_folders.length > 0
19
- @env.logger.info "Clearing previously set shared folders..."
19
+ @env.ui.info I18n.t("vagrant.actions.vm.clear_shared_folders.deleting")
20
20
 
21
21
  folders = @env["vm"].vm.shared_folders.dup
22
22
  folders.each do |shared_folder|
@@ -8,7 +8,7 @@ module Vagrant
8
8
 
9
9
  def call(env)
10
10
  if !env.env.config.vm.proc_stack.empty?
11
- env.logger.info "Running any VM customizations..."
11
+ env.ui.info I18n.t("vagrant.actions.vm.customize.running")
12
12
  env.env.config.vm.run_procs!(env["vm"].vm)
13
13
  env["vm"].vm.save
14
14
  end
@@ -7,10 +7,9 @@ module Vagrant
7
7
  end
8
8
 
9
9
  def call(env)
10
- env.logger.info "Destroying VM and associated drives..."
10
+ env.ui.info I18n.t("vagrant.actions.vm.destroy.destroying")
11
11
  env["vm"].vm.destroy(:destroy_medium => :delete)
12
12
  env["vm"].vm = nil
13
- env.env.update_dotfile
14
13
 
15
14
  @app.call(env)
16
15
  end
@@ -21,7 +21,7 @@ module Vagrant
21
21
  # Destroy the network interface if there is only one
22
22
  # attached VM (which must be this VM)
23
23
  if interface.attached_vms.length == 1
24
- env.logger.info "Destroying unused network interface..."
24
+ env.ui.info I18n.t("vagrant.actions.vm.destroy_network.destroying")
25
25
  interface.destroy
26
26
  end
27
27
  end
@@ -10,18 +10,20 @@ module Vagrant
10
10
  end
11
11
 
12
12
  def call(env)
13
- logged = false
13
+ if env["vm"].created?
14
+ logged = false
14
15
 
15
- env["vm"].vm.network_adapters.each do |adapter|
16
- next if adapter.attachment_type != :host_only
16
+ env["vm"].vm.network_adapters.each do |adapter|
17
+ next if adapter.attachment_type != :host_only
17
18
 
18
- if !logged
19
- env.logger.info "Disabling host only networks..."
20
- logged = true
21
- end
19
+ if !logged
20
+ env.ui.info I18n.t("vagrant.actions.vm.disable_networks.disabling")
21
+ logged = true
22
+ end
22
23
 
23
- adapter.enabled = false
24
- adapter.save
24
+ adapter.enabled = false
25
+ adapter.save
26
+ end
25
27
  end
26
28
 
27
29
  @app.call(env)
@@ -9,8 +9,8 @@ module Vagrant
9
9
  end
10
10
 
11
11
  def call(env)
12
- if env["vm"].vm.saved?
13
- env.logger.info "Discarding saved state of VM..."
12
+ if env["vm"].created? && env["vm"].vm.saved?
13
+ env.ui.info I18n.t("vagrant.actions.vm.discard_state.discarding")
14
14
  env["vm"].vm.discard_state
15
15
  end
16
16
 
@@ -1,3 +1,5 @@
1
+ require 'fileutils'
2
+
1
3
  module Vagrant
2
4
  class Action
3
5
  module VM
@@ -12,36 +14,33 @@ module Vagrant
12
14
  def call(env)
13
15
  @env = env
14
16
 
15
- return env.error!(:vm_power_off_to_package) if !@env["vm"].vm.powered_off?
16
- return if env.error?
17
+ raise Errors::VMPowerOffToPackage.new if !@env["vm"].vm.powered_off?
17
18
 
18
19
  setup_temp_dir
19
20
  export
20
21
 
21
- @app.call(env) if !env.error?
22
+ @app.call(env)
22
23
 
23
- cleanup
24
+ recover(env) # called to cleanup temp directory
24
25
  end
25
26
 
26
- def cleanup
27
+ def recover(env)
27
28
  if temp_dir && File.exist?(temp_dir)
28
29
  FileUtils.rm_rf(temp_dir)
29
30
  end
30
31
  end
31
32
 
32
33
  def setup_temp_dir
33
- @env.logger.info "Creating temporary directory for export..."
34
- @temp_dir = @env["export.temp_dir"] = File.join(@env.env.tmp_path, Time.now.to_i.to_s)
34
+ @env.ui.info I18n.t("vagrant.actions.vm.export.create_dir")
35
+ @temp_dir = @env["export.temp_dir"] = @env.env.tmp_path.join(Time.now.to_i.to_s)
35
36
  FileUtils.mkpath(@env["export.temp_dir"])
36
37
  end
37
38
 
38
39
  def export
39
- @env.logger.info "Exporting VM to #{ovf_path}..."
40
+ @env.ui.info I18n.t("vagrant.actions.vm.export.exporting")
40
41
  @env["vm"].vm.export(ovf_path) do |progress|
41
- @env.logger.report_progress(progress.percent, 100, false)
42
+ @env.ui.report_progress(progress.percent, 100, false)
42
43
  end
43
- ensure
44
- @env.logger.clear_progress
45
44
  end
46
45
 
47
46
  def ovf_path
@@ -11,7 +11,7 @@ module Vagrant
11
11
  @env = env
12
12
 
13
13
  threshold_check
14
- external_collision_check if !env.error?
14
+ external_collision_check
15
15
  end
16
16
 
17
17
  #--------------------------------------------------------------
@@ -23,7 +23,7 @@ module Vagrant
23
23
  # 1024, which causes the forwarded ports to fail.
24
24
  def threshold_check
25
25
  @env.env.config.vm.forwarded_ports.each do |name, options|
26
- return @env.error!(:vm_port_below_threshold) if options[:hostport] <= 1024
26
+ raise Errors::ForwardPortBelowThreshold.new if options[:hostport] <= 1024
27
27
  end
28
28
  end
29
29
 
@@ -47,7 +47,9 @@ module Vagrant
47
47
  if !options[:auto]
48
48
  # Auto fixing is disabled for this port forward, so we
49
49
  # must throw an error so the user can fix it.
50
- return @env.error!(:vm_port_collision, :name => name, :hostport => options[:hostport].to_s, :guestport => options[:guestport].to_s, :adapter => options[:adapter])
50
+ raise Errors::ForwardPortCollision.new(:name => name,
51
+ :host_port => options[:hostport].to_s,
52
+ :guest_port => options[:guestport].to_s)
51
53
  end
52
54
 
53
55
  # Get the auto port range and get rid of the used ports and
@@ -58,7 +60,10 @@ module Vagrant
58
60
  range -= existing_ports
59
61
 
60
62
  if range.empty?
61
- return @env.error!(:vm_port_auto_empty, :vm_name => @env["vm"].name, :name => name, :options => options)
63
+ raise Errors::ForwardPortAutolistEmpty.new(:vm_name => @env["vm"].name,
64
+ :name => name,
65
+ :host_port => options[:hostport].to_s,
66
+ :guest_port => options[:guestport].to_s)
62
67
  end
63
68
 
64
69
  # Set the port up to be the first one and add that port to
@@ -67,7 +72,9 @@ module Vagrant
67
72
  existing_ports << options[:hostport]
68
73
 
69
74
  # Notify the user
70
- @env.logger.info "Fixed port collision: #{name} now on port #{options[:hostport]}"
75
+ @env.ui.info(I18n.t("vagrant.actions.vm.forward_ports.fixed_collision",
76
+ :name => name,
77
+ :new_port => options[:hostport]))
71
78
  end
72
79
 
73
80
  #--------------------------------------------------------------
@@ -82,20 +89,25 @@ module Vagrant
82
89
  end
83
90
 
84
91
  def forward_ports
85
- @env.logger.info "Forwarding ports..."
92
+ @env.ui.info I18n.t("vagrant.actions.vm.forward_ports.forwarding")
86
93
 
87
94
  @env.env.config.vm.forwarded_ports.each do |name, options|
88
95
  adapter = options[:adapter]
96
+ message_attributes = {
97
+ :name => name,
98
+ :guest_port => options[:guestport],
99
+ :host_port => options[:hostport],
100
+ :adapter => adapter + 1
101
+ }
89
102
 
90
103
  # Assuming the only reason to establish port forwarding is because the VM is using Virtualbox NAT networking.
91
104
  # Host-only or Bridged networking don't require port-forwarding and establishing forwarded ports on these
92
105
  # attachment types has uncertain behaviour.
93
106
  if @env["vm"].vm.network_adapters[adapter].attachment_type == :nat
94
- @env.logger.info "Forwarding \"#{name}\": #{options[:guestport]} on adapter \##{adapter+1} => #{options[:hostport]}"
107
+ @env.ui.info(I18n.t("vagrant.actions.vm.forward_ports.forwarding_entry", message_attributes))
95
108
  forward_port(name, options)
96
109
  else
97
- @env.logger.info "VirtualBox adapter \##{adapter+1} not configured as \"NAT\"."
98
- @env.logger.info "Skipped port forwarding \"#{name}\": #{options[:guestport]} on adapter\##{adapter+1} => #{options[:hostport]}"
110
+ @env.ui.info(I18n.t("vagrant.actions.vm.forward_ports.non_nat", message_attributes))
99
111
  end
100
112
  end
101
113
 
@@ -2,22 +2,17 @@ module Vagrant
2
2
  class Action
3
3
  module VM
4
4
  class Halt
5
- include ExceptionCatcher
6
-
7
5
  def initialize(app, env, options=nil)
8
6
  @app = app
9
7
  env.merge!(options || {})
10
8
  end
11
9
 
12
10
  def call(env)
13
- if env["vm"].vm.running?
14
- if !env["force"]
15
- catch_action_exception(env) { env["vm"].system.halt }
16
- return if env.error?
17
- end
11
+ if env["vm"].created? && env["vm"].vm.running?
12
+ env["vm"].system.halt if !env["force"]
18
13
 
19
14
  if env["vm"].vm.state(true) != :powered_off
20
- env.logger.info "Forcing shutdown of VM..."
15
+ env.ui.info I18n.t("vagrant.actions.vm.halt.force")
21
16
  env["vm"].vm.stop
22
17
  end
23
18
 
@@ -7,25 +7,27 @@ module Vagrant
7
7
  end
8
8
 
9
9
  def call(env)
10
- env.logger.info "Importing base VM (#{env.env.box.ovf_file})"
10
+ env.ui.info I18n.t("vagrant.actions.vm.import.importing", :name => env.env.box.name)
11
11
 
12
- begin
13
- # Import the virtual machine
14
- env.env.vm.vm = VirtualBox::VM.import(env.env.box.ovf_file) do |progress|
15
- env.logger.report_progress(progress.percent, 100, false)
16
- end
17
-
18
- # Flag as erroneous and return if import failed
19
- return env.error!(:virtualbox_import_failure) if !env['vm'].vm
20
- ensure
21
- env.logger.clear_progress
12
+ # Import the virtual machine
13
+ env.env.vm.vm = VirtualBox::VM.import(env.env.box.ovf_file.to_s) do |progress|
14
+ env.ui.report_progress(progress.percent, 100, false)
22
15
  end
23
16
 
17
+ # Flag as erroneous and return if import failed
18
+ raise Errors::VMImportFailure.new if !env["vm"].vm
19
+
24
20
  # Import completed successfully. Continue the chain
25
- @app.call(env) if !env.error?
21
+ @app.call(env)
22
+ end
26
23
 
27
- # Interrupted, destroy the VM
28
- env["actions"].run(:destroy) if env.interrupted?
24
+ def recover(env)
25
+ if env["vm"].created?
26
+ return if env["vagrant.error"].is_a?(Errors::VagrantError)
27
+
28
+ # Interrupted, destroy the VM
29
+ env["actions"].run(:destroy)
30
+ end
29
31
  end
30
32
  end
31
33
  end
@@ -7,7 +7,7 @@ module Vagrant
7
7
  end
8
8
 
9
9
  def call(env)
10
- env.logger.info "Matching MAC addresses..."
10
+ env.ui.info I18n.t("vagrant.actions.vm.match_mac.matching")
11
11
  env["vm"].vm.network_adapters.first.mac_address = env.env.config.vm.base_mac
12
12
  env["vm"].vm.save
13
13
 
@@ -4,17 +4,12 @@ module Vagrant
4
4
  # Networking middleware for Vagrant. This enables host only
5
5
  # networking on VMs if configured as such.
6
6
  class Network
7
- include ExceptionCatcher
8
-
9
7
  def initialize(app, env)
10
8
  @app = app
11
9
  @env = env
12
10
 
13
11
  env["config"].vm.network_options.compact.each do |network_options|
14
- if !verify_no_bridge_collision(network_options)
15
- env.error!(:network_collides)
16
- return
17
- end
12
+ raise Errors::NetworkCollision.new if !verify_no_bridge_collision(network_options)
18
13
  end
19
14
  end
20
15
 
@@ -24,13 +19,11 @@ module Vagrant
24
19
 
25
20
  @app.call(env)
26
21
 
27
- if !env.error? && enable_network?
28
- catch_action_exception(env) do
29
- @env.logger.info "Enabling host only network..."
30
- @env["vm"].system.prepare_host_only_network
31
- @env.env.config.vm.network_options.compact.each do |network_options|
32
- @env["vm"].system.enable_host_only_network(network_options)
33
- end
22
+ if enable_network?
23
+ @env.ui.info I18n.t("vagrant.actions.vm.network.enabling")
24
+ @env["vm"].system.prepare_host_only_network
25
+ @env.env.config.vm.network_options.compact.each do |network_options|
26
+ @env["vm"].system.enable_host_only_network(network_options)
34
27
  end
35
28
  end
36
29
  end
@@ -61,7 +54,7 @@ module Vagrant
61
54
  # Enables and assigns the host only network to the proper
62
55
  # adapter on the VM, and saves the adapter.
63
56
  def assign_network
64
- @env.logger.info "Preparing host only network..."
57
+ @env.ui.info I18n.t("vagrant.actions.vm.network.preparing")
65
58
 
66
59
  @env.env.config.vm.network_options.compact.each do |network_options|
67
60
  adapter = @env["vm"].vm.network_adapters[network_options[:adapter]]
@@ -90,10 +83,10 @@ module Vagrant
90
83
  end
91
84
  end
92
85
 
93
- return @env.error!(:network_not_found, :name => net_options[:name]) if net_options[:name]
86
+ raise Errors::NetworkNotFound.new(:name => net_options[:name]) if net_options[:name]
94
87
 
95
88
  # One doesn't exist, create it.
96
- @env.logger.info "Creating new host only network for environment..."
89
+ @env.ui.info I18n.t("vagrant.actions.vm.network.creating")
97
90
 
98
91
  ni = interfaces.create
99
92
  ni.enable_static(network_ip(net_options[:ip], net_options[:netmask]),
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'nfs_helpers')
1
+ require File.expand_path("../nfs_helpers", __FILE__)
2
2
 
3
3
  module Vagrant
4
4
  class Action
@@ -16,7 +16,6 @@ module Vagrant
16
16
  # folder.
17
17
  #
18
18
  class NFS
19
- include ExceptionCatcher
20
19
  include NFSHelpers
21
20
 
22
21
  def initialize(app,env)
@@ -37,12 +36,13 @@ module Vagrant
37
36
  export_folders
38
37
  end
39
38
 
40
- return if env.error?
41
-
42
39
  @app.call(env)
43
40
 
44
- mount_folders if !folders.empty? && !env.error?
45
- clear_nfs_exports(env) if env.error?
41
+ mount_folders if !folders.empty?
42
+ end
43
+
44
+ def recover(env)
45
+ clear_nfs_exports(env)
46
46
  end
47
47
 
48
48
  # Returns the folders which are to be synced via NFS.
@@ -91,7 +91,7 @@ module Vagrant
91
91
 
92
92
  # The options on the hash get priority, then the default
93
93
  # values
94
- value = opts[key] || @env["config"].nfs.send(key)
94
+ value = opts.has_key?(key) ? opts[key] : @env["config"].nfs.send(key)
95
95
  return value if value != :auto
96
96
 
97
97
  # Get UID/GID from folder if we've made it this far
@@ -104,20 +104,16 @@ module Vagrant
104
104
  # involves adding a line to `/etc/exports` for this VM, but it is
105
105
  # up to the host class to define the specific behavior.
106
106
  def export_folders
107
- @env.logger.info "Exporting NFS shared folders..."
107
+ @env.ui.info I18n.t("vagrant.actions.vm.nfs.exporting")
108
108
 
109
- catch_action_exception(@env) do
110
- @env["host"].nfs_export(guest_ip, folders)
111
- end
109
+ @env["host"].nfs_export(guest_ip, folders)
112
110
  end
113
111
 
114
112
  # Uses the system class to mount the NFS folders.
115
113
  def mount_folders
116
- @env.logger.info "Mounting NFS shared folders..."
114
+ @env.ui.info I18n.t("vagrant.actions.vm.nfs.mounting")
117
115
 
118
- catch_action_exception(@env) do
119
- @env["vm"].system.mount_nfs(host_ip, folders)
120
- end
116
+ @env["vm"].system.mount_nfs(host_ip, folders)
121
117
  end
122
118
 
123
119
  # Returns the IP address of the first host only network adapter
@@ -151,9 +147,9 @@ module Vagrant
151
147
 
152
148
  # Verifies that the host is set and supports NFS.
153
149
  def verify_settings
154
- return @env.error!(:nfs_host_required) if @env["host"].nil?
155
- return @env.error!(:nfs_not_supported) if !@env["host"].nfs?
156
- return @env.error!(:nfs_no_host_network) if @env["config"].vm.network_options.empty?
150
+ raise Errors::NFSHostRequired.new if @env["host"].nil?
151
+ raise Errors::NFSNotSupported.new if !@env["host"].nfs?
152
+ raise Errors::NFSNoHostNetwork.new if @env["config"].vm.network_options.empty?
157
153
  end
158
154
  end
159
155
  end