diff --git a/lib/vagrant/commands/destroy.rb b/lib/vagrant/commands/destroy.rb index 56ac11d00..a67d61b1d 100644 --- a/lib/vagrant/commands/destroy.rb +++ b/lib/vagrant/commands/destroy.rb @@ -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" diff --git a/lib/vagrant/commands/reload.rb b/lib/vagrant/commands/reload.rb new file mode 100644 index 000000000..6ace6983d --- /dev/null +++ b/lib/vagrant/commands/reload.rb @@ -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 \ No newline at end of file diff --git a/lib/vagrant/commands/up.rb b/lib/vagrant/commands/up.rb index 137e04bc0..49daef4d8 100644 --- a/lib/vagrant/commands/up.rb +++ b/lib/vagrant/commands/up.rb @@ -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" diff --git a/test/vagrant/commands/reload_test.rb b/test/vagrant/commands/reload_test.rb new file mode 100644 index 000000000..f0e005ded --- /dev/null +++ b/test/vagrant/commands/reload_test.rb @@ -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