vagrant 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,22 @@
1
+ ## 0.9.2 (January 20, 2012)
2
+
3
+ - Support shell expansions in shared folder guest paths again. [GH-656]
4
+ - Fix issue where Chef solo always expected the host to have a
5
+ "cookbooks" folder in their directory. [GH-638]
6
+ - Fix `forward_agent` not working when outside of blocks. [GH-651]
7
+ - Fix issue causing custom guest implementations to not load properly.
8
+ - Filter clear screen character out of output on SSH.
9
+ - Log output now goes on `stderr`, since it is utility information.
10
+ - Get rid of case where a `NoMethodError` could be raised while
11
+ determining VirtualBox version. [GH-658]
12
+ - Debian/Ubuntu uses `ifdown` again, instead of `ifconfig xxx down`, since
13
+ the behavior seems different/wrong.
14
+ - Give a nice error if `:vagrant` is used as a JSON key, since Vagrant
15
+ uses this. [GH-661]
16
+ - If there is only one bridgable interface, use that without asking
17
+ the user. [GH-655]
18
+ - The shell will have color output if ANSICON is installed on Windows. [GH-666]
19
+
1
20
  ## 0.9.1 (January 18, 2012)
2
21
 
3
22
  - Use `ifconfig device down` instead of `ifdown`. [GH-649]
@@ -19,7 +19,7 @@ opts = {}
19
19
  # Disable color if the proper argument was passed or if we're
20
20
  # on Windows since the default Windows terminal doesn't support
21
21
  # colors.
22
- if !$stdout.tty? || ARGV.include?("--no-color") || Vagrant::Util::Platform.windows?
22
+ if ARGV.include?("--no-color") || !$stdout.tty? || !Vagrant::Util::Platform.terminal_supports_colors?
23
23
  # Delete the argument from the list so that it doesn't cause any
24
24
  # invalid arguments down the road.
25
25
  ARGV.delete("--no-color")
@@ -11,6 +11,7 @@ Vagrant::Config.run do |config|
11
11
  config.ssh.timeout = 10
12
12
  config.ssh.forward_agent = false
13
13
  config.ssh.forward_x11 = false
14
+ config.ssh.shell = "bash"
14
15
 
15
16
  config.vm.auto_port_range = (2200..2250)
16
17
  config.vm.box_url = nil
@@ -35,7 +35,7 @@ if ENV["VAGRANT_LOG"] && ENV["VAGRANT_LOG"] != ""
35
35
  # logs as long as we have a valid level.
36
36
  if level
37
37
  logger = Log4r::Logger.new("vagrant")
38
- logger.outputters = Log4r::Outputter.stdout
38
+ logger.outputters = Log4r::Outputter.stderr
39
39
  logger.level = level
40
40
  logger = nil
41
41
  end
@@ -314,29 +314,40 @@ module Vagrant
314
314
  def bridged_adapter(config)
315
315
  bridgedifs = @env[:vm].driver.read_bridged_interfaces
316
316
 
317
- # Output all the interfaces that are available as choices
318
- @env[:ui].info I18n.t("vagrant.actions.vm.bridged_networking.available",
319
- :prefix => false)
320
- bridgedifs.each_index do |index|
321
- interface = bridgedifs[index]
322
- @env[:ui].info("#{index + 1}) #{interface[:name]}", :prefix => false)
323
- end
317
+ chosen_bridge = nil
318
+ if bridgedifs.length == 1
319
+ # One bridgable interface? Just use it.
320
+ chosen_bridge = bridgedifs[0][:name]
321
+ else
322
+ # More than one bridgable interface requires a user decision, so
323
+ # show options to choose from.
324
+ @env[:ui].info I18n.t("vagrant.actions.vm.bridged_networking.available",
325
+ :prefix => false)
326
+ bridgedifs.each_index do |index|
327
+ interface = bridgedifs[index]
328
+ @env[:ui].info("#{index + 1}) #{interface[:name]}", :prefix => false)
329
+ end
324
330
 
325
- # The range of valid choices
326
- valid = Range.new(1, bridgedifs.length)
331
+ # The range of valid choices
332
+ valid = Range.new(1, bridgedifs.length)
327
333
 
328
- # The choice that the user has chosen as the bridging interface
329
- choice = nil
330
- while !valid.include?(choice)
331
- choice = @env[:ui].ask("What interface should the network bridge to? ")
332
- choice = choice.to_i
334
+ # The choice that the user has chosen as the bridging interface
335
+ choice = nil
336
+ while !valid.include?(choice)
337
+ choice = @env[:ui].ask("What interface should the network bridge to? ")
338
+ choice = choice.to_i
339
+ end
340
+
341
+ chosen_bridge = bridgedifs[choice - 1][:name]
333
342
  end
334
343
 
344
+ @logger.info("Bridging adapter #{config[:adapter]} to #{bridge}")
345
+
335
346
  # Given the choice we can now define the adapter we're using
336
347
  return {
337
348
  :adapter => config[:adapter],
338
349
  :type => :bridged,
339
- :bridge => bridgedifs[choice - 1][:name],
350
+ :bridge => chosen_bridge,
340
351
  :mac_address => config[:mac]
341
352
  }
342
353
  end
@@ -66,7 +66,6 @@ module Vagrant
66
66
  def prepare_folders
67
67
  @folders = @folders.inject({}) do |acc, data|
68
68
  key, opts = data
69
- opts[:nfs] = {} if !opts.is_a?(Hash)
70
69
  opts[:map_uid] = prepare_permission(:uid, opts)
71
70
  opts[:map_gid] = prepare_permission(:gid, opts)
72
71
 
@@ -71,6 +71,8 @@ module Vagrant
71
71
  end
72
72
 
73
73
  def upload(from, to)
74
+ @logger.debug("Uploading: #{from} to #{to}")
75
+
74
76
  # Do an SCP-based upload...
75
77
  connect do |connection|
76
78
  scp = Net::SCP.new(connection)
@@ -102,7 +104,7 @@ module Vagrant
102
104
  # If the @connection is still around, then it is valid,
103
105
  # and we use it.
104
106
  if @connection
105
- @logger.info("Re-using SSH connection.")
107
+ @logger.debug("Re-using SSH connection.")
106
108
  return yield @connection if block_given?
107
109
  return
108
110
  end
@@ -148,13 +150,11 @@ module Vagrant
148
150
  rescue Errno::ECONNREFUSED
149
151
  # This is raised if we failed to connect the max amount of times
150
152
  raise Errors::SSHConnectionRefused
151
- ensure
152
- # Be sure the connection is always closed
153
- # connection.close if connection && !connection.closed?
154
153
  end
155
154
 
156
155
  # Executes the command on an SSH connection within a login shell.
157
156
  def shell_execute(connection, command, sudo=false)
157
+ @logger.info("Execute: #{command} (sudo=#{sudo.inspect})")
158
158
  exit_status = nil
159
159
 
160
160
  # Determine the shell to execute. If we are using `sudo` then we
@@ -167,15 +167,26 @@ module Vagrant
167
167
  ch.exec(shell) do |ch2, _|
168
168
  # Setup the channel callbacks so we can get data and exit status
169
169
  ch2.on_data do |ch3, data|
170
- yield :stdout, data if block_given?
170
+ if block_given?
171
+ # Filter out the clear screen command
172
+ data.gsub!("\e[H", "")
173
+ @logger.debug("stdout: #{data}")
174
+ yield :stdout, data
175
+ end
171
176
  end
172
177
 
173
178
  ch2.on_extended_data do |ch3, type, data|
174
- yield :stderr, data if block_given?
179
+ if block_given?
180
+ # Filter out the clear screen command
181
+ data.gsub!("\e[H", "")
182
+ @logger.debug("stderr: #{data}")
183
+ yield :stderr, data
184
+ end
175
185
  end
176
186
 
177
187
  ch2.on_request("exit-status") do |ch3, data|
178
188
  exit_status = data.read_long
189
+ @logger.debug("Exit status: #{exit_status}")
179
190
  end
180
191
 
181
192
  # Set the terminal
@@ -33,7 +33,12 @@ module Vagrant
33
33
  def merge(other)
34
34
  result = self.class.new
35
35
  instance_variables_hash.merge(other.instance_variables_hash).each do |key, value|
36
- result.instance_variable_set("@#{key}".to_sym, value)
36
+ # Ignore keys that start with a double underscore. This allows
37
+ # configuration classes to still hold around internal state
38
+ # that isn't propagated.
39
+ if !key.start_with?("__")
40
+ result.instance_variable_set("@#{key}".to_sym, value)
41
+ end
37
42
  end
38
43
 
39
44
  result
@@ -13,12 +13,6 @@ module Vagrant
13
13
  attr_accessor :forward_x11
14
14
  attr_accessor :shell
15
15
 
16
- def initialize
17
- @shell = "bash"
18
- @forward_agent = false
19
- @forward_x11 = false
20
- end
21
-
22
16
  def forwarded_port_key=(value)
23
17
  raise Errors::DeprecationError, :message => <<-MESSAGE
24
18
  `config.ssh.forwarded_port_key` is now gone. You must now use
@@ -39,6 +39,14 @@ module Vagrant
39
39
  result
40
40
  end
41
41
 
42
+ def system=(value)
43
+ raise Errors::DeprecationError, :message => <<-MESSAGE
44
+ `config.vm.system` has changed to `config.vm.guest` in Vagrant 0.9,
45
+ since this is more clear about the use of the configuration key.
46
+ Please change all references of `config.vm.system` to `config.vm.guest`.
47
+ MESSAGE
48
+ end
49
+
42
50
  def forward_port(guestport, hostport, options=nil)
43
51
  if !guestport.kind_of?(Integer)
44
52
  raise Errors::DeprecationError, :message => <<-MESSAGE
@@ -33,7 +33,7 @@ module Vagrant
33
33
  # Read and assign the version of VirtualBox we know which
34
34
  # specific driver to instantiate.
35
35
  begin
36
- @version = read_version
36
+ @version = read_version || ""
37
37
  rescue Subprocess::LaunchError
38
38
  # This means that VirtualBox was not found, so we raise this
39
39
  # error here.
@@ -113,8 +113,13 @@ module Vagrant
113
113
  # * 4.1.8r1234_OSE
114
114
  # * 4.1.8_MacPortsr1234
115
115
  #
116
- # Below accounts for all of these:
117
- execute("--version").split("_")[0].split("r")[0]
116
+ # Below accounts for all of these.
117
+
118
+ # Note: We split this into multiple lines because apparently "".split("_")
119
+ # is [], so we have to check for an empty array in between.
120
+ parts = execute("--version").split("_")
121
+ return nil if parts.empty?
122
+ parts[0].split("r")[0]
118
123
  end
119
124
  end
120
125
  end
@@ -38,7 +38,7 @@ module Vagrant
38
38
  # each specifically, we avoid reconfiguring eth0 (the NAT interface) so
39
39
  # SSH never dies.
40
40
  interfaces.each do |interface|
41
- vm.channel.sudo("/sbin/ifconfig eth#{interface} down 2> /dev/null")
41
+ vm.channel.sudo("/sbin/ifdown eth#{interface} 2> /dev/null")
42
42
  end
43
43
 
44
44
  vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/network/interfaces")
@@ -1,9 +1,17 @@
1
+ require 'log4r'
2
+
1
3
  require 'vagrant/guest/linux/error'
2
4
  require 'vagrant/guest/linux/config'
3
5
 
4
6
  module Vagrant
5
7
  module Guest
6
8
  class Linux < Base
9
+ def initialize(*args)
10
+ super
11
+
12
+ @logger = Log4r::Logger.new("vagrant::guest::linux")
13
+ end
14
+
7
15
  def distro_dispatch
8
16
  if @vm.channel.test("cat /etc/debian_version")
9
17
  return :debian if @vm.channel.test("cat /proc/version | grep 'Debian'")
@@ -20,32 +28,53 @@ module Vagrant
20
28
  end
21
29
 
22
30
  def halt
23
- vm.channel.sudo("shutdown -h now")
31
+ @vm.channel.sudo("shutdown -h now")
24
32
 
25
33
  # Wait until the VM's state is actually powered off. If this doesn't
26
34
  # occur within a reasonable amount of time (15 seconds by default),
27
35
  # then simply return and allow Vagrant to kill the machine.
28
36
  count = 0
29
- while vm.state != :poweroff
37
+ while @vm.state != :poweroff
30
38
  count += 1
31
39
 
32
- return if count >= vm.config.linux.halt_timeout
33
- sleep vm.config.linux.halt_check_interval
40
+ return if count >= @vm.config.linux.halt_timeout
41
+ sleep @vm.config.linux.halt_check_interval
34
42
  end
35
43
  end
36
44
 
37
45
  def mount_shared_folder(name, guestpath, options)
38
- @vm.channel.sudo("mkdir -p #{guestpath}")
39
- mount_folder(name, guestpath, options)
40
- @vm.channel.sudo("chown `id -u #{options[:owner]}`:`id -g #{options[:group]}` #{guestpath}")
46
+ # Determine the real guest path. Since we use a `sudo` shell everywhere
47
+ # else, things like '~' don't expand properly in shared folders. We have
48
+ # to `echo` here to get that path.
49
+ real_guestpath = nil
50
+ @vm.channel.execute("echo #{guestpath}") do |type, data|
51
+ if type == :stdout
52
+ real_guestpath ||= ""
53
+ real_guestpath += data
54
+ end
55
+ end
56
+
57
+ if !real_guestpath
58
+ # Really strange error case if this happens. Let's throw an error,
59
+ # tell the user to check the echo output.
60
+ raise LinuxError, :_key => :guestpath_expand_fail
61
+ end
62
+
63
+ # Chomp off the newline if it exists
64
+ real_guestpath = real_guestpath.chomp
65
+ @logger.debug("Shell expanded guest path: #{real_guestpath}")
66
+
67
+ @vm.channel.sudo("mkdir -p #{real_guestpath}")
68
+ mount_folder(name, real_guestpath, options)
69
+ @vm.channel.sudo("chown `id -u #{options[:owner]}`:`id -g #{options[:group]}` #{real_guestpath}")
41
70
  end
42
71
 
43
72
  def mount_nfs(ip, folders)
44
73
  # TODO: Maybe check for nfs support on the guest, since its often
45
74
  # not installed by default
46
75
  folders.each do |name, opts|
47
- vm.channel.sudo("mkdir -p #{opts[:guestpath]}")
48
- vm.channel.sudo("mount #{ip}:'#{opts[:hostpath]}' #{opts[:guestpath]}",
76
+ @vm.channel.sudo("mkdir -p #{opts[:guestpath]}")
77
+ @vm.channel.sudo("mount #{ip}:'#{opts[:hostpath]}' #{opts[:guestpath]}",
49
78
  :error_class => LinuxError,
50
79
  :error_key => :mount_nfs_fail)
51
80
  end
@@ -115,11 +115,11 @@ module Vagrant
115
115
  attr_accessor :attempts
116
116
  attr_writer :run_list
117
117
 
118
- def initialize
119
- @attempts = 1
120
- @json = {}
121
- @log_level = :info
122
- end
118
+ # Provide defaults in such a way that they won't override the instance
119
+ # variable. This is so merging continues to work properly.
120
+ def attempts; @attempts || 1; end
121
+ def json; @json ||= {}; end
122
+ def log_level; @log_level || :info; end
123
123
 
124
124
  # This returns the json that is merged with the defaults and the
125
125
  # user set data.
@@ -147,6 +147,12 @@ module Vagrant
147
147
  run_list << name
148
148
  end
149
149
 
150
+ def validate(env, errors)
151
+ super
152
+
153
+ errors.add(I18n.t("vagrant.config.chef.vagrant_as_json_key")) if json.has_key?(:vagrant)
154
+ end
155
+
150
156
  def instance_variables_hash
151
157
  # Overridden so that the 'json' key could be removed, since its just
152
158
  # merged into the config anyways
@@ -18,15 +18,13 @@ module Vagrant
18
18
  attr_accessor :encrypted_data_bag_secret_key_path
19
19
  attr_accessor :encrypted_data_bag_secret
20
20
 
21
- def initialize
22
- super
23
-
24
- @validation_client_name = "chef-validator"
25
- @client_key_path = "/etc/chef/client.pem"
26
- @file_cache_path = "/srv/chef/file_store"
27
- @file_backup_path = "/srv/chef/cache"
28
- @encrypted_data_bag_secret = "/tmp/encrypted_data_bag_secret"
29
- end
21
+ # Provide defaults in such a way that they won't override the instance
22
+ # variable. This is so merging continues to work properly.
23
+ def validation_client_name; @validation_client_name || "chef-validator"; end
24
+ def client_key_path; @client_key_path || "/etc/chef/client.pem"; end
25
+ def file_cache_path; @file_cache_path || "/srv/chef/file_store"; end
26
+ def file_backup_path; @file_backup_path || "/srv/chef/cache"; end
27
+ def encrypted_data_bag_secret; @encrypted_data_bag_secret || "/tmp/encrypted_data_bag_secret"; end
30
28
 
31
29
  def validate(env, errors)
32
30
  super
@@ -19,8 +19,24 @@ module Vagrant
19
19
  def initialize
20
20
  super
21
21
 
22
- @cookbooks_path = ["cookbooks", [:vm, "cookbooks"]]
23
- @nfs = false
22
+ @__default = ["cookbooks", [:vm, "cookbooks"]]
23
+ end
24
+
25
+ # Provide defaults in such a way that they won't override the instance
26
+ # variable. This is so merging continues to work properly.
27
+ def cookbooks_path
28
+ @cookbooks_path || _default_cookbook_path
29
+ end
30
+
31
+ # This stores a reference to the default cookbook path which is used
32
+ # later. Do not use this publicly. I apologize for not making it
33
+ # "protected" but it has to be called by Vagrant internals later.
34
+ def _default_cookbook_path
35
+ @__default
36
+ end
37
+
38
+ def nfs
39
+ @nfs || false
24
40
  end
25
41
 
26
42
  def validate(env, errors)
@@ -83,16 +99,27 @@ module Vagrant
83
99
  # path element which contains the folder location (:host or :vm)
84
100
  paths = [paths] if paths.is_a?(String) || paths.first.is_a?(Symbol)
85
101
 
86
- paths.map do |path|
102
+ results = []
103
+ paths.each do |path|
87
104
  path = [:host, path] if !path.is_a?(Array)
88
105
  type, path = path
89
106
 
90
107
  # Create the local/remote path based on whether this is a host
91
108
  # or VM path.
92
109
  local_path = nil
93
- local_path = File.expand_path(path, env[:root_path]) if type == :host
94
110
  remote_path = nil
95
111
  if type == :host
112
+ # Get the expanded path that the host path points to
113
+ local_path = File.expand_path(path, env[:root_path])
114
+
115
+ # Super hacky but if we're expanded the default cookbook paths,
116
+ # and one of the host paths doesn't exist, then just ignore it,
117
+ # because that is fine.
118
+ if paths.equal?(config._default_cookbook_path) && !File.directory?(local_path)
119
+ @logger.info("'cookbooks' folder doesn't exist on defaults. Ignoring.")
120
+ next
121
+ end
122
+
96
123
  # Path exists on the host, setup the remote path
97
124
  remote_path = "#{config.provisioning_path}/chef-solo-#{get_and_update_counter(:cookbooks_path)}"
98
125
  else
@@ -110,9 +137,11 @@ module Vagrant
110
137
  # If we have specified a folder name to append then append it
111
138
  remote_path += "/#{appended_folder}" if appended_folder
112
139
 
113
- # Return the result
114
- [type, local_path, remote_path]
140
+ # Append the result
141
+ results << [type, local_path, remote_path]
115
142
  end
143
+
144
+ results
116
145
  end
117
146
 
118
147
  # Shares the given folders with the given prefix. The folders should
@@ -44,6 +44,16 @@ module Vagrant
44
44
  !bit64?
45
45
  end
46
46
 
47
+ # Returns a boolean noting whether the terminal supports color.
48
+ # output.
49
+ def terminal_supports_colors?
50
+ if windows?
51
+ return ENV.has_key?("ANSICON")
52
+ end
53
+
54
+ true
55
+ end
56
+
47
57
  def tar_file_options
48
58
  # create, write only, fail if the file exists, binary if windows
49
59
  File::WRONLY | File::EXCL | File::CREAT | (windows? ? File::BINARY : 0)
@@ -69,7 +69,7 @@ module Vagrant
69
69
  stderr_writer.close
70
70
 
71
71
  # Create a dictionary to store all the output we see.
72
- io_data = { stdout => "", stderr => "" }
72
+ io_data = { :stdout => "", :stderr => "" }
73
73
 
74
74
  # Record the start time for timeout purposes
75
75
  start_time = Time.now.to_i
@@ -94,7 +94,7 @@ module Vagrant
94
94
  io_name = r == stdout ? :stdout : :stderr
95
95
  @logger.debug("#{io_name}: #{data}")
96
96
 
97
- io_data[r] += data
97
+ io_data[io_name] += data
98
98
  yield io_name, data if block_given?
99
99
  end
100
100
  end
@@ -133,15 +133,15 @@ module Vagrant
133
133
 
134
134
  # Log it out and accumulate
135
135
  @logger.debug(extra_data)
136
- io_data[io] += extra_data
136
+ io_name = io == stdout ? :stdout : :stderr
137
+ io_data[io_name] += extra_data
137
138
 
138
139
  # Yield to any listeners any remaining data
139
- io_name = io == stdout ? :stdout : :stderr
140
140
  yield io_name, extra_data if block_given?
141
141
  end
142
142
 
143
143
  # Return an exit status container
144
- return Result.new(process.exit_code, io_data[stdout], io_data[stderr])
144
+ return Result.new(process.exit_code, io_data[:stdout], io_data[:stderr])
145
145
  end
146
146
 
147
147
  protected
@@ -2,5 +2,5 @@ module Vagrant
2
2
  # This will always be up to date with the current version of Vagrant,
3
3
  # since it is used to generate the gemspec and is also the source of
4
4
  # the version for `vagrant -v`
5
- VERSION = "0.9.1"
5
+ VERSION = "0.9.2"
6
6
  end
@@ -49,7 +49,7 @@ module Vagrant
49
49
  @logger.info("Loading guest: #{guest}")
50
50
 
51
51
  if guest.is_a?(Class)
52
- raise Errors::VMGuestError, :_key => :invalid_class, :system => guest.to_s if !(guest <= Systems::Base)
52
+ raise Errors::VMGuestError, :_key => :invalid_class, :system => guest.to_s if !(guest <= Guest::Base)
53
53
  @guest = guest.new(self)
54
54
  elsif guest.is_a?(Symbol)
55
55
  guest_klass = Vagrant.guests.get(guest)
@@ -188,9 +188,11 @@ en:
188
188
  common:
189
189
  error_empty: "`%{field}` must be filled in."
190
190
  chef:
191
- run_list_empty: "Run list must not be empty."
192
191
  cookbooks_path_empty: "Must specify a cookbooks path for chef solo."
192
+ run_list_empty: "Run list must not be empty."
193
193
  server_url_empty: "Chef server URL must be populated."
194
+ vagrant_as_json_key: |-
195
+ `vagrant` cannot be a JSON key, because it is used by Vagrant already.
194
196
  validation_key_path: "Validation key path must be valid path to your chef server validation key."
195
197
  ssh:
196
198
  private_key_missing: "`private_key_path` file must exist: %{path}"
@@ -667,6 +669,11 @@ en:
667
669
  back the logic necessary to set this up. Please report a bug as well as the
668
670
  box you're using.
669
671
  linux:
672
+ guestpath_expand_fail: |-
673
+ Vagrant failed to determine the shell expansion of the guest path
674
+ for one of your shared folders. This is an extremely rare error case
675
+ and most likely indicates an unusual configuration of the guest system.
676
+ Please report a bug with your Vagrantfile.
670
677
  mount_fail: "Failed to mount shared folders. `vboxsf` was not available."
671
678
  mount_nfs_fail: |-
672
679
  Mounting NFS shared folders failed. This is most often caused by the NFS
@@ -0,0 +1,84 @@
1
+ require File.expand_path("../base", __FILE__)
2
+ require "acceptance/support/shared/command_examples"
3
+
4
+ describe "vagrant shared folders" do
5
+ include_context "acceptance"
6
+
7
+ # This creates an initial environment that is ready for a "vagrant up"
8
+ def initialize_valid_environment
9
+ require_box("default")
10
+
11
+ assert_execute("vagrant", "box", "add", "base", box_path("default"))
12
+ assert_execute("vagrant", "init")
13
+ end
14
+
15
+ it "should have a '/vagrant' shared folder" do
16
+ initialize_valid_environment
17
+
18
+ # This is the file that will be created from the VM,
19
+ # but should then exist on the host machine
20
+ foofile = environment.workdir.join("foo")
21
+
22
+ assert_execute("vagrant", "up")
23
+ foofile.exist?.should_not be,
24
+ "'foo' should not exist yet."
25
+
26
+ assert_execute("vagrant", "ssh", "-c", "touch /vagrant/foo")
27
+ foofile.exist?.should be, "'foo' should exist since it was touched in the shared folder"
28
+ end
29
+
30
+ it "should create a shared folder if the :create flag is set" do
31
+ initialize_valid_environment
32
+
33
+ # Setup the custom Vagrantfile
34
+ environment.workdir.join("Vagrantfile").open("w+") do |f|
35
+ f.write(<<-VF)
36
+ Vagrant::Config.run do |config|
37
+ config.vm.box = "base"
38
+ config.vm.share_folder "v-root", "/vagrant", "./data", :create => true
39
+ end
40
+ VF
41
+ end
42
+
43
+ data_dir = environment.workdir.join("data")
44
+
45
+ # Verify the directory doesn't exist prior, for sanity
46
+ data_dir.exist?.should_not be
47
+
48
+ # Bring up the VM
49
+ assert_execute("vagrant", "up")
50
+
51
+ # Verify the directory exists
52
+ data_dir.should be_directory
53
+
54
+ # Touch a file and verify it is shared
55
+ assert_execute("vagrant", "ssh", "-c", "touch /vagrant/foo")
56
+ data_dir.join("foo").exist?.should be
57
+ end
58
+
59
+ it "should properly shell expand relative directories on the guest" do
60
+ initialize_valid_environment
61
+
62
+ # Setup the custom Vagrantfile
63
+ environment.workdir.join("Vagrantfile").open("w+") do |f|
64
+ f.write(<<-VF)
65
+ Vagrant::Config.run do |config|
66
+ config.vm.box = "base"
67
+ config.vm.share_folder "v-root", "~/data", "."
68
+ end
69
+ VF
70
+ end
71
+
72
+ # Sanity
73
+ foo_file = environment.workdir.join("foo")
74
+ foo_file.exist?.should_not be
75
+
76
+ # Bring up the VM
77
+ assert_execute("vagrant", "up")
78
+
79
+ # Touch a file in the shared folder we expect and verify
80
+ # it is shared.
81
+ assert_execute("vagrant", "ssh", "-c", "touch ~/data/foo")
82
+ foo_file.exist?.should be
83
+ end
84
+ end
@@ -30,48 +30,4 @@ describe "vagrant up", "basics" do
30
30
  foodir.mkdir
31
31
  assert_execute("vagrant", "up", :chdir => foodir.to_s)
32
32
  end
33
-
34
- it "should have a '/vagrant' shared folder" do
35
- initialize_valid_environment
36
-
37
- # This is the file that will be created from the VM,
38
- # but should then exist on the host machine
39
- foofile = environment.workdir.join("foo")
40
-
41
- assert_execute("vagrant", "up")
42
- foofile.exist?.should_not be,
43
- "'foo' should not exist yet."
44
-
45
- assert_execute("vagrant", "ssh", "-c", "touch /vagrant/foo")
46
- foofile.exist?.should be, "'foo' should exist since it was touched in the shared folder"
47
- end
48
-
49
- it "should create a shared folder if the :create flag is set" do
50
- initialize_valid_environment
51
-
52
- # Setup the custom Vagrantfile
53
- environment.workdir.join("Vagrantfile").open("w+") do |f|
54
- f.write(<<-VF)
55
- Vagrant::Config.run do |config|
56
- config.vm.box = "base"
57
- config.vm.share_folder "v-root", "/vagrant", "./data", :create => true
58
- end
59
- VF
60
- end
61
-
62
- data_dir = environment.workdir.join("data")
63
-
64
- # Verify the directory doesn't exist prior, for sanity
65
- data_dir.exist?.should_not be
66
-
67
- # Bring up the VM
68
- assert_execute("vagrant", "up")
69
-
70
- # Verify the directory exists
71
- data_dir.should be_directory
72
-
73
- # Touch a file and verify it is shared
74
- assert_execute("vagrant", "ssh", "-c", "touch /vagrant/foo")
75
- data_dir.join("foo").exist?.should be
76
- end
77
33
  end
@@ -22,4 +22,26 @@ describe Vagrant::Config::Base do
22
22
  result.one.should == 2
23
23
  result.two.should == 5
24
24
  end
25
+
26
+ it "doesn't merge values that start with a double underscore" do
27
+ bar_class = Class.new(foo_class) do
28
+ @@counter = 0
29
+ def initialize
30
+ @__test = @@counter
31
+ @@counter += 1
32
+ end
33
+ end
34
+
35
+ one = bar_class.new
36
+ one.one = 2
37
+ one.two = 1
38
+
39
+ two = bar_class.new
40
+ two.two = 5
41
+
42
+ # Verify the counters
43
+ one.instance_variable_get(:@__test).should == 0
44
+ two.instance_variable_get(:@__test).should == 1
45
+ one.merge(two).instance_variable_get(:@__test).should == 2
46
+ end
25
47
  end
@@ -0,0 +1,17 @@
1
+ require File.expand_path("../../../base", __FILE__)
2
+
3
+ describe Vagrant::Config::SSHConfig do
4
+ include_context "unit"
5
+
6
+ [:forward_agent, :forward_x11].each do |bool_setting|
7
+ it "merges boolean #{bool_setting} properly" do
8
+ a = described_class.new
9
+ a.send("#{bool_setting}=", true)
10
+
11
+ b = described_class.new
12
+
13
+ c = a.merge(b)
14
+ c.send(bool_setting).should be
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 63
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 1
10
- version: 0.9.1
9
+ - 2
10
+ version: 0.9.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mitchell Hashimoto
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-01-18 00:00:00 Z
19
+ date: 2012-01-20 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -456,6 +456,7 @@ files:
456
456
  - test/acceptance/provisioning/chef_solo_test.rb
457
457
  - test/acceptance/provisioning/shell_test.rb
458
458
  - test/acceptance/resume_test.rb
459
+ - test/acceptance/shared_folders_test.rb
459
460
  - test/acceptance/skeletons/chef_solo_basic/README.md
460
461
  - test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb
461
462
  - test/acceptance/skeletons/chef_solo_json/README.md
@@ -557,6 +558,7 @@ files:
557
558
  - test/unit/vagrant/command/base_test.rb
558
559
  - test/unit/vagrant/config/base_test.rb
559
560
  - test/unit/vagrant/config/loader_test.rb
561
+ - test/unit/vagrant/config/ssh_test.rb
560
562
  - test/unit/vagrant/config/top_test.rb
561
563
  - test/unit/vagrant/config/vm_test.rb
562
564
  - test/unit/vagrant/config_test.rb