Halt command
This commit is contained in:
parent
fa3ca57c9f
commit
28a2fd5466
|
@ -0,0 +1,23 @@
|
|||
module Vagrant
|
||||
class Commands
|
||||
# Halts a running vagrant instance. This forcibly halts the instance;
|
||||
# it is the equivalent of pulling the power on a machine. The instance
|
||||
# can be restarted again with {up}.
|
||||
#
|
||||
# This command requires than an instance already be brought up with
|
||||
# `vagrant up`.
|
||||
class Halt < Base
|
||||
Base.subcommand "halt", self
|
||||
description "Halts the currently running vagrant environment"
|
||||
|
||||
def execute(args=[])
|
||||
env.require_persisted_vm
|
||||
env.vm.execute!(Actions::VM::Halt)
|
||||
end
|
||||
|
||||
def options_spec(opts)
|
||||
opts.banner = "Usage: vagrant halt"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,10 +1,7 @@
|
|||
module Vagrant
|
||||
class Commands
|
||||
# Reload the environment. This is almost equivalent to the {up} command
|
||||
# except that it doesn't import the VM and do the initialize bootstrapping
|
||||
# of the instance. Instead, it forces a shutdown (if its running) of the
|
||||
# VM, updates the metadata (shared folders, forwarded ports), restarts
|
||||
# the VM, and then reruns the provisioning if enabled.
|
||||
# Outputs a valid entry for .ssh/config which can be used to connect
|
||||
# to this environment.
|
||||
class SSHConfig < Base
|
||||
Base.subcommand "ssh-config", self
|
||||
description "outputs .ssh/config valid syntax for connecting to this environment via ssh"
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||
|
||||
class CommandsHaltTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Commands::Halt
|
||||
|
||||
@persisted_vm = mock("persisted_vm")
|
||||
@persisted_vm.stubs(:execute!)
|
||||
|
||||
@env = mock_environment
|
||||
@env.stubs(:require_persisted_vm)
|
||||
@env.stubs(:vm).returns(@persisted_vm)
|
||||
|
||||
@instance = @klass.new(@env)
|
||||
end
|
||||
|
||||
context "executing" do
|
||||
should "require a persisted VM" do
|
||||
@env.expects(:require_persisted_vm).once
|
||||
@instance.execute
|
||||
end
|
||||
|
||||
should "call the `halt` action on the VM" do
|
||||
@persisted_vm.expects(:execute!).with(Vagrant::Actions::VM::Halt).once
|
||||
@instance.execute
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue