vagrant 0.9.7 → 1.0.0
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.
- data/CHANGELOG.md +41 -0
- data/config/default.rb +0 -1
- data/lib/vagrant.rb +9 -5
- data/lib/vagrant/action.rb +1 -0
- data/lib/vagrant/action/builtin.rb +10 -0
- data/lib/vagrant/action/general/check_virtualbox.rb +28 -0
- data/lib/vagrant/action/general/package.rb +10 -7
- data/lib/vagrant/action/general/validate.rb +2 -3
- data/lib/vagrant/action/vm/customize.rb +1 -1
- data/lib/vagrant/action/vm/network.rb +10 -9
- data/lib/vagrant/action/vm/nfs.rb +7 -0
- data/lib/vagrant/command.rb +1 -0
- data/lib/vagrant/command/base.rb +8 -2
- data/lib/vagrant/command/destroy.rb +29 -3
- data/lib/vagrant/command/gem.rb +35 -0
- data/lib/vagrant/command/package.rb +1 -1
- data/lib/vagrant/command/ssh.rb +1 -1
- data/lib/vagrant/command/ssh_config.rb +1 -1
- data/lib/vagrant/config/loader.rb +2 -0
- data/lib/vagrant/config/ssh.rb +0 -20
- data/lib/vagrant/config/vm.rb +0 -48
- data/lib/vagrant/data_store.rb +18 -9
- data/lib/vagrant/driver/virtualbox.rb +1 -0
- data/lib/vagrant/driver/virtualbox_4_0.rb +36 -14
- data/lib/vagrant/driver/virtualbox_4_1.rb +36 -14
- data/lib/vagrant/driver/virtualbox_base.rb +37 -19
- data/lib/vagrant/environment.rb +21 -2
- data/lib/vagrant/errors.rb +10 -0
- data/lib/vagrant/guest.rb +1 -0
- data/lib/vagrant/guest/arch.rb +10 -2
- data/lib/vagrant/guest/base.rb +1 -1
- data/lib/vagrant/guest/debian.rb +5 -2
- data/lib/vagrant/guest/fedora.rb +66 -0
- data/lib/vagrant/guest/freebsd.rb +18 -7
- data/lib/vagrant/guest/gentoo.rb +6 -0
- data/lib/vagrant/guest/linux.rb +1 -0
- data/lib/vagrant/guest/redhat.rb +1 -0
- data/lib/vagrant/guest/ubuntu.rb +1 -1
- data/lib/vagrant/hosts.rb +1 -0
- data/lib/vagrant/hosts/opensuse.rb +30 -0
- data/lib/vagrant/plugin.rb +21 -19
- data/lib/vagrant/provisioners/chef.rb +3 -1
- data/lib/vagrant/provisioners/puppet.rb +18 -7
- data/lib/vagrant/util/line_ending_helpers.rb +14 -0
- data/lib/vagrant/util/subprocess.rb +9 -0
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +6 -6
- data/templates/commands/init/Vagrantfile.erb +1 -1
- data/templates/guests/fedora/network_dhcp.erb +6 -0
- data/templates/guests/fedora/network_static.erb +13 -0
- data/templates/guests/freebsd/network_dhcp.erb +3 -0
- data/templates/guests/freebsd/network_static.erb +3 -0
- data/templates/locales/en.yml +26 -0
- data/templates/nfs/exports_linux.erb +1 -1
- data/test/acceptance/networking/host_only_test.rb +2 -2
- data/test/unit/vagrant/config/vm_test.rb +4 -4
- data/test/unit/vagrant/data_store_test.rb +12 -0
- data/test/unit/vagrant/environment_test.rb +20 -0
- data/test/unit/vagrant/util/line_endings_helper_test.rb +16 -0
- data/vagrant.gemspec +1 -1
- metadata +37 -27
@@ -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")
|
@@ -232,6 +234,12 @@ module Vagrant
|
|
232
234
|
def suspend
|
233
235
|
end
|
234
236
|
|
237
|
+
# Verifies that the driver is ready to accept work.
|
238
|
+
#
|
239
|
+
# This should raise a VagrantError if things are not ready.
|
240
|
+
def verify!
|
241
|
+
end
|
242
|
+
|
235
243
|
# Verifies that an image can be imported properly.
|
236
244
|
#
|
237
245
|
# @param [String] path Path to an OVF file.
|
@@ -245,28 +253,38 @@ module Vagrant
|
|
245
253
|
def vm_exists?(uuid)
|
246
254
|
end
|
247
255
|
|
248
|
-
protected
|
249
|
-
|
250
256
|
# Execute the given subcommand for VBoxManage and return the output.
|
251
257
|
def execute(*command, &block)
|
252
|
-
#
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
258
|
+
# Get the options hash if it exists
|
259
|
+
opts = {}
|
260
|
+
opts = command.pop if command.last.is_a?(Hash)
|
261
|
+
|
262
|
+
tries = 0
|
263
|
+
tries = 3 if opts[:retryable]
|
264
|
+
|
265
|
+
# Variable to store our execution result
|
266
|
+
r = nil
|
267
|
+
|
268
|
+
retryable(:on => Errors::VBoxManageError, :tries => tries, :sleep => 1) do
|
269
|
+
# Execute the command
|
270
|
+
r = raw(*command, &block)
|
271
|
+
|
272
|
+
# If the command was a failure, then raise an exception that is
|
273
|
+
# nicely handled by Vagrant.
|
274
|
+
if r.exit_code != 0
|
275
|
+
if @interrupted
|
276
|
+
@logger.info("Exit code != 0, but interrupted. Ignoring.")
|
277
|
+
else
|
278
|
+
raise Errors::VBoxManageError, :command => command.inspect
|
279
|
+
end
|
260
280
|
else
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
@logger.info("VBoxManage error text found, assuming error.")
|
269
|
-
raise Errors::VBoxManageError, :command => command.inspect
|
281
|
+
# Sometimes, VBoxManage fails but doesn't actual return a non-zero
|
282
|
+
# exit code. For this we inspect the output and determine if an error
|
283
|
+
# occurred.
|
284
|
+
if r.stderr =~ /VBoxManage: error:/
|
285
|
+
@logger.info("VBoxManage error text found, assuming error.")
|
286
|
+
raise Errors::VBoxManageError, :command => command.inspect
|
287
|
+
end
|
270
288
|
end
|
271
289
|
end
|
272
290
|
|
data/lib/vagrant/environment.rb
CHANGED
@@ -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
|
#---------------------------------------------------------------
|
@@ -131,7 +138,7 @@ module Vagrant
|
|
131
138
|
def primary_vm
|
132
139
|
return vms.values.first if !multivm?
|
133
140
|
|
134
|
-
config.vm.defined_vms.each do |name, subvm|
|
141
|
+
config.global.vm.defined_vms.each do |name, subvm|
|
135
142
|
return vms[name] if subvm.options[:primary]
|
136
143
|
end
|
137
144
|
|
@@ -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
|
data/lib/vagrant/errors.rb
CHANGED
@@ -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")
|
data/lib/vagrant/guest.rb
CHANGED
@@ -5,6 +5,7 @@ module Vagrant
|
|
5
5
|
# Specific guests
|
6
6
|
autoload :Arch, 'vagrant/guest/arch'
|
7
7
|
autoload :Debian, 'vagrant/guest/debian'
|
8
|
+
autoload :Fedora, 'vagrant/guest/fedora'
|
8
9
|
autoload :FreeBSD, 'vagrant/guest/freebsd'
|
9
10
|
autoload :Gentoo, 'vagrant/guest/gentoo'
|
10
11
|
autoload :Linux, 'vagrant/guest/linux'
|
data/lib/vagrant/guest/arch.rb
CHANGED
@@ -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
|
-
|
27
|
-
|
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
|
|
data/lib/vagrant/guest/base.rb
CHANGED
data/lib/vagrant/guest/debian.rb
CHANGED
@@ -22,13 +22,16 @@ module Vagrant
|
|
22
22
|
entries = []
|
23
23
|
networks.each do |network|
|
24
24
|
interfaces.add(network[:interface])
|
25
|
-
|
26
|
-
|
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
|
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'set'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
require 'vagrant/util/template_renderer'
|
5
|
+
|
6
|
+
module Vagrant
|
7
|
+
module Guest
|
8
|
+
class Fedora < Linux
|
9
|
+
# Make the TemplateRenderer top-level
|
10
|
+
include Vagrant::Util
|
11
|
+
|
12
|
+
def configure_networks(networks)
|
13
|
+
# Accumulate the configurations to add to the interfaces file as well
|
14
|
+
# as what interfaces we're actually configuring since we use that later.
|
15
|
+
interfaces = Set.new
|
16
|
+
networks.each do |network|
|
17
|
+
interfaces.add(network[:interface])
|
18
|
+
|
19
|
+
# Remove any previous vagrant configuration in this network
|
20
|
+
# interface's configuration files.
|
21
|
+
vm.channel.sudo("touch #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}")
|
22
|
+
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-p7p#{network[:interface]} > /tmp/vagrant-ifcfg-p7p#{network[:interface]}")
|
23
|
+
vm.channel.sudo("cat /tmp/vagrant-ifcfg-p7p#{network[:interface]} > #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}")
|
24
|
+
|
25
|
+
# Render and upload the network entry file to a deterministic
|
26
|
+
# temporary location.
|
27
|
+
entry = TemplateRenderer.render("guests/fedora/network_#{network[:type]}",
|
28
|
+
:options => network)
|
29
|
+
|
30
|
+
temp = Tempfile.new("vagrant")
|
31
|
+
temp.binmode
|
32
|
+
temp.write(entry)
|
33
|
+
temp.close
|
34
|
+
|
35
|
+
vm.channel.upload(temp.path, "/tmp/vagrant-network-entry_#{network[:interface]}")
|
36
|
+
end
|
37
|
+
|
38
|
+
# Bring down all the interfaces we're reconfiguring. By bringing down
|
39
|
+
# each specifically, we avoid reconfiguring p7p (the NAT interface) so
|
40
|
+
# SSH never dies.
|
41
|
+
interfaces.each do |interface|
|
42
|
+
vm.channel.sudo("/sbin/ifdown p7p#{interface} 2> /dev/null", :error_check => false)
|
43
|
+
vm.channel.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-p7p#{interface}")
|
44
|
+
vm.channel.sudo("/sbin/ifup p7p#{interface} 2> /dev/null")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# The path to the directory with the network configuration scripts.
|
49
|
+
# This is pulled out into its own directory since there are other
|
50
|
+
# operating systems (SuSE) which behave similarly but with a different
|
51
|
+
# path to the network scripts.
|
52
|
+
def network_scripts_dir
|
53
|
+
'/etc/sysconfig/network-scripts'
|
54
|
+
end
|
55
|
+
|
56
|
+
def change_host_name(name)
|
57
|
+
# Only do this if the hostname is not already set
|
58
|
+
if !vm.channel.test("sudo hostname | grep '#{name}'")
|
59
|
+
vm.channel.sudo("sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/sysconfig/network")
|
60
|
+
vm.channel.sudo("hostname #{name}")
|
61
|
+
vm.channel.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'vagrant/util/template_renderer'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
module Guest
|
3
5
|
# A general Vagrant system implementation for "freebsd".
|
@@ -57,19 +59,28 @@ module Vagrant
|
|
57
59
|
end
|
58
60
|
|
59
61
|
def configure_networks(networks)
|
60
|
-
# Remove any previous
|
61
|
-
|
62
|
-
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN-HOSTONLY/,/^#VAGRANT-END-HOSTONLY/ d' /etc/rc.conf > /tmp/rc.conf")
|
63
|
-
vm.channel.sudo("mv /tmp/rc.conf /etc/rc.conf")
|
62
|
+
# Remove any previous network additions to the configuration file.
|
63
|
+
vm.channel.sudo("sed -i '' -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf")
|
64
64
|
|
65
65
|
networks.each do |network|
|
66
|
-
entry = "#
|
66
|
+
entry = TemplateRenderer.render("guests/freebsd/network_#{network[:type]}",
|
67
|
+
:options => network)
|
67
68
|
vm.channel.upload(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
68
|
-
|
69
69
|
vm.channel.sudo("su -m root -c 'cat /tmp/vagrant-network-entry >> /etc/rc.conf'")
|
70
|
-
|
70
|
+
if network[:type].to_sym == :static
|
71
|
+
vm.channel.sudo("ifconfig em#{network[:interface]} inet #{network[:ip]} netmask #{network[:netmask]}")
|
72
|
+
elsif network[:type].to_sym == :dhcp
|
73
|
+
vm.channel.sudo("dhclient em#{network[:interface]}")
|
74
|
+
end
|
71
75
|
end
|
72
76
|
end
|
77
|
+
|
78
|
+
def change_host_name(name)
|
79
|
+
if !vm.channel.test("hostname -f | grep '^#{name}$' || hostname -s | grep '^#{name}$'")
|
80
|
+
vm.channel.sudo("sed -i '' 's/^hostname=.*$/hostname=#{name}/' /etc/rc.conf")
|
81
|
+
vm.channel.sudo("hostname #{name}")
|
82
|
+
end
|
83
|
+
end
|
73
84
|
end
|
74
85
|
end
|
75
86
|
end
|
data/lib/vagrant/guest/gentoo.rb
CHANGED
@@ -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
|
|
data/lib/vagrant/guest/linux.rb
CHANGED
@@ -19,6 +19,7 @@ module Vagrant
|
|
19
19
|
end
|
20
20
|
|
21
21
|
return :gentoo if @vm.channel.test("cat /etc/gentoo-release")
|
22
|
+
return :fedora if @vm.channel.test("grep 'Fedora release 16' /etc/redhat-release")
|
22
23
|
return :redhat if @vm.channel.test("cat /etc/redhat-release")
|
23
24
|
return :suse if @vm.channel.test("cat /etc/SuSE-release")
|
24
25
|
return :arch if @vm.channel.test("cat /etc/arch-release")
|
data/lib/vagrant/guest/redhat.rb
CHANGED
data/lib/vagrant/guest/ubuntu.rb
CHANGED
@@ -8,7 +8,7 @@ module Vagrant
|
|
8
8
|
super
|
9
9
|
|
10
10
|
# Emit an upstart event if upstart is available
|
11
|
-
|
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)
|
data/lib/vagrant/hosts.rb
CHANGED
@@ -7,6 +7,7 @@ module Vagrant
|
|
7
7
|
autoload :BSD, 'vagrant/hosts/bsd'
|
8
8
|
autoload :FreeBSD, 'vagrant/hosts/freebsd'
|
9
9
|
autoload :Fedora, 'vagrant/hosts/fedora'
|
10
|
+
autoload :OpenSUSE, 'vagrant/hosts/opensuse'
|
10
11
|
autoload :Gentoo, 'vagrant/hosts/gentoo'
|
11
12
|
autoload :Linux, 'vagrant/hosts/linux'
|
12
13
|
autoload :Windows, 'vagrant/hosts/windows'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module Hosts
|
5
|
+
class OpenSUSE < Linux
|
6
|
+
def self.match?
|
7
|
+
release_file = Pathname.new("/etc/SuSE-release")
|
8
|
+
|
9
|
+
if release_file.exist?
|
10
|
+
release_file.open("r") do |f|
|
11
|
+
return true if f.gets =~ /^openSUSE/
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
false
|
16
|
+
end
|
17
|
+
|
18
|
+
# Normal, mid-range precedence.
|
19
|
+
def self.precedence
|
20
|
+
5
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(*args)
|
24
|
+
super
|
25
|
+
|
26
|
+
@nfs_server_binary = "/etc/init.d/nfsserver"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/vagrant/plugin.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|