Stubbed vagrant-reload command

This commit is contained in:
Mitchell Hashimoto 2010-02-16 13:04:18 -08:00
parent 05f4845509
commit 7c61792b19
5 changed files with 67 additions and 0 deletions

30
bin/vagrant-reload Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env ruby
begin
require File.expand_path('../../.bundle/environment', __FILE__)
rescue LoadError
# Fallback on rubygems
require "rubygems"
end
require 'git-style-binary/command'
# Get library
libdir = File.join(File.dirname(__FILE__), '..', 'lib')
$:.unshift(libdir) unless $:.include?(libdir)
require 'vagrant'
GitStyleBinary.command do
short_desc "reload the vagrant environment"
banner <<-EOS
Usage: #{command.full_name} #{all_options_string}
Reloads the vagrant environment. This forces a shutdown of the VM,
updates the metadata (forwarded ports, shared folders, etc.), restarts
the VM, and reruns the chef recipes.
EOS
run do |command|
Vagrant::Commands.reload
end
end

View File

@ -0,0 +1,6 @@
module Vagrant
module Actions
class Reload < Base
end
end
end

View File

@ -55,6 +55,18 @@ error
Env.persisted_vm.destroy
end
# 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.
def reload
Env.load!
Env.require_persisted_vm
VM.execute!(Actions::Reload)
end
# SSH into the vagrant instance. This will setup an SSH connection into
# the vagrant instance, replacing the running ruby process with the SSH
# connection.

View File

@ -0,0 +1,7 @@
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
class ReloadActionTest < Test::Unit::TestCase
setup do
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::Reload)
end
end

View File

@ -68,6 +68,18 @@ class CommandsTest < Test::Unit::TestCase
end
end
context "reload" do
should "require a persisted VM" do
Vagrant::Env.expects(:require_persisted_vm).once
Vagrant::Commands.reload
end
should "call the `reload` action on the VM" do
Vagrant::VM.expects(:execute!).with(Vagrant::Actions::Reload).once
Vagrant::Commands.reload
end
end
context "ssh" do
setup do
Vagrant::SSH.stubs(:connect)