Message on `up` that VM is already running [GH-1558]

This commit is contained in:
Mitchell Hashimoto 2013-04-08 09:09:23 -07:00
parent c1acdc2409
commit 88b34d3b71
4 changed files with 24 additions and 1 deletions

View File

@ -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:

View File

@ -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]

View File

@ -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

View File

@ -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: