vagrantup 0.8.10 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +77 -1
- data/Gemfile +0 -14
- data/LICENSE +1 -1
- data/bin/vagrant +47 -20
- data/config/default.rb +6 -14
- data/lib/vagrant/action/box/destroy.rb +7 -3
- data/lib/vagrant/action/box/download.rb +8 -8
- data/lib/vagrant/action/box/package.rb +2 -2
- data/lib/vagrant/action/box/unpackage.rb +13 -7
- data/lib/vagrant/action/box/verify.rb +5 -5
- data/lib/vagrant/action/builder.rb +23 -19
- data/lib/vagrant/action/builtin.rb +117 -79
- data/lib/vagrant/action/env/set.rb +7 -4
- data/lib/vagrant/action/environment.rb +3 -41
- data/lib/vagrant/action/general/package.rb +14 -29
- data/lib/vagrant/action/general/validate.rb +2 -2
- data/lib/vagrant/action/runner.rb +53 -0
- data/lib/vagrant/action/vm/boot.rb +9 -9
- data/lib/vagrant/action/vm/check_accessible.rb +2 -2
- data/lib/vagrant/action/vm/check_box.rb +10 -12
- data/lib/vagrant/action/vm/check_guest_additions.rb +8 -8
- data/lib/vagrant/action/vm/check_port_collisions.rb +85 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +4 -4
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +3 -11
- data/lib/vagrant/action/vm/clear_network_interfaces.rb +31 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +2 -11
- data/lib/vagrant/action/vm/customize.rb +19 -9
- data/lib/vagrant/action/vm/destroy.rb +4 -4
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +2 -12
- data/lib/vagrant/action/vm/discard_state.rb +4 -4
- data/lib/vagrant/action/vm/export.rb +13 -8
- data/lib/vagrant/action/vm/forward_ports.rb +55 -102
- data/lib/vagrant/action/vm/halt.rb +9 -6
- data/lib/vagrant/action/vm/host_name.rb +4 -4
- data/lib/vagrant/action/vm/import.rb +19 -10
- data/lib/vagrant/action/vm/match_mac_address.rb +4 -9
- data/lib/vagrant/action/vm/network.rb +300 -94
- data/lib/vagrant/action/vm/nfs.rb +41 -26
- data/lib/vagrant/action/vm/package.rb +1 -1
- data/lib/vagrant/action/vm/package_vagrantfile.rb +5 -2
- data/lib/vagrant/action/vm/provision.rb +42 -13
- data/lib/vagrant/action/vm/provisioner_cleanup.rb +2 -2
- data/lib/vagrant/action/vm/{clear_nfs_exports.rb → prune_nfs_exports.rb} +7 -7
- data/lib/vagrant/action/vm/resume.rb +4 -4
- data/lib/vagrant/action/vm/setup_package_files.rb +54 -0
- data/lib/vagrant/action/vm/share_folders.rb +63 -39
- data/lib/vagrant/action/vm/suspend.rb +4 -4
- data/lib/vagrant/action/warden.rb +13 -6
- data/lib/vagrant/action.rb +45 -123
- data/lib/vagrant/box.rb +9 -55
- data/lib/vagrant/box_collection.rb +22 -17
- data/lib/vagrant/cli.rb +62 -47
- data/lib/vagrant/command/base.rb +135 -90
- data/lib/vagrant/command/box.rb +46 -21
- data/lib/vagrant/command/box_add.rb +33 -0
- data/lib/vagrant/command/box_list.rb +25 -0
- data/lib/vagrant/command/box_remove.rb +23 -0
- data/lib/vagrant/command/box_repackage.rb +23 -0
- data/lib/vagrant/command/destroy.rb +16 -5
- data/lib/vagrant/command/halt.rb +25 -7
- data/lib/vagrant/command/init.rb +30 -7
- data/lib/vagrant/command/package.rb +49 -18
- data/lib/vagrant/command/provision.rb +22 -9
- data/lib/vagrant/command/reload.rb +18 -5
- data/lib/vagrant/command/resume.rb +18 -5
- data/lib/vagrant/command/ssh.rb +69 -31
- data/lib/vagrant/command/ssh_config.rb +37 -22
- data/lib/vagrant/command/status.rb +22 -20
- data/lib/vagrant/command/suspend.rb +18 -5
- data/lib/vagrant/command/up.rb +41 -8
- data/lib/vagrant/command.rb +18 -20
- data/lib/vagrant/communication/base.rb +56 -0
- data/lib/vagrant/communication/ssh.rb +200 -0
- data/lib/vagrant/communication.rb +7 -0
- data/lib/vagrant/config/base.rb +18 -26
- data/lib/vagrant/config/container.rb +37 -0
- data/lib/vagrant/config/error_recorder.rb +1 -1
- data/lib/vagrant/config/loader.rb +125 -0
- data/lib/vagrant/config/nfs.rb +1 -3
- data/lib/vagrant/config/package.rb +1 -3
- data/lib/vagrant/config/ssh.rb +31 -16
- data/lib/vagrant/config/top.rb +36 -25
- data/lib/vagrant/config/vagrant.rb +2 -5
- data/lib/vagrant/config/vm/provisioner.rb +16 -20
- data/lib/vagrant/config/vm/sub_vm.rb +1 -1
- data/lib/vagrant/config/vm.rb +115 -56
- data/lib/vagrant/config.rb +29 -103
- data/lib/vagrant/data_store.rb +23 -15
- data/lib/vagrant/downloaders/base.rb +7 -5
- data/lib/vagrant/downloaders/file.rb +4 -4
- data/lib/vagrant/downloaders/http.rb +4 -5
- data/lib/vagrant/driver/virtualbox.rb +121 -0
- data/lib/vagrant/driver/virtualbox_4_0.rb +411 -0
- data/lib/vagrant/driver/virtualbox_4_1.rb +411 -0
- data/lib/vagrant/driver/virtualbox_base.rb +284 -0
- data/lib/vagrant/driver.rb +7 -0
- data/lib/vagrant/environment.rb +221 -240
- data/lib/vagrant/errors.rb +74 -25
- data/lib/vagrant/guest/arch.rb +48 -0
- data/lib/vagrant/{systems → guest}/base.rb +30 -18
- data/lib/vagrant/guest/debian.rb +61 -0
- data/lib/vagrant/{systems → guest}/freebsd.rb +11 -18
- data/lib/vagrant/guest/gentoo.rb +32 -0
- data/lib/vagrant/{systems → guest}/linux/config.rb +2 -4
- data/lib/vagrant/guest/linux/error.rb +9 -0
- data/lib/vagrant/guest/linux.rb +78 -0
- data/lib/vagrant/guest/redhat.rb +66 -0
- data/lib/vagrant/guest/solaris.rb +114 -0
- data/lib/vagrant/{systems → guest}/suse.rb +2 -2
- data/lib/vagrant/guest/ubuntu.rb +23 -0
- data/lib/vagrant/guest.rb +16 -0
- data/lib/vagrant/hosts/arch.rb +7 -3
- data/lib/vagrant/hosts/base.rb +36 -46
- data/lib/vagrant/hosts/bsd.rb +53 -16
- data/lib/vagrant/hosts/fedora.rb +14 -0
- data/lib/vagrant/hosts/freebsd.rb +6 -36
- data/lib/vagrant/hosts/linux.rb +45 -20
- data/lib/vagrant/hosts/windows.rb +16 -0
- data/lib/vagrant/hosts.rb +23 -6
- data/lib/vagrant/provisioners/base.rb +11 -34
- data/lib/vagrant/provisioners/chef.rb +30 -26
- data/lib/vagrant/provisioners/chef_client.rb +37 -23
- data/lib/vagrant/provisioners/chef_solo.rb +61 -16
- data/lib/vagrant/provisioners/puppet.rb +70 -38
- data/lib/vagrant/provisioners/puppet_server.rb +12 -13
- data/lib/vagrant/provisioners/shell.rb +24 -24
- data/lib/vagrant/provisioners.rb +10 -7
- data/lib/vagrant/registry.rb +49 -0
- data/lib/vagrant/ssh.rb +82 -153
- data/lib/vagrant/ui.rb +118 -50
- data/lib/vagrant/util/busy.rb +1 -1
- data/lib/vagrant/util/file_mode.rb +12 -0
- data/lib/vagrant/util/network_ip.rb +28 -0
- data/lib/vagrant/util/platform.rb +1 -0
- data/lib/vagrant/util/subprocess.rb +227 -0
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +111 -97
- data/lib/vagrant.rb +132 -5
- data/tasks/acceptance.rake +3 -3
- data/tasks/test.rake +7 -2
- data/templates/commands/init/Vagrantfile.erb +11 -4
- data/templates/{ssh_config.erb → commands/ssh_config/config.erb} +0 -0
- data/templates/guests/arch/network_dhcp.erb +7 -0
- data/templates/guests/arch/network_static.erb +7 -0
- data/templates/guests/debian/network_dhcp.erb +6 -0
- data/templates/guests/debian/network_static.erb +7 -0
- data/templates/guests/gentoo/network_dhcp.erb +4 -0
- data/templates/guests/gentoo/network_static.erb +4 -0
- data/templates/guests/redhat/network_dhcp.erb +6 -0
- data/templates/guests/redhat/network_static.erb +7 -0
- data/templates/locales/en.yml +241 -122
- data/templates/{chef_server_client.erb → provisioners/chef_client/client.erb} +0 -0
- data/templates/{chef_solo_solo.erb → provisioners/chef_solo/solo.erb} +0 -0
- data/test/acceptance/base.rb +10 -10
- data/test/acceptance/box_test.rb +28 -6
- data/test/acceptance/destroy_test.rb +1 -1
- data/test/acceptance/halt_test.rb +4 -4
- data/test/acceptance/init_test.rb +3 -3
- data/test/acceptance/networking/host_only_test.rb +37 -0
- data/test/acceptance/networking/port_forward_test.rb +125 -0
- data/test/acceptance/package_test.rb +46 -0
- data/test/acceptance/provisioning/basic_test.rb +61 -0
- data/test/acceptance/provisioning/chef_solo_test.rb +37 -0
- data/test/acceptance/provisioning/shell_test.rb +53 -0
- data/test/acceptance/resume_test.rb +1 -1
- data/test/acceptance/skeletons/chef_solo_basic/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/skeletons/chef_solo_json/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_json/cookbooks/basic/recipes/default.rb +6 -0
- data/test/acceptance/skeletons/provisioner_multi/README.md +3 -0
- data/test/acceptance/skeletons/provisioner_multi/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/ssh_test.rb +7 -2
- data/test/acceptance/support/config.rb +1 -1
- data/test/acceptance/support/isolated_environment.rb +41 -150
- data/test/acceptance/support/matchers/match_output.rb +1 -1
- data/test/acceptance/support/matchers/succeed.rb +14 -0
- data/test/acceptance/support/network_tests.rb +29 -0
- data/test/acceptance/support/output.rb +9 -1
- data/test/acceptance/support/shared/base_context.rb +16 -9
- data/test/acceptance/support/shared/command_examples.rb +4 -4
- data/test/acceptance/suspend_test.rb +1 -1
- data/test/acceptance/up_basic_test.rb +26 -7
- data/test/acceptance/up_with_box_url.rb +1 -1
- data/test/acceptance/vagrant_test.rb +1 -1
- data/test/acceptance/version_test.rb +0 -5
- data/test/support/isolated_environment.rb +46 -0
- data/test/{acceptance/support → support}/tempdir.rb +0 -0
- data/test/unit/base.rb +21 -0
- data/test/unit/support/isolated_environment.rb +39 -0
- data/test/unit/support/shared/base_context.rb +30 -0
- data/test/unit/vagrant/action/builder_test.rb +126 -177
- data/test/unit/vagrant/action/environment_test.rb +10 -21
- data/test/unit/vagrant/action/runner_test.rb +65 -0
- data/test/unit/vagrant/action/warden_test.rb +64 -97
- data/test/unit/vagrant/box_collection_test.rb +44 -33
- data/test/unit/vagrant/box_test.rb +25 -65
- data/test/unit/vagrant/command/base_test.rb +141 -14
- data/test/unit/vagrant/config/base_test.rb +16 -43
- data/test/unit/vagrant/config/loader_test.rb +79 -0
- data/test/unit/vagrant/config/top_test.rb +69 -0
- data/test/unit/vagrant/config/vm_test.rb +62 -47
- data/test/unit/vagrant/config_test.rb +16 -151
- data/test/unit/vagrant/data_store_test.rb +43 -61
- data/test/unit/vagrant/downloaders/base_test.rb +12 -22
- data/test/unit/vagrant/downloaders/file_test.rb +58 -31
- data/test/unit/vagrant/downloaders/http_test.rb +12 -86
- data/test/unit/vagrant/environment_test.rb +107 -536
- data/test/unit/vagrant/hosts_test.rb +36 -0
- data/test/unit/vagrant/registry_test.rb +56 -0
- data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
- data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +23 -24
- data/test/unit/vagrant/util/network_ip_test.rb +17 -0
- data/test/unit/vagrant/util/retryable_test.rb +90 -34
- data/test/unit/vagrant_test.rb +27 -0
- data/test/{unit → unit_legacy}/locales/en.yml +0 -0
- data/test/{unit → unit_legacy}/test_helper.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/destroy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/download_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/unpackage_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/verify_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/env/set_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/general/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/general/validate_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/boot_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_accessible_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_box_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_guest_additions_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clean_machine_folder_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_forwarded_ports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_nfs_exports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_shared_folders_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/customize_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/discard_state_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/export_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/halt_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/host_name_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/import_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/match_mac_address_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/modify_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/network_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/package_vagrantfile_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/provision_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/provisioner_cleanup_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/resume_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/share_folders_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/suspend_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action_test.rb +0 -0
- data/test/unit_legacy/vagrant/box_collection_test.rb +45 -0
- data/test/unit_legacy/vagrant/box_test.rb +74 -0
- data/test/{unit → unit_legacy}/vagrant/cli_test.rb +0 -0
- data/test/unit_legacy/vagrant/command/base_test.rb +23 -0
- data/test/{unit → unit_legacy}/vagrant/command/group_base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/init_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/package_test.rb +0 -0
- data/test/unit_legacy/vagrant/config/base_test.rb +52 -0
- data/test/{unit → unit_legacy}/vagrant/config/error_recorder_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/ssh_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/vagrant_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/vm/provisioner_test.rb +0 -0
- data/test/unit_legacy/vagrant/config/vm_test.rb +47 -0
- data/test/unit_legacy/vagrant/config_test.rb +148 -0
- data/test/unit_legacy/vagrant/downloaders/http_test.rb +93 -0
- data/test/unit_legacy/vagrant/environment_test.rb +539 -0
- data/test/{unit → unit_legacy}/vagrant/errors_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/bsd_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/linux_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/plugin_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_client_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_solo_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_server_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/shell_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/ssh/session_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/ssh_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/systems/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/systems/linux_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/busy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/counter_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/platform_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/stacked_proc_runner_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/template_renderer_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/vm_test.rb +0 -0
- data/vagrant.gemspec +7 -9
- metadata +183 -179
- data/keys/vagrant.ppk +0 -26
- data/lib/vagrant/action/box.rb +0 -11
- data/lib/vagrant/action/env.rb +0 -7
- data/lib/vagrant/action/general.rb +0 -8
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +0 -28
- data/lib/vagrant/action/vm/modify.rb +0 -37
- data/lib/vagrant/action/vm/nfs_helpers.rb +0 -11
- data/lib/vagrant/action/vm.rb +0 -34
- data/lib/vagrant/command/group_base.rb +0 -107
- data/lib/vagrant/command/helpers.rb +0 -33
- data/lib/vagrant/command/named_base.rb +0 -14
- data/lib/vagrant/command/upgrade_to_060.rb +0 -45
- data/lib/vagrant/command/version.rb +0 -13
- data/lib/vagrant/ssh/session.rb +0 -136
- data/lib/vagrant/systems/arch.rb +0 -34
- data/lib/vagrant/systems/debian.rb +0 -36
- data/lib/vagrant/systems/gentoo.rb +0 -27
- data/lib/vagrant/systems/linux/error.rb +0 -9
- data/lib/vagrant/systems/linux.rb +0 -82
- data/lib/vagrant/systems/redhat.rb +0 -48
- data/lib/vagrant/systems/solaris.rb +0 -113
- data/lib/vagrant/systems/ubuntu.rb +0 -17
- data/lib/vagrant/systems.rb +0 -13
- data/templates/network_entry_arch.erb +0 -9
- data/templates/network_entry_debian.erb +0 -8
- data/templates/network_entry_gentoo.erb +0 -5
- data/templates/network_entry_redhat.erb +0 -9
- data/test/unit/vagrant/ui_test.rb +0 -29
data/lib/vagrant/config/ssh.rb
CHANGED
@@ -1,37 +1,52 @@
|
|
1
1
|
module Vagrant
|
2
|
-
|
2
|
+
module Config
|
3
3
|
class SSHConfig < Base
|
4
|
-
configures :ssh
|
5
|
-
|
6
4
|
attr_accessor :username
|
5
|
+
attr_accessor :password
|
7
6
|
attr_accessor :host
|
8
|
-
attr_accessor :
|
9
|
-
attr_accessor :
|
7
|
+
attr_accessor :port
|
8
|
+
attr_accessor :guest_port
|
10
9
|
attr_accessor :max_tries
|
11
10
|
attr_accessor :timeout
|
12
|
-
|
11
|
+
attr_accessor :private_key_path
|
13
12
|
attr_accessor :forward_agent
|
14
13
|
attr_accessor :forward_x11
|
15
14
|
attr_accessor :shell
|
16
|
-
attr_accessor :port
|
17
15
|
|
18
16
|
def initialize
|
19
|
-
@shell
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@forward_x11 = false
|
17
|
+
@shell = "bash"
|
18
|
+
@forward_agent = false
|
19
|
+
@forward_x11 = false
|
23
20
|
end
|
24
21
|
|
25
|
-
def
|
26
|
-
|
22
|
+
def forwarded_port_key=(value)
|
23
|
+
raise Errors::DeprecationError, :message => <<-MESSAGE
|
24
|
+
`config.ssh.forwarded_port_key` is now gone. You must now use
|
25
|
+
`config.ssh.guest_port` which is expected to be the port on the
|
26
|
+
guest that SSH is listening on. Vagrant will automatically scan
|
27
|
+
the forwarded ports to look for a forwarded port from this port
|
28
|
+
and use it.
|
29
|
+
MESSAGE
|
27
30
|
end
|
28
31
|
|
29
|
-
def
|
30
|
-
|
32
|
+
def forwarded_port_destination=(value)
|
33
|
+
raise Errors::DeprecationError, :message => <<-MESSAGE
|
34
|
+
`config.ssh.forwarded_port_destination` is now gone. You must now use
|
35
|
+
`config.ssh.guest_port` which is expected to be the port on the
|
36
|
+
guest that SSH is listening on. Vagrant will automatically scan
|
37
|
+
the forwarded ports to look for a forwarded port from this port
|
38
|
+
and use it.
|
39
|
+
MESSAGE
|
40
|
+
end
|
41
|
+
|
42
|
+
def validate(env, errors)
|
43
|
+
[:username, :host, :max_tries, :timeout].each do |field|
|
31
44
|
errors.add(I18n.t("vagrant.config.common.error_empty", :field => field)) if !instance_variable_get("@#{field}".to_sym)
|
32
45
|
end
|
33
46
|
|
34
|
-
|
47
|
+
if private_key_path && !File.file?(private_key_path)
|
48
|
+
errors.add(I18n.t("vagrant.config.ssh.private_key_missing", :path => private_key_path))
|
49
|
+
end
|
35
50
|
end
|
36
51
|
end
|
37
52
|
end
|
data/lib/vagrant/config/top.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Vagrant
|
2
|
-
|
2
|
+
module Config
|
3
3
|
# This class is the "top" configure class, which handles registering
|
4
4
|
# other configuration classes as well as validation of all configured
|
5
5
|
# classes. This is the object which is returned by {Environment#config}
|
@@ -7,34 +7,45 @@ module Vagrant
|
|
7
7
|
#
|
8
8
|
# If you're looking to create your own configuration class, see {Base}.
|
9
9
|
class Top < Base
|
10
|
-
|
10
|
+
attr_reader :keys
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
def initialize(registry=nil)
|
13
|
+
@keys = {}
|
14
|
+
@registry = registry || Vagrant.config_keys
|
15
|
+
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@@configures ||= {}
|
20
|
-
end
|
17
|
+
# We use method_missing as a way to get the configuration that is used
|
18
|
+
# for Vagrant and load the proper configuration classes for each.
|
19
|
+
def method_missing(name, *args)
|
20
|
+
return @keys[name] if @keys.has_key?(name)
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
config_klass = @registry.get(name.to_sym)
|
23
|
+
if config_klass
|
24
|
+
# Instantiate the class and return the instance
|
25
|
+
@keys[name] = config_klass.new
|
26
|
+
return @keys[name]
|
27
|
+
else
|
28
|
+
# Super it up to probably raise a NoMethodError
|
29
|
+
super
|
27
30
|
end
|
28
31
|
end
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
# Custom implementation to merge each key separately.
|
34
|
+
def merge(other)
|
35
|
+
result = self.class.new
|
36
|
+
@keys.each do |key, value|
|
37
|
+
result.keys[key] = value.merge(other.send(key))
|
38
|
+
end
|
39
|
+
|
40
|
+
other.keys.each do |key, value|
|
41
|
+
if !@keys.has_key?(key)
|
42
|
+
# This is a key that the other configuration class has
|
43
|
+
# that we don't, so just copy it in.
|
44
|
+
result.keys[key] = value.dup
|
45
|
+
end
|
35
46
|
end
|
36
47
|
|
37
|
-
|
48
|
+
result
|
38
49
|
end
|
39
50
|
|
40
51
|
# Validates the configuration classes of this instance and raises an
|
@@ -42,13 +53,13 @@ module Vagrant
|
|
42
53
|
# class, the method you want to implement is {Base#validate}. This is
|
43
54
|
# the method that checks all the validation, not one which defines
|
44
55
|
# validation rules.
|
45
|
-
def validate!
|
56
|
+
def validate!(env)
|
46
57
|
# Validate each of the configured classes and store the results into
|
47
58
|
# a hash.
|
48
|
-
errors =
|
49
|
-
key,
|
59
|
+
errors = @keys.inject({}) do |container, data|
|
60
|
+
key, instance = data
|
50
61
|
recorder = ErrorRecorder.new
|
51
|
-
|
62
|
+
instance.validate(env, recorder)
|
52
63
|
container[key.to_sym] = recorder if !recorder.errors.empty?
|
53
64
|
container
|
54
65
|
end
|
@@ -1,13 +1,10 @@
|
|
1
1
|
module Vagrant
|
2
|
-
|
2
|
+
module Config
|
3
3
|
class VagrantConfig < Base
|
4
|
-
configures :vagrant
|
5
|
-
|
6
4
|
attr_accessor :dotfile_name
|
7
5
|
attr_accessor :host
|
8
|
-
attr_accessor :ssh_session_cache
|
9
6
|
|
10
|
-
def validate(errors)
|
7
|
+
def validate(env, errors)
|
11
8
|
[:dotfile_name, :host].each do |field|
|
12
9
|
errors.add(I18n.t("vagrant.config.common.error_empty", :field => field)) if !instance_variable_get("@#{field}".to_sym)
|
13
10
|
end
|
@@ -1,42 +1,38 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
|
1
3
|
module Vagrant
|
2
|
-
|
4
|
+
module Config
|
3
5
|
class VMConfig < Base
|
4
6
|
# Represents a single configured provisioner for a VM.
|
5
7
|
class Provisioner
|
6
|
-
attr_reader :top
|
7
8
|
attr_reader :shortcut
|
8
9
|
attr_reader :provisioner
|
9
10
|
attr_reader :config
|
10
11
|
|
11
|
-
def initialize(
|
12
|
-
@
|
12
|
+
def initialize(shortcut, options=nil, &block)
|
13
|
+
@logger = Log4r::Logger.new("vagrant::config::vm::provisioner")
|
14
|
+
@logger.debug("Provisioner config: #{shortcut}")
|
13
15
|
@shortcut = shortcut
|
14
16
|
@provisioner = shortcut
|
15
|
-
@provisioner =
|
17
|
+
@provisioner = Vagrant.provisioners.get(shortcut) if shortcut.is_a?(Symbol)
|
16
18
|
@config = nil
|
17
19
|
|
18
|
-
|
20
|
+
@logger.info("Provisioner class: #{provisioner}")
|
21
|
+
configure(options, &block) if @provisioner
|
19
22
|
end
|
20
23
|
|
21
24
|
# Configures the provisioner if it can (if it is valid).
|
22
25
|
def configure(options=nil, &block)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# We assume that every provisioner has a `Config` class beneath
|
29
|
-
# it for configuring.
|
30
|
-
return if !@provisioner || !@provisioner.const_defined?(*const_args)
|
31
|
-
|
32
|
-
# Instantiate the config class and configure it
|
33
|
-
@config = @provisioner.const_get(*const_args).new
|
34
|
-
@config.top = top
|
26
|
+
config_class = @provisioner.config_class
|
27
|
+
return if !config_class
|
28
|
+
|
29
|
+
@logger.debug("Configuring provisioner with: #{config_class}")
|
30
|
+
@config = config_class.new
|
35
31
|
@config.set_options(options) if options
|
36
32
|
block.call(@config) if block
|
37
33
|
end
|
38
34
|
|
39
|
-
def validate(errors)
|
35
|
+
def validate(env, errors)
|
40
36
|
if !provisioner
|
41
37
|
# If we don't have a provisioner then the whole thing is invalid.
|
42
38
|
errors.add(I18n.t("vagrant.config.vm.provisioner_not_found", :shortcut => shortcut))
|
@@ -48,7 +44,7 @@ module Vagrant
|
|
48
44
|
end
|
49
45
|
|
50
46
|
# Pass on validation to the provisioner config
|
51
|
-
config.validate(errors) if config
|
47
|
+
config.validate(env, errors) if config
|
52
48
|
end
|
53
49
|
end
|
54
50
|
end
|
data/lib/vagrant/config/vm.rb
CHANGED
@@ -1,77 +1,120 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
require 'vagrant/config/vm/sub_vm'
|
2
4
|
require 'vagrant/config/vm/provisioner'
|
3
5
|
|
4
6
|
module Vagrant
|
5
|
-
|
7
|
+
module Config
|
6
8
|
class VMConfig < Base
|
7
|
-
|
8
|
-
|
9
|
-
include Util::StackedProcRunner
|
10
|
-
|
9
|
+
attr_accessor :name
|
11
10
|
attr_accessor :auto_port_range
|
12
11
|
attr_accessor :box
|
13
12
|
attr_accessor :box_url
|
14
|
-
attr_accessor :box_ovf
|
15
13
|
attr_accessor :base_mac
|
16
14
|
attr_accessor :boot_mode
|
17
15
|
attr_accessor :host_name
|
18
16
|
attr_reader :forwarded_ports
|
19
17
|
attr_reader :shared_folders
|
20
|
-
attr_reader :
|
18
|
+
attr_reader :networks
|
21
19
|
attr_reader :provisioners
|
22
|
-
|
20
|
+
attr_reader :customizations
|
21
|
+
attr_accessor :guest
|
23
22
|
|
24
23
|
def initialize
|
25
|
-
@forwarded_ports =
|
24
|
+
@forwarded_ports = []
|
26
25
|
@shared_folders = {}
|
27
|
-
@
|
26
|
+
@networks = []
|
28
27
|
@provisioners = []
|
28
|
+
@customizations = []
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
# Custom merge method since some keys here are merged differently.
|
32
|
+
def merge(other)
|
33
|
+
result = super
|
34
|
+
result.instance_variable_set(:@forwarded_ports, @forwarded_ports + other.forwarded_ports)
|
35
|
+
result.instance_variable_set(:@shared_folders, @shared_folders.merge(other.shared_folders))
|
36
|
+
result.instance_variable_set(:@networks, @networks + other.networks)
|
37
|
+
result.instance_variable_set(:@provisioners, @provisioners + other.provisioners)
|
38
|
+
result.instance_variable_set(:@customizations, @customizations + other.customizations)
|
39
|
+
result
|
40
|
+
end
|
41
|
+
|
42
|
+
def forward_port(guestport, hostport, options=nil)
|
43
|
+
if !guestport.kind_of?(Integer)
|
44
|
+
raise Errors::DeprecationError, :message => <<-MESSAGE
|
45
|
+
`config.vm.forward_port` changed in 0.9.0 where the required name
|
46
|
+
argument is now removed. Vagrant will now automatically generate
|
47
|
+
a unique name for your forwarded port. For example, to forward
|
48
|
+
port 80 to port 8080 you now do the following:
|
49
|
+
|
50
|
+
config.vm.forward_port 80, 8080
|
51
|
+
|
52
|
+
Please change your configurations to match this new syntax.
|
53
|
+
MESSAGE
|
54
|
+
end
|
55
|
+
|
56
|
+
@forwarded_ports << {
|
57
|
+
:name => "#{guestport.to_s(32)}-#{hostport.to_s(32)}",
|
33
58
|
:guestport => guestport,
|
34
59
|
:hostport => hostport,
|
35
60
|
:protocol => :tcp,
|
36
|
-
:adapter =>
|
61
|
+
:adapter => 1,
|
37
62
|
:auto => false
|
38
63
|
}.merge(options || {})
|
39
|
-
|
40
|
-
forwarded_ports[name] = options
|
41
64
|
end
|
42
65
|
|
43
66
|
def share_folder(name, guestpath, hostpath, opts=nil)
|
44
67
|
@shared_folders[name] = {
|
45
|
-
:guestpath => guestpath,
|
46
|
-
:hostpath => hostpath,
|
68
|
+
:guestpath => guestpath.to_s,
|
69
|
+
:hostpath => hostpath.to_s,
|
70
|
+
:create => false,
|
47
71
|
:owner => nil,
|
48
72
|
:group => nil,
|
49
|
-
:nfs => false
|
73
|
+
:nfs => false,
|
74
|
+
:extra => nil
|
50
75
|
}.merge(opts || {})
|
51
76
|
end
|
52
77
|
|
53
|
-
def network(
|
54
|
-
|
55
|
-
:
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
}.merge(options || {})
|
78
|
+
def network(type, *args)
|
79
|
+
if !type.kind_of?(Symbol)
|
80
|
+
raise Errors::DeprecationError, :message => <<-MESSAGE
|
81
|
+
`config.vm.network` changed in 0.9.0 where the first argument is
|
82
|
+
now the type of network and the remaining arguments are options for
|
83
|
+
that type. For example, host only networks are now configured like
|
84
|
+
so:
|
61
85
|
|
62
|
-
|
86
|
+
config.vm.network :hostonly, "172.24.24.24"
|
87
|
+
|
88
|
+
Please change your configurations to match this new syntax.
|
89
|
+
MESSAGE
|
90
|
+
end
|
91
|
+
|
92
|
+
@networks << [type, args]
|
63
93
|
end
|
64
94
|
|
65
95
|
def provision(name, options=nil, &block)
|
66
|
-
@provisioners << Provisioner.new(
|
96
|
+
@provisioners << Provisioner.new(name, options, &block)
|
67
97
|
end
|
68
98
|
|
69
|
-
|
70
|
-
|
71
|
-
|
99
|
+
# TODO: This argument should not be `nil` in the future.
|
100
|
+
# It is only defaulted to nil so that the deprecation error
|
101
|
+
# can be properly shown.
|
102
|
+
def customize(command=nil)
|
103
|
+
if block_given?
|
104
|
+
raise Errors::DeprecationError, :message => <<-MESSAGE
|
105
|
+
`config.vm.customize` now takes an array of arguments to send to
|
106
|
+
`VBoxManage` instead of having a block which gets a virtual machine
|
107
|
+
object. Example of the new usage:
|
108
|
+
|
109
|
+
config.vm.customize ["modifyvm", :id, "--memory", "1024"]
|
110
|
+
|
111
|
+
The above will run `VBoxManage modifyvm 1234 --memory 1024` where
|
112
|
+
"1234" is the ID of your current virtual machine. Anything you could
|
113
|
+
do before is certainly still possible with `VBoxManage` as well.
|
114
|
+
MESSAGE
|
115
|
+
end
|
72
116
|
|
73
|
-
|
74
|
-
!defined_vms.empty?
|
117
|
+
@customizations << command if command
|
75
118
|
end
|
76
119
|
|
77
120
|
def defined_vms
|
@@ -95,17 +138,19 @@ module Vagrant
|
|
95
138
|
# Add the SubVM to the hash of defined VMs
|
96
139
|
defined_vms[name] ||= SubVM.new
|
97
140
|
defined_vms[name].options.merge!(options)
|
98
|
-
defined_vms[name].push_proc(&block)
|
141
|
+
defined_vms[name].push_proc(&block) if block
|
99
142
|
end
|
100
143
|
|
101
|
-
def validate(errors)
|
144
|
+
def validate(env, errors)
|
102
145
|
errors.add(I18n.t("vagrant.config.vm.box_missing")) if !box
|
103
|
-
errors.add(I18n.t("vagrant.config.vm.box_not_found", :name => box)) if box && !box_url && !env.box
|
104
|
-
errors.add(I18n.t("vagrant.config.vm.boot_mode_invalid")) if ![:
|
105
|
-
errors.add(I18n.t("vagrant.config.vm.base_mac_invalid")) if env.box && !base_mac
|
146
|
+
errors.add(I18n.t("vagrant.config.vm.box_not_found", :name => box)) if box && !box_url && !env.boxes.find(box)
|
147
|
+
errors.add(I18n.t("vagrant.config.vm.boot_mode_invalid")) if ![:headless, :gui].include?(boot_mode.to_sym)
|
148
|
+
errors.add(I18n.t("vagrant.config.vm.base_mac_invalid")) if env.boxes.find(box) && !base_mac
|
106
149
|
|
107
150
|
shared_folders.each do |name, options|
|
108
|
-
|
151
|
+
hostpath = Pathname.new(options[:hostpath]).expand_path(env.root_path)
|
152
|
+
|
153
|
+
if !hostpath.directory? && !options[:create]
|
109
154
|
errors.add(I18n.t("vagrant.config.vm.shared_folder_hostpath_missing",
|
110
155
|
:name => name,
|
111
156
|
:path => options[:hostpath]))
|
@@ -119,28 +164,42 @@ module Vagrant
|
|
119
164
|
end
|
120
165
|
|
121
166
|
# Validate some basic networking
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
if
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
167
|
+
#
|
168
|
+
# TODO: One day we need to abstract this out, since in the future
|
169
|
+
# providers other than VirtualBox will not be able to satisfy
|
170
|
+
# all types of networks.
|
171
|
+
networks.each do |type, args|
|
172
|
+
if type == :hostonly && args[0] == :dhcp
|
173
|
+
# Valid. There is no real way this can be invalid at the moment.
|
174
|
+
elsif type == :hostonly
|
175
|
+
# Validate the host-only network
|
176
|
+
ip = args[0]
|
177
|
+
options = args[1] || {}
|
178
|
+
|
179
|
+
if !ip
|
180
|
+
errors.add(I18n.t("vagrant.config.vm.network_ip_required"))
|
181
|
+
else
|
182
|
+
ip_parts = ip.split(".")
|
183
|
+
|
184
|
+
if ip_parts.length != 4
|
185
|
+
errors.add(I18n.t("vagrant.config.vm.network_ip_invalid",
|
186
|
+
:ip => ip))
|
187
|
+
elsif ip_parts.last == "1"
|
188
|
+
errors.add(I18n.t("vagrant.config.vm.network_ip_ends_one",
|
189
|
+
:ip => ip))
|
190
|
+
end
|
191
|
+
end
|
192
|
+
elsif type == :bridged
|
193
|
+
else
|
194
|
+
# Invalid network type
|
195
|
+
errors.add(I18n.t("vagrant.config.vm.network_invalid",
|
196
|
+
:type => type.to_s))
|
133
197
|
end
|
134
198
|
end
|
135
199
|
|
136
200
|
# Each provisioner can validate itself
|
137
201
|
provisioners.each do |prov|
|
138
|
-
|
139
|
-
if prov.shortcut == :chef_server
|
140
|
-
errors.add(I18n.t("vagrant.config.vm.provisioner_chef_server_changed"))
|
141
|
-
else
|
142
|
-
prov.validate(errors)
|
143
|
-
end
|
202
|
+
prov.validate(env, errors)
|
144
203
|
end
|
145
204
|
end
|
146
205
|
end
|
data/lib/vagrant/config.rb
CHANGED
@@ -1,46 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module Vagrant
|
2
|
+
module Config
|
3
|
+
autoload :Base, 'vagrant/config/base'
|
4
|
+
autoload :Container, 'vagrant/config/container'
|
5
|
+
autoload :ErrorRecorder, 'vagrant/config/error_recorder'
|
6
|
+
autoload :Loader, 'vagrant/config/loader'
|
7
|
+
autoload :Top, 'vagrant/config/top'
|
4
8
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
require 'vagrant/config/package'
|
9
|
+
autoload :NFSConfig, 'vagrant/config/nfs'
|
10
|
+
autoload :PackageConfig, 'vagrant/config/package'
|
11
|
+
autoload :SSHConfig, 'vagrant/config/ssh'
|
12
|
+
autoload :VagrantConfig, 'vagrant/config/vagrant'
|
13
|
+
autoload :VMConfig, 'vagrant/config/vm'
|
11
14
|
|
12
|
-
|
13
|
-
# The config class is responsible for loading Vagrant configurations, which
|
14
|
-
# are usually found in Vagrantfiles but may also be procs. The loading is done
|
15
|
-
# by specifying a queue of files or procs that are for configuration, and then
|
16
|
-
# executing them. The config loader will run each item in the queue, so that
|
17
|
-
# configuration from later items overwrite that from earlier items. This is how
|
18
|
-
# Vagrant "scoping" of Vagranfiles is implemented.
|
19
|
-
#
|
20
|
-
# If you're looking to create your own configuration classes, see {Base}.
|
21
|
-
#
|
22
|
-
# # Loading Configuration Files
|
23
|
-
#
|
24
|
-
# If you are in fact looking to load configuration files, then this is the
|
25
|
-
# class you are looking for. Loading configuration is quite easy. The following
|
26
|
-
# example assumes `env` is already a loaded instance of {Environment}:
|
27
|
-
#
|
28
|
-
# config = Vagrant::Config.new
|
29
|
-
# config.set(:first, "/path/to/some/Vagrantfile")
|
30
|
-
# config.set(:second, "/path/to/another/Vagrantfile")
|
31
|
-
# config.load_order = [:first, :second]
|
32
|
-
# result = config.load(env)
|
33
|
-
#
|
34
|
-
# p "Your box is: #{result.vm.box}"
|
35
|
-
#
|
36
|
-
# The load order determines what order the config files specified are loaded.
|
37
|
-
# If a key is not mentioned (for example if above the load order was set to
|
38
|
-
# `[:first]`, therefore `:second` was not mentioned), then that config file
|
39
|
-
# won't be loaded.
|
40
|
-
class Config
|
41
|
-
# An array of symbols specifying the load order for the procs.
|
42
|
-
attr_accessor :load_order
|
43
|
-
attr_reader :procs
|
15
|
+
CONFIGURE_MUTEX = Mutex.new
|
44
16
|
|
45
17
|
# This is the method which is called by all Vagrantfiles to configure Vagrant.
|
46
18
|
# This method expects a block which accepts a single argument representing
|
@@ -54,69 +26,23 @@ module Vagrant
|
|
54
26
|
@last_procs << block
|
55
27
|
end
|
56
28
|
|
57
|
-
#
|
58
|
-
#
|
59
|
-
# will not return duplicates.
|
60
|
-
#
|
61
|
-
# @return [Proc]
|
62
|
-
def self.last_proc
|
63
|
-
value = @last_procs
|
64
|
-
@last_procs = nil
|
65
|
-
value
|
66
|
-
end
|
67
|
-
|
68
|
-
def initialize(parent=nil)
|
69
|
-
@procs = {}
|
70
|
-
@load_order = []
|
71
|
-
|
72
|
-
if parent
|
73
|
-
# Shallow copy the procs and load order from parent if given
|
74
|
-
@procs = parent.procs.dup
|
75
|
-
@load_order = parent.load_order.dup
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# Adds a Vagrantfile to be loaded to the queue of config procs. Note
|
80
|
-
# that this causes the Vagrantfile file to be loaded at this point,
|
81
|
-
# and it will never be loaded again.
|
82
|
-
def set(key, path)
|
83
|
-
return if @procs.has_key?(key)
|
84
|
-
@procs[key] = [path].flatten.map(&method(:proc_for)).flatten
|
85
|
-
end
|
86
|
-
|
87
|
-
# Loads the added procs using the set `load_order` attribute and returns
|
88
|
-
# the {Config::Top} object result. The configuration is loaded for the
|
89
|
-
# given {Environment} object.
|
29
|
+
# This is a method which will yield to a block and will capture all
|
30
|
+
# ``Vagrant.configure`` calls, returning an array of `Proc`s.
|
90
31
|
#
|
91
|
-
#
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
config
|
106
|
-
end
|
107
|
-
|
108
|
-
protected
|
109
|
-
|
110
|
-
def proc_for(path)
|
111
|
-
return nil if !path
|
112
|
-
return path if path.is_a?(Proc)
|
113
|
-
|
114
|
-
begin
|
115
|
-
Kernel.load path if File.exist?(path)
|
116
|
-
return self.class.last_proc
|
117
|
-
rescue SyntaxError => e
|
118
|
-
# Report syntax errors in a nice way for Vagrantfiles
|
119
|
-
raise Errors::VagrantfileSyntaxError, :file => e.message
|
32
|
+
# Wrapping this around anytime you call code which loads configurations
|
33
|
+
# will force a mutex so that procs never get mixed up. This keeps
|
34
|
+
# the configuration loading part of Vagrant thread-safe.
|
35
|
+
def self.capture_configures
|
36
|
+
CONFIGURE_MUTEX.synchronize do
|
37
|
+
# Reset the last procs so that we start fresh
|
38
|
+
@last_procs = []
|
39
|
+
|
40
|
+
# Yield to allow the caller to do whatever loading needed
|
41
|
+
yield
|
42
|
+
|
43
|
+
# Return the last procs we've seen while still in the mutex,
|
44
|
+
# knowing we're safe.
|
45
|
+
return @last_procs
|
120
46
|
end
|
121
47
|
end
|
122
48
|
end
|