vagrantup 0.8.5 → 0.8.6

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: cfcb796c5e978beb88e68c498fcd3e8fce2d236e
4
- data.tar.gz: 3f78d29f52fe07097b71829e6400379548dc3fae
3
+ metadata.gz: 7987b8b05b53d439752efd835d69fb49f6c4acaa
4
+ data.tar.gz: 1eb3052430da1bde3227df39f30b12c5bfab6d30
5
5
  SHA512:
6
- metadata.gz: 862bc46fd94295df359dbd4903d21083adb04220ec96928db43765c15b9bb6a946e9828ab68a3dd5aa70d67a7a505e449f11002b5b4cfcf29809ddc213875952
7
- data.tar.gz: 720ae318636e3c926c1f6f0d167838b068fe8944a75a0e9a031826c84ec8ad70a37332af560c54f5523e1129daf0d1c90bb066d53f71dc3244bb1f0044b03f81
6
+ metadata.gz: 5f130096790cd9b8e3954ce26366cd00d023093a2906bee5574ad73de17f1d886ce90dc6ffb528a2594bc9c65d49163152dbd38d1a3d1f829f2008f8abc1267d
7
+ data.tar.gz: 7c21f13ad6a8ebe7cce682fc10242a2e905fefdda6a828f6a9bf28abac9bed86b3dbe10a8a63dacf13572fd310537450f45fdc8abc06ffb637df562903f679a9
data/.gitignore CHANGED
@@ -17,6 +17,9 @@ _site/*
17
17
  .yardoc/
18
18
  doc/
19
19
 
20
+ # Rubinius
21
+ *.rbc
22
+
20
23
  # IDE junk
21
24
  .idea/*
22
25
  *.iml
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.8.6 (August 28, 2011)
2
+
3
+ - Fix issue with download progress not properly clearing the line. [GH-476]
4
+ - NFS should work properly on Fedora. [GH-450]
5
+ - Arguments can be specified to the `shell` provisioner via the `args` option. [GH-475]
6
+ - Vagrant behaves much better when there are "inaccessible" VMs. [GH-453]
7
+
1
8
  ## 0.8.5 (August 15, 2011)
2
9
 
3
10
  Note: 0.8.3 and 0.8.4 was yanked due to RubyGems encoding issue.
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
+ require "rbconfig"
2
+ platform = RbConfig::CONFIG["host_os"].downcase
3
+
1
4
  source "http://rubygems.org"
2
5
 
3
6
  gem "vagrant", :path => '.'
@@ -6,6 +9,11 @@ gem "vagrant", :path => '.'
6
9
  # typically coincides with it
7
10
  gem "virtualbox", :git => "git://github.com/mitchellh/virtualbox.git"
8
11
 
12
+ if platform.include?("mingw") || platform.include?("mswin")
13
+ gem "jruby-openssl", "~> 0.7.4", :platforms => :jruby
14
+ gem "jruby-win32ole", "~> 0.8.5", :platforms => :jruby
15
+ end
16
+
9
17
  group :test do
10
18
  gem "rake"
11
19
  gem "contest", ">= 0.1.2"
data/config/default.rb CHANGED
@@ -19,7 +19,6 @@ Vagrant::Config.run do |config|
19
19
  config.vm.box_url = nil
20
20
  config.vm.base_mac = nil
21
21
  config.vm.forward_port("ssh", 22, 2222, :auto => true)
22
- config.vm.disk_image_format = 'VMDK'
23
22
  config.vm.boot_mode = "vrdp"
24
23
  config.vm.system = :linux
25
24
 
@@ -101,6 +101,7 @@ module Vagrant
101
101
  # now, these are limited to what are needed internally.
102
102
  register(:before_action_run, Builder.new do
103
103
  use General::Validate
104
+ use VM::CheckAccessible
104
105
  end)
105
106
  end
106
107
  end
@@ -2,6 +2,7 @@ module Vagrant
2
2
  class Action
3
3
  module VM
4
4
  autoload :Boot, 'vagrant/action/vm/boot'
5
+ autoload :CheckAccessible, 'vagrant/action/vm/check_accessible'
5
6
  autoload :CheckBox, 'vagrant/action/vm/check_box'
6
7
  autoload :CheckGuestAdditions, 'vagrant/action/vm/check_guest_additions'
7
8
  autoload :CleanMachineFolder, 'vagrant/action/vm/clean_machine_folder'
@@ -0,0 +1,23 @@
1
+ module Vagrant
2
+ class Action
3
+ module VM
4
+ class CheckAccessible
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ if env["vm"] && env["vm"].created? && !env["vm"].vm.accessible?
11
+ # The VM we are attempting to manipulate is inaccessible. This
12
+ # is a very bad situation and can only be fixed by the user. It
13
+ # also prohibits us from actually doing anything with the virtual
14
+ # machine, so we raise an error.
15
+ raise Errors::VMInaccessible
16
+ end
17
+
18
+ @app.call(env)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -11,7 +11,7 @@ module Vagrant
11
11
  # @return [Array<String>]
12
12
  def used_ports
13
13
  result = VirtualBox::VM.all.collect do |vm|
14
- if vm.running? && vm.uuid != @env["vm"].uuid
14
+ if vm.accessible? && vm.running? && vm.uuid != @env["vm"].uuid
15
15
  vm.network_adapters.collect do |na|
16
16
  na.nat_driver.forwarded_ports.collect do |fp|
17
17
  fp.hostport.to_i
@@ -6,7 +6,9 @@ module Vagrant
6
6
  def execute
7
7
  target_vms.each do |vm|
8
8
  if vm.created?
9
- if vm.vm.running?
9
+ if !vm.vm.accessible?
10
+ raise Errors::VMInaccessible
11
+ elsif vm.vm.running?
10
12
  vm.provision
11
13
  else
12
14
  vm.env.ui.info I18n.t("vagrant.commands.common.vm_not_running")
@@ -27,8 +27,6 @@ module Vagrant
27
27
  end
28
28
 
29
29
  def ssh_connect
30
- raise Errors::VMNotCreatedError if !ssh_vm.created?
31
- raise Errors::VMNotRunningError if !ssh_vm.vm.running?
32
30
  ssh_vm.ssh.connect
33
31
  end
34
32
 
@@ -37,6 +35,12 @@ module Vagrant
37
35
  vm = self.name.nil? && env.multivm? ? env.primary_vm : nil
38
36
  raise Errors::MultiVMTargetRequired, :command => "ssh" if !vm && target_vms.length > 1
39
37
  vm = target_vms.first if !vm
38
+
39
+ # Basic checks that are required for proper SSH
40
+ raise Errors::VMNotCreatedError if !vm.created?
41
+ raise Errors::VMInaccessible if !vm.vm.accessible?
42
+ raise Errors::VMNotRunningError if !vm.vm.running?
43
+
40
44
  vm
41
45
  end
42
46
  end
@@ -8,6 +8,7 @@ module Vagrant
8
8
  raise Errors::MultiVMTargetRequired, :command => "ssh_config" if target_vms.length > 1
9
9
  vm = target_vms.first
10
10
  raise Errors::VMNotCreatedError if !vm.created?
11
+ raise Errors::VMInaccessible if !vm.vm.accessible?
11
12
 
12
13
  # We need to fix the file permissions of the key if they aren't set
13
14
  # properly, otherwise if the user attempts to SSH in, it won't work!
@@ -3,10 +3,19 @@ module Vagrant
3
3
  class StatusCommand < NamedBase
4
4
  register "status", "Shows the status of the current Vagrant environment."
5
5
 
6
- def route
6
+ def execute
7
7
  state = nil
8
8
  results = target_vms.collect do |vm|
9
- state = vm.created? ? vm.vm.state.to_s : "not_created"
9
+ if vm.created?
10
+ if vm.vm.accessible?
11
+ state = vm.vm.state.to_s
12
+ else
13
+ state = "inaccessible"
14
+ end
15
+ else
16
+ state = "not_created"
17
+ end
18
+
10
19
  "#{vm.name.to_s.ljust(25)}#{state.gsub("_", " ")}"
11
20
  end
12
21
 
@@ -19,7 +19,6 @@ module Vagrant
19
19
  attr_reader :shared_folders
20
20
  attr_reader :network_options
21
21
  attr_reader :provisioners
22
- attr_accessor :disk_image_format
23
22
  attr_accessor :system
24
23
 
25
24
  def initialize
@@ -49,6 +49,7 @@ module Vagrant
49
49
  # Progress reporting is limited to every 25 segments just so
50
50
  # we're not constantly updating
51
51
  if segment_count % 25 == 0
52
+ env.ui.clear_line
52
53
  env.ui.report_progress(progress, total)
53
54
  segment_count = 0
54
55
  end
@@ -56,6 +57,9 @@ module Vagrant
56
57
  # Store the segment
57
58
  destination_file.write(segment)
58
59
  end
60
+
61
+ # Clear the line one last time so that the progress meter disappears
62
+ env.ui.clear_line
59
63
  end
60
64
  end
61
65
  rescue SocketError
@@ -319,6 +319,11 @@ module Vagrant
319
319
  error_key(:failure, "vagrant.actions.vm.import")
320
320
  end
321
321
 
322
+ class VMInaccessible < VagrantError
323
+ status_code(54)
324
+ error_key(:vm_inaccessible)
325
+ end
326
+
322
327
  class VMNotCreatedError < VagrantError
323
328
  status_code(6)
324
329
  error_key(:vm_creation_required)
data/lib/vagrant/hosts.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  module Vagrant
2
2
  module Hosts
3
3
  autoload :Base, 'vagrant/hosts/base'
4
+ autoload :Arch, 'vagrant/hosts/arch'
4
5
  autoload :BSD, 'vagrant/hosts/bsd'
6
+ autoload :Fedora, 'vagrant/hosts/fedora'
5
7
  autoload :Linux, 'vagrant/hosts/linux'
6
- autoload :Arch, 'vagrant/hosts/arch'
7
8
  end
8
9
  end
@@ -8,41 +8,39 @@ module Vagrant
8
8
  # The {Environment} which this host belongs to.
9
9
  attr_reader :env
10
10
 
11
- class << self
12
- # Loads the proper host for the given value. If the value is nil
13
- # or is the symbol `:detect`, then the host class will be detected
14
- # using the `RUBY_PLATFORM` constant.
15
- #
16
- # @param [Environment] env
17
- # @param [String] klass
18
- # @return [Base]
19
- def load(env, klass)
20
- klass = detect if klass.nil? || klass == :detect
21
- return nil if !klass
22
- return klass.new(env)
23
- end
11
+ # Loads the proper host for the given value. If the value is nil
12
+ # or is the symbol `:detect`, then the host class will be detected
13
+ # using the `RUBY_PLATFORM` constant.
14
+ #
15
+ # @param [Environment] env
16
+ # @param [String] klass
17
+ # @return [Base]
18
+ def self.load(env, klass)
19
+ klass = detect if klass.nil? || klass == :detect
20
+ return nil if !klass
21
+ return klass.new(env)
22
+ end
24
23
 
25
- # Detects the proper host class for current platform and returns
26
- # the class.
27
- #
28
- # @return [Class]
29
- def detect
30
- # More coming soon
31
- classes = {
32
- :darwin => BSD,
33
- :bsd => BSD,
34
- :arch => Arch,
35
- :linux => Linux
36
- }
24
+ # Detects the proper host class for current platform and returns
25
+ # the class.
26
+ #
27
+ # @return [Class]
28
+ def self.detect
29
+ [BSD, Linux].each do |type|
30
+ result = type.distro_dispatch
31
+ return result if result
32
+ end
37
33
 
38
- classes.each do |type, klass|
39
- return klass if Util::Platform.send("#{type}?")
40
- end
34
+ nil
35
+ rescue Exception
36
+ nil
37
+ end
41
38
 
42
- nil
43
- rescue Exception
44
- nil
45
- end
39
+ # This must be implemented by subclasses to dispatch to the proper
40
+ # distro-specific class for the host. If this returns nil then it is
41
+ # an invalid host class.
42
+ def self.distro_dispatch
43
+ nil
46
44
  end
47
45
 
48
46
  # Initialzes a new host. This method shouldn't be called directly,
@@ -1,3 +1,5 @@
1
+ require 'vagrant/util/platform'
2
+
1
3
  module Vagrant
2
4
  module Hosts
3
5
  # Represents a BSD host, such as FreeBSD and Darwin (Mac OS X).
@@ -5,6 +7,10 @@ module Vagrant
5
7
  include Util
6
8
  include Util::Retryable
7
9
 
10
+ def self.distro_dispatch
11
+ return self if Util::Platform.darwin? || Util::Platform.bsd?
12
+ end
13
+
8
14
  def nfs?
9
15
  retryable(:tries => 10, :on => TypeError) do
10
16
  system("which nfsd > /dev/null 2>&1")
@@ -0,0 +1,11 @@
1
+ module Vagrant
2
+ module Hosts
3
+ class Fedora < Linux
4
+ def initialize(*args)
5
+ super
6
+
7
+ @nfs_server_binary = "/etc/init.d/nfs"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,5 @@
1
+ require 'vagrant/util/platform'
2
+
1
3
  module Vagrant
2
4
  module Hosts
3
5
  # Represents a Linux based host, such as Ubuntu.
@@ -5,6 +7,26 @@ module Vagrant
5
7
  include Util
6
8
  include Util::Retryable
7
9
 
10
+ def self.distro_dispatch
11
+ return nil if !Util::Platform.linux?
12
+ return Arch if File.exist?("/etc/rc.conf") && File.exist?("/etc/pacman.conf")
13
+
14
+ if File.exist?("/etc/redhat-release")
15
+ # Check if we have a known redhat release
16
+ File.open("/etc/redhat-release") do |f|
17
+ return Fedora if f.gets =~ /^Fedora/
18
+ end
19
+ end
20
+
21
+ return self
22
+ end
23
+
24
+ def initialize(*args)
25
+ super
26
+
27
+ @nfs_server_binary = "/etc/init.d/nfs-kernel-server"
28
+ end
29
+
8
30
  def nfs?
9
31
  retryable(:tries => 10, :on => TypeError) do
10
32
  # Check procfs to see if NFSd is a supported filesystem
@@ -29,7 +51,7 @@ module Vagrant
29
51
 
30
52
  # We run restart here instead of "update" just in case nfsd
31
53
  # is not starting
32
- system("sudo /etc/init.d/nfs-kernel-server restart")
54
+ system("sudo #{@nfs_server_binary} restart")
33
55
  end
34
56
 
35
57
  def nfs_cleanup
@@ -74,9 +74,9 @@ module Vagrant
74
74
  # Path exists on the host, setup the remote path
75
75
  remote_path = "#{config.provisioning_path}/chef-solo-#{get_and_update_counter(:cookbooks_path)}"
76
76
  else
77
- # Path already exists on the virtual machine. Expand it
78
- # relative to where we're provisioning.
79
- remote_path = File.expand_path(path, config.provisioning_path)
77
+ # Path already exists on the virtual machine, therefore
78
+ # just use the path given.
79
+ remote_path = path
80
80
  end
81
81
 
82
82
  # Return the result
@@ -7,11 +7,13 @@ module Vagrant
7
7
  attr_accessor :inline
8
8
  attr_accessor :path
9
9
  attr_accessor :upload_path
10
+ attr_accessor :args
10
11
 
11
12
  def initialize
12
13
  @inline = nil
13
14
  @path = nil
14
15
  @upload_path = "/tmp/vagrant-shell"
16
+ @args = nil
15
17
  end
16
18
 
17
19
  def expanded_path
@@ -37,6 +39,11 @@ module Vagrant
37
39
  if !upload_path
38
40
  errors.add(I18n.t("vagrant.provisioners.shell.upload_path_not_set"))
39
41
  end
42
+
43
+ # If there are args and its not a string, that is a problem
44
+ if args && !args.is_a?(String)
45
+ errors.add(I18n.t("vagrant.provisioners.shell.args_not_string"))
46
+ end
40
47
  end
41
48
  end
42
49
 
@@ -64,7 +71,9 @@ module Vagrant
64
71
  end
65
72
 
66
73
  def provision!
67
- commands = ["chmod +x #{config.upload_path}", config.upload_path]
74
+ args = ""
75
+ args = " #{config.args}" if config.args
76
+ commands = ["chmod +x #{config.upload_path}", "#{config.upload_path}#{args}"]
68
77
 
69
78
  with_script_file do |path|
70
79
  # Upload the script to the VM
@@ -27,13 +27,6 @@ module Vagrant
27
27
  false
28
28
  end
29
29
 
30
- def arch?
31
- linux? &&
32
- File.exist?('/etc/rc.conf') &&
33
- File.exist?('/etc/pacman.conf') &&
34
- File.exist?('/etc/rc.d/')
35
- end
36
-
37
30
  # Returns boolean noting whether this is a 64-bit CPU. This
38
31
  # is not 100% accurate and there could easily be false negatives.
39
32
  #
@@ -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.8.5"
5
+ VERSION = "0.8.6"
6
6
  end
data/lib/vagrant/vm.rb CHANGED
@@ -141,6 +141,7 @@ module Vagrant
141
141
  end
142
142
 
143
143
  def start(options=nil)
144
+ raise Errors::VMInaccessible if !@vm.accessible?
144
145
  return if @vm.running?
145
146
  return resume if @vm.saved?
146
147
 
@@ -144,6 +144,11 @@ en:
144
144
  http://vagrantup.com/docs/getting-started/setup/windows_x64.html
145
145
 
146
146
  vm_creation_required: "VM must be created before running this command. Run `vagrant up` first."
147
+ vm_inaccessible: |-
148
+ Your VM has become "inaccessible." Unfortunately, this is a critical error
149
+ with VirtualBox that Vagrant can not cleanly recover from. Please open VirtualBox
150
+ and clear out your inaccessible virtual machines or find a way to fix
151
+ them.
147
152
  vm_not_found: "A VM by the name of %{name} was not found."
148
153
  vm_not_running: "VM must be running to open SSH connection."
149
154
 
@@ -191,6 +196,11 @@ en:
191
196
  stopped without properly closing the session. Run `vagrant up`
192
197
  to resume this virtual machine. If any problems persist, you may
193
198
  have to destroy and restart the virtual machine.
199
+ inaccessible: |-
200
+ The VM is inaccessible! This is a rare case which means that VirtualBox
201
+ can't find your VM configuration. This usually happens when upgrading
202
+ VirtualBox, moving to a new computer, etc. Please consult VirtualBox
203
+ for how to handle this issue.
194
204
  output: |-
195
205
  Current VM states:
196
206
 
@@ -509,6 +519,7 @@ en:
509
519
  running_puppetd: "Running Puppet agent..."
510
520
 
511
521
  shell:
522
+ args_not_string: "Shell provisioner `args` must be a string."
512
523
  path_and_inline_set: "Only one of `path` or `inline` may be set."
513
524
  no_path_or_inline: "One of `path` or `inline` must be set."
514
525
  path_invalid: "`path` for shell provisioner does not exist on the host system: %{path}"
@@ -0,0 +1,61 @@
1
+ require 'test_helper'
2
+
3
+ class CheckAccessibleVMActionTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Action::VM::CheckAccessible
6
+ end
7
+
8
+ context "calling" do
9
+ setup do
10
+ @app, @env = action_env
11
+ @instance = @klass.new(@app, @env)
12
+ end
13
+
14
+ should "continue up the chain if the VM is nil" do
15
+ @env["vm"] = nil
16
+
17
+ @app.expects(:call).once
18
+
19
+ assert_nothing_raised {
20
+ @instance.call(@env)
21
+ }
22
+ end
23
+
24
+ should "continue up the chain if the VM is not created" do
25
+ @env["vm"] = mock("vm")
26
+ @env["vm"].stubs(:created?).returns(false)
27
+
28
+ @app.expects(:call).once
29
+
30
+ assert_nothing_raised {
31
+ @instance.call(@env)
32
+ }
33
+ end
34
+
35
+ should "continue up the chain if the VM is created and accessible" do
36
+ @env["vm"] = mock("vm")
37
+ @env["vm"].stubs(:created?).returns(true)
38
+ @env["vm"].stubs(:vm).returns(mock("real_vm"))
39
+ @env["vm"].vm.stubs(:accessible?).returns(true)
40
+
41
+ @app.expects(:call).once
42
+
43
+ assert_nothing_raised {
44
+ @instance.call(@env)
45
+ }
46
+ end
47
+
48
+ should "fail if the VM is not accessible" do
49
+ @env["vm"] = mock("vm")
50
+ @env["vm"].stubs(:created?).returns(true)
51
+ @env["vm"].stubs(:vm).returns(mock("real_vm"))
52
+ @env["vm"].vm.stubs(:accessible?).returns(false)
53
+
54
+ @app.expects(:call).never
55
+
56
+ assert_raises(Vagrant::Errors::VMInaccessible) {
57
+ @instance.call(@env)
58
+ }
59
+ end
60
+ end
61
+ end
@@ -64,5 +64,16 @@ class ShellProvisionerTest < Test::Unit::TestCase
64
64
 
65
65
  @action.provision!
66
66
  end
67
+
68
+ should "append arguments if provided" do
69
+ @config.args = "foo bar baz"
70
+ commands = ["chmod +x #{@config.upload_path}", "#{@config.upload_path} #{@config.args}"]
71
+
72
+ p_seq = sequence("provisioning")
73
+ @action.vm.ssh.expects(:upload!).with(@config.expanded_path.to_s, @config.upload_path).in_sequence(p_seq)
74
+ @ssh.expects(:sudo!).with(commands).in_sequence(p_seq)
75
+
76
+ @action.provision!
77
+ end
67
78
  end
68
79
  end
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.8.5
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitchell Hashimoto
@@ -223,6 +223,7 @@ files:
223
223
  - lib/vagrant/action/general/validate.rb
224
224
  - lib/vagrant/action/vm.rb
225
225
  - lib/vagrant/action/vm/boot.rb
226
+ - lib/vagrant/action/vm/check_accessible.rb
226
227
  - lib/vagrant/action/vm/check_box.rb
227
228
  - lib/vagrant/action/vm/check_guest_additions.rb
228
229
  - lib/vagrant/action/vm/clean_machine_folder.rb
@@ -297,6 +298,7 @@ files:
297
298
  - lib/vagrant/hosts/arch.rb
298
299
  - lib/vagrant/hosts/base.rb
299
300
  - lib/vagrant/hosts/bsd.rb
301
+ - lib/vagrant/hosts/fedora.rb
300
302
  - lib/vagrant/hosts/linux.rb
301
303
  - lib/vagrant/plugin.rb
302
304
  - lib/vagrant/provisioners.rb
@@ -361,6 +363,7 @@ files:
361
363
  - test/vagrant/action/general/package_test.rb
362
364
  - test/vagrant/action/general/validate_test.rb
363
365
  - test/vagrant/action/vm/boot_test.rb
366
+ - test/vagrant/action/vm/check_accessible_test.rb
364
367
  - test/vagrant/action/vm/check_box_test.rb
365
368
  - test/vagrant/action/vm/check_guest_additions_test.rb
366
369
  - test/vagrant/action/vm/clean_machine_folder_test.rb