diff --git a/CHANGELOG.md b/CHANGELOG.md index 365598018..fe040f5a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ IMPROVEMENTS: - Add `--rtcuseutc on` as a sane default for VirtualBox. [GH-912] - SSH will send keep-alive packets every 5 seconds by default to keep connections alive. Can be disabled with `config.ssh.keep_alive`. [GH-516] + - Show a message on `vagrant up` if the machine is already running. [GH-1558] BUG FIXES: diff --git a/plugins/providers/virtualbox/action.rb b/plugins/providers/virtualbox/action.rb index f4e14889d..c83bc9b01 100644 --- a/plugins/providers/virtualbox/action.rb +++ b/plugins/providers/virtualbox/action.rb @@ -27,6 +27,7 @@ module VagrantPlugins autoload :IsRunning, File.expand_path("../action/is_running", __FILE__) autoload :IsSaved, File.expand_path("../action/is_saved", __FILE__) autoload :MatchMACAddress, File.expand_path("../action/match_mac_address", __FILE__) + autoload :MessageAlreadyRunning, File.expand_path("../action/message_already_running", __FILE__) autoload :MessageNotCreated, File.expand_path("../action/message_not_created", __FILE__) autoload :MessageNotRunning, File.expand_path("../action/message_not_running", __FILE__) autoload :MessageWillNotDestroy, File.expand_path("../action/message_will_not_destroy", __FILE__) @@ -245,7 +246,10 @@ module VagrantPlugins b.use ConfigValidate b.use Call, IsRunning do |env, b2| # If the VM is running, then our work here is done, exit - next if env[:result] + if env[:result] + b2.use MessageAlreadyRunning + next + end b2.use Call, IsSaved do |env2, b3| if env2[:result] diff --git a/plugins/providers/virtualbox/action/message_already_running.rb b/plugins/providers/virtualbox/action/message_already_running.rb new file mode 100644 index 000000000..dd8c30efe --- /dev/null +++ b/plugins/providers/virtualbox/action/message_already_running.rb @@ -0,0 +1,16 @@ +module VagrantPlugins + module ProviderVirtualBox + module Action + class MessageAlreadyRunning + def initialize(app, env) + @app = app + end + + def call(env) + env[:ui].info I18n.t("vagrant.commands.common.vm_already_running") + @app.call(env) + end + end + end + end +end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 434d31733..7038c5786 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -580,6 +580,8 @@ en: #------------------------------------------------------------------------------- commands: common: + vm_already_running: |- + VirtualBox VM is already running. vm_not_created: "VM not created. Moving on..." vm_not_running: "VM is not currently running. Please bring it up to run this command." box: