vagrantup 0.4.3.dev → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/config/default.rb +6 -6
- data/lib/vagrant.rb +6 -3
- data/lib/vagrant/action.rb +77 -0
- data/lib/vagrant/action/action_exception.rb +16 -0
- data/lib/vagrant/action/box/destroy.rb +19 -0
- data/lib/vagrant/action/box/download.rb +78 -0
- data/lib/vagrant/action/box/unpackage.rb +58 -0
- data/lib/vagrant/action/box/verify.rb +23 -0
- data/lib/vagrant/action/builder.rb +151 -0
- data/lib/vagrant/action/builtin.rb +114 -0
- data/lib/vagrant/action/env/error_halt.rb +16 -0
- data/lib/vagrant/action/env/set.rb +18 -0
- data/lib/vagrant/action/environment.rb +98 -0
- data/lib/vagrant/action/exception_catcher.rb +14 -0
- data/lib/vagrant/action/vm/boot.rb +54 -0
- data/lib/vagrant/action/vm/check_box.rb +27 -0
- data/lib/vagrant/action/vm/check_guest_additions.rb +32 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +43 -0
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +39 -0
- data/lib/vagrant/action/vm/clear_nfs_exports.rb +20 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +32 -0
- data/lib/vagrant/action/vm/customize.rb +21 -0
- data/lib/vagrant/action/vm/destroy.rb +20 -0
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +35 -0
- data/lib/vagrant/action/vm/disable_networks.rb +26 -0
- data/lib/vagrant/action/vm/export.rb +53 -0
- data/lib/vagrant/action/vm/forward_ports.rb +121 -0
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +28 -0
- data/lib/vagrant/action/vm/halt.rb +34 -0
- data/lib/vagrant/action/vm/import.rb +33 -0
- data/lib/vagrant/action/vm/match_mac_address.rb +19 -0
- data/lib/vagrant/{actions → action}/vm/network.rb +47 -55
- data/lib/vagrant/action/vm/nfs.rb +161 -0
- data/lib/vagrant/action/vm/nfs_helpers.rb +11 -0
- data/lib/vagrant/action/vm/package.rb +99 -0
- data/lib/vagrant/action/vm/persist.rb +22 -0
- data/lib/vagrant/action/vm/provision.rb +50 -0
- data/lib/vagrant/action/vm/resume.rb +20 -0
- data/lib/vagrant/{actions/vm/shared_folders.rb → action/vm/share_folders.rb} +48 -45
- data/lib/vagrant/action/vm/suspend.rb +20 -0
- data/lib/vagrant/box.rb +3 -7
- data/lib/vagrant/commands/base.rb +1 -3
- data/lib/vagrant/commands/package.rb +4 -9
- data/lib/vagrant/commands/up.rb +0 -2
- data/lib/vagrant/config.rb +15 -1
- data/lib/vagrant/downloaders/file.rb +1 -1
- data/lib/vagrant/downloaders/http.rb +2 -1
- data/lib/vagrant/environment.rb +18 -14
- data/lib/vagrant/hosts/base.rb +77 -0
- data/lib/vagrant/hosts/bsd.rb +53 -0
- data/lib/vagrant/hosts/linux.rb +52 -0
- data/lib/vagrant/provisioners/base.rb +17 -9
- data/lib/vagrant/provisioners/chef.rb +1 -1
- data/lib/vagrant/provisioners/chef_server.rb +4 -8
- data/lib/vagrant/provisioners/chef_solo.rb +1 -2
- data/lib/vagrant/ssh.rb +12 -4
- data/lib/vagrant/systems/base.rb +4 -0
- data/lib/vagrant/systems/linux.rb +12 -1
- data/lib/vagrant/util.rb +16 -0
- data/lib/vagrant/util/busy.rb +59 -0
- data/lib/vagrant/util/plain_logger.rb +11 -0
- data/lib/vagrant/util/platform.rb +18 -0
- data/lib/vagrant/util/resource_logger.rb +128 -0
- data/lib/vagrant/version.rb +6 -0
- data/lib/vagrant/vm.rb +10 -12
- data/templates/chef_solo_solo.erb +2 -1
- data/templates/nfs/exports.erb +3 -0
- data/templates/nfs/exports_linux.erb +3 -0
- data/templates/strings.yml +23 -3
- metadata +121 -196
- data/.gitignore +0 -11
- data/Gemfile +0 -18
- data/Rakefile +0 -41
- data/VERSION +0 -1
- data/bin/.gitignore +0 -0
- data/lib/vagrant/actions/base.rb +0 -130
- data/lib/vagrant/actions/box/add.rb +0 -23
- data/lib/vagrant/actions/box/destroy.rb +0 -14
- data/lib/vagrant/actions/box/download.rb +0 -67
- data/lib/vagrant/actions/box/unpackage.rb +0 -42
- data/lib/vagrant/actions/box/verify.rb +0 -32
- data/lib/vagrant/actions/collection.rb +0 -36
- data/lib/vagrant/actions/runner.rb +0 -131
- data/lib/vagrant/actions/vm/boot.rb +0 -43
- data/lib/vagrant/actions/vm/customize.rb +0 -19
- data/lib/vagrant/actions/vm/destroy.rb +0 -24
- data/lib/vagrant/actions/vm/down.rb +0 -22
- data/lib/vagrant/actions/vm/export.rb +0 -45
- data/lib/vagrant/actions/vm/forward_ports.rb +0 -134
- data/lib/vagrant/actions/vm/halt.rb +0 -24
- data/lib/vagrant/actions/vm/import.rb +0 -23
- data/lib/vagrant/actions/vm/move_hard_drive.rb +0 -51
- data/lib/vagrant/actions/vm/package.rb +0 -94
- data/lib/vagrant/actions/vm/provision.rb +0 -49
- data/lib/vagrant/actions/vm/reload.rb +0 -17
- data/lib/vagrant/actions/vm/resume.rb +0 -16
- data/lib/vagrant/actions/vm/start.rb +0 -26
- data/lib/vagrant/actions/vm/suspend.rb +0 -16
- data/lib/vagrant/actions/vm/up.rb +0 -53
- data/lib/vagrant/busy.rb +0 -79
- data/lib/vagrant/resource_logger.rb +0 -126
- data/lib/vagrant/util/error_helper.rb +0 -13
- data/lib/vagrant/util/output_helper.rb +0 -9
- data/test/test_helper.rb +0 -149
- data/test/vagrant/actions/base_test.rb +0 -32
- data/test/vagrant/actions/box/add_test.rb +0 -36
- data/test/vagrant/actions/box/destroy_test.rb +0 -17
- data/test/vagrant/actions/box/download_test.rb +0 -137
- data/test/vagrant/actions/box/unpackage_test.rb +0 -99
- data/test/vagrant/actions/box/verify_test.rb +0 -44
- data/test/vagrant/actions/collection_test.rb +0 -113
- data/test/vagrant/actions/runner_test.rb +0 -268
- data/test/vagrant/actions/vm/boot_test.rb +0 -49
- data/test/vagrant/actions/vm/customize_test.rb +0 -21
- data/test/vagrant/actions/vm/destroy_test.rb +0 -37
- data/test/vagrant/actions/vm/down_test.rb +0 -39
- data/test/vagrant/actions/vm/export_test.rb +0 -88
- data/test/vagrant/actions/vm/forward_ports_test.rb +0 -253
- data/test/vagrant/actions/vm/halt_test.rb +0 -65
- data/test/vagrant/actions/vm/import_test.rb +0 -45
- data/test/vagrant/actions/vm/move_hard_drive_test.rb +0 -106
- data/test/vagrant/actions/vm/network_test.rb +0 -291
- data/test/vagrant/actions/vm/package_test.rb +0 -254
- data/test/vagrant/actions/vm/provision_test.rb +0 -99
- data/test/vagrant/actions/vm/reload_test.rb +0 -46
- data/test/vagrant/actions/vm/resume_test.rb +0 -26
- data/test/vagrant/actions/vm/shared_folders_test.rb +0 -211
- data/test/vagrant/actions/vm/start_test.rb +0 -73
- data/test/vagrant/actions/vm/suspend_test.rb +0 -26
- data/test/vagrant/actions/vm/up_test.rb +0 -96
- data/test/vagrant/active_list_test.rb +0 -173
- data/test/vagrant/box_test.rb +0 -154
- data/test/vagrant/busy_test.rb +0 -78
- data/test/vagrant/command_test.rb +0 -53
- data/test/vagrant/commands/base_test.rb +0 -139
- data/test/vagrant/commands/box/add_test.rb +0 -34
- data/test/vagrant/commands/box/list_test.rb +0 -32
- data/test/vagrant/commands/box/remove_test.rb +0 -41
- data/test/vagrant/commands/destroy_test.rb +0 -44
- data/test/vagrant/commands/halt_test.rb +0 -50
- data/test/vagrant/commands/init_test.rb +0 -55
- data/test/vagrant/commands/package_test.rb +0 -104
- data/test/vagrant/commands/provision_test.rb +0 -60
- data/test/vagrant/commands/reload_test.rb +0 -44
- data/test/vagrant/commands/resume_test.rb +0 -44
- data/test/vagrant/commands/ssh_config_test.rb +0 -77
- data/test/vagrant/commands/ssh_test.rb +0 -129
- data/test/vagrant/commands/status_test.rb +0 -40
- data/test/vagrant/commands/suspend_test.rb +0 -44
- data/test/vagrant/commands/up_test.rb +0 -47
- data/test/vagrant/config_test.rb +0 -287
- data/test/vagrant/downloaders/base_test.rb +0 -28
- data/test/vagrant/downloaders/file_test.rb +0 -33
- data/test/vagrant/downloaders/http_test.rb +0 -62
- data/test/vagrant/environment_test.rb +0 -770
- data/test/vagrant/provisioners/base_test.rb +0 -33
- data/test/vagrant/provisioners/chef_server_test.rb +0 -176
- data/test/vagrant/provisioners/chef_solo_test.rb +0 -183
- data/test/vagrant/provisioners/chef_test.rb +0 -175
- data/test/vagrant/resource_logger_test.rb +0 -145
- data/test/vagrant/ssh_session_test.rb +0 -46
- data/test/vagrant/ssh_test.rb +0 -296
- data/test/vagrant/systems/linux_test.rb +0 -179
- data/test/vagrant/util/error_helper_test.rb +0 -5
- data/test/vagrant/util/output_helper_test.rb +0 -5
- data/test/vagrant/util/plain_logger_test.rb +0 -17
- data/test/vagrant/util/platform_test.rb +0 -18
- data/test/vagrant/util/stacked_proc_runner_test.rb +0 -43
- data/test/vagrant/util/template_renderer_test.rb +0 -144
- data/test/vagrant/util/translator_test.rb +0 -61
- data/test/vagrant/util_test.rb +0 -27
- data/test/vagrant/vm_test.rb +0 -235
- data/vagrant.gemspec +0 -291
@@ -0,0 +1,77 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Hosts
|
3
|
+
# Base class representing a host machine. These classes
|
4
|
+
# define methods which may have host-specific (Mac OS X, Windows,
|
5
|
+
# Linux, etc) behavior. The class is automatically determined by
|
6
|
+
# default but may be explicitly set via `config.vagrant.host`.
|
7
|
+
class Base
|
8
|
+
# The {Environment} which this host belongs to.
|
9
|
+
attr_reader :env
|
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
|
24
|
+
|
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
|
+
:linux => Linux
|
35
|
+
}
|
36
|
+
|
37
|
+
classes.each do |type, klass|
|
38
|
+
return klass if Util::Platform.send("#{type}?")
|
39
|
+
end
|
40
|
+
|
41
|
+
nil
|
42
|
+
rescue Exception
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Initialzes a new host. This method shouldn't be called directly,
|
48
|
+
# typically, since it will be called by {Environment#load_host!}
|
49
|
+
#
|
50
|
+
# @param [Environment] env
|
51
|
+
def initialize(env)
|
52
|
+
@env = env
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns true of false denoting whether or not this host supports
|
56
|
+
# NFS shared folder setup. This method ideally should verify that
|
57
|
+
# NFS is installed.
|
58
|
+
#
|
59
|
+
# @return [Boolean]
|
60
|
+
def nfs?
|
61
|
+
false
|
62
|
+
end
|
63
|
+
|
64
|
+
# Exports the given hash of folders via NFS. This method will raise
|
65
|
+
# an {Vagrant::Action::ActionException} if anything goes wrong.
|
66
|
+
#
|
67
|
+
# @param [String] ip IP of the guest machine.
|
68
|
+
# @param [Hash] folders Shared folders to sync.
|
69
|
+
def nfs_export(ip, folders)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Cleans up the exports for the current VM.
|
73
|
+
def nfs_cleanup
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Hosts
|
3
|
+
# Represents a BSD host, such as FreeBSD and Darwin (Mac OS X).
|
4
|
+
class BSD < Base
|
5
|
+
include Util
|
6
|
+
|
7
|
+
def nfs?
|
8
|
+
tries = 10
|
9
|
+
begin
|
10
|
+
system("which nfsd > /dev/null 2>&1")
|
11
|
+
rescue TypeError
|
12
|
+
tries -= 1
|
13
|
+
retry if tries > 0
|
14
|
+
|
15
|
+
# Hopefully this point isn't reached
|
16
|
+
raise
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def nfs_export(ip, folders)
|
21
|
+
output = TemplateRenderer.render('nfs/exports',
|
22
|
+
:uuid => env.vm.uuid,
|
23
|
+
:ip => ip,
|
24
|
+
:folders => folders)
|
25
|
+
|
26
|
+
# The sleep ensures that the output is truly flushed before any `sudo`
|
27
|
+
# commands are issued.
|
28
|
+
env.logger.info "Preparing to edit /etc/exports. Administrator priveleges will be required..."
|
29
|
+
sleep 0.5
|
30
|
+
|
31
|
+
output.split("\n").each do |line|
|
32
|
+
# This should only ask for administrative permission once, even
|
33
|
+
# though its executed in multiple subshells.
|
34
|
+
system(%Q[sudo su root -c "echo '#{line}' >> /etc/exports"])
|
35
|
+
end
|
36
|
+
|
37
|
+
# We run restart here instead of "update" just in case nfsd
|
38
|
+
# is not starting
|
39
|
+
system("sudo nfsd restart")
|
40
|
+
end
|
41
|
+
|
42
|
+
def nfs_cleanup
|
43
|
+
system("cat /etc/exports | grep 'VAGRANT-BEGIN: #{env.vm.uuid}' > /dev/null 2>&1")
|
44
|
+
|
45
|
+
if $?.to_i == 0
|
46
|
+
# Use sed to just strip out the block of code which was inserted
|
47
|
+
# by Vagrant
|
48
|
+
system("sudo sed -e '/^# VAGRANT-BEGIN: #{env.vm.uuid}/,/^# VAGRANT-END: #{env.vm.uuid}/ d' -i bak /etc/exports")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Hosts
|
3
|
+
# Represents a Linux based host, such as Ubuntu.
|
4
|
+
class Linux < Base
|
5
|
+
include Util
|
6
|
+
|
7
|
+
def nfs?
|
8
|
+
tries = 10
|
9
|
+
begin
|
10
|
+
# Check procfs to see if NFSd is a supported filesystem
|
11
|
+
system("cat /proc/filesystems | grep nfsd > /dev/null 2>&1")
|
12
|
+
rescue TypeError
|
13
|
+
tries -= 1
|
14
|
+
retry if tries > 0
|
15
|
+
|
16
|
+
# Hopefully this point isn't reached
|
17
|
+
raise
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def nfs_export(ip, folders)
|
22
|
+
output = TemplateRenderer.render('nfs/exports_linux',
|
23
|
+
:uuid => env.vm.uuid,
|
24
|
+
:ip => ip,
|
25
|
+
:folders => folders)
|
26
|
+
|
27
|
+
env.logger.info "Preparing to edit /etc/exports. Administrator priveleges will be required..."
|
28
|
+
sleep 0.5
|
29
|
+
|
30
|
+
output.split("\n").each do |line|
|
31
|
+
# This should only ask for administrative permission once, even
|
32
|
+
# though its executed in multiple subshells.
|
33
|
+
system(%Q[sudo su root -c "echo '#{line}' >> /etc/exports"])
|
34
|
+
end
|
35
|
+
|
36
|
+
# We run restart here instead of "update" just in case nfsd
|
37
|
+
# is not starting
|
38
|
+
system("sudo /etc/init.d/nfs-kernel-server restart")
|
39
|
+
end
|
40
|
+
|
41
|
+
def nfs_cleanup
|
42
|
+
system("cat /etc/exports | grep 'VAGRANT-BEGIN: #{env.vm.uuid}' > /dev/null 2>&1")
|
43
|
+
|
44
|
+
if $?.to_i == 0
|
45
|
+
# Use sed to just strip out the block of code which was inserted
|
46
|
+
# by Vagrant
|
47
|
+
system("sudo sed -e '/^# VAGRANT-BEGIN: #{env.vm.uuid}/,/^# VAGRANT-END: #{env.vm.uuid}/ d' -ibak /etc/exports")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -7,19 +7,27 @@ module Vagrant
|
|
7
7
|
class Base
|
8
8
|
include Vagrant::Util
|
9
9
|
|
10
|
-
# The
|
11
|
-
|
10
|
+
# The environment which provisioner is running in. This is a
|
11
|
+
# {Vagrant::Action::Environment}
|
12
|
+
attr_reader :action_env
|
12
13
|
|
13
|
-
def initialize(
|
14
|
-
@
|
14
|
+
def initialize(env)
|
15
|
+
@action_env = env
|
15
16
|
end
|
16
17
|
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
18
|
+
# Returns the actual {Vagrant::Environment} which this provisioner
|
19
|
+
# represents.
|
20
|
+
#
|
21
|
+
# @return [Vagrant::Environment]
|
21
22
|
def env
|
22
|
-
|
23
|
+
action_env.env
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the VM which this provisioner is working on.
|
27
|
+
#
|
28
|
+
# @return [Vagrant::VM]
|
29
|
+
def vm
|
30
|
+
env.vm
|
23
31
|
end
|
24
32
|
|
25
33
|
# This method returns the environment's logger as a convenience
|
@@ -5,13 +5,11 @@ module Vagrant
|
|
5
5
|
class ChefServer < Chef
|
6
6
|
def prepare
|
7
7
|
if env.config.chef.validation_key_path.nil?
|
8
|
-
|
8
|
+
action_env.error!(:chef_server_validation_key_required)
|
9
9
|
elsif !File.file?(validation_key_path)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
if env.config.chef.chef_server_url.nil?
|
14
|
-
raise Actions::ActionException.new(:chef_server_url_required)
|
10
|
+
action_env.error!(:chef_server_validation_key_doesnt_exist)
|
11
|
+
elsif env.config.chef.chef_server_url.nil?
|
12
|
+
action_env.error!(:chef_server_url_required)
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
@@ -55,8 +53,6 @@ module Vagrant
|
|
55
53
|
logger.info "Running chef-client..."
|
56
54
|
vm.ssh.execute do |ssh|
|
57
55
|
ssh.exec!(command) do |channel, type, data|
|
58
|
-
# TODO: Very verbose. It would be easier to save the data and only show it during
|
59
|
-
# an error, or when verbosity level is set high
|
60
56
|
if type == :exit_status
|
61
57
|
ssh.check_exit_status(data, command)
|
62
58
|
else
|
@@ -29,6 +29,7 @@ module Vagrant
|
|
29
29
|
|
30
30
|
def setup_solo_config
|
31
31
|
setup_config("chef_solo_solo", "solo.rb", {
|
32
|
+
:node_name => env.config.chef.node_name,
|
32
33
|
:provisioning_path => env.config.chef.provisioning_path,
|
33
34
|
:cookbooks_path => cookbooks_path,
|
34
35
|
:roles_path => roles_path
|
@@ -41,8 +42,6 @@ module Vagrant
|
|
41
42
|
logger.info "Running chef-solo..."
|
42
43
|
vm.ssh.execute do |ssh|
|
43
44
|
ssh.exec!(command) do |channel, type, data|
|
44
|
-
# TODO: Very verbose. It would be easier to save the data and only show it during
|
45
|
-
# an error, or when verbosity level is set high
|
46
45
|
ssh.check_exit_status(data, command) if type == :exit_status
|
47
46
|
logger.info("#{data}: #{type}") if type != :exit_status
|
48
47
|
end
|
data/lib/vagrant/ssh.rb
CHANGED
@@ -31,12 +31,17 @@ module Vagrant
|
|
31
31
|
|
32
32
|
check_key_permissions(options[:private_key_path])
|
33
33
|
|
34
|
+
# Command line options
|
35
|
+
command_options = ["-p #{options[:port]}", "-o UserKnownHostsFile=/dev/null",
|
36
|
+
"-o StrictHostKeyChecking=no", "-i #{options[:private_key_path]}"]
|
37
|
+
command_options << "-o ForwardAgent=yes" if env.config.ssh.forward_agent
|
38
|
+
|
34
39
|
# Some hackery going on here. On Mac OS X Leopard (10.5), exec fails
|
35
40
|
# (GH-51). As a workaround, we fork and wait. On all other platforms,
|
36
41
|
# we simply exec.
|
37
42
|
pid = nil
|
38
43
|
pid = fork if Util::Platform.leopard?
|
39
|
-
Kernel.exec "ssh
|
44
|
+
Kernel.exec "ssh #{command_options.join(" ")} #{options[:username]}@#{options[:host]}".strip if pid.nil?
|
40
45
|
Process.wait(pid) if pid
|
41
46
|
end
|
42
47
|
|
@@ -46,6 +51,10 @@ module Vagrant
|
|
46
51
|
# Check the key permissions to avoid SSH hangs
|
47
52
|
check_key_permissions(env.config.ssh.private_key_path)
|
48
53
|
|
54
|
+
# Merge in any additional options
|
55
|
+
opts = opts.dup
|
56
|
+
opts[:forward_agent] = true if env.config.ssh.forward_agent
|
57
|
+
|
49
58
|
Net::SSH.start(env.config.ssh.host,
|
50
59
|
env.config[:ssh][:username],
|
51
60
|
opts.merge( :port => port,
|
@@ -98,10 +107,9 @@ module Vagrant
|
|
98
107
|
# Checks the file permissions for the private key, resetting them
|
99
108
|
# if needed, or on failure erroring.
|
100
109
|
def check_key_permissions(key_path)
|
110
|
+
# Windows systems don't have this issue
|
101
111
|
return if Mario::Platform.windows?
|
102
112
|
|
103
|
-
# TODO: This only works on unix based systems for now. Windows
|
104
|
-
# systems will need to be investigated further.
|
105
113
|
stat = File.stat(key_path)
|
106
114
|
|
107
115
|
if stat.owned? && file_perms(key_path) != "600"
|
@@ -219,7 +227,7 @@ module Vagrant
|
|
219
227
|
}
|
220
228
|
}.merge(options || {})
|
221
229
|
|
222
|
-
raise
|
230
|
+
raise Action::ActionException.new(options[:error_key], options[:error_data])
|
223
231
|
end
|
224
232
|
end
|
225
233
|
end
|
data/lib/vagrant/systems/base.rb
CHANGED
@@ -55,6 +55,10 @@ module Vagrant
|
|
55
55
|
# wants the folder mounted.
|
56
56
|
def mount_shared_folder(ssh, name, guestpath); end
|
57
57
|
|
58
|
+
# Mounts a shared folder via NFS. This assumes that the exports
|
59
|
+
# via the host are already done.
|
60
|
+
def mount_nfs(ip, folders); end
|
61
|
+
|
58
62
|
# Prepares the system for unison folder syncing. This is called
|
59
63
|
# once once prior to any `create_unison` calls.
|
60
64
|
def prepare_unison(ssh); end
|
@@ -52,6 +52,17 @@ module Vagrant
|
|
52
52
|
ssh.exec!("sudo chown #{config.ssh.username} #{guestpath}")
|
53
53
|
end
|
54
54
|
|
55
|
+
def mount_nfs(ip, folders)
|
56
|
+
# TODO: Maybe check for nfs support on the guest, since its often
|
57
|
+
# not installed by default
|
58
|
+
folders.each do |name, opts|
|
59
|
+
vm.ssh.execute do |ssh|
|
60
|
+
ssh.exec!("sudo mkdir -p #{opts[:guestpath]}")
|
61
|
+
ssh.exec!("sudo mount #{ip}:#{opts[:hostpath]} #{opts[:guestpath]}")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
55
66
|
def prepare_unison(ssh)
|
56
67
|
ssh.exec!("which unison", :error_key => :unison_not_found)
|
57
68
|
|
@@ -119,7 +130,7 @@ module Vagrant
|
|
119
130
|
break unless result
|
120
131
|
|
121
132
|
attempts += 1
|
122
|
-
raise
|
133
|
+
raise Action::ActionException.new(:vm_mount_fail) if attempts >= 10
|
123
134
|
sleep sleeptime
|
124
135
|
end
|
125
136
|
end
|
data/lib/vagrant/util.rb
CHANGED
@@ -3,5 +3,21 @@ module Vagrant
|
|
3
3
|
def self.included(base)
|
4
4
|
base.extend(self)
|
5
5
|
end
|
6
|
+
|
7
|
+
def error_and_exit(key, data = {})
|
8
|
+
abort <<-error
|
9
|
+
=====================================================================
|
10
|
+
Vagrant experienced an error!
|
11
|
+
|
12
|
+
#{Translator.t(key, data).chomp}
|
13
|
+
=====================================================================
|
14
|
+
error
|
15
|
+
end
|
16
|
+
|
17
|
+
def wrap_output
|
18
|
+
puts "====================================================================="
|
19
|
+
yield
|
20
|
+
puts "====================================================================="
|
21
|
+
end
|
6
22
|
end
|
7
23
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Util
|
3
|
+
# Utility class which allows blocks of code to be marked as "busy"
|
4
|
+
# with a specified interrupt handler. During busy areas of code, it
|
5
|
+
# is often undesirable for SIGINTs to immediately kill the application.
|
6
|
+
# This class is a helper to cleanly register callbacks to handle this
|
7
|
+
# situation.
|
8
|
+
class Busy
|
9
|
+
@@registered = []
|
10
|
+
@@mutex = Mutex.new
|
11
|
+
|
12
|
+
class << self
|
13
|
+
# Mark a given block of code as a "busy" block of code, which will
|
14
|
+
# register a SIGINT handler for the duration of the block. When a
|
15
|
+
# SIGINT occurs, the `sig_callback` proc will be called. It is up
|
16
|
+
# to the callback to behave properly and exit the application.
|
17
|
+
def busy(sig_callback)
|
18
|
+
register(sig_callback)
|
19
|
+
yield
|
20
|
+
ensure
|
21
|
+
unregister(sig_callback)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Registers a SIGINT handler. This typically is called from {busy}.
|
25
|
+
# Callbacks are only registered once, so calling this multiple times
|
26
|
+
# with the same callback has no consequence.
|
27
|
+
def register(sig_callback)
|
28
|
+
@@mutex.synchronize do
|
29
|
+
registered << sig_callback
|
30
|
+
registered.uniq!
|
31
|
+
|
32
|
+
# Register the handler if this is our first callback.
|
33
|
+
Signal.trap("INT") { fire_callbacks } if registered.length == 1
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Unregisters a SIGINT handler.
|
38
|
+
def unregister(sig_callback)
|
39
|
+
@@mutex.synchronize do
|
40
|
+
registered.delete(sig_callback)
|
41
|
+
|
42
|
+
# Remove the signal trap if no more registered callbacks exist
|
43
|
+
Signal.trap("INT", "DEFAULT") if registered.empty?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Fires all the registered callbacks.
|
48
|
+
def fire_callbacks
|
49
|
+
registered.each { |r| r.call }
|
50
|
+
end
|
51
|
+
|
52
|
+
# Helper method to get access to the class variable. This is mostly
|
53
|
+
# exposed for tests. This shouldn't be mucked with directly, since it's
|
54
|
+
# structure may change at any time.
|
55
|
+
def registered; @@registered; end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|