vagrant 0.7.8 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +39 -0
- data/Gemfile +1 -7
- data/Rakefile +0 -11
- data/bin/vagrant +4 -0
- data/config/default.rb +1 -2
- data/lib/vagrant.rb +7 -5
- data/lib/vagrant/action.rb +5 -1
- data/lib/vagrant/action/builtin.rb +4 -1
- data/lib/vagrant/action/general/package.rb +6 -2
- data/lib/vagrant/action/vm.rb +2 -0
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +9 -22
- data/lib/vagrant/action/vm/clear_shared_folders.rb +9 -14
- data/lib/vagrant/action/vm/customize.rb +9 -4
- data/lib/vagrant/action/vm/forward_ports.rb +10 -11
- data/lib/vagrant/action/vm/match_mac_address.rb +8 -3
- data/lib/vagrant/action/vm/modify.rb +37 -0
- data/lib/vagrant/action/vm/network.rb +9 -2
- data/lib/vagrant/action/vm/provision.rb +10 -17
- data/lib/vagrant/action/vm/provisioner_cleanup.rb +26 -0
- data/lib/vagrant/action/vm/share_folders.rb +16 -8
- data/lib/vagrant/action/warden.rb +8 -2
- data/lib/vagrant/command/ssh.rb +4 -4
- data/lib/vagrant/command/ssh_config.rb +4 -2
- data/lib/vagrant/config/ssh.rb +3 -0
- data/lib/vagrant/config/vm.rb +16 -12
- data/lib/vagrant/downloaders/http.rb +2 -0
- data/lib/vagrant/environment.rb +136 -12
- data/lib/vagrant/errors.rb +15 -0
- data/lib/vagrant/provisioners.rb +1 -1
- data/lib/vagrant/provisioners/base.rb +4 -0
- data/lib/vagrant/provisioners/chef.rb +13 -11
- data/lib/vagrant/provisioners/{chef_server.rb → chef_client.rb} +5 -5
- data/lib/vagrant/provisioners/chef_solo.rb +48 -89
- data/lib/vagrant/provisioners/shell.rb +47 -12
- data/lib/vagrant/ssh.rb +61 -27
- data/lib/vagrant/systems.rb +1 -0
- data/lib/vagrant/systems/base.rb +1 -1
- data/lib/vagrant/systems/linux.rb +7 -9
- data/lib/vagrant/systems/redhat.rb +12 -4
- data/lib/vagrant/systems/solaris.rb +9 -4
- data/lib/vagrant/systems/suse.rb +9 -0
- data/lib/vagrant/ui.rb +12 -5
- data/lib/vagrant/util.rb +2 -2
- data/lib/vagrant/util/counter.rb +22 -0
- data/lib/vagrant/util/platform.rb +1 -2
- data/lib/vagrant/util/safe_exec.rb +28 -0
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +2 -0
- data/templates/chef_solo_solo.erb +4 -4
- data/templates/commands/init/Vagrantfile.erb +4 -0
- data/templates/locales/en.yml +31 -8
- data/templates/ssh_config.erb +6 -0
- data/test/test_helper.rb +5 -3
- data/test/vagrant/action/builder_test.rb +4 -0
- data/test/vagrant/action/vm/clear_forwarded_ports_test.rb +18 -38
- data/test/vagrant/action/vm/clear_shared_folders_test.rb +7 -16
- data/test/vagrant/action/vm/customize_test.rb +12 -5
- data/test/vagrant/action/vm/forward_ports_test.rb +12 -7
- data/test/vagrant/action/vm/match_mac_address_test.rb +5 -1
- data/test/vagrant/action/vm/modify_test.rb +38 -0
- data/test/vagrant/action/vm/provision_test.rb +13 -38
- data/test/vagrant/action/vm/provisioner_cleanup_test.rb +56 -0
- data/test/vagrant/action/vm/share_folders_test.rb +10 -5
- data/test/vagrant/action/warden_test.rb +13 -7
- data/test/vagrant/config/vm_test.rb +0 -22
- data/test/vagrant/downloaders/http_test.rb +2 -0
- data/test/vagrant/environment_test.rb +110 -20
- data/test/vagrant/provisioners/{chef_server_test.rb → chef_client_test.rb} +2 -2
- data/test/vagrant/provisioners/chef_solo_test.rb +16 -173
- data/test/vagrant/ssh_test.rb +8 -43
- data/test/vagrant/systems/linux_test.rb +9 -19
- data/test/vagrant/util/counter_test.rb +29 -0
- data/test/vagrant/util/platform_test.rb +2 -2
- data/vagrant.gemspec +1 -2
- metadata +114 -84
- data/lib/vagrant/util/plain_logger.rb +0 -25
- data/lib/vagrant/util/resource_logger.rb +0 -63
- data/test/vagrant/util/plain_logger_test.rb +0 -17
- data/test/vagrant/util/resource_logger_test.rb +0 -78
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'logger'
|
2
|
-
|
3
|
-
module Vagrant
|
4
|
-
module Util
|
5
|
-
# Subclass of the standard library logger which has no format on
|
6
|
-
# its own. The message sent to the logger is outputted as-is.
|
7
|
-
class PlainLogger < ::Logger
|
8
|
-
# This is the method which is called for all debug, info, error,
|
9
|
-
# etc. methods by the logger. This is overriden to verify that
|
10
|
-
# the output is always flushed.
|
11
|
-
#
|
12
|
-
# Logger by default syncs all log devices but this just verifies
|
13
|
-
# it is truly flushed.
|
14
|
-
def add(*args)
|
15
|
-
super
|
16
|
-
@logdev.dev.flush if @logdev
|
17
|
-
end
|
18
|
-
|
19
|
-
def format_message(level, time, progname, msg)
|
20
|
-
# We do no formatting, its up to the user
|
21
|
-
"#{msg}\n"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'thread'
|
2
|
-
|
3
|
-
module Vagrant
|
4
|
-
module Util
|
5
|
-
# Represents a logger for a specific resource within Vagrant. Each
|
6
|
-
# logger should be initialized and set to represent a single
|
7
|
-
# resource. Each logged message will then appear in the following
|
8
|
-
# format:
|
9
|
-
#
|
10
|
-
# [resource] message
|
11
|
-
#
|
12
|
-
# This class is thread safe. The backing class which actually does
|
13
|
-
# all the logging IO is protected.
|
14
|
-
class ResourceLogger
|
15
|
-
@@singleton_logger = nil
|
16
|
-
@@writer_lock = Mutex.new
|
17
|
-
|
18
|
-
# The resource which this logger represents.
|
19
|
-
attr_reader :resource
|
20
|
-
|
21
|
-
# The environment that this logger is part of
|
22
|
-
attr_reader :env
|
23
|
-
|
24
|
-
# The backing logger which actually handles the IO. This logger
|
25
|
-
# should be a subclass of the standard library Logger, in general.
|
26
|
-
# IMPORTANT: This logger must be thread-safe.
|
27
|
-
attr_reader :logger
|
28
|
-
|
29
|
-
class << self
|
30
|
-
# Returns a singleton logger. If one has not yet be
|
31
|
-
# instantiated, then the given environment will be used to
|
32
|
-
# create a new logger.
|
33
|
-
def singleton_logger(env=nil)
|
34
|
-
return PlainLogger.new(nil) if !env.loaded?
|
35
|
-
|
36
|
-
@@singleton_logger ||= begin
|
37
|
-
file = env.log_path.join("#{Time.now.to_i}.log")
|
38
|
-
PlainLogger.new(file)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Resets the singleton logger (only used for testing).
|
43
|
-
def reset_singleton_logger!
|
44
|
-
@@singleton_logger = nil
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def initialize(resource, env)
|
49
|
-
@resource = resource
|
50
|
-
@env = env
|
51
|
-
@logger = self.class.singleton_logger(env)
|
52
|
-
end
|
53
|
-
|
54
|
-
[:debug, :info, :error, :fatal].each do |method|
|
55
|
-
define_method(method) do |message|
|
56
|
-
@@writer_lock.synchronize do
|
57
|
-
logger.send(method, "[#{resource}] #{message}")
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class PlainLoggerUtilTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Util::PlainLogger
|
6
|
-
@instance = @klass.new(nil)
|
7
|
-
end
|
8
|
-
|
9
|
-
should "inherit from the standard logger" do
|
10
|
-
assert @instance.is_a?(::Logger)
|
11
|
-
end
|
12
|
-
|
13
|
-
should "just add a newline to the message" do
|
14
|
-
msg = "foo bar baz"
|
15
|
-
assert_equal "#{msg}\n", @instance.format_message("1", "2", "3", msg)
|
16
|
-
end
|
17
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class ResourceLoggerUtilTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Util::ResourceLogger
|
6
|
-
end
|
7
|
-
|
8
|
-
context "singleton logger" do
|
9
|
-
setup do
|
10
|
-
@klass.reset_singleton_logger!
|
11
|
-
|
12
|
-
@result = mock("result")
|
13
|
-
end
|
14
|
-
|
15
|
-
should "return a nil plain logger if the environment is not loaded" do
|
16
|
-
env = vagrant_env
|
17
|
-
env.stubs(:loaded?).returns(false)
|
18
|
-
|
19
|
-
Vagrant::Util::PlainLogger.expects(:new).with(nil).returns(@result)
|
20
|
-
assert_equal @result, @klass.singleton_logger(env)
|
21
|
-
end
|
22
|
-
|
23
|
-
should "return a logger with the output file set if environment is ready" do
|
24
|
-
env = vagrant_env
|
25
|
-
|
26
|
-
Vagrant::Util::PlainLogger.expects(:new).returns(@result).with() do |path|
|
27
|
-
assert path.to_s =~ /logs/
|
28
|
-
true
|
29
|
-
end
|
30
|
-
|
31
|
-
assert_equal @result, @klass.singleton_logger(env)
|
32
|
-
end
|
33
|
-
|
34
|
-
should "only load the logger once" do
|
35
|
-
env = vagrant_env
|
36
|
-
|
37
|
-
Vagrant::Util::PlainLogger.expects(:new).with(anything).returns(@result)
|
38
|
-
assert_equal @result, @klass.singleton_logger(env)
|
39
|
-
assert_equal @result, @klass.singleton_logger(env)
|
40
|
-
assert_equal @result, @klass.singleton_logger(env)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "initialization" do
|
45
|
-
should "setup the logger and attributes" do
|
46
|
-
env = vagrant_env
|
47
|
-
resource = mock("resource")
|
48
|
-
result = mock("result")
|
49
|
-
|
50
|
-
@klass.expects(:singleton_logger).with(env).returns(result)
|
51
|
-
instance = @klass.new(resource, env)
|
52
|
-
assert_equal resource, instance.resource
|
53
|
-
assert_equal env, instance.env
|
54
|
-
assert_equal result, instance.logger
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context "with an instance" do
|
59
|
-
setup do
|
60
|
-
@resource = "foo"
|
61
|
-
@env = vagrant_env
|
62
|
-
@logger = mock("logger")
|
63
|
-
|
64
|
-
@klass.stubs(:singleton_logger).returns(@logger)
|
65
|
-
@instance = @klass.new(@resource, @env)
|
66
|
-
end
|
67
|
-
|
68
|
-
context "logging methods" do
|
69
|
-
[:debug, :info, :error, :fatal].each do |method|
|
70
|
-
should "log with the proper format on #{method}" do
|
71
|
-
message = "bar"
|
72
|
-
@logger.expects(method).with("[#{@resource}] #{message}").once
|
73
|
-
@instance.send(method, message)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|