Stubbed vagrant-reload command
This commit is contained in:
parent
05f4845509
commit
7c61792b19
|
@ -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
|
|
@ -0,0 +1,6 @@
|
||||||
|
module Vagrant
|
||||||
|
module Actions
|
||||||
|
class Reload < Base
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -55,6 +55,18 @@ error
|
||||||
Env.persisted_vm.destroy
|
Env.persisted_vm.destroy
|
||||||
end
|
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
|
# SSH into the vagrant instance. This will setup an SSH connection into
|
||||||
# the vagrant instance, replacing the running ruby process with the SSH
|
# the vagrant instance, replacing the running ruby process with the SSH
|
||||||
# connection.
|
# connection.
|
||||||
|
|
|
@ -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
|
|
@ -68,6 +68,18 @@ class CommandsTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
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
|
context "ssh" do
|
||||||
setup do
|
setup do
|
||||||
Vagrant::SSH.stubs(:connect)
|
Vagrant::SSH.stubs(:connect)
|
||||||
|
|
Loading…
Reference in New Issue