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
@@ -1,32 +1,61 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
1
3
|
module Vagrant
|
2
|
-
|
4
|
+
module Action
|
3
5
|
module VM
|
4
6
|
class Provision
|
5
7
|
def initialize(app, env)
|
8
|
+
@logger = Log4r::Logger.new("vagrant::action::vm::provision")
|
6
9
|
@app = app
|
7
|
-
|
8
|
-
|
10
|
+
|
11
|
+
env["provision.enabled"] = true if !env.has_key?("provision.enabled")
|
9
12
|
end
|
10
13
|
|
11
14
|
def call(env)
|
12
|
-
|
13
|
-
|
14
|
-
provisioners =
|
15
|
-
|
15
|
+
@env = env
|
16
|
+
|
17
|
+
provisioners = nil
|
18
|
+
|
19
|
+
# We set this here so that even if this value is changed in the future,
|
20
|
+
# it stays constant to what we expect here in this moment.
|
21
|
+
enabled = env["provision.enabled"]
|
22
|
+
if enabled
|
23
|
+
# Instantiate and prepare the provisioners. Preparation must happen here
|
24
|
+
# so that shared folders and such can properly take effect.
|
25
|
+
provisioners = enabled_provisioners
|
26
|
+
provisioners.map { |p| p.prepare }
|
27
|
+
end
|
16
28
|
|
17
29
|
@app.call(env)
|
18
30
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
31
|
+
if enabled
|
32
|
+
# Take prepared provisioners and run the provisioning
|
33
|
+
provisioners.each do |instance|
|
34
|
+
@env[:ui].info I18n.t("vagrant.actions.vm.provision.beginning",
|
35
|
+
:provisioner => instance.class)
|
36
|
+
instance.provision!
|
37
|
+
end
|
23
38
|
end
|
24
39
|
end
|
25
40
|
|
26
41
|
def enabled_provisioners
|
27
|
-
|
28
|
-
|
42
|
+
enabled = []
|
43
|
+
@env[:vm].config.vm.provisioners.each do |provisioner|
|
44
|
+
if @env["provision.types"]
|
45
|
+
# If we've specified types of provisioners to enable, then we
|
46
|
+
# only use those provisioners, and skip any that we haven't
|
47
|
+
# specified.
|
48
|
+
if !@env["provision.types"].include?(provisioner.shortcut.to_s)
|
49
|
+
@logger.debug("Skipping provisioner: #{provisioner.shortcut}")
|
50
|
+
next
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
enabled << provisioner.provisioner.new(@env, provisioner.config)
|
29
55
|
end
|
56
|
+
|
57
|
+
# Return the enable provisioners
|
58
|
+
enabled
|
30
59
|
end
|
31
60
|
end
|
32
61
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Vagrant
|
2
|
-
|
2
|
+
module Action
|
3
3
|
module VM
|
4
4
|
class ProvisionerCleanup
|
5
5
|
def initialize(app, env)
|
@@ -16,7 +16,7 @@ module Vagrant
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def enabled_provisioners
|
19
|
-
@env[
|
19
|
+
@env[:vm].config.vm.provisioners.map do |provisioner|
|
20
20
|
provisioner.provisioner.new(@env, provisioner.config)
|
21
21
|
end
|
22
22
|
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
require File.expand_path("../nfs_helpers", __FILE__)
|
2
|
-
|
3
1
|
module Vagrant
|
4
|
-
|
2
|
+
module Action
|
5
3
|
module VM
|
6
|
-
class
|
7
|
-
include NFSHelpers
|
8
|
-
|
4
|
+
class PruneNFSExports
|
9
5
|
def initialize(app, env)
|
10
6
|
@app = app
|
11
7
|
end
|
12
8
|
|
13
9
|
def call(env)
|
14
|
-
|
10
|
+
if env[:host]
|
11
|
+
valid_ids = env[:vm].driver.read_vms
|
12
|
+
env[:host].nfs_prune(valid_ids)
|
13
|
+
end
|
14
|
+
|
15
15
|
@app.call(env)
|
16
16
|
end
|
17
17
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Vagrant
|
2
|
-
|
2
|
+
module Action
|
3
3
|
module VM
|
4
4
|
class Resume
|
5
5
|
def initialize(app, env)
|
@@ -7,9 +7,9 @@ module Vagrant
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(env)
|
10
|
-
if env[
|
11
|
-
env
|
12
|
-
env[
|
10
|
+
if env[:vm].state == :saved
|
11
|
+
env[:ui].info I18n.t("vagrant.actions.vm.resume.resuming")
|
12
|
+
env[:action_runner].run(Boot, env)
|
13
13
|
end
|
14
14
|
|
15
15
|
@app.call(env)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module Action
|
5
|
+
module VM
|
6
|
+
# Sets up the mapping of files to copy into the package and verifies
|
7
|
+
# that the files can be properly copied.
|
8
|
+
class SetupPackageFiles
|
9
|
+
def initialize(app, env)
|
10
|
+
@app = app
|
11
|
+
|
12
|
+
env["package.include"] ||= []
|
13
|
+
env["package.vagrantfile"] ||= nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
files = {}
|
18
|
+
env["package.include"].each do |file|
|
19
|
+
source = Pathname.new(file)
|
20
|
+
dest = nil
|
21
|
+
|
22
|
+
# If the source is relative then we add the file as-is to the include
|
23
|
+
# directory. Otherwise, we copy only the file into the root of the
|
24
|
+
# include directory. Kind of strange, but seems to match what people
|
25
|
+
# expect based on history.
|
26
|
+
if source.relative?
|
27
|
+
dest = source
|
28
|
+
else
|
29
|
+
dest = source.basename
|
30
|
+
end
|
31
|
+
|
32
|
+
# Assign the mapping
|
33
|
+
files[file] = dest
|
34
|
+
end
|
35
|
+
|
36
|
+
if env["package.vagrantfile"]
|
37
|
+
# Vagrantfiles are treated special and mapped to a specific file
|
38
|
+
files[env["package.vagrantfile"]] = "_Vagrantfile"
|
39
|
+
end
|
40
|
+
|
41
|
+
# Verify the mapping
|
42
|
+
files.each do |from, _|
|
43
|
+
raise Errors::PackageIncludeMissing, :file => from if !File.exist?(from)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Save the mapping
|
47
|
+
env["package.files"] = files
|
48
|
+
|
49
|
+
@app.call(env)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,15 +1,20 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
require 'log4r'
|
4
|
+
|
1
5
|
module Vagrant
|
2
|
-
|
6
|
+
module Action
|
3
7
|
module VM
|
4
8
|
class ShareFolders
|
5
9
|
def initialize(app, env)
|
6
|
-
@
|
7
|
-
@
|
10
|
+
@logger = Log4r::Logger.new("vagrant::action::vm::share_folders")
|
11
|
+
@app = app
|
8
12
|
end
|
9
13
|
|
10
14
|
def call(env)
|
11
15
|
@env = env
|
12
16
|
|
17
|
+
prepare_folders
|
13
18
|
create_metadata
|
14
19
|
|
15
20
|
@app.call(env)
|
@@ -20,7 +25,7 @@ module Vagrant
|
|
20
25
|
# This method returns an actual list of VirtualBox shared
|
21
26
|
# folders to create and their proper path.
|
22
27
|
def shared_folders
|
23
|
-
@env.
|
28
|
+
@env[:vm].config.vm.shared_folders.inject({}) do |acc, data|
|
24
29
|
key, value = data
|
25
30
|
|
26
31
|
next acc if value[:disabled]
|
@@ -32,54 +37,73 @@ module Vagrant
|
|
32
37
|
end
|
33
38
|
end
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
# Prepares the shared folders by verifying they exist and creating them
|
41
|
+
# if they don't.
|
42
|
+
def prepare_folders
|
43
|
+
shared_folders.each do |name, options|
|
44
|
+
hostpath = Pathname.new(options[:hostpath]).expand_path(@env[:root_path])
|
45
|
+
|
46
|
+
if !hostpath.directory? && options[:create]
|
47
|
+
# Host path doesn't exist, so let's create it.
|
48
|
+
@logger.debug("Host path doesn't exist, creating: #{hostpath}")
|
49
|
+
|
50
|
+
begin
|
51
|
+
hostpath.mkpath
|
52
|
+
rescue Errno::EACCES
|
53
|
+
raise Errors::SharedFolderCreateFailed, :path => hostpath.to_s
|
54
|
+
end
|
44
55
|
end
|
45
56
|
end
|
57
|
+
end
|
46
58
|
|
47
|
-
|
59
|
+
def create_metadata
|
60
|
+
@env[:ui].info I18n.t("vagrant.actions.vm.share_folders.creating")
|
61
|
+
|
62
|
+
folders = []
|
63
|
+
shared_folders.each do |name, data|
|
64
|
+
folders << {
|
65
|
+
:name => name,
|
66
|
+
:hostpath => File.expand_path(data[:hostpath], @env[:root_path])
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
@env[:vm].driver.share_folders(folders)
|
48
71
|
end
|
49
72
|
|
50
73
|
def mount_shared_folders
|
51
|
-
@env
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
10000
|
61
|
-
end
|
74
|
+
@env[:ui].info I18n.t("vagrant.actions.vm.share_folders.mounting")
|
75
|
+
|
76
|
+
# short guestpaths first, so we don't step on ourselves
|
77
|
+
folders = shared_folders.sort_by do |name, data|
|
78
|
+
if data[:guestpath]
|
79
|
+
data[:guestpath].length
|
80
|
+
else
|
81
|
+
# A long enough path to just do this at the end.
|
82
|
+
10000
|
62
83
|
end
|
84
|
+
end
|
63
85
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
86
|
+
# Go through each folder and mount
|
87
|
+
folders.each do |name, data|
|
88
|
+
if data[:guestpath]
|
89
|
+
# Guest path specified, so mount the folder to specified point
|
90
|
+
@env[:ui].info(I18n.t("vagrant.actions.vm.share_folders.mounting_entry",
|
69
91
|
:name => name,
|
70
92
|
:guest_path => data[:guestpath]))
|
71
93
|
|
72
|
-
|
73
|
-
|
74
|
-
group = data[:group] || @env["config"].ssh.username
|
94
|
+
# Dup the data so we can pass it to the guest API
|
95
|
+
data = data.dup
|
75
96
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
97
|
+
# Calculate the owner and group
|
98
|
+
data[:owner] ||= @env[:vm].config.ssh.username
|
99
|
+
data[:group] ||= @env[:vm].config.ssh.username
|
100
|
+
|
101
|
+
# Mount the actual folder
|
102
|
+
@env[:vm].guest.mount_shared_folder(name, data[:guestpath], data)
|
103
|
+
else
|
104
|
+
# If no guest path is specified, then automounting is disabled
|
105
|
+
@env[:ui].info(I18n.t("vagrant.actions.vm.share_folders.nomount_entry",
|
81
106
|
:name => name))
|
82
|
-
end
|
83
107
|
end
|
84
108
|
end
|
85
109
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Vagrant
|
2
|
-
|
2
|
+
module Action
|
3
3
|
module VM
|
4
4
|
class Suspend
|
5
5
|
def initialize(app, env)
|
@@ -7,9 +7,9 @@ module Vagrant
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(env)
|
10
|
-
if env[
|
11
|
-
env
|
12
|
-
env[
|
10
|
+
if env[:vm].state == :running
|
11
|
+
env[:ui].info I18n.t("vagrant.actions.vm.suspend.suspending")
|
12
|
+
env[:vm].driver.suspend
|
13
13
|
end
|
14
14
|
|
15
15
|
@app.call(env)
|
@@ -1,5 +1,7 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
1
3
|
module Vagrant
|
2
|
-
|
4
|
+
module Action
|
3
5
|
# The action warden is a middleware which injects itself between
|
4
6
|
# every other middleware, watching for exceptions which are raised
|
5
7
|
# and performing proper cleanup on every action by calling the `recover`
|
@@ -16,6 +18,7 @@ module Vagrant
|
|
16
18
|
def initialize(actions, env)
|
17
19
|
@stack = []
|
18
20
|
@actions = actions.map { |m| finalize_action(m, env) }
|
21
|
+
@logger = Log4r::Logger.new("vagrant::action::warden")
|
19
22
|
end
|
20
23
|
|
21
24
|
def call(env)
|
@@ -24,17 +27,17 @@ module Vagrant
|
|
24
27
|
begin
|
25
28
|
# Call the next middleware in the sequence, appending to the stack
|
26
29
|
# of "recoverable" middlewares in case something goes wrong!
|
27
|
-
raise Errors::VagrantInterrupt if env
|
30
|
+
raise Errors::VagrantInterrupt if env[:interrupted]
|
28
31
|
action = @actions.shift
|
29
|
-
|
32
|
+
@logger.info("Calling action: #{action}")
|
30
33
|
@stack.unshift(action).first.call(env)
|
31
|
-
raise Errors::VagrantInterrupt if env
|
34
|
+
raise Errors::VagrantInterrupt if env[:interrupted]
|
32
35
|
rescue SystemExit
|
33
36
|
# This means that an "exit" or "abort" was called. In these cases,
|
34
37
|
# we just exit immediately.
|
35
38
|
raise
|
36
39
|
rescue Exception => e
|
37
|
-
|
40
|
+
@logger.error("Error occurred: #{e}")
|
38
41
|
env["vagrant.error"] = e
|
39
42
|
|
40
43
|
# Something went horribly wrong. Start the rescue chain then
|
@@ -50,7 +53,7 @@ module Vagrant
|
|
50
53
|
def begin_rescue(env)
|
51
54
|
@stack.each do |act|
|
52
55
|
if act.respond_to?(:recover)
|
53
|
-
|
56
|
+
@logger.info("Calling recover: #{act}")
|
54
57
|
act.recover(env)
|
55
58
|
end
|
56
59
|
end
|
@@ -65,6 +68,10 @@ module Vagrant
|
|
65
68
|
def finalize_action(action, env)
|
66
69
|
klass, args, block = action
|
67
70
|
|
71
|
+
# Default the arguments to an empty array. Otherwise in Ruby 1.8
|
72
|
+
# a `nil` args will actually pass `nil` into the class.
|
73
|
+
args ||= []
|
74
|
+
|
68
75
|
if klass.is_a?(Class)
|
69
76
|
# A action klass which is to be instantiated with the
|
70
77
|
# app, env, and any arguments given
|
data/lib/vagrant/action.rb
CHANGED
@@ -1,138 +1,60 @@
|
|
1
1
|
require 'vagrant/action/builder'
|
2
2
|
require 'vagrant/action/builtin'
|
3
3
|
|
4
|
-
# The builtin middlewares
|
5
|
-
require 'vagrant/action/box'
|
6
|
-
require 'vagrant/action/env'
|
7
|
-
require 'vagrant/action/general'
|
8
|
-
require 'vagrant/action/vm'
|
9
|
-
|
10
4
|
module Vagrant
|
11
|
-
|
12
|
-
# has an instance of {Action} to allow for running in the context of
|
13
|
-
# the environment, which is accessible at {Environment#actions}. Actions
|
14
|
-
# are the foundation of most functionality in Vagrant, and are implemented
|
15
|
-
# architecturally as "middleware."
|
16
|
-
#
|
17
|
-
# # Registering an Action
|
18
|
-
#
|
19
|
-
# The main benefits of registering an action is the ability to retrieve and
|
20
|
-
# modify that registered action, as well as easily run the action. An example
|
21
|
-
# of registering an action is shown below, with a simple middleware which just
|
22
|
-
# outputs to `STDOUT`:
|
23
|
-
#
|
24
|
-
# class StdoutMiddleware
|
25
|
-
# def initialize(app, env)
|
26
|
-
# @app = app
|
27
|
-
# end
|
28
|
-
#
|
29
|
-
# def call(env)
|
30
|
-
# puts "HI!"
|
31
|
-
# @app.call(env)
|
32
|
-
# end
|
33
|
-
# end
|
34
|
-
#
|
35
|
-
# Vagrant::Action.register(:stdout, StdoutMiddleware)
|
36
|
-
#
|
37
|
-
# Then to run a registered action, assuming `env` is a loaded {Environment}:
|
38
|
-
#
|
39
|
-
# env.actions.run(:stdout)
|
40
|
-
#
|
41
|
-
# Or to retrieve the action class for any reason:
|
42
|
-
#
|
43
|
-
# Vagrant::Action[:stdout]
|
44
|
-
#
|
45
|
-
# # Running an Action
|
46
|
-
#
|
47
|
-
# There are various built-in registered actions such as `start`, `stop`, `up`,
|
48
|
-
# etc. Actions are built to be run in the context of an environment, so use
|
49
|
-
# {Environment#actions} to run all actions. Then simply call {#run}:
|
50
|
-
#
|
51
|
-
# env.actions.run(:name)
|
52
|
-
#
|
53
|
-
# Where `:name` is the name of the registered action.
|
54
|
-
#
|
55
|
-
class Action
|
5
|
+
module Action
|
56
6
|
autoload :Environment, 'vagrant/action/environment'
|
7
|
+
autoload :Runner, 'vagrant/action/runner'
|
57
8
|
autoload :Warden, 'vagrant/action/warden'
|
58
9
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
# @return [Array]
|
66
|
-
def actions
|
67
|
-
@actions ||= {}
|
68
|
-
end
|
69
|
-
|
70
|
-
# Registers an action and associates it with a symbol. This
|
71
|
-
# symbol can then be referenced in other action builds and
|
72
|
-
# callbacks can be registered on that symbol.
|
73
|
-
#
|
74
|
-
# @param [Symbol] key
|
75
|
-
def register(key, callable)
|
76
|
-
actions[key.to_sym] = callable
|
77
|
-
end
|
78
|
-
|
79
|
-
# Retrieves a registered action by key.
|
80
|
-
#
|
81
|
-
# @param [Symbol] key
|
82
|
-
def [](key)
|
83
|
-
actions[key.to_sym]
|
84
|
-
end
|
10
|
+
module Box
|
11
|
+
autoload :Destroy, 'vagrant/action/box/destroy'
|
12
|
+
autoload :Download, 'vagrant/action/box/download'
|
13
|
+
autoload :Package, 'vagrant/action/box/package'
|
14
|
+
autoload :Unpackage, 'vagrant/action/box/unpackage'
|
15
|
+
autoload :Verify, 'vagrant/action/box/verify'
|
85
16
|
end
|
86
17
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
# Initializes the action with the given environment which the actions
|
91
|
-
# will be run in.
|
92
|
-
#
|
93
|
-
# @param [Environment] env
|
94
|
-
def initialize(env)
|
95
|
-
@env = env
|
18
|
+
module Env
|
19
|
+
autoload :Set, 'vagrant/action/env/set'
|
96
20
|
end
|
97
21
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
# Any options given are injected into the environment hash.
|
103
|
-
#
|
104
|
-
# @param [Object] callable An object which responds to `call`.
|
105
|
-
def run(callable_id, options=nil)
|
106
|
-
callable = callable_id
|
107
|
-
callable = Builder.new.use(callable_id) if callable_id.kind_of?(Class)
|
108
|
-
callable = self.class.actions[callable_id] if callable_id.kind_of?(Symbol)
|
109
|
-
raise ArgumentError, "Argument to run must be a callable object or registered action." if !callable || !callable.respond_to?(:call)
|
110
|
-
|
111
|
-
action_environment = Action::Environment.new(env)
|
112
|
-
action_environment.merge!(options || {})
|
113
|
-
|
114
|
-
# Run the before action run callback, if we're not doing that already
|
115
|
-
run(:before_action_run, action_environment) if callable_id != :before_action_run
|
116
|
-
|
117
|
-
# Run the action chain in a busy block, marking the environment as
|
118
|
-
# interrupted if a SIGINT occurs, and exiting cleanly once the
|
119
|
-
# chain has been run.
|
120
|
-
int_callback = lambda do
|
121
|
-
if action_environment.interrupted?
|
122
|
-
env.ui.error I18n.t("vagrant.actions.runner.exit_immediately")
|
123
|
-
abort
|
124
|
-
end
|
125
|
-
|
126
|
-
env.ui.warn I18n.t("vagrant.actions.runner.waiting_cleanup") if !@@reported_interrupt
|
127
|
-
action_environment.interrupt!
|
128
|
-
@@reported_interrupt = true
|
129
|
-
end
|
22
|
+
module General
|
23
|
+
autoload :Package, 'vagrant/action/general/package'
|
24
|
+
autoload :Validate, 'vagrant/action/general/validate'
|
25
|
+
end
|
130
26
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
27
|
+
module VM
|
28
|
+
autoload :Boot, 'vagrant/action/vm/boot'
|
29
|
+
autoload :CheckAccessible, 'vagrant/action/vm/check_accessible'
|
30
|
+
autoload :CheckBox, 'vagrant/action/vm/check_box'
|
31
|
+
autoload :CheckGuestAdditions, 'vagrant/action/vm/check_guest_additions'
|
32
|
+
autoload :CheckPortCollisions, 'vagrant/action/vm/check_port_collisions'
|
33
|
+
autoload :CleanMachineFolder, 'vagrant/action/vm/clean_machine_folder'
|
34
|
+
autoload :ClearForwardedPorts, 'vagrant/action/vm/clear_forwarded_ports'
|
35
|
+
autoload :ClearNetworkInterfaces, 'vagrant/action/vm/clear_network_interfaces'
|
36
|
+
autoload :ClearSharedFolders, 'vagrant/action/vm/clear_shared_folders'
|
37
|
+
autoload :Customize, 'vagrant/action/vm/customize'
|
38
|
+
autoload :Destroy, 'vagrant/action/vm/destroy'
|
39
|
+
autoload :DestroyUnusedNetworkInterfaces, 'vagrant/action/vm/destroy_unused_network_interfaces'
|
40
|
+
autoload :DiscardState, 'vagrant/action/vm/discard_state'
|
41
|
+
autoload :Export, 'vagrant/action/vm/export'
|
42
|
+
autoload :ForwardPorts, 'vagrant/action/vm/forward_ports'
|
43
|
+
autoload :Halt, 'vagrant/action/vm/halt'
|
44
|
+
autoload :HostName, 'vagrant/action/vm/host_name'
|
45
|
+
autoload :Import, 'vagrant/action/vm/import'
|
46
|
+
autoload :MatchMACAddress, 'vagrant/action/vm/match_mac_address'
|
47
|
+
autoload :Network, 'vagrant/action/vm/network'
|
48
|
+
autoload :NFS, 'vagrant/action/vm/nfs'
|
49
|
+
autoload :Package, 'vagrant/action/vm/package'
|
50
|
+
autoload :PackageVagrantfile, 'vagrant/action/vm/package_vagrantfile'
|
51
|
+
autoload :Provision, 'vagrant/action/vm/provision'
|
52
|
+
autoload :ProvisionerCleanup, 'vagrant/action/vm/provisioner_cleanup'
|
53
|
+
autoload :PruneNFSExports, 'vagrant/action/vm/prune_nfs_exports'
|
54
|
+
autoload :Resume, 'vagrant/action/vm/resume'
|
55
|
+
autoload :ShareFolders, 'vagrant/action/vm/share_folders'
|
56
|
+
autoload :SetupPackageFiles, 'vagrant/action/vm/setup_package_files'
|
57
|
+
autoload :Suspend, 'vagrant/action/vm/suspend'
|
136
58
|
end
|
137
59
|
end
|
138
60
|
end
|