vagrantup 0.9.7 → 0.9.99.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1d7e8f9a0b6d47c68c8cfb4192bd3afa8d9d2ce
4
- data.tar.gz: a8865e244a54fc4dcd14b54a27c87ad0740df019
3
+ metadata.gz: 2e96062b6fdca98e03dead5bc15cb7bee039c360
4
+ data.tar.gz: d22414b06f0fa20c534f940c7749420a458ac736
5
5
  SHA512:
6
- metadata.gz: 1bbd300b908863fc8a714108f1e9d11a29cbde5d9cd0ffe2be1b8e669fde5222fde1a35b05ba412ce7b3627aa3f979fcd31b1fa5b9b8a200705a1599886562cb
7
- data.tar.gz: 7c2c4860f428ffecca43814ff4929a6b2019cc89eba5fc6b4f14da7025513ba81af1a83c00fe80a332d491fea287ffe3575970ec7ab29bbe5a361ca38779de60
6
+ metadata.gz: 205eb4b0eb766e9ca4487bbe2e1ef1bdf7ff86e74e780244b94a057b512aba5061023e689bf43e1fdbb72a4e2a8f62d66bc37052a882a33621c67d32159b1d8e
7
+ data.tar.gz: 5316a1d824364e938bd798d082de4d3bd42c97afe66518d1957580f2f511f58f4df7f9235f9fb6488e618ad4f60b45f353c3d369bed913a92e12776219a4b348
data/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## 1.0.0 (unreleased)
2
+
3
+ - `vagrant gem` should now be used to install Vagrant plugins that are
4
+ gems. This installs the gems to a private gem folder that Vagrant adds
5
+ to its own load path. This isolates Vagrant-related gems from system
6
+ gems.
7
+ - Plugin loading no longer happens right when Vagrant is loaded, but when
8
+ a Vagrant environment is loaded. I don't anticipate this causing any
9
+ problems but it is a backwards incompatible change should a plugin
10
+ depend on this (but I don't see any reason why they would).
11
+ - `vagrant destroy` now asks for confirmation by default. This can be
12
+ overridden with the `--force` flag. [GH-699]
13
+ - Fix issue with Puppet config inheritance. [GH-722]
14
+ - Fix issue where starting a VM on some systems was incorrectly treated
15
+ as failing. [GH-720]
16
+ - It is now an error to specify the packaging `output` as a directory. [GH-730]
17
+ - Unix-style line endings are used properly for guest OS. [GH-727]
18
+ - Retry certain VirtualBox operations, since they intermittently fail.
19
+ [GH-726]
20
+
1
21
  ## 0.9.7 (February 9, 2012)
2
22
 
3
23
  - Fix regression where all subprocess IO simply didn't work with
data/lib/vagrant.rb CHANGED
@@ -50,6 +50,9 @@ require 'i18n'
50
50
  # there are issues with ciphers not being properly loaded.
51
51
  require 'openssl'
52
52
 
53
+ # Always make the version available
54
+ require 'vagrant/version'
55
+
53
56
  module Vagrant
54
57
  autoload :Action, 'vagrant/action'
55
58
  autoload :Box, 'vagrant/box'
@@ -136,6 +139,7 @@ I18n.load_path << File.expand_path("templates/locales/en.yml", Vagrant.source_ro
136
139
  # Register the built-in commands
137
140
  Vagrant.commands.register(:box) { Vagrant::Command::Box }
138
141
  Vagrant.commands.register(:destroy) { Vagrant::Command::Destroy }
142
+ Vagrant.commands.register(:gem) { Vagrant::Command::Gem }
139
143
  Vagrant.commands.register(:halt) { Vagrant::Command::Halt }
140
144
  Vagrant.commands.register(:init) { Vagrant::Command::Init }
141
145
  Vagrant.commands.register(:package) { Vagrant::Command::Package }
@@ -186,7 +190,3 @@ Vagrant.provisioners.register(:shell) { Vagrant::Provisioners::Shell }
186
190
  Vagrant.config_keys.register(:freebsd) { Vagrant::Guest::FreeBSD::FreeBSDConfig }
187
191
  Vagrant.config_keys.register(:linux) { Vagrant::Guest::Linux::LinuxConfig }
188
192
  Vagrant.config_keys.register(:solaris) { Vagrant::Guest::Solaris::SolarisConfig }
189
-
190
- # Load the things which must be loaded before anything else.
191
- require 'vagrant/version'
192
- Vagrant::Plugin.load!
@@ -27,6 +27,7 @@ module Vagrant
27
27
  def call(env)
28
28
  @env = env
29
29
 
30
+ raise Errors::PackageOutputDirectory if File.directory?(tar_path)
30
31
  raise Errors::PackageOutputExists if File.exist?(tar_path)
31
32
  raise Errors::PackageRequiresDirectory if !env["package.directory"] ||
32
33
  !File.directory?(env["package.directory"])
@@ -37,12 +38,14 @@ module Vagrant
37
38
  end
38
39
 
39
40
  def recover(env)
40
- # Don't delete the tar_path if the error is that the output already
41
- # exists, since this will nuke the user's previous file.
42
- if !env["vagrant.error"].is_a?(Errors::PackageOutputExists)
43
- # Cleanup any packaged files if the packaging failed at some point.
44
- File.delete(tar_path) if File.exist?(tar_path)
45
- end
41
+ # There are certain exceptions that we don't delete the file for.
42
+ ignore_exc = [Errors::PackageOutputDirectory, Errors::PackageOutputExists]
43
+ ignore_exc.each do |exc|
44
+ return if env["vagrant.error"].is_a?(exc)
45
+ end
46
+
47
+ # Cleanup any packaged files if the packaging failed at some point.
48
+ File.delete(tar_path) if File.exist?(tar_path)
46
49
  end
47
50
 
48
51
  # This method copies the include files (passed in via command line)
@@ -90,7 +93,7 @@ module Vagrant
90
93
 
91
94
  # Path to the final box output file
92
95
  def tar_path
93
- File.join(FileUtils.pwd, @env["package.output"])
96
+ File.expand_path(@env["package.output"], FileUtils.pwd)
94
97
  end
95
98
  end
96
99
  end
@@ -8,6 +8,7 @@ module Vagrant
8
8
  autoload :BoxRepackage, 'vagrant/command/box_repackage'
9
9
  autoload :BoxList, 'vagrant/command/box_list'
10
10
  autoload :Destroy, 'vagrant/command/destroy'
11
+ autoload :Gem, 'vagrant/command/gem'
11
12
  autoload :Halt, 'vagrant/command/halt'
12
13
  autoload :Init, 'vagrant/command/init'
13
14
  autoload :Package, 'vagrant/command/package'
@@ -4,8 +4,15 @@ module Vagrant
4
4
  module Command
5
5
  class Destroy < Base
6
6
  def execute
7
+ options = {}
8
+
7
9
  opts = OptionParser.new do |opts|
8
10
  opts.banner = "Usage: vagrant destroy [vm-name]"
11
+ opts.separator ""
12
+
13
+ opts.on("-f", "--force", "Destroy without confirmation.") do |f|
14
+ options[:force] = f
15
+ end
9
16
  end
10
17
 
11
18
  # Parse the options
@@ -15,8 +22,27 @@ module Vagrant
15
22
  @logger.debug("'Destroy' each target VM...")
16
23
  with_target_vms(argv[0]) do |vm|
17
24
  if vm.created?
18
- @logger.info("Destroying: #{vm.name}")
19
- vm.destroy
25
+ # Boolean whether we should actually go through with the destroy
26
+ # or not. This is true only if the "--force" flag is set or if the
27
+ # user confirms it.
28
+ do_destroy = false
29
+
30
+ if options[:force]
31
+ do_destroy = true
32
+ else
33
+ choice = @env.ui.ask(I18n.t("vagrant.commands.destroy.confirmation",
34
+ :name => vm.name))
35
+ do_destroy = choice.upcase == "Y"
36
+ end
37
+
38
+ if do_destroy
39
+ @logger.info("Destroying: #{vm.name}")
40
+ vm.destroy
41
+ else
42
+ @logger.info("Not destroying #{vm.name} since confirmation was declined.")
43
+ @env.ui.success(I18n.t("vagrant.commands.destroy.will_not_destroy",
44
+ :name => vm.name), :prefix => false)
45
+ end
20
46
  else
21
47
  @logger.info("Not destroying #{vm.name}, since it isn't created.")
22
48
  vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
@@ -0,0 +1,35 @@
1
+ require "rubygems"
2
+ require "rubygems/gem_runner"
3
+
4
+ module Vagrant
5
+ module Command
6
+ class Gem < Base
7
+ def execute
8
+ # Bundler sets up its own custom gem load paths such that our
9
+ # own gems are never loaded. Therefore, give an error if a user
10
+ # tries to install gems while within a Bundler-managed environment.
11
+ if defined?(Bundler)
12
+ require 'bundler/shared_helpers'
13
+ if Bundler::SharedHelpers.in_bundle?
14
+ raise Errors::GemCommandInBundler
15
+ end
16
+ end
17
+
18
+ # If the user needs some help, we add our own little message at the
19
+ # top so that they're aware of what `vagrant gem` is doing, really.
20
+ if @argv.empty? || @argv.include?("-h") || @argv.include?("--help")
21
+ @env.ui.info(I18n.t("vagrant.commands.gem.help_preamble"),
22
+ :prefix => false)
23
+ puts
24
+ end
25
+
26
+ # We just proxy the arguments onto a real RubyGems command
27
+ # but change `GEM_HOME` so that the gems are installed into
28
+ # our own private gem folder.
29
+ ENV["GEM_HOME"] = @env.gems_path.to_s
30
+ ::Gem.clear_paths
31
+ ::Gem::GemRunner.new.run(@argv.dup)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -23,7 +23,8 @@ module Vagrant
23
23
  end
24
24
 
25
25
  def clear_shared_folders
26
- execute("showvminfo", @uuid, "--machinereadable").split("\n").each do |line|
26
+ info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
27
+ info.split("\n").each do |line|
27
28
  if line =~ /^SharedFolderNameMachineMapping\d+="(.+?)"$/
28
29
  execute("sharedfolder", "remove", @uuid, "--name", $1.to_s)
29
30
  end
@@ -70,8 +71,9 @@ module Vagrant
70
71
 
71
72
  execute("list", "vms").split("\n").each do |line|
72
73
  if line =~ /^".+?"\s+\{(.+?)\}$/
73
- execute("showvminfo", $1.to_s, "--machinereadable").split("\n").each do |info|
74
- if info =~ /^hostonlyadapter\d+="(.+?)"$/
74
+ info = execute("showvminfo", $1.to_s, "--machinereadable", :retryable => true)
75
+ info.split("\n").each do |line|
76
+ if line =~ /^hostonlyadapter\d+="(.+?)"$/
75
77
  networks.delete($1.to_s)
76
78
  end
77
79
  end
@@ -202,7 +204,8 @@ module Vagrant
202
204
 
203
205
  results = []
204
206
  current_nic = nil
205
- execute("showvminfo", uuid, "--machinereadable").split("\n").each do |line|
207
+ info = execute("showvminfo", uuid, "--machinereadable", :retryable => true)
208
+ info.split("\n").each do |line|
206
209
  # This is how we find the nic that a FP is attached to,
207
210
  # since this comes first.
208
211
  current_nic = $1.to_i if line =~ /^nic(\d+)=".+?"$/
@@ -246,7 +249,8 @@ module Vagrant
246
249
  end
247
250
 
248
251
  def read_guest_additions_version
249
- output = execute("guestproperty", "get", @uuid, "/VirtualBox/GuestAdd/Version")
252
+ output = execute("guestproperty", "get", @uuid, "/VirtualBox/GuestAdd/Version",
253
+ :retryable => true)
250
254
  if output =~ /^Value: (.+?)$/
251
255
  # Split the version by _ since some distro versions modify it
252
256
  # to look like this: 4.1.2_ubuntu, and the distro part isn't
@@ -260,7 +264,7 @@ module Vagrant
260
264
 
261
265
  def read_host_only_interfaces
262
266
  dhcp = {}
263
- execute("list", "dhcpservers").split("\n\n").each do |block|
267
+ execute("list", "dhcpservers", :retryable => true).split("\n\n").each do |block|
264
268
  info = {}
265
269
 
266
270
  block.split("\n").each do |line|
@@ -279,7 +283,7 @@ module Vagrant
279
283
  dhcp[info[:network]] = info
280
284
  end
281
285
 
282
- execute("list", "hostonlyifs").split("\n\n").collect do |block|
286
+ execute("list", "hostonlyifs", :retryable => true).split("\n\n").collect do |block|
283
287
  info = {}
284
288
 
285
289
  block.split("\n").each do |line|
@@ -302,7 +306,8 @@ module Vagrant
302
306
  end
303
307
 
304
308
  def read_mac_address
305
- execute("showvminfo", @uuid, "--machinereadable").split("\n").each do |line|
309
+ info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
310
+ info.split("\n").each do |line|
306
311
  return $1.to_s if line =~ /^macaddress1="(.+?)"$/
307
312
  end
308
313
 
@@ -310,7 +315,7 @@ module Vagrant
310
315
  end
311
316
 
312
317
  def read_machine_folder
313
- execute("list", "systemproperties").split("\n").each do |line|
318
+ execute("list", "systemproperties", :retryable => true).split("\n").each do |line|
314
319
  if line =~ /^Default machine folder:\s+(.+?)$/i
315
320
  return $1.to_s
316
321
  end
@@ -321,7 +326,8 @@ module Vagrant
321
326
 
322
327
  def read_network_interfaces
323
328
  nics = {}
324
- execute("showvminfo", @uuid, "--machinereadable").split("\n").each do |line|
329
+ info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
330
+ info.split("\n").each do |line|
325
331
  if line =~ /^nic(\d+)="(.+?)"$/
326
332
  adapter = $1.to_i
327
333
  type = $2.to_sym
@@ -347,7 +353,7 @@ module Vagrant
347
353
  end
348
354
 
349
355
  def read_state
350
- output = execute("showvminfo", @uuid, "--machinereadable")
356
+ output = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
351
357
  if output =~ /^name="<inaccessible>"$/
352
358
  return :inaccessible
353
359
  elsif output =~ /^VMState="(.+?)"$/
@@ -359,7 +365,7 @@ module Vagrant
359
365
 
360
366
  def read_used_ports
361
367
  ports = []
362
- execute("list", "vms").split("\n").each do |line|
368
+ execute("list", "vms", :retryable => true).split("\n").each do |line|
363
369
  if line =~ /^".+?" \{(.+?)\}$/
364
370
  uuid = $1.to_s
365
371
 
@@ -377,7 +383,7 @@ module Vagrant
377
383
 
378
384
  def read_vms
379
385
  results = []
380
- execute("list", "vms").split("\n").each do |line|
386
+ execute("list", "vms", :retryable => true).split("\n").each do |line|
381
387
  if line =~ /^".+?" \{(.+?)\}$/
382
388
  results << $1.to_s
383
389
  end
@@ -417,7 +423,17 @@ module Vagrant
417
423
  end
418
424
 
419
425
  def start(mode)
420
- execute("startvm", @uuid, "--type", mode.to_s)
426
+ command = ["startvm", @uuid, "--type", mode.to_s]
427
+ r = raw(*command)
428
+
429
+ if r.exit_code == 0 || r.stdout =~ /VM ".+?" has been successfully started/
430
+ # Some systems return an exit code 1 for some reason. For that
431
+ # we depend on the output.
432
+ return true
433
+ end
434
+
435
+ # If we reached this point then it didn't work out.
436
+ raise Errors::VBoxManageError, :command => command.inspect
421
437
  end
422
438
 
423
439
  def suspend
@@ -23,7 +23,8 @@ module Vagrant
23
23
  end
24
24
 
25
25
  def clear_shared_folders
26
- execute("showvminfo", @uuid, "--machinereadable").split("\n").each do |line|
26
+ info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
27
+ info.split("\n").each do |line|
27
28
  if line =~ /^SharedFolderNameMachineMapping\d+="(.+?)"$/
28
29
  execute("sharedfolder", "remove", @uuid, "--name", $1.to_s)
29
30
  end
@@ -70,8 +71,9 @@ module Vagrant
70
71
 
71
72
  execute("list", "vms").split("\n").each do |line|
72
73
  if line =~ /^".+?"\s+\{(.+?)\}$/
73
- execute("showvminfo", $1.to_s, "--machinereadable").split("\n").each do |info|
74
- if info =~ /^hostonlyadapter\d+="(.+?)"$/
74
+ info = execute("showvminfo", $1.to_s, "--machinereadable", :retryable => true)
75
+ info.split("\n").each do |line|
76
+ if line =~ /^hostonlyadapter\d+="(.+?)"$/
75
77
  networks.delete($1.to_s)
76
78
  end
77
79
  end
@@ -202,7 +204,8 @@ module Vagrant
202
204
 
203
205
  results = []
204
206
  current_nic = nil
205
- execute("showvminfo", uuid, "--machinereadable").split("\n").each do |line|
207
+ info = execute("showvminfo", uuid, "--machinereadable", :retryable => true)
208
+ info.split("\n").each do |line|
206
209
  # This is how we find the nic that a FP is attached to,
207
210
  # since this comes first.
208
211
  current_nic = $1.to_i if line =~ /^nic(\d+)=".+?"$/
@@ -246,7 +249,8 @@ module Vagrant
246
249
  end
247
250
 
248
251
  def read_guest_additions_version
249
- output = execute("guestproperty", "get", @uuid, "/VirtualBox/GuestAdd/Version")
252
+ output = execute("guestproperty", "get", @uuid, "/VirtualBox/GuestAdd/Version",
253
+ :retryable => true)
250
254
  if output =~ /^Value: (.+?)$/
251
255
  # Split the version by _ since some distro versions modify it
252
256
  # to look like this: 4.1.2_ubuntu, and the distro part isn't
@@ -260,7 +264,7 @@ module Vagrant
260
264
 
261
265
  def read_host_only_interfaces
262
266
  dhcp = {}
263
- execute("list", "dhcpservers").split("\n\n").each do |block|
267
+ execute("list", "dhcpservers", :retryable => true).split("\n\n").each do |block|
264
268
  info = {}
265
269
 
266
270
  block.split("\n").each do |line|
@@ -279,7 +283,7 @@ module Vagrant
279
283
  dhcp[info[:network]] = info
280
284
  end
281
285
 
282
- execute("list", "hostonlyifs").split("\n\n").collect do |block|
286
+ execute("list", "hostonlyifs", :retryable => true).split("\n\n").collect do |block|
283
287
  info = {}
284
288
 
285
289
  block.split("\n").each do |line|
@@ -302,7 +306,8 @@ module Vagrant
302
306
  end
303
307
 
304
308
  def read_mac_address
305
- execute("showvminfo", @uuid, "--machinereadable").split("\n").each do |line|
309
+ info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
310
+ info.split("\n").each do |line|
306
311
  return $1.to_s if line =~ /^macaddress1="(.+?)"$/
307
312
  end
308
313
 
@@ -310,7 +315,7 @@ module Vagrant
310
315
  end
311
316
 
312
317
  def read_machine_folder
313
- execute("list", "systemproperties").split("\n").each do |line|
318
+ execute("list", "systemproperties", :retryable => true).split("\n").each do |line|
314
319
  if line =~ /^Default machine folder:\s+(.+?)$/i
315
320
  return $1.to_s
316
321
  end
@@ -321,7 +326,8 @@ module Vagrant
321
326
 
322
327
  def read_network_interfaces
323
328
  nics = {}
324
- execute("showvminfo", @uuid, "--machinereadable").split("\n").each do |line|
329
+ info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
330
+ info.split("\n").each do |line|
325
331
  if line =~ /^nic(\d+)="(.+?)"$/
326
332
  adapter = $1.to_i
327
333
  type = $2.to_sym
@@ -347,7 +353,7 @@ module Vagrant
347
353
  end
348
354
 
349
355
  def read_state
350
- output = execute("showvminfo", @uuid, "--machinereadable")
356
+ output = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
351
357
  if output =~ /^name="<inaccessible>"$/
352
358
  return :inaccessible
353
359
  elsif output =~ /^VMState="(.+?)"$/
@@ -359,7 +365,7 @@ module Vagrant
359
365
 
360
366
  def read_used_ports
361
367
  ports = []
362
- execute("list", "vms").split("\n").each do |line|
368
+ execute("list", "vms", :retryable => true).split("\n").each do |line|
363
369
  if line =~ /^".+?" \{(.+?)\}$/
364
370
  uuid = $1.to_s
365
371
 
@@ -377,7 +383,7 @@ module Vagrant
377
383
 
378
384
  def read_vms
379
385
  results = []
380
- execute("list", "vms").split("\n").each do |line|
386
+ execute("list", "vms", :retryable => true).split("\n").each do |line|
381
387
  if line =~ /^".+?" \{(.+?)\}$/
382
388
  results << $1.to_s
383
389
  end
@@ -417,7 +423,17 @@ module Vagrant
417
423
  end
418
424
 
419
425
  def start(mode)
420
- execute("startvm", @uuid, "--type", mode.to_s)
426
+ command = ["startvm", @uuid, "--type", mode.to_s]
427
+ r = raw(*command)
428
+
429
+ if r.exit_code == 0 || r.stdout =~ /VM ".+?" has been successfully started/
430
+ # Some systems return an exit code 1 for some reason. For that
431
+ # we depend on the output.
432
+ return true
433
+ end
434
+
435
+ # If we reached this point then it didn't work out.
436
+ raise Errors::VBoxManageError, :command => command.inspect
421
437
  end
422
438
 
423
439
  def suspend
@@ -2,6 +2,7 @@ require 'log4r'
2
2
 
3
3
  require 'vagrant/util/busy'
4
4
  require 'vagrant/util/platform'
5
+ require 'vagrant/util/retryable'
5
6
  require 'vagrant/util/subprocess'
6
7
 
7
8
  module Vagrant
@@ -13,6 +14,7 @@ module Vagrant
13
14
  class VirtualBoxBase
14
15
  # Include this so we can use `Subprocess` more easily.
15
16
  include Vagrant::Util
17
+ include Vagrant::Util::Retryable
16
18
 
17
19
  def initialize
18
20
  @logger = Log4r::Logger.new("vagrant::driver::virtualbox_base")
@@ -245,28 +247,38 @@ module Vagrant
245
247
  def vm_exists?(uuid)
246
248
  end
247
249
 
248
- protected
249
-
250
250
  # Execute the given subcommand for VBoxManage and return the output.
251
251
  def execute(*command, &block)
252
- # Execute the command
253
- r = raw(*command, &block)
254
-
255
- # If the command was a failure, then raise an exception that is
256
- # nicely handled by Vagrant.
257
- if r.exit_code != 0
258
- if @interrupted
259
- @logger.info("Exit code != 0, but interrupted. Ignoring.")
252
+ # Get the options hash if it exists
253
+ opts = {}
254
+ opts = command.pop if command.last.is_a?(Hash)
255
+
256
+ tries = 0
257
+ tries = 3 if opts[:retryable]
258
+
259
+ # Variable to store our execution result
260
+ r = nil
261
+
262
+ retryable(:on => Errors::VBoxManageError, :tries => tries, :sleep => 1) do
263
+ # Execute the command
264
+ r = raw(*command, &block)
265
+
266
+ # If the command was a failure, then raise an exception that is
267
+ # nicely handled by Vagrant.
268
+ if r.exit_code != 0
269
+ if @interrupted
270
+ @logger.info("Exit code != 0, but interrupted. Ignoring.")
271
+ else
272
+ raise Errors::VBoxManageError, :command => command.inspect
273
+ end
260
274
  else
261
- raise Errors::VBoxManageError, :command => command.inspect
262
- end
263
- else
264
- # Sometimes, VBoxManage fails but doesn't actual return a non-zero
265
- # exit code. For this we inspect the output and determine if an error
266
- # occurred.
267
- if r.stderr =~ /VBoxManage: error:/
268
- @logger.info("VBoxManage error text found, assuming error.")
269
- raise Errors::VBoxManageError, :command => command.inspect
275
+ # Sometimes, VBoxManage fails but doesn't actual return a non-zero
276
+ # exit code. For this we inspect the output and determine if an error
277
+ # occurred.
278
+ if r.stderr =~ /VBoxManage: error:/
279
+ @logger.info("VBoxManage error text found, assuming error.")
280
+ raise Errors::VBoxManageError, :command => command.inspect
281
+ end
270
282
  end
271
283
  end
272
284
 
@@ -11,7 +11,7 @@ module Vagrant
11
11
  # defined as basically a folder with a "Vagrantfile." This class allows
12
12
  # access to the VMs, CLI, etc. all in the scope of this environment.
13
13
  class Environment
14
- HOME_SUBDIRS = ["tmp", "boxes"]
14
+ HOME_SUBDIRS = ["tmp", "boxes", "gems"]
15
15
  DEFAULT_VM = :default
16
16
  DEFAULT_HOME = "~/.vagrant.d"
17
17
 
@@ -34,6 +34,9 @@ module Vagrant
34
34
  # The directory where boxes are stored.
35
35
  attr_reader :boxes_path
36
36
 
37
+ # The path where the plugins are stored (gems)
38
+ attr_reader :gems_path
39
+
37
40
  # The path to the default private key
38
41
  attr_reader :default_private_key_path
39
42
 
@@ -80,10 +83,14 @@ module Vagrant
80
83
  setup_home_path
81
84
  @tmp_path = @home_path.join("tmp")
82
85
  @boxes_path = @home_path.join("boxes")
86
+ @gems_path = @home_path.join("gems")
83
87
 
84
88
  # Setup the default private key
85
89
  @default_private_key_path = @home_path.join("insecure_private_key")
86
90
  copy_insecure_private_key
91
+
92
+ # Load the plugins
93
+ load_plugins
87
94
  end
88
95
 
89
96
  #---------------------------------------------------------------
@@ -490,5 +497,17 @@ module Vagrant
490
497
 
491
498
  nil
492
499
  end
500
+
501
+ # Loads the Vagrant plugins by properly setting up RubyGems so that
502
+ # our private gem repository is on the path.
503
+ def load_plugins
504
+ # Add our private gem path to the gem path and reset the paths
505
+ # that Rubygems knows about.
506
+ ENV["GEM_PATH"] = "#{@gems_path}:#{ENV["GEM_PATH"]}"
507
+ ::Gem.clear_paths
508
+
509
+ # Load the plugins
510
+ Plugin.load!
511
+ end
493
512
  end
494
513
  end
@@ -173,6 +173,11 @@ module Vagrant
173
173
  error_key(:environment_locked)
174
174
  end
175
175
 
176
+ class GemCommandInBundler < VagrantError
177
+ status_code(71)
178
+ error_key(:gem_command_in_bundler)
179
+ end
180
+
176
181
  class HomeDirectoryMigrationFailed < VagrantError
177
182
  status_code(53)
178
183
  error_key(:home_dir_migration_failed)
@@ -258,6 +263,11 @@ module Vagrant
258
263
  error_key(:include_file_missing, "vagrant.actions.general.package")
259
264
  end
260
265
 
266
+ class PackageOutputDirectory < VagrantError
267
+ status_code(72)
268
+ error_key(:output_is_directory, "vagrant.actions.general.package")
269
+ end
270
+
261
271
  class PackageOutputExists < VagrantError
262
272
  status_code(16)
263
273
  error_key(:output_exists, "vagrant.actions.general.package")
@@ -1,9 +1,14 @@
1
1
  require 'set'
2
2
  require 'tempfile'
3
3
 
4
+ require 'vagrant/util/template_renderer'
5
+
4
6
  module Vagrant
5
7
  module Guest
6
8
  class Arch < Linux
9
+ # Make the TemplateRenderer top-level
10
+ include Vagrant::Util
11
+
7
12
  def change_host_name(name)
8
13
  # Only do this if the hostname is not already set
9
14
  if !vm.channel.test("sudo hostname | grep '#{name}'")
@@ -23,13 +28,16 @@ module Vagrant
23
28
  entries = []
24
29
  networks.each do |network|
25
30
  interfaces.add(network[:interface])
26
- entries << TemplateRenderer.render("guests/arch/network_#{network[:type]}",
27
- :options => network)
31
+ entry = TemplateRenderer.render("guests/arch/network_#{network[:type]}",
32
+ :options => network)
33
+
34
+ entries << entry
28
35
  end
29
36
 
30
37
  # Perform the careful dance necessary to reconfigure
31
38
  # the network interfaces
32
39
  temp = Tempfile.new("vagrant")
40
+ temp.binmode
33
41
  temp.write(entries.join("\n"))
34
42
  temp.close
35
43
 
@@ -81,7 +81,7 @@ module Vagrant
81
81
  #
82
82
  # {
83
83
  # :type => :static,
84
- # :ip => "33.33.33.10",
84
+ # :ip => "192.168.33.10",
85
85
  # :netmask => "255.255.255.0",
86
86
  # :interface => 1
87
87
  # }
@@ -22,13 +22,16 @@ module Vagrant
22
22
  entries = []
23
23
  networks.each do |network|
24
24
  interfaces.add(network[:interface])
25
- entries << TemplateRenderer.render("guests/debian/network_#{network[:type]}",
26
- :options => network)
25
+ entry = TemplateRenderer.render("guests/debian/network_#{network[:type]}",
26
+ :options => network)
27
+
28
+ entries << entry
27
29
  end
28
30
 
29
31
  # Perform the careful dance necessary to reconfigure
30
32
  # the network interfaces
31
33
  temp = Tempfile.new("vagrant")
34
+ temp.binmode
32
35
  temp.write(entries.join("\n"))
33
36
  temp.close
34
37
 
@@ -1,8 +1,13 @@
1
1
  require 'tempfile'
2
2
 
3
+ require 'vagrant/util/template_renderer'
4
+
3
5
  module Vagrant
4
6
  module Guest
5
7
  class Gentoo < Linux
8
+ # Make the TemplateRenderer top-level
9
+ include Vagrant::Util
10
+
6
11
  def configure_networks(networks)
7
12
  # Remove any previous host only network additions to the interface file
8
13
  vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
@@ -15,6 +20,7 @@ module Vagrant
15
20
 
16
21
  # Upload the entry to a temporary location
17
22
  temp = Tempfile.new("vagrant")
23
+ temp.binmode
18
24
  temp.write(entry)
19
25
  temp.close
20
26
 
@@ -29,6 +29,7 @@ module Vagrant
29
29
  :options => network)
30
30
 
31
31
  temp = Tempfile.new("vagrant")
32
+ temp.binmode
32
33
  temp.write(entry)
33
34
  temp.close
34
35
 
@@ -8,7 +8,7 @@ module Vagrant
8
8
  super
9
9
 
10
10
  # Emit an upstart event if upstart is available
11
- @vm.channel.sudo("[ -x /sbin/initctl ] && /sbin/initctl emit vagrant-mounted MOUNTPOINT=#{guestpath}")
11
+ vm.channel.sudo("[ -x /sbin/initctl ] && /sbin/initctl emit vagrant-mounted MOUNTPOINT=#{guestpath}")
12
12
  end
13
13
 
14
14
  def change_host_name(name)
@@ -1,5 +1,7 @@
1
1
  require "rubygems"
2
2
 
3
+ require "log4r"
4
+
3
5
  module Vagrant
4
6
  # Represents a single plugin and also manages loading plugins from
5
7
  # RubyGems. If a plugin has a `vagrant_init.rb` file somewhere on its
@@ -7,20 +9,17 @@ module Vagrant
7
9
  # (for debugging), the list of loaded plugins is stored in the {plugins}
8
10
  # array.
9
11
  class Plugin
10
- # The array of loaded plugins.
12
+ # The array of gem specifications that were loaded as plugins.
11
13
  @@plugins = []
12
14
 
13
- # The gemspec of this plugin. This is an actual gemspec object.
14
- attr_reader :gemspec
15
-
16
- # The path to the `vagrant_init.rb` file which was loaded for this plugin.
17
- attr_reader :file
18
-
19
15
  # Loads all the plugins for Vagrant. Plugins are currently
20
16
  # gems which have a "vagrant_init.rb" somewhere on their
21
17
  # load path. This file is loaded to kick off the load sequence
22
18
  # for that plugin.
23
19
  def self.load!
20
+ logger = Log4r::Logger.new("vagrant::plugin")
21
+ logger.info("Searching and loading any available plugins...")
22
+
24
23
  # Our version is used for checking dependencies
25
24
  our_version = Gem::Version.create(Vagrant::VERSION)
26
25
 
@@ -41,10 +40,18 @@ module Vagrant
41
40
  specs = Gem::VERSION >= "1.6.0" ? source.latest_specs(true) : source.latest_specs
42
41
 
43
42
  specs.each do |spec|
43
+ if @@plugins.include?(spec)
44
+ logger.debug("Plugin already loaded, not loading again: #{spec.name}")
45
+ next
46
+ end
47
+
44
48
  # If this gem depends on Vagrant, verify this is a valid release of
45
49
  # Vagrant for this gem to load into.
46
50
  vagrant_dep = spec.dependencies.find { |d| d.name == "vagrant" }
47
- next if vagrant_dep && !vagrant_dep.requirement.satisfied_by?(our_version)
51
+ if vagrant_dep && !vagrant_dep.requirement.satisfied_by?(our_version)
52
+ logger.debug("Plugin Vagrant dependency mismatch: #{spec.name} (#{spec.version})")
53
+ next
54
+ end
48
55
 
49
56
  # Find a vagrant_init.rb to verify if this is a plugin
50
57
  file = nil
@@ -55,8 +62,13 @@ module Vagrant
55
62
  end
56
63
 
57
64
  next if !file
58
- @@plugins << new(spec, file)
65
+
66
+ logger.info("Loading plugin: #{spec.name} (#{spec.version})")
67
+ @@plugins << spec
68
+ load file
59
69
  end
70
+
71
+ logger.info("Loaded #{@@plugins.length} plugins.")
60
72
  end
61
73
  end
62
74
 
@@ -65,15 +77,5 @@ module Vagrant
65
77
  #
66
78
  # @return [Array]
67
79
  def self.plugins; @@plugins; end
68
-
69
- # Initializes a new plugin, given a Gemspec and the path to the
70
- # gem's `vagrant_init.rb` file. This should never be called manually.
71
- # Instead {load!} creates all the instances.
72
- def initialize(spec, file)
73
- @gemspec = spec
74
- @file = file
75
-
76
- load file
77
- end
78
80
  end
79
81
  end
@@ -14,12 +14,10 @@ module Vagrant
14
14
  attr_accessor :pp_path
15
15
  attr_accessor :options
16
16
 
17
- def initialize
18
- @manifest_file = "default.pp"
19
- @manifests_path = "manifests"
20
- @pp_path = "/tmp/vagrant-puppet"
21
- @options = []
22
- end
17
+ def manifest_file; @manifest_file || "default.pp"; end
18
+ def manifests_path; @manifests_path || "manifests"; end
19
+ def pp_path; @pp_path || "/tmp/vagrant-puppet"; end
20
+ def options; @options ||= []; end
23
21
 
24
22
  # Returns the manifests path expanded relative to the root path of the
25
23
  # environment.
@@ -0,0 +1,14 @@
1
+ module Vagrant
2
+ module Util
3
+ module LineEndingHelpers
4
+ # Converts line endings to unix-style line endings in the
5
+ # given string.
6
+ #
7
+ # @param [String] string Original string
8
+ # @return [String] The fixed string
9
+ def dos_to_unix(string)
10
+ string.gsub("\r\n", "\n")
11
+ end
12
+ end
13
+ end
14
+ 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.7"
5
+ VERSION = "0.9.99.1"
6
6
  end
@@ -20,7 +20,7 @@ Vagrant::Config.run do |config|
20
20
  # via the IP. Host-only networks can talk to the host machine as well as
21
21
  # any other machines on the same network, but cannot be accessed (through this
22
22
  # network interface) by any external networks.
23
- # config.vm.network :hostonly, "33.33.33.10"
23
+ # config.vm.network :hostonly, "192.168.33.10"
24
24
 
25
25
  # Assign this VM to a bridged network, allowing you to connect directly to a
26
26
  # network using the host's network device. This makes the VM appear as another
@@ -47,6 +47,12 @@ en:
47
47
  may run at any given time to avoid problems with VirtualBox inconsistencies
48
48
  occurring. Please wait for the other instance of Vagrant to end and then
49
49
  try again.
50
+ gem_command_in_bundler: |-
51
+ You cannot run the `vagrant gem` command while in a bundler environment.
52
+ Bundler messes around quite a bit with the RubyGem load paths and gems
53
+ installed via `vagrant gem` are excluded by Bundler.
54
+
55
+ Instead, please include your Vagrant plugins in your Gemfile itself.
50
56
  guest:
51
57
  invalid_class: |-
52
58
  The specified guest class does not inherit from `Vagrant::Guest::Base`.
@@ -225,6 +231,18 @@ en:
225
231
  vm_not_running: "VM is not currently running. Please bring it up to run this command."
226
232
  box:
227
233
  no_installed_boxes: "There are no installed boxes! Use `vagrant box add` to add some."
234
+ destroy:
235
+ confirmation: "Are you sure you want to destroy the '%{name}' VM? [Y/N] "
236
+ will_not_destroy: |-
237
+ The VM '%{name}' will not be destroyed, since the confirmation
238
+ was declined.
239
+ gem:
240
+ help_preamble: |-
241
+ `vagrant gem` is used to install Vagrant plugins via the RubyGems
242
+ system. In fact, `vagrant gem` is just a frontend to the actual `gem`
243
+ interface, with the difference being that Vagrant sets up a custom
244
+ directory where gems are installed so that they are isolated from your
245
+ system gems.
228
246
  init:
229
247
  success: |-
230
248
  A `Vagrantfile` has been placed in this directory. You are now
@@ -522,6 +540,9 @@ en:
522
540
  output_exists: |-
523
541
  The specified file to save the package as already exists. Please
524
542
  remove this file or specify a different file name for outputting.
543
+ output_is_directory: |-
544
+ The specified output is a directory. Please specify a path including
545
+ a filename.
525
546
  requires_directory: |-
526
547
  A directory was not specified to package. This should never happen
527
548
  and is a result of an internal inconsistency.
@@ -26,12 +26,12 @@ describe "vagrant host only networking" do
26
26
  f.puts(<<VFILE)
27
27
  Vagrant::Config.run do |config|
28
28
  config.vm.box = "base"
29
- config.vm.network :hostonly, "33.33.33.10"
29
+ config.vm.network :hostonly, "192.168.33.10"
30
30
  end
31
31
  VFILE
32
32
  end
33
33
 
34
34
  assert_execute("vagrant", "up")
35
- assert_host_to_vm_network("http://33.33.33.10:8000/", 8000)
35
+ assert_host_to_vm_network("http://192.168.33.10:8000/", 8000)
36
36
  end
37
37
  end
@@ -34,15 +34,15 @@ describe Vagrant::Config::VMConfig do
34
34
 
35
35
  it "merges by appending networks" do
36
36
  a = described_class.new
37
- a.network :hostonly, "33.33.33.10"
37
+ a.network :hostonly, "192.168.33.10"
38
38
 
39
39
  b = described_class.new
40
- b.network :hostonly, "33.33.33.11"
40
+ b.network :hostonly, "192.168.33.11"
41
41
 
42
42
  c = a.merge(b)
43
43
  c.networks.length.should == 2
44
- c.networks[0].should == [:hostonly, ["33.33.33.10"]]
45
- c.networks[1].should == [:hostonly, ["33.33.33.11"]]
44
+ c.networks[0].should == [:hostonly, ["192.168.33.10"]]
45
+ c.networks[1].should == [:hostonly, ["192.168.33.11"]]
46
46
  end
47
47
 
48
48
  it "merges by appending provisioners" do
@@ -0,0 +1,16 @@
1
+ require File.expand_path("../../../base", __FILE__)
2
+
3
+ require "vagrant/util/line_ending_helpers"
4
+
5
+ describe Vagrant::Util::LineEndingHelpers do
6
+ let(:klass) do
7
+ Class.new do
8
+ extend Vagrant::Util::LineEndingHelpers
9
+ end
10
+ end
11
+
12
+ it "should convert DOS to unix-style line endings" do
13
+ klass.dos_to_unix("foo\r\nbar\r\n").should == "foo\nbar\n"
14
+ end
15
+ end
16
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrantup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.99.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitchell Hashimoto
@@ -303,6 +303,7 @@ files:
303
303
  - lib/vagrant/command/box_remove.rb
304
304
  - lib/vagrant/command/box_repackage.rb
305
305
  - lib/vagrant/command/destroy.rb
306
+ - lib/vagrant/command/gem.rb
306
307
  - lib/vagrant/command/halt.rb
307
308
  - lib/vagrant/command/init.rb
308
309
  - lib/vagrant/command/package.rb
@@ -384,6 +385,7 @@ files:
384
385
  - lib/vagrant/util/file_checksum.rb
385
386
  - lib/vagrant/util/file_mode.rb
386
387
  - lib/vagrant/util/hash_with_indifferent_access.rb
388
+ - lib/vagrant/util/line_ending_helpers.rb
387
389
  - lib/vagrant/util/network_ip.rb
388
390
  - lib/vagrant/util/platform.rb
389
391
  - lib/vagrant/util/retryable.rb
@@ -542,6 +544,7 @@ files:
542
544
  - test/unit/vagrant/util/ansi_escape_code_remover_test.rb
543
545
  - test/unit/vagrant/util/file_checksum_test.rb
544
546
  - test/unit/vagrant/util/hash_with_indifferent_access_test.rb
547
+ - test/unit/vagrant/util/line_endings_helper_test.rb
545
548
  - test/unit/vagrant/util/network_ip_test.rb
546
549
  - test/unit/vagrant/util/retryable_test.rb
547
550
  - test/unit/vagrant_test.rb