vagrant 0.7.8 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/CHANGELOG.md +39 -0
  2. data/Gemfile +1 -7
  3. data/Rakefile +0 -11
  4. data/bin/vagrant +4 -0
  5. data/config/default.rb +1 -2
  6. data/lib/vagrant.rb +7 -5
  7. data/lib/vagrant/action.rb +5 -1
  8. data/lib/vagrant/action/builtin.rb +4 -1
  9. data/lib/vagrant/action/general/package.rb +6 -2
  10. data/lib/vagrant/action/vm.rb +2 -0
  11. data/lib/vagrant/action/vm/clear_forwarded_ports.rb +9 -22
  12. data/lib/vagrant/action/vm/clear_shared_folders.rb +9 -14
  13. data/lib/vagrant/action/vm/customize.rb +9 -4
  14. data/lib/vagrant/action/vm/forward_ports.rb +10 -11
  15. data/lib/vagrant/action/vm/match_mac_address.rb +8 -3
  16. data/lib/vagrant/action/vm/modify.rb +37 -0
  17. data/lib/vagrant/action/vm/network.rb +9 -2
  18. data/lib/vagrant/action/vm/provision.rb +10 -17
  19. data/lib/vagrant/action/vm/provisioner_cleanup.rb +26 -0
  20. data/lib/vagrant/action/vm/share_folders.rb +16 -8
  21. data/lib/vagrant/action/warden.rb +8 -2
  22. data/lib/vagrant/command/ssh.rb +4 -4
  23. data/lib/vagrant/command/ssh_config.rb +4 -2
  24. data/lib/vagrant/config/ssh.rb +3 -0
  25. data/lib/vagrant/config/vm.rb +16 -12
  26. data/lib/vagrant/downloaders/http.rb +2 -0
  27. data/lib/vagrant/environment.rb +136 -12
  28. data/lib/vagrant/errors.rb +15 -0
  29. data/lib/vagrant/provisioners.rb +1 -1
  30. data/lib/vagrant/provisioners/base.rb +4 -0
  31. data/lib/vagrant/provisioners/chef.rb +13 -11
  32. data/lib/vagrant/provisioners/{chef_server.rb → chef_client.rb} +5 -5
  33. data/lib/vagrant/provisioners/chef_solo.rb +48 -89
  34. data/lib/vagrant/provisioners/shell.rb +47 -12
  35. data/lib/vagrant/ssh.rb +61 -27
  36. data/lib/vagrant/systems.rb +1 -0
  37. data/lib/vagrant/systems/base.rb +1 -1
  38. data/lib/vagrant/systems/linux.rb +7 -9
  39. data/lib/vagrant/systems/redhat.rb +12 -4
  40. data/lib/vagrant/systems/solaris.rb +9 -4
  41. data/lib/vagrant/systems/suse.rb +9 -0
  42. data/lib/vagrant/ui.rb +12 -5
  43. data/lib/vagrant/util.rb +2 -2
  44. data/lib/vagrant/util/counter.rb +22 -0
  45. data/lib/vagrant/util/platform.rb +1 -2
  46. data/lib/vagrant/util/safe_exec.rb +28 -0
  47. data/lib/vagrant/version.rb +1 -1
  48. data/lib/vagrant/vm.rb +2 -0
  49. data/templates/chef_solo_solo.erb +4 -4
  50. data/templates/commands/init/Vagrantfile.erb +4 -0
  51. data/templates/locales/en.yml +31 -8
  52. data/templates/ssh_config.erb +6 -0
  53. data/test/test_helper.rb +5 -3
  54. data/test/vagrant/action/builder_test.rb +4 -0
  55. data/test/vagrant/action/vm/clear_forwarded_ports_test.rb +18 -38
  56. data/test/vagrant/action/vm/clear_shared_folders_test.rb +7 -16
  57. data/test/vagrant/action/vm/customize_test.rb +12 -5
  58. data/test/vagrant/action/vm/forward_ports_test.rb +12 -7
  59. data/test/vagrant/action/vm/match_mac_address_test.rb +5 -1
  60. data/test/vagrant/action/vm/modify_test.rb +38 -0
  61. data/test/vagrant/action/vm/provision_test.rb +13 -38
  62. data/test/vagrant/action/vm/provisioner_cleanup_test.rb +56 -0
  63. data/test/vagrant/action/vm/share_folders_test.rb +10 -5
  64. data/test/vagrant/action/warden_test.rb +13 -7
  65. data/test/vagrant/config/vm_test.rb +0 -22
  66. data/test/vagrant/downloaders/http_test.rb +2 -0
  67. data/test/vagrant/environment_test.rb +110 -20
  68. data/test/vagrant/provisioners/{chef_server_test.rb → chef_client_test.rb} +2 -2
  69. data/test/vagrant/provisioners/chef_solo_test.rb +16 -173
  70. data/test/vagrant/ssh_test.rb +8 -43
  71. data/test/vagrant/systems/linux_test.rb +9 -19
  72. data/test/vagrant/util/counter_test.rb +29 -0
  73. data/test/vagrant/util/platform_test.rb +2 -2
  74. data/vagrant.gemspec +1 -2
  75. metadata +114 -84
  76. data/lib/vagrant/util/plain_logger.rb +0 -25
  77. data/lib/vagrant/util/resource_logger.rb +0 -63
  78. data/test/vagrant/util/plain_logger_test.rb +0 -17
  79. 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