vagrant 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.6.5 (October 8, 2010)
2
+
3
+ - Validations on base MAC address to avoid situation described in GH-166, GH-181
4
+ from ever happening again.
5
+ - Properly load sub-VM configuration on first-pass of config loading. Solves
6
+ a LOT of problems with multi-VM. [GH-166] [GH-181]
7
+ - Configuration now only validates on final Vagrantfile proc, so multi-VM
8
+ validates correctly.
9
+ - A nice error message is given if ".vagrant" is a directory and therefore
10
+ can't be accessed. [GH-172]
11
+ - Fix plugin loading in a Rails 2.3.x project. [GH-176]
12
+
1
13
  ## 0.6.4 (October 4, 2010)
2
14
 
3
15
  - Default VM name is now properly the parent folder of the working directory
data/Gemfile.lock CHANGED
@@ -8,7 +8,7 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- vagrant (0.6.4)
11
+ vagrant (0.6.5)
12
12
  archive-tar-minitar (= 0.5.2)
13
13
  erubis (~> 2.6.6)
14
14
  i18n (~> 0.4.1)
@@ -58,7 +58,7 @@ GEM
58
58
  ruby-debug-base19 (>= 0.11.19)
59
59
  ruby_core_source (0.1.4)
60
60
  archive-tar-minitar (>= 0.5.2)
61
- thor (0.14.2)
61
+ thor (0.14.3)
62
62
  yard (0.6.1)
63
63
 
64
64
  PLATFORMS
data/config/default.rb CHANGED
@@ -16,7 +16,7 @@ Vagrant::Config.run do |config|
16
16
  config.vm.auto_port_range = (2200..2250)
17
17
  config.vm.box_ovf = "box.ovf"
18
18
  config.vm.box_url = nil
19
- config.vm.base_mac = "0800279C2E42"
19
+ config.vm.base_mac = nil
20
20
  config.vm.forward_port("ssh", 22, 2222, :auto => true)
21
21
  config.vm.disk_image_format = 'VMDK'
22
22
  config.vm.provisioner = nil
@@ -7,6 +7,8 @@ module Vagrant
7
7
  end
8
8
 
9
9
  def call(env)
10
+ raise Errors::VMBaseMacNotSpecified if !env.env.config.vm.base_mac
11
+
10
12
  env.ui.info I18n.t("vagrant.actions.vm.match_mac.matching")
11
13
  env["vm"].vm.network_adapters.first.mac_address = env.env.config.vm.base_mac
12
14
  env["vm"].vm.save
@@ -68,11 +68,13 @@ module Vagrant
68
68
  # and returns the final configured object. This also validates the
69
69
  # configuration by calling {Top#validate!} on every configuration
70
70
  # class.
71
- def execute!(config_object=nil)
71
+ def execute!(validate=true)
72
72
  config_object ||= config
73
-
74
73
  run_procs!(config_object)
75
- config_object.validate!
74
+
75
+ # Validate if we're looking at a config object which represents a
76
+ # real VM.
77
+ config_object.validate! if validate && config_object.env.vm
76
78
  config_object
77
79
  end
78
80
  end
@@ -88,7 +90,7 @@ module Vagrant
88
90
 
89
91
  # Loads the queue of files/procs, executes them in the proper
90
92
  # sequence, and returns the resulting configuration object.
91
- def load!
93
+ def load!(validate=true)
92
94
  self.class.reset!(@env)
93
95
 
94
96
  queue.flatten.each do |item|
@@ -104,7 +106,7 @@ module Vagrant
104
106
  end
105
107
  end
106
108
 
107
- return self.class.execute!
109
+ return self.class.execute!(validate)
108
110
  end
109
111
  end
110
112
 
@@ -105,6 +105,7 @@ module Vagrant
105
105
  end
106
106
 
107
107
  errors.add(I18n.t("vagrant.config.vm.boot_mode_invalid")) if ![:vrdp, :gui].include?(boot_mode.to_sym)
108
+ errors.add(I18n.t("vagrant.config.vm.base_mac_invalid")) if !base_mac
108
109
  end
109
110
  end
110
111
  end
@@ -24,6 +24,8 @@ module Vagrant
24
24
  end
25
25
  rescue Errno::ENOENT
26
26
  clear
27
+ rescue Errno::EISDIR
28
+ raise Errors::DotfileIsDirectory
27
29
  end
28
30
 
29
31
  # Commits any changes to the data to disk. Even if the data
@@ -158,7 +158,7 @@ module Vagrant
158
158
  if parent
159
159
  parent.multivm?
160
160
  else
161
- vms.length > 1
161
+ vms.length > 1 || vms.keys.first != DEFAULT_VM
162
162
  end
163
163
  end
164
164
 
@@ -306,14 +306,14 @@ module Vagrant
306
306
 
307
307
  # If this environment is representing a sub-VM, then we push that
308
308
  # proc on as the last configuration.
309
- if !first_run && vm
309
+ if vm
310
310
  subvm = parent.config.vm.defined_vms[vm.name]
311
311
  loader.queue << subvm.proc_stack if subvm
312
312
  end
313
313
 
314
314
  # Execute the configuration stack and store the result as the final
315
315
  # value in the config ivar.
316
- @config = loader.load!
316
+ @config = loader.load!(!first_run)
317
317
 
318
318
  # (re)load the logger
319
319
  @logger = nil
@@ -133,6 +133,11 @@ module Vagrant
133
133
  error_key(:config_validation)
134
134
  end
135
135
 
136
+ class DotfileIsDirectory < VagrantError
137
+ status_code(46)
138
+ error_key(:dotfile_is_directory)
139
+ end
140
+
136
141
  class DownloaderFileDoesntExist < VagrantError
137
142
  status_code(37)
138
143
  error_key(:file_missing, "vagrant.downloaders.file")
@@ -278,6 +283,11 @@ module Vagrant
278
283
  error_key(:virtualbox_not_detected)
279
284
  end
280
285
 
286
+ class VMBaseMacNotSpecified < VagrantError
287
+ status_code(47)
288
+ error_key(:no_base_mac, "vagrant.actions.vm.match_mac")
289
+ end
290
+
281
291
  class VMFailedToBoot < VagrantError
282
292
  status_code(21)
283
293
  error_key(:failed_to_boot, "vagrant.actions.vm.boot")
@@ -21,13 +21,20 @@ module Vagrant
21
21
  # load path. This file is loaded to kick off the load sequence
22
22
  # for that plugin.
23
23
  def self.load!
24
+ # Stupid hack since Rails 2.3.x overrides Gem.source_index with their
25
+ # own incomplete replacement which causes issues.
26
+ index = Gem.source_index
27
+ index = [index.installed_source_index, index.vendor_source_index] if defined?(Rails::VendorGemSourceIndex) && index.is_a?(Rails::VendorGemSourceIndex)
28
+
24
29
  # Look for a vagrant_init.rb in all the gems, but only the
25
30
  # latest version of the gems.
26
- Gem.source_index.latest_specs.each do |spec|
27
- file = Gem.searcher.matching_files(spec, "vagrant_init.rb").first
28
- next if !file
31
+ [index].flatten.each do |source|
32
+ source.latest_specs.each do |spec|
33
+ file = Gem.searcher.matching_files(spec, "vagrant_init.rb").first
34
+ next if !file
29
35
 
30
- @@plugins << new(spec, file)
36
+ @@plugins << new(spec, file)
37
+ end
31
38
  end
32
39
  end
33
40
 
@@ -29,6 +29,7 @@ module Vagrant
29
29
  File.open(path.to_s, "w") do |f|
30
30
  f.puts "Vagrant::Config.run do |config|"
31
31
  f.puts "config.vagrant.home = '#{home_path}'"
32
+ f.puts "config.vm.base_mac = 'foo' if !config.vm.base_mac"
32
33
  f.puts str
33
34
  f.puts "end"
34
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.6.4"
5
+ VERSION = "0.6.5"
6
6
  end
@@ -15,6 +15,12 @@ en:
15
15
  are printed below:
16
16
 
17
17
  %{messages}
18
+ dotfile_is_directory: |-
19
+ The local file Vagrant uses to store data ".vagrant" already exists
20
+ and is a directory! If you are in your home directory, then please run
21
+ this command in another directory. If you aren't in a home directory,
22
+ then please rename ".vagrant" to something else, or configure Vagrant
23
+ to use another filename by modifying `config.vagrant.dotfile_name`.
18
24
  interrupted: Vagrant exited after cleanup due to external interrupt.
19
25
  multi_vm_required: A multi-vm environment is required for name specification to this command.
20
26
  multi_vm_target_required: `vagrant %{command}` requires a specific VM name to target in a multi-VM environment.
@@ -107,8 +113,9 @@ en:
107
113
  ssh:
108
114
  private_key_missing: "`private_key_path` file must exist: %{path}"
109
115
  vm:
110
- shared_folder_hostpath_missing: "Shared folder host path for '%{name}' doesn't exist: %{path}"
116
+ base_mac_invalid: "Base MAC address for eth0/NAT must be set. Contact box maintainer for more information."
111
117
  boot_mode_invalid: "Boot mode must be one of: vrdp or gui"
118
+ shared_folder_hostpath_missing: "Shared folder host path for '%{name}' doesn't exist: %{path}"
112
119
 
113
120
  #-------------------------------------------------------------------------------
114
121
  # Translations for commands. e.g. `vagrant x`
@@ -258,6 +265,11 @@ en:
258
265
  manually for more verbose error output.
259
266
  match_mac:
260
267
  matching: Matching MAC address for NAT networking...
268
+ no_base_mac: |-
269
+ No base MAC address was specified. This is required for the NAT networking
270
+ to work properly (and hence port forwarding, SSH, etc.). Specifying this
271
+ MAC address is typically up to the box and box maintiner. Please contact
272
+ the relevant person to solve this issue.
261
273
  network:
262
274
  collides: |-
263
275
  The specified host network collides with a non-hostonly network!
@@ -25,4 +25,12 @@ class MatchMACAddressVMActionTest < Test::Unit::TestCase
25
25
 
26
26
  @instance.call(@env)
27
27
  end
28
+
29
+ should "raise an exception if no base MAC address is specified" do
30
+ @env.env.config.vm.base_mac = nil
31
+
32
+ assert_raises(Vagrant::Errors::VMBaseMacNotSpecified) {
33
+ @instance.call(@env)
34
+ }
35
+ end
28
36
  end
@@ -39,11 +39,11 @@ class CommandHelpersTest < Test::Unit::TestCase
39
39
 
40
40
  context "without multivm" do
41
41
  setup do
42
- @env.stubs(:vms).returns({ :one => 1 })
42
+ @env.stubs(:vms).returns({ :one => 1, :two => 2 })
43
43
  end
44
44
 
45
45
  should "raise an exception if a name is specified" do
46
- instance = command(["foo"], @env)
46
+ instance = command(["foo"], vagrant_env)
47
47
  assert_raises(Vagrant::Errors::MultiVMEnvironmentRequired) {
48
48
  instance.target_vms
49
49
  }
@@ -10,7 +10,6 @@ class ConfigTest < Test::Unit::TestCase
10
10
  @env = vagrant_env
11
11
  @instance = @klass.new(@env)
12
12
 
13
- # Don't want validation to occur for these tests
14
13
  @klass::Top.any_instance.stubs(:validate!)
15
14
  end
16
15
 
@@ -21,10 +20,17 @@ class ConfigTest < Test::Unit::TestCase
21
20
  should "reset the config class on load, then execute" do
22
21
  seq = sequence("sequence")
23
22
  @klass.expects(:reset!).with(@env).in_sequence(seq)
24
- @klass.expects(:execute!).in_sequence(seq)
23
+ @klass.expects(:execute!).with(true).in_sequence(seq)
25
24
  @instance.load!
26
25
  end
27
26
 
27
+ should "not validate if told not to" do
28
+ seq = sequence("sequence")
29
+ @klass.expects(:reset!).with(@env).in_sequence(seq)
30
+ @klass.expects(:execute!).with(false).in_sequence(seq)
31
+ @instance.load!(false)
32
+ end
33
+
28
34
  should "run the queue in the order given" do
29
35
  @instance.queue << Proc.new { |config| config.vm.box = "foo" }
30
36
  @instance.queue << Proc.new { |config| config.vm.box = "bar" }
@@ -74,6 +80,7 @@ class ConfigTest < Test::Unit::TestCase
74
80
 
75
81
  context "resetting" do
76
82
  setup do
83
+ @klass.reset!(vagrant_env)
77
84
  @klass::Top.any_instance.stubs(:validate!)
78
85
  @klass.run { |config| }
79
86
  @klass.execute!
@@ -105,7 +112,7 @@ class ConfigTest < Test::Unit::TestCase
105
112
 
106
113
  context "initializing" do
107
114
  setup do
108
- @klass.reset!
115
+ @klass.reset!(vagrant_env)
109
116
  @klass::Top.any_instance.stubs(:validate!)
110
117
  end
111
118
 
@@ -115,25 +122,34 @@ class ConfigTest < Test::Unit::TestCase
115
122
  assert_equal [proc], @klass.proc_stack
116
123
  end
117
124
 
118
- should "run the proc stack with the config when execute is called" do
125
+ should "run the validation on an environment which represents a VM" do
126
+ @klass.reset!(vagrant_env.vms[:default].env)
119
127
  seq = sequence('seq')
120
128
  @klass.expects(:run_procs!).with(@klass.config).once.in_sequence(seq)
121
129
  @klass.config.expects(:validate!).once.in_sequence(seq)
122
130
  @klass.execute!
123
131
  end
124
132
 
133
+ should "not run the validation on an environment that doesn't directly represent a VM" do
134
+ seq = sequence('seq')
135
+ @klass.expects(:run_procs!).with(@klass.config).once.in_sequence(seq)
136
+ @klass.expects(:validate!).never
137
+ @klass.execute!
138
+ end
139
+
140
+ should "not run the validation if explicitly told not to" do
141
+ @klass.reset!(vagrant_env.vms[:default].env)
142
+ seq = sequence('seq')
143
+ @klass.expects(:run_procs!).with(@klass.config).once.in_sequence(seq)
144
+ @klass.config.expects(:validate!).never
145
+ @klass.execute!(false)
146
+ end
147
+
125
148
  should "return the configuration on execute!" do
126
149
  @klass.run {}
127
150
  result = @klass.execute!
128
151
  assert result.is_a?(@klass::Top)
129
152
  end
130
-
131
- should "use given configuration object if given" do
132
- fake_env = mock("env")
133
- config = @klass::Top.new(fake_env)
134
- result = @klass.execute!(config)
135
- assert_equal config.env, result.env
136
- end
137
153
  end
138
154
 
139
155
  context "top config class" do
@@ -1,3 +1,4 @@
1
+ require "fileutils"
1
2
  require "test_helper"
2
3
 
3
4
  class DataStoreTest < Test::Unit::TestCase
@@ -11,7 +12,15 @@ class DataStoreTest < Test::Unit::TestCase
11
12
  end
12
13
 
13
14
  teardown do
14
- File.delete(@db_file) if File.file?(@db_file)
15
+ File.delete(@db_file) if File.exist?(@db_file)
16
+ end
17
+
18
+ should "raise an exception if the db file is a directory" do
19
+ file = tmp_path.join("data_store_folder_test")
20
+ FileUtils.mkdir_p(file)
21
+ assert_raises (Vagrant::Errors::DotfileIsDirectory) {
22
+ @klass.new(file)
23
+ }
15
24
  end
16
25
 
17
26
  should "be a hash with indifferent access" do
@@ -129,12 +129,16 @@ class EnvironmentTest < Test::Unit::TestCase
129
129
  assert env.multivm?
130
130
  end
131
131
 
132
- should "return false if VM length is 1" do
132
+ should "return true if VM length is 1 and a sub-VM is defined" do
133
133
  env = vagrant_env(vagrantfile(<<-vf))
134
134
  config.vm.define :web
135
135
  vf
136
136
 
137
- assert !env.multivm?
137
+ assert env.multivm?
138
+ end
139
+
140
+ should "return false if only default VM exists" do
141
+ assert !vagrant_env.multivm?
138
142
  end
139
143
  end
140
144
 
@@ -361,7 +365,10 @@ class EnvironmentTest < Test::Unit::TestCase
361
365
  end
362
366
 
363
367
  def create_box_vagrantfile
364
- vagrantfile(vagrant_box("box"), 'config.package.name = "box.box"')
368
+ vagrantfile(vagrant_box("box"), <<-FILE)
369
+ config.package.name = "box.box"
370
+ config.vm.base_mac = "set"
371
+ FILE
365
372
  end
366
373
 
367
374
  def create_home_vagrantfile
@@ -396,15 +403,18 @@ class EnvironmentTest < Test::Unit::TestCase
396
403
 
397
404
  should "load from a sub-vm configuration if environment represents a VM" do
398
405
  create_home_vagrantfile
406
+ create_box_vagrantfile
399
407
  vagrantfile(@env.root_path, <<-vf)
400
408
  config.package.name = "root.box"
401
409
  config.vm.define :web do |web|
410
+ web.vm.box = "box"
402
411
  web.package.name = "web.box"
403
412
  end
404
413
  vf
405
414
 
406
415
  assert_equal "root.box", @env.config.package.name
407
416
  assert_equal "web.box", @env.vms[:web].env.config.package.name
417
+ assert_equal "set", @env.vms[:web].env.config.vm.base_mac
408
418
  end
409
419
 
410
420
  should "reload the logger after executing" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 4
9
- version: 0.6.4
8
+ - 5
9
+ version: 0.6.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mitchell Hashimoto
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-04 00:00:00 -07:00
18
+ date: 2010-10-08 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -455,7 +455,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
455
455
  requirements:
456
456
  - - ">="
457
457
  - !ruby/object:Gem::Version
458
- hash: -4185578386053162887
458
+ hash: 2202900524961152479
459
459
  segments:
460
460
  - 0
461
461
  version: "0"