Reload command and some docs for other commands

This commit is contained in:
Mitchell Hashimoto 2010-04-13 16:22:14 -07:00
parent 33c3a2df45
commit 453f4774e4
4 changed files with 60 additions and 0 deletions

View File

@ -1,5 +1,11 @@
module Vagrant
class Commands
# Destroys a vagrant instance. This not only shuts down the instance
# (if its running), but also deletes it from the system, including the
# hard disks associated with it.
#
# This command requires that an instance already be brought up with
# `vagrant up`.
class Destroy < Base
Base.subcommand "destroy", self
description "Destroys the vagrant environment"

View File

@ -0,0 +1,22 @@
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.
class Reload < Base
Base.subcommand "reload", self
description "Reload the vagrant environment"
def execute(args=[])
env.require_persisted_vm
env.vm.execute!(Actions::VM::Reload)
end
def options_spec(opts)
opts.banner = "Usage: vagrant reload"
end
end
end
end

View File

@ -1,5 +1,9 @@
module Vagrant
class Commands
# Bring up a vagrant instance. This handles everything from importing
# the base VM, setting up shared folders, forwarded ports, etc to
# provisioning the instance with chef. {up} also starts the instance,
# running it in the background.
class Up < Base
Base.subcommand "up", self
description "Creates the vagrant environment"

View File

@ -0,0 +1,28 @@
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
class CommandsReloadTest < Test::Unit::TestCase
setup do
@klass = Vagrant::Commands::Reload
@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 `reload` action on the VM" do
@persisted_vm.expects(:execute!).with(Vagrant::Actions::VM::Reload).once
@instance.execute
end
end
end