vagrant 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,11 @@
1
+ ## 0.9.3 (January 24, 2012)
2
+
3
+ - Proper error handling for not enough arguments to `box` commands.
4
+ - Fix issue causing crashes with bridged networking. [GH-673]
5
+ - Ignore host only network interfaces that are "down." [GH-675]
6
+ - Use "printf" instead of "echo" to determine shell expanded files paths
7
+ which is more generally POSIX compliant. [GH-676]
8
+
1
9
  ## 0.9.2 (January 20, 2012)
2
10
 
3
11
  - Support shell expansions in shared folder guest paths again. [GH-656]
@@ -298,7 +298,7 @@ module Vagrant
298
298
 
299
299
  @env[:vm].driver.read_bridged_interfaces.each do |interface|
300
300
  that_netaddr = network_address(interface[:ip], interface[:netmask])
301
- raise Errors::NetworkCollision if this_netaddr == that_netaddr
301
+ raise Errors::NetworkCollision if this_netaddr == that_netaddr && interface[:status] != "Down"
302
302
  end
303
303
  end
304
304
 
@@ -341,7 +341,7 @@ module Vagrant
341
341
  chosen_bridge = bridgedifs[choice - 1][:name]
342
342
  end
343
343
 
344
- @logger.info("Bridging adapter #{config[:adapter]} to #{bridge}")
344
+ @logger.info("Bridging adapter #{config[:adapter]} to #{chosen_bridge}")
345
345
 
346
346
  # Given the choice we can now define the adapter we're using
347
347
  return {
@@ -18,6 +18,7 @@ module Vagrant
18
18
  # Parse the options
19
19
  argv = parse_options(opts)
20
20
  return if !argv
21
+ raise Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 2
21
22
 
22
23
  # If we're force adding, then be sure to destroy any existing box if it
23
24
  # exists.
@@ -13,6 +13,7 @@ module Vagrant
13
13
  # Parse the options
14
14
  argv = parse_options(opts)
15
15
  return if !argv
16
+ raise Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 1
16
17
 
17
18
  b = @env.boxes.find(argv[0])
18
19
  raise Errors::BoxNotFound, :name => argv[0] if !b
@@ -13,6 +13,7 @@ module Vagrant
13
13
  # Parse the options
14
14
  argv = parse_options(opts)
15
15
  return if !argv
16
+ raise Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 1
16
17
 
17
18
  b = @env.boxes.find(argv[0])
18
19
  raise Errors::BoxNotFound, :name => argv[0] if !b
@@ -4,6 +4,7 @@ require 'log4r'
4
4
  require 'net/ssh'
5
5
  require 'net/scp'
6
6
 
7
+ require 'vagrant/util/ansi_escape_code_remover'
7
8
  require 'vagrant/util/file_mode'
8
9
  require 'vagrant/util/platform'
9
10
  require 'vagrant/util/retryable'
@@ -12,6 +13,7 @@ module Vagrant
12
13
  module Communication
13
14
  # Provides communication with the VM via SSH.
14
15
  class SSH < Base
16
+ include Util::ANSIEscapeCodeRemover
15
17
  include Util::Retryable
16
18
 
17
19
  def initialize(vm)
@@ -169,7 +171,7 @@ module Vagrant
169
171
  ch2.on_data do |ch3, data|
170
172
  if block_given?
171
173
  # Filter out the clear screen command
172
- data.gsub!("\e[H", "")
174
+ data = remove_ansi_escape_codes(data)
173
175
  @logger.debug("stdout: #{data}")
174
176
  yield :stdout, data
175
177
  end
@@ -178,7 +180,7 @@ module Vagrant
178
180
  ch2.on_extended_data do |ch3, type, data|
179
181
  if block_given?
180
182
  # Filter out the clear screen command
181
- data.gsub!("\e[H", "")
183
+ data = remove_ansi_escape_codes(data)
182
184
  @logger.debug("stderr: #{data}")
183
185
  yield :stderr, data
184
186
  end
@@ -273,6 +273,8 @@ module Vagrant
273
273
  info[:ip] = $1.to_s
274
274
  elsif line =~ /^NetworkMask:\s+(.+?)$/
275
275
  info[:netmask] = $1.to_s
276
+ elsif line =~ /^Status:\s+(.+?)$/
277
+ info[:status] = $1.to_s
276
278
  end
277
279
  end
278
280
 
@@ -273,6 +273,8 @@ module Vagrant
273
273
  info[:ip] = $1.to_s
274
274
  elsif line =~ /^NetworkMask:\s+(.+?)$/
275
275
  info[:netmask] = $1.to_s
276
+ elsif line =~ /^Status:\s+(.+?)$/
277
+ info[:status] = $1.to_s
276
278
  end
277
279
  end
278
280
 
@@ -128,6 +128,11 @@ module Vagrant
128
128
  error_key(:failed, "vagrant.actions.box.verify")
129
129
  end
130
130
 
131
+ class CLIInvalidUsage < VagrantError
132
+ status_code(69)
133
+ error_key(:cli_invalid_usage)
134
+ end
135
+
131
136
  class CLIInvalidOptions < VagrantError
132
137
  status_code(1)
133
138
  error_key(:cli_invalid_options)
@@ -47,7 +47,7 @@ module Vagrant
47
47
  # else, things like '~' don't expand properly in shared folders. We have
48
48
  # to `echo` here to get that path.
49
49
  real_guestpath = nil
50
- @vm.channel.execute("echo #{guestpath}") do |type, data|
50
+ @vm.channel.execute("printf #{guestpath}") do |type, data|
51
51
  if type == :stdout
52
52
  real_guestpath ||= ""
53
53
  real_guestpath += data
@@ -0,0 +1,35 @@
1
+ module Vagrant
2
+ module Util
3
+ module ANSIEscapeCodeRemover
4
+ # Removes ANSI escape code sequences from the text and returns
5
+ # it.
6
+ #
7
+ # This removes all the ANSI escape codes listed here along with
8
+ # the escape codes for VT100 terminals:
9
+ #
10
+ # http://ascii-table.com/ansi-escape-sequences.php
11
+ def remove_ansi_escape_codes(text)
12
+ # An array of regular expressions which match various kinds
13
+ # of escape sequences. I can't think of a better single regular
14
+ # expression or any faster way to do this.
15
+ matchers = [/\e\[\d*[ABCD]/, # Matches things like \e[4D
16
+ /\e\[(\d*;)?\d*[HF]/, # Matches \e[1;2H or \e[H
17
+ /\e\[(s|u|2J|K)/, # Matches \e[s, \e[2J, etc.
18
+ /\e\[(\d*;){0,2}\d*m/, # Matches color escapes: \e[32m
19
+ /\e\[=\d*[hl]/, # Matches \e[=24h
20
+ /\e\[\?[1-9][hl]/, # Matches \e[?2h
21
+ /\e\[20[hl]/, # Matches \e[20l]
22
+ /\e[DME78H]/, # Matches \eD, \eH, etc.
23
+ /\e\[[0-2]?[JK]/, # Matches \e[0J, \e[K, etc.
24
+ ]
25
+
26
+ # Take each matcher and replace it with emptiness.
27
+ matchers.each do |matcher|
28
+ text.gsub!(matcher, "")
29
+ end
30
+
31
+ text
32
+ end
33
+ end
34
+ end
35
+ end
@@ -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.2"
5
+ VERSION = "0.9.3"
6
6
  end
@@ -30,6 +30,11 @@ en:
30
30
  An invalid option was specified. The help for this command
31
31
  is available below.
32
32
 
33
+ %{help}
34
+ cli_invalid_usage: |-
35
+ This command was not invoked properly. The help for this command is
36
+ available below.
37
+
33
38
  %{help}
34
39
  config_validation: |-
35
40
  There was a problem with the configuration of Vagrant. The error message(s)
@@ -25,10 +25,11 @@ describe Vagrant::Config::Base do
25
25
 
26
26
  it "doesn't merge values that start with a double underscore" do
27
27
  bar_class = Class.new(foo_class) do
28
- @@counter = 0
28
+ class_variable_set(:@@counter, 0)
29
+
29
30
  def initialize
30
- @__test = @@counter
31
- @@counter += 1
31
+ @__test = self.class.send(:class_variable_get, :@@counter)
32
+ self.class.send(:class_variable_set, :@@counter, @__test + 1)
32
33
  end
33
34
  end
34
35
 
@@ -0,0 +1,17 @@
1
+ require File.expand_path("../../../base", __FILE__)
2
+
3
+ require "vagrant/util/ansi_escape_code_remover"
4
+
5
+ describe Vagrant::Util::ANSIEscapeCodeRemover do
6
+ let(:klass) do
7
+ Class.new do
8
+ extend Vagrant::Util::ANSIEscapeCodeRemover
9
+ end
10
+ end
11
+
12
+ it "should remove ANSI escape codes" do
13
+ klass.remove_ansi_escape_codes("\e[Hyo").should == "yo"
14
+ klass.remove_ansi_escape_codes("\e[38myo").should == "yo"
15
+ end
16
+ end
17
+
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: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 2
10
- version: 0.9.2
9
+ - 3
10
+ version: 0.9.3
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-20 00:00:00 Z
19
+ date: 2012-01-24 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -410,6 +410,7 @@ files:
410
410
  - lib/vagrant/test_helpers.rb
411
411
  - lib/vagrant/ui.rb
412
412
  - lib/vagrant/util.rb
413
+ - lib/vagrant/util/ansi_escape_code_remover.rb
413
414
  - lib/vagrant/util/busy.rb
414
415
  - lib/vagrant/util/counter.rb
415
416
  - lib/vagrant/util/file_checksum.rb
@@ -569,6 +570,7 @@ files:
569
570
  - test/unit/vagrant/environment_test.rb
570
571
  - test/unit/vagrant/hosts_test.rb
571
572
  - test/unit/vagrant/registry_test.rb
573
+ - test/unit/vagrant/util/ansi_escape_code_remover_test.rb
572
574
  - test/unit/vagrant/util/file_checksum_test.rb
573
575
  - test/unit/vagrant/util/hash_with_indifferent_access_test.rb
574
576
  - test/unit/vagrant/util/network_ip_test.rb