vagrantup 1.0.7 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +91 -0
- data/LICENSE +2 -2
- data/README.md +11 -13
- data/bin/vagrant +29 -5
- data/config/default.rb +14 -9
- data/contrib/bash/completion.sh +3 -0
- data/keys/README.md +3 -3
- data/lib/vagrant.rb +156 -102
- data/lib/vagrant/action.rb +26 -47
- data/lib/vagrant/action/builder.rb +49 -23
- data/lib/vagrant/action/builtin/box_add.rb +85 -0
- data/lib/vagrant/action/builtin/call.rb +67 -0
- data/lib/vagrant/action/builtin/config_validate.rb +30 -0
- data/lib/vagrant/action/builtin/confirm.rb +38 -0
- data/lib/vagrant/action/builtin/env_set.rb +24 -0
- data/lib/vagrant/action/builtin/graceful_halt.rb +73 -0
- data/lib/vagrant/action/builtin/handle_box_url.rb +43 -0
- data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +117 -0
- data/lib/vagrant/action/builtin/lock.rb +57 -0
- data/lib/vagrant/action/builtin/nfs.rb +117 -0
- data/lib/vagrant/action/builtin/provision.rb +70 -0
- data/lib/vagrant/action/builtin/set_hostname.rb +27 -0
- data/lib/vagrant/action/builtin/ssh_exec.rb +42 -0
- data/lib/vagrant/action/builtin/ssh_run.rb +43 -0
- data/lib/vagrant/action/general/package.rb +19 -18
- data/lib/vagrant/action/hook.rb +103 -0
- data/lib/vagrant/action/runner.rb +21 -5
- data/lib/vagrant/action/warden.rb +20 -9
- data/lib/vagrant/box.rb +75 -26
- data/lib/vagrant/box_collection.rb +301 -35
- data/lib/vagrant/cli.rb +20 -14
- data/lib/vagrant/config.rb +23 -9
- data/lib/vagrant/config/loader.rb +131 -36
- data/lib/vagrant/config/v1.rb +9 -0
- data/lib/vagrant/config/v1/dummy_config.rb +13 -0
- data/lib/vagrant/config/v1/loader.rb +105 -0
- data/lib/vagrant/config/v1/root.rb +60 -0
- data/lib/vagrant/config/v2.rb +9 -0
- data/lib/vagrant/config/v2/dummy_config.rb +13 -0
- data/lib/vagrant/config/v2/loader.rb +141 -0
- data/lib/vagrant/config/v2/root.rb +105 -0
- data/lib/vagrant/config/v2/util.rb +21 -0
- data/lib/vagrant/config/version_base.rb +80 -0
- data/lib/vagrant/downloaders/base.rb +0 -3
- data/lib/vagrant/downloaders/file.rb +10 -4
- data/lib/vagrant/downloaders/http.rb +29 -10
- data/lib/vagrant/environment.rb +447 -240
- data/lib/vagrant/errors.rb +138 -97
- data/lib/vagrant/hosts.rb +3 -12
- data/lib/vagrant/machine.rb +325 -0
- data/lib/vagrant/machine_state.rb +45 -0
- data/lib/vagrant/plugin.rb +3 -78
- data/lib/vagrant/plugin/v1.rb +19 -0
- data/lib/vagrant/plugin/v1/command.rb +169 -0
- data/lib/vagrant/plugin/v1/communicator.rb +98 -0
- data/lib/vagrant/plugin/v1/config.rb +112 -0
- data/lib/vagrant/plugin/v1/errors.rb +15 -0
- data/lib/vagrant/plugin/v1/guest.rb +92 -0
- data/lib/vagrant/plugin/v1/host.rb +66 -0
- data/lib/vagrant/plugin/v1/manager.rb +131 -0
- data/lib/vagrant/plugin/v1/plugin.rb +229 -0
- data/lib/vagrant/plugin/v1/provider.rb +68 -0
- data/lib/vagrant/plugin/v1/provisioner.rb +50 -0
- data/lib/vagrant/plugin/v2.rb +22 -0
- data/lib/vagrant/plugin/v2/command.rb +234 -0
- data/lib/vagrant/plugin/v2/communicator.rb +98 -0
- data/lib/vagrant/plugin/v2/components.rb +29 -0
- data/lib/vagrant/plugin/v2/config.rb +101 -0
- data/lib/vagrant/plugin/v2/errors.rb +15 -0
- data/lib/vagrant/plugin/v2/guest.rb +92 -0
- data/lib/vagrant/plugin/v2/host.rb +66 -0
- data/lib/vagrant/plugin/v2/manager.rb +158 -0
- data/lib/vagrant/plugin/v2/plugin.rb +217 -0
- data/lib/vagrant/plugin/v2/provider.rb +69 -0
- data/lib/vagrant/plugin/v2/provisioner.rb +47 -0
- data/lib/vagrant/registry.rb +43 -17
- data/lib/vagrant/ssh.rb +15 -9
- data/lib/vagrant/ui.rb +7 -5
- data/lib/vagrant/util/is_port_open.rb +1 -1
- data/lib/vagrant/util/platform.rb +19 -0
- data/lib/vagrant/util/retryable.rb +8 -2
- data/lib/vagrant/util/safe_exec.rb +2 -2
- data/lib/vagrant/util/scoped_hash_override.rb +45 -0
- data/lib/vagrant/util/ssh.rb +126 -0
- data/lib/vagrant/util/string_block_editor.rb +75 -0
- data/lib/vagrant/util/subprocess.rb +33 -10
- data/lib/vagrant/util/which.rb +43 -0
- data/lib/vagrant/version.rb +1 -1
- data/plugins/README.md +5 -0
- data/plugins/commands/box/command/add.rb +46 -0
- data/plugins/commands/box/command/list.rb +41 -0
- data/plugins/commands/box/command/remove.rb +37 -0
- data/plugins/commands/box/command/repackage.rb +43 -0
- data/plugins/commands/box/command/root.rb +75 -0
- data/plugins/commands/box/plugin.rb +15 -0
- data/plugins/commands/destroy/command.rb +31 -0
- data/plugins/commands/destroy/plugin.rb +18 -0
- data/plugins/commands/halt/command.rb +33 -0
- data/plugins/commands/halt/plugin.rb +18 -0
- data/{lib/vagrant/command/init.rb → plugins/commands/init/command.rb} +4 -4
- data/plugins/commands/init/plugin.rb +18 -0
- data/plugins/commands/package/command.rb +83 -0
- data/plugins/commands/package/plugin.rb +18 -0
- data/plugins/commands/plugin/action.rb +52 -0
- data/plugins/commands/plugin/action/bundler_check.rb +25 -0
- data/plugins/commands/plugin/action/install_gem.rb +70 -0
- data/plugins/commands/plugin/action/license_plugin.rb +54 -0
- data/plugins/commands/plugin/action/list_plugins.rb +54 -0
- data/plugins/commands/plugin/action/prune_gems.rb +149 -0
- data/plugins/commands/plugin/action/uninstall_plugin.rb +23 -0
- data/plugins/commands/plugin/command/base.rb +22 -0
- data/plugins/commands/plugin/command/install.rb +39 -0
- data/plugins/commands/plugin/command/license.rb +31 -0
- data/plugins/commands/plugin/command/list.rb +28 -0
- data/plugins/commands/plugin/command/root.rb +75 -0
- data/plugins/commands/plugin/command/uninstall.rb +28 -0
- data/plugins/commands/plugin/gem_helper.rb +74 -0
- data/plugins/commands/plugin/plugin.rb +22 -0
- data/plugins/commands/plugin/state_file.rb +57 -0
- data/plugins/commands/provision/command.rb +34 -0
- data/plugins/commands/provision/plugin.rb +18 -0
- data/plugins/commands/reload/command.rb +37 -0
- data/plugins/commands/reload/plugin.rb +18 -0
- data/plugins/commands/resume/command.rb +25 -0
- data/plugins/commands/resume/plugin.rb +17 -0
- data/{lib/vagrant/command/ssh.rb → plugins/commands/ssh/command.rb} +17 -41
- data/plugins/commands/ssh/plugin.rb +17 -0
- data/{lib/vagrant/command/ssh_config.rb → plugins/commands/ssh_config/command.rb} +14 -16
- data/plugins/commands/ssh_config/plugin.rb +18 -0
- data/plugins/commands/status/command.rb +39 -0
- data/plugins/commands/status/plugin.rb +18 -0
- data/plugins/commands/suspend/command.rb +25 -0
- data/plugins/commands/suspend/plugin.rb +18 -0
- data/plugins/commands/up/command.rb +45 -0
- data/plugins/commands/up/plugin.rb +17 -0
- data/{lib/vagrant/command → plugins/commands/up}/start_mixins.rb +6 -6
- data/{lib/vagrant/communication/ssh.rb → plugins/communicators/ssh/communicator.rb} +139 -52
- data/plugins/communicators/ssh/plugin.rb +19 -0
- data/plugins/guests/arch/guest.rb +41 -0
- data/plugins/guests/arch/plugin.rb +15 -0
- data/{lib/vagrant/guest/debian.rb → plugins/guests/debian/guest.rb} +21 -13
- data/plugins/guests/debian/plugin.rb +15 -0
- data/{lib/vagrant/guest/fedora.rb → plugins/guests/fedora/guest.rb} +19 -14
- data/plugins/guests/fedora/plugin.rb +15 -0
- data/plugins/guests/freebsd/config.rb +13 -0
- data/plugins/guests/freebsd/guest.rb +70 -0
- data/plugins/guests/freebsd/plugin.rb +20 -0
- data/plugins/guests/gentoo/guest.rb +51 -0
- data/plugins/guests/gentoo/plugin.rb +15 -0
- data/plugins/guests/linux/config.rb +13 -0
- data/{lib/vagrant/guest/linux.rb → plugins/guests/linux/guest.rb} +35 -34
- data/plugins/guests/linux/plugin.rb +20 -0
- data/plugins/guests/openbsd/guest.rb +13 -0
- data/plugins/guests/openbsd/plugin.rb +15 -0
- data/{lib/vagrant/guest/redhat.rb → plugins/guests/redhat/guest.rb} +22 -15
- data/plugins/guests/redhat/plugin.rb +15 -0
- data/plugins/guests/solaris/config.rb +18 -0
- data/plugins/guests/solaris/guest.rb +73 -0
- data/plugins/guests/solaris/plugin.rb +20 -0
- data/plugins/guests/suse/guest.rb +24 -0
- data/plugins/guests/suse/plugin.rb +15 -0
- data/plugins/guests/ubuntu/guest.rb +44 -0
- data/plugins/guests/ubuntu/plugin.rb +15 -0
- data/{lib/vagrant/hosts/arch.rb → plugins/hosts/arch/host.rb} +18 -5
- data/plugins/hosts/arch/plugin.rb +15 -0
- data/{lib/vagrant/hosts/bsd.rb → plugins/hosts/bsd/host.rb} +16 -11
- data/plugins/hosts/bsd/plugin.rb +15 -0
- data/{lib/vagrant/hosts/fedora.rb → plugins/hosts/fedora/host.rb} +8 -4
- data/plugins/hosts/fedora/plugin.rb +15 -0
- data/{lib/vagrant/hosts/freebsd.rb → plugins/hosts/freebsd/host.rb} +10 -8
- data/plugins/hosts/freebsd/plugin.rb +15 -0
- data/{lib/vagrant/hosts/gentoo.rb → plugins/hosts/gentoo/host.rb} +7 -3
- data/plugins/hosts/gentoo/plugin.rb +15 -0
- data/{lib/vagrant/hosts/linux.rb → plugins/hosts/linux/host.rb} +12 -11
- data/plugins/hosts/linux/plugin.rb +15 -0
- data/{lib/vagrant/hosts/opensuse.rb → plugins/hosts/opensuse/host.rb} +8 -4
- data/plugins/hosts/opensuse/plugin.rb +15 -0
- data/{lib/vagrant/hosts/windows.rb → plugins/hosts/windows/host.rb} +5 -4
- data/plugins/hosts/windows/plugin.rb +15 -0
- data/plugins/kernel_v1/config/nfs.rb +20 -0
- data/plugins/kernel_v1/config/package.rb +17 -0
- data/plugins/kernel_v1/config/ssh.rb +46 -0
- data/plugins/kernel_v1/config/vagrant.rb +31 -0
- data/plugins/kernel_v1/config/vm.rb +184 -0
- data/plugins/kernel_v1/plugin.rb +44 -0
- data/plugins/kernel_v2/config/nfs.rb +10 -0
- data/plugins/kernel_v2/config/package.rb +9 -0
- data/plugins/kernel_v2/config/ssh.rb +35 -0
- data/plugins/kernel_v2/config/vagrant.rb +9 -0
- data/plugins/kernel_v2/config/vm.rb +314 -0
- data/plugins/kernel_v2/config/vm_provisioner.rb +40 -0
- data/plugins/kernel_v2/config/vm_subvm.rb +30 -0
- data/plugins/kernel_v2/plugin.rb +44 -0
- data/plugins/providers/virtualbox/action.rb +308 -0
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/boot.rb +12 -16
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/check_accessible.rb +5 -5
- data/plugins/providers/virtualbox/action/check_created.rb +21 -0
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/check_guest_additions.rb +18 -11
- data/plugins/providers/virtualbox/action/check_running.rb +21 -0
- data/plugins/providers/virtualbox/action/check_virtualbox.rb +22 -0
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/clean_machine_folder.rb +5 -5
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/clear_forwarded_ports.rb +4 -4
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/clear_network_interfaces.rb +4 -4
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/clear_shared_folders.rb +4 -5
- data/plugins/providers/virtualbox/action/created.rb +20 -0
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/customize.rb +7 -7
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/destroy.rb +5 -5
- data/plugins/providers/virtualbox/action/destroy_confirm.rb +17 -0
- data/plugins/providers/virtualbox/action/destroy_unused_network_interfaces.rb +16 -0
- data/plugins/providers/virtualbox/action/discard_state.rb +20 -0
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/export.rb +7 -7
- data/plugins/providers/virtualbox/action/forced_halt.rb +25 -0
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/forward_ports.rb +29 -42
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/import.rb +15 -12
- data/plugins/providers/virtualbox/action/is_paused.rb +20 -0
- data/plugins/providers/virtualbox/action/is_running.rb +20 -0
- data/plugins/providers/virtualbox/action/is_saved.rb +20 -0
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/match_mac_address.rb +5 -5
- data/plugins/providers/virtualbox/action/message_not_created.rb +16 -0
- data/plugins/providers/virtualbox/action/message_not_running.rb +16 -0
- data/plugins/providers/virtualbox/action/message_will_not_destroy.rb +17 -0
- data/plugins/providers/virtualbox/action/network.rb +366 -0
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/package.rb +4 -7
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/package_vagrantfile.rb +5 -8
- data/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb +35 -0
- data/plugins/providers/virtualbox/action/prepare_nfs_settings.rb +51 -0
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/prune_nfs_exports.rb +5 -5
- data/plugins/providers/virtualbox/action/resume.rb +25 -0
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/sane_defaults.rb +41 -32
- data/plugins/providers/virtualbox/action/set_name.rb +40 -0
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/setup_package_files.rb +5 -8
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/share_folders.rb +24 -25
- data/{lib/vagrant/action/vm → plugins/providers/virtualbox/action}/suspend.rb +5 -5
- data/plugins/providers/virtualbox/config.rb +82 -0
- data/plugins/providers/virtualbox/driver/base.rb +344 -0
- data/plugins/providers/virtualbox/driver/meta.rb +142 -0
- data/plugins/providers/virtualbox/driver/version_4_0.rb +485 -0
- data/plugins/providers/virtualbox/driver/version_4_1.rb +485 -0
- data/plugins/providers/virtualbox/driver/version_4_2.rb +475 -0
- data/plugins/providers/virtualbox/model/forwarded_port.rb +58 -0
- data/plugins/providers/virtualbox/plugin.rb +42 -0
- data/plugins/providers/virtualbox/provider.rb +92 -0
- data/plugins/providers/virtualbox/util/compile_forwarded_ports.rb +31 -0
- data/plugins/provisioners/chef/config/base.rb +65 -0
- data/plugins/provisioners/chef/config/chef_client.rb +39 -0
- data/plugins/provisioners/chef/config/chef_solo.rb +87 -0
- data/plugins/provisioners/chef/plugin.rb +33 -0
- data/plugins/provisioners/chef/provisioner/base.rb +91 -0
- data/plugins/provisioners/chef/provisioner/chef_client.rb +103 -0
- data/plugins/provisioners/chef/provisioner/chef_solo.rb +182 -0
- data/plugins/provisioners/puppet/config/puppet.rb +70 -0
- data/plugins/provisioners/puppet/config/puppet_server.rb +16 -0
- data/plugins/provisioners/puppet/plugin.rb +33 -0
- data/plugins/provisioners/puppet/provisioner/puppet.rb +110 -0
- data/plugins/provisioners/puppet/provisioner/puppet_server.rb +67 -0
- data/plugins/provisioners/shell/config.rb +46 -0
- data/plugins/provisioners/shell/plugin.rb +23 -0
- data/plugins/provisioners/shell/provisioner.rb +66 -0
- data/templates/commands/init/Vagrantfile.erb +33 -21
- data/templates/commands/ssh_config/config.erb +1 -0
- data/templates/config/messages.erb +14 -0
- data/templates/config/validation_failed.erb +3 -3
- data/templates/guests/arch/network_dhcp.erb +4 -7
- data/templates/guests/arch/network_static.erb +6 -7
- data/templates/guests/debian/network_dhcp.erb +5 -0
- data/templates/locales/en.yml +336 -100
- data/templates/rgloader.rb +9 -0
- data/test/acceptance/support/isolated_environment.rb +3 -2
- data/test/support/tempdir.rb +13 -4
- data/test/unit/base.rb +6 -0
- data/test/unit/support/dummy_provider.rb +16 -0
- data/test/unit/support/isolated_environment.rb +132 -0
- data/test/unit/support/shared/base_context.rb +74 -0
- data/test/unit/vagrant/action/builder_test.rb +88 -48
- data/test/unit/vagrant/action/builtin/call_test.rb +145 -0
- data/test/unit/vagrant/action/builtin/confirm_test.rb +36 -0
- data/test/unit/vagrant/action/builtin/env_set_test.rb +20 -0
- data/test/unit/vagrant/action/builtin/graceful_halt_test.rb +61 -0
- data/test/unit/vagrant/action/builtin/lock_test.rb +98 -0
- data/test/unit/vagrant/action/builtin/ssh_exec_test.rb +57 -0
- data/test/unit/vagrant/action/hook_test.rb +101 -0
- data/test/unit/vagrant/action/runner_test.rb +15 -9
- data/test/unit/vagrant/box_collection_test.rb +219 -38
- data/test/unit/vagrant/box_test.rb +94 -19
- data/test/unit/vagrant/cli_test.rb +27 -0
- data/test/unit/vagrant/config/loader_test.rb +154 -49
- data/test/unit/vagrant/config/v1/dummy_config_test.rb +24 -0
- data/test/unit/vagrant/config/v1/loader_test.rb +145 -0
- data/test/unit/vagrant/config/v1/root_test.rb +40 -0
- data/test/unit/vagrant/config/v2/dummy_config_test.rb +24 -0
- data/test/unit/vagrant/config/v2/loader_test.rb +151 -0
- data/test/unit/vagrant/config/v2/root_test.rb +97 -0
- data/test/unit/vagrant/config/v2/util_test.rb +21 -0
- data/test/unit/vagrant/config_test.rb +40 -1
- data/test/unit/vagrant/downloaders/base_test.rb +0 -4
- data/test/unit/vagrant/downloaders/file_test.rb +21 -9
- data/test/unit/vagrant/downloaders/http_test.rb +4 -0
- data/test/unit/vagrant/environment_test.rb +414 -63
- data/test/unit/vagrant/hosts_test.rb +10 -9
- data/test/unit/vagrant/machine_state_test.rb +26 -0
- data/test/unit/vagrant/machine_test.rb +418 -0
- data/test/unit/vagrant/{command/base_test.rb → plugin/v1/command_test.rb} +2 -9
- data/test/unit/vagrant/plugin/v1/communicator_test.rb +9 -0
- data/test/unit/vagrant/plugin/v1/config_test.rb +50 -0
- data/test/unit/vagrant/plugin/v1/host_test.rb +5 -0
- data/test/unit/vagrant/plugin/v1/manager_test.rb +114 -0
- data/test/unit/vagrant/plugin/v1/plugin_test.rb +267 -0
- data/test/unit/vagrant/plugin/v1/provider_test.rb +18 -0
- data/test/unit/vagrant/plugin/v2/command_test.rb +238 -0
- data/test/unit/vagrant/plugin/v2/communicator_test.rb +9 -0
- data/test/unit/vagrant/plugin/v2/components_test.rb +17 -0
- data/test/unit/vagrant/plugin/v2/config_test.rb +60 -0
- data/test/unit/vagrant/plugin/v2/host_test.rb +5 -0
- data/test/unit/vagrant/plugin/v2/manager_test.rb +157 -0
- data/test/unit/vagrant/plugin/v2/plugin_test.rb +287 -0
- data/test/unit/vagrant/plugin/v2/provider_test.rb +18 -0
- data/test/unit/vagrant/registry_test.rb +59 -5
- data/test/unit/vagrant/util/scoped_hash_override_test.rb +48 -0
- data/test/unit/vagrant/util/ssh_test.rb +30 -0
- data/test/unit/vagrant/util/string_block_editor_test.rb +98 -0
- data/test/unit/vagrant/util/which_test.rb +43 -0
- data/test/unit/vagrant_test.rb +42 -13
- data/vagrant.gemspec +6 -7
- data/vagrant.gemspecbak +6 -7
- metadata +273 -358
- data/lib/vagrant/action/box/destroy.rb +0 -25
- data/lib/vagrant/action/box/download.rb +0 -84
- data/lib/vagrant/action/box/package.rb +0 -19
- data/lib/vagrant/action/box/unpackage.rb +0 -61
- data/lib/vagrant/action/box/verify.rb +0 -23
- data/lib/vagrant/action/builtin.rb +0 -171
- data/lib/vagrant/action/env/set.rb +0 -21
- data/lib/vagrant/action/environment.rb +0 -12
- data/lib/vagrant/action/general/check_virtualbox.rb +0 -28
- data/lib/vagrant/action/general/validate.rb +0 -18
- data/lib/vagrant/action/vm/check_box.rb +0 -33
- data/lib/vagrant/action/vm/check_port_collisions.rb +0 -89
- data/lib/vagrant/action/vm/default_name.rb +0 -22
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +0 -20
- data/lib/vagrant/action/vm/discard_state.rb +0 -22
- data/lib/vagrant/action/vm/halt.rb +0 -32
- data/lib/vagrant/action/vm/host_name.rb +0 -21
- data/lib/vagrant/action/vm/network.rb +0 -403
- data/lib/vagrant/action/vm/nfs.rb +0 -196
- data/lib/vagrant/action/vm/provision.rb +0 -61
- data/lib/vagrant/action/vm/provisioner_cleanup.rb +0 -26
- data/lib/vagrant/action/vm/resume.rb +0 -20
- data/lib/vagrant/command.rb +0 -24
- data/lib/vagrant/command/base.rb +0 -167
- data/lib/vagrant/command/box.rb +0 -58
- data/lib/vagrant/command/box_add.rb +0 -37
- data/lib/vagrant/command/box_list.rb +0 -28
- data/lib/vagrant/command/box_remove.rb +0 -27
- data/lib/vagrant/command/box_repackage.rb +0 -27
- data/lib/vagrant/command/destroy.rb +0 -64
- data/lib/vagrant/command/gem.rb +0 -39
- data/lib/vagrant/command/halt.rb +0 -39
- data/lib/vagrant/command/package.rb +0 -75
- data/lib/vagrant/command/provision.rb +0 -40
- data/lib/vagrant/command/reload.rb +0 -39
- data/lib/vagrant/command/resume.rb +0 -33
- data/lib/vagrant/command/status.rb +0 -36
- data/lib/vagrant/command/suspend.rb +0 -33
- data/lib/vagrant/command/up.rb +0 -40
- data/lib/vagrant/communication.rb +0 -7
- data/lib/vagrant/communication/base.rb +0 -56
- data/lib/vagrant/config/base.rb +0 -82
- data/lib/vagrant/config/error_recorder.rb +0 -19
- data/lib/vagrant/config/nfs.rb +0 -8
- data/lib/vagrant/config/package.rb +0 -7
- data/lib/vagrant/config/ssh.rb +0 -27
- data/lib/vagrant/config/top.rb +0 -72
- data/lib/vagrant/config/vagrant.rb +0 -14
- data/lib/vagrant/config/vm.rb +0 -168
- data/lib/vagrant/config/vm/provisioner.rb +0 -52
- data/lib/vagrant/config/vm/sub_vm.rb +0 -17
- data/lib/vagrant/data_store.rb +0 -92
- data/lib/vagrant/driver.rb +0 -8
- data/lib/vagrant/driver/virtualbox.rb +0 -134
- data/lib/vagrant/driver/virtualbox_4_0.rb +0 -459
- data/lib/vagrant/driver/virtualbox_4_1.rb +0 -459
- data/lib/vagrant/driver/virtualbox_4_2.rb +0 -606
- data/lib/vagrant/driver/virtualbox_base.rb +0 -326
- data/lib/vagrant/guest.rb +0 -18
- data/lib/vagrant/guest/arch.rb +0 -56
- data/lib/vagrant/guest/base.rb +0 -99
- data/lib/vagrant/guest/freebsd.rb +0 -86
- data/lib/vagrant/guest/gentoo.rb +0 -46
- data/lib/vagrant/guest/linux/config.rb +0 -19
- data/lib/vagrant/guest/linux/error.rb +0 -9
- data/lib/vagrant/guest/openbsd.rb +0 -20
- data/lib/vagrant/guest/solaris.rb +0 -118
- data/lib/vagrant/guest/suse.rb +0 -17
- data/lib/vagrant/guest/ubuntu.rb +0 -23
- data/lib/vagrant/hosts/base.rb +0 -66
- data/lib/vagrant/provisioners.rb +0 -12
- data/lib/vagrant/provisioners/base.rb +0 -44
- data/lib/vagrant/provisioners/chef.rb +0 -168
- data/lib/vagrant/provisioners/chef_client.rb +0 -132
- data/lib/vagrant/provisioners/chef_solo.rb +0 -234
- data/lib/vagrant/provisioners/puppet.rb +0 -176
- data/lib/vagrant/provisioners/puppet_server.rb +0 -78
- data/lib/vagrant/provisioners/shell.rb +0 -103
- data/lib/vagrant/vm.rb +0 -195
- data/test/buildbot/README.md +0 -72
- data/test/buildbot/buildbot_config/__init__.py +0 -0
- data/test/buildbot/buildbot_config/config/__init__.py +0 -0
- data/test/buildbot/buildbot_config/config/loader.py +0 -24
- data/test/buildbot/buildbot_config/config/master.py +0 -24
- data/test/buildbot/buildbot_config/config/slave.py +0 -22
- data/test/buildbot/buildbot_config/master/__init__.py +0 -6
- data/test/buildbot/buildbot_config/master/builders.py +0 -78
- data/test/buildbot/buildbot_config/master/buildsteps.py +0 -100
- data/test/buildbot/buildbot_config/master/change_sources.py +0 -8
- data/test/buildbot/buildbot_config/master/schedulers.py +0 -32
- data/test/buildbot/buildbot_config/master/slaves.py +0 -60
- data/test/buildbot/buildbot_config/master/status.py +0 -52
- data/test/buildbot/master/Makefile.sample +0 -28
- data/test/buildbot/master/buildbot.tac +0 -36
- data/test/buildbot/master/master.cfg +0 -67
- data/test/buildbot/master/public_html/bg_gradient.jpg +0 -0
- data/test/buildbot/master/public_html/default.css +0 -545
- data/test/buildbot/master/public_html/favicon.ico +0 -0
- data/test/buildbot/master/public_html/robots.txt +0 -10
- data/test/buildbot/master/public_html/static/css/bootstrap-1.4.0.min.css +0 -356
- data/test/buildbot/master/public_html/static/css/prettify.css +0 -97
- data/test/buildbot/master/public_html/static/css/syntax.css +0 -60
- data/test/buildbot/master/public_html/static/css/vagrant.base.css +0 -205
- data/test/buildbot/master/public_html/static/images/base_box_mac.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/getting-started/success.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/icons/error.png +0 -0
- data/test/buildbot/master/public_html/static/images/vagrant_chilling.png +0 -0
- data/test/buildbot/master/public_html/static/images/vagrant_holding.png +0 -0
- data/test/buildbot/master/public_html/static/images/vagrant_looking.png +0 -0
- data/test/buildbot/master/public_html/static/images/windows/alter_path.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/edit_path.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/environment_variables_button.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/port_and_ppk_path.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/ppk_selection.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/putty_first_screen.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/save_result.jpg +0 -0
- data/test/buildbot/master/public_html/static/images/windows/vbox_manage_default_location.jpg +0 -0
- data/test/buildbot/master/public_html/static/js/bootstrap-tabs.js +0 -80
- data/test/buildbot/master/public_html/static/js/jquery-1.7.min.js +0 -4
- data/test/buildbot/master/templates/authfail.html +0 -9
- data/test/buildbot/master/templates/build.html +0 -205
- data/test/buildbot/master/templates/builder.html +0 -118
- data/test/buildbot/master/templates/builders.html +0 -33
- data/test/buildbot/master/templates/buildslave.html +0 -72
- data/test/buildbot/master/templates/buildslaves.html +0 -70
- data/test/buildbot/master/templates/change.html +0 -15
- data/test/buildbot/master/templates/layouts/base.html +0 -58
- data/test/buildbot/master/templates/macros/box.html +0 -37
- data/test/buildbot/master/templates/macros/build_line.html +0 -50
- data/test/buildbot/master/templates/macros/change.html +0 -81
- data/test/buildbot/master/templates/macros/forms.html +0 -300
- data/test/buildbot/master/templates/root.html +0 -42
- data/test/buildbot/master/templates/waterfall.html +0 -53
- data/test/buildbot/requirements.txt +0 -4
- data/test/buildbot/scripts/deploy.sh +0 -38
- data/test/buildbot/scripts/setup.sh +0 -107
- data/test/buildbot/slave/buildbot.tac +0 -43
- data/test/buildbot/slave/info/admin +0 -1
- data/test/buildbot/slave/info/host +0 -1
- data/test/buildbot/tests/__init__.py +0 -0
- data/test/buildbot/tests/master/__init__.py +0 -0
- data/test/buildbot/tests/master/test_slaves.py +0 -41
- data/test/buildbot/vendor/choices-0.4.0.tar.gz +0 -0
- data/test/unit/vagrant/action/environment_test.rb +0 -16
- data/test/unit/vagrant/config/base_test.rb +0 -48
- data/test/unit/vagrant/config/ssh_test.rb +0 -17
- data/test/unit/vagrant/config/top_test.rb +0 -69
- data/test/unit/vagrant/config/vm_test.rb +0 -71
- data/test/unit/vagrant/data_store_test.rb +0 -79
- data/test/unit_legacy/locales/en.yml +0 -8
- data/test/unit_legacy/test_helper.rb +0 -32
- data/test/unit_legacy/vagrant/action/box/destroy_test.rb +0 -18
- data/test/unit_legacy/vagrant/action/box/download_test.rb +0 -125
- data/test/unit_legacy/vagrant/action/box/package_test.rb +0 -25
- data/test/unit_legacy/vagrant/action/box/unpackage_test.rb +0 -84
- data/test/unit_legacy/vagrant/action/box/verify_test.rb +0 -30
- data/test/unit_legacy/vagrant/action/env/set_test.rb +0 -24
- data/test/unit_legacy/vagrant/action/general/package_test.rb +0 -268
- data/test/unit_legacy/vagrant/action/general/validate_test.rb +0 -31
- data/test/unit_legacy/vagrant/action/vm/boot_test.rb +0 -66
- data/test/unit_legacy/vagrant/action/vm/check_accessible_test.rb +0 -61
- data/test/unit_legacy/vagrant/action/vm/check_box_test.rb +0 -61
- data/test/unit_legacy/vagrant/action/vm/check_guest_additions_test.rb +0 -9
- data/test/unit_legacy/vagrant/action/vm/clean_machine_folder_test.rb +0 -84
- data/test/unit_legacy/vagrant/action/vm/clear_forwarded_ports_test.rb +0 -52
- data/test/unit_legacy/vagrant/action/vm/clear_nfs_exports_test.rb +0 -22
- data/test/unit_legacy/vagrant/action/vm/clear_shared_folders_test.rb +0 -40
- data/test/unit_legacy/vagrant/action/vm/customize_test.rb +0 -37
- data/test/unit_legacy/vagrant/action/vm/destroy_test.rb +0 -25
- data/test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +0 -49
- data/test/unit_legacy/vagrant/action/vm/discard_state_test.rb +0 -45
- data/test/unit_legacy/vagrant/action/vm/export_test.rb +0 -107
- data/test/unit_legacy/vagrant/action/vm/forward_ports_helpers_test.rb +0 -77
- data/test/unit_legacy/vagrant/action/vm/forward_ports_test.rb +0 -197
- data/test/unit_legacy/vagrant/action/vm/halt_test.rb +0 -79
- data/test/unit_legacy/vagrant/action/vm/host_name_test.rb +0 -36
- data/test/unit_legacy/vagrant/action/vm/import_test.rb +0 -66
- data/test/unit_legacy/vagrant/action/vm/match_mac_address_test.rb +0 -40
- data/test/unit_legacy/vagrant/action/vm/modify_test.rb +0 -38
- data/test/unit_legacy/vagrant/action/vm/network_test.rb +0 -286
- data/test/unit_legacy/vagrant/action/vm/nfs_helpers_test.rb +0 -26
- data/test/unit_legacy/vagrant/action/vm/nfs_test.rb +0 -260
- data/test/unit_legacy/vagrant/action/vm/package_test.rb +0 -25
- data/test/unit_legacy/vagrant/action/vm/package_vagrantfile_test.rb +0 -46
- data/test/unit_legacy/vagrant/action/vm/provision_test.rb +0 -65
- data/test/unit_legacy/vagrant/action/vm/provisioner_cleanup_test.rb +0 -56
- data/test/unit_legacy/vagrant/action/vm/resume_test.rb +0 -35
- data/test/unit_legacy/vagrant/action/vm/share_folders_test.rb +0 -144
- data/test/unit_legacy/vagrant/action/vm/suspend_test.rb +0 -35
- data/test/unit_legacy/vagrant/action_test.rb +0 -89
- data/test/unit_legacy/vagrant/box_collection_test.rb +0 -45
- data/test/unit_legacy/vagrant/box_test.rb +0 -74
- data/test/unit_legacy/vagrant/cli_test.rb +0 -35
- data/test/unit_legacy/vagrant/command/base_test.rb +0 -23
- data/test/unit_legacy/vagrant/command/group_base_test.rb +0 -15
- data/test/unit_legacy/vagrant/command/helpers_test.rb +0 -88
- data/test/unit_legacy/vagrant/command/init_test.rb +0 -10
- data/test/unit_legacy/vagrant/command/package_test.rb +0 -27
- data/test/unit_legacy/vagrant/config/base_test.rb +0 -52
- data/test/unit_legacy/vagrant/config/error_recorder_test.rb +0 -18
- data/test/unit_legacy/vagrant/config/ssh_test.rb +0 -12
- data/test/unit_legacy/vagrant/config/vagrant_test.rb +0 -35
- data/test/unit_legacy/vagrant/config/vm/provisioner_test.rb +0 -92
- data/test/unit_legacy/vagrant/config/vm_test.rb +0 -47
- data/test/unit_legacy/vagrant/config_test.rb +0 -148
- data/test/unit_legacy/vagrant/downloaders/http_test.rb +0 -93
- data/test/unit_legacy/vagrant/environment_test.rb +0 -539
- data/test/unit_legacy/vagrant/errors_test.rb +0 -42
- data/test/unit_legacy/vagrant/hosts/base_test.rb +0 -46
- data/test/unit_legacy/vagrant/hosts/bsd_test.rb +0 -53
- data/test/unit_legacy/vagrant/hosts/linux_test.rb +0 -54
- data/test/unit_legacy/vagrant/plugin_test.rb +0 -9
- data/test/unit_legacy/vagrant/provisioners/base_test.rb +0 -63
- data/test/unit_legacy/vagrant/provisioners/chef_client_test.rb +0 -190
- data/test/unit_legacy/vagrant/provisioners/chef_solo_test.rb +0 -115
- data/test/unit_legacy/vagrant/provisioners/chef_test.rb +0 -209
- data/test/unit_legacy/vagrant/provisioners/puppet_server_test.rb +0 -68
- data/test/unit_legacy/vagrant/provisioners/puppet_test.rb +0 -182
- data/test/unit_legacy/vagrant/provisioners/shell_test.rb +0 -79
- data/test/unit_legacy/vagrant/ssh/session_test.rb +0 -40
- data/test/unit_legacy/vagrant/ssh_test.rb +0 -304
- data/test/unit_legacy/vagrant/systems/base_test.rb +0 -18
- data/test/unit_legacy/vagrant/systems/linux_test.rb +0 -104
- data/test/unit_legacy/vagrant/util/busy_test.rb +0 -106
- data/test/unit_legacy/vagrant/util/counter_test.rb +0 -29
- data/test/unit_legacy/vagrant/util/platform_test.rb +0 -18
- data/test/unit_legacy/vagrant/util/stacked_proc_runner_test.rb +0 -43
- data/test/unit_legacy/vagrant/util/template_renderer_test.rb +0 -145
- data/test/unit_legacy/vagrant/vm_test.rb +0 -300
- data/vagrant-1.1.4.gem +0 -0
- data/vagrantup-0.1.0.gem +0 -0
- data/vagrantup-0.1.1.gem +0 -0
- data/vagrantup-0.1.2.gem +0 -0
- data/vagrantup-0.1.3.gem +0 -0
- data/vagrantup-0.1.4.gem +0 -0
- data/vagrantup-0.2.0.gem +0 -0
- data/vagrantup-0.3.0.gem +0 -0
- data/vagrantup-0.3.1.gem +0 -0
- data/vagrantup-0.3.2.gem +0 -0
- data/vagrantup-0.3.3.gem +0 -0
- data/vagrantup-0.3.4.gem +0 -0
- data/vagrantup-0.4.0.gem +0 -0
- data/vagrantup-0.4.1.gem +0 -0
- data/vagrantup-0.4.3.dev.gem +0 -0
- data/vagrantup-0.5.0.gem +0 -0
- data/vagrantup-0.5.1.gem +0 -0
- data/vagrantup-0.5.2.gem +0 -0
- data/vagrantup-0.5.3.gem +0 -0
- data/vagrantup-0.5.4.gem +0 -0
- data/vagrantup-0.6.0.gem +0 -0
- data/vagrantup-0.6.1.gem +0 -0
- data/vagrantup-0.6.2.gem +0 -0
- data/vagrantup-0.6.3.gem +0 -0
- data/vagrantup-0.6.4.gem +0 -0
- data/vagrantup-0.6.5.gem +0 -0
- data/vagrantup-0.6.6.gem +0 -0
- data/vagrantup-0.6.7.gem +0 -0
- data/vagrantup-0.6.8.gem +0 -0
- data/vagrantup-0.6.9.gem +0 -0
- data/vagrantup-0.7.0.gem +0 -0
- data/vagrantup-0.7.1.gem +0 -0
- data/vagrantup-0.7.2.gem +0 -0
- data/vagrantup-0.7.3.gem +0 -0
- data/vagrantup-0.7.4.gem +0 -0
- data/vagrantup-0.7.5.gem +0 -0
- data/vagrantup-0.7.6.gem +0 -0
- data/vagrantup-0.7.7.gem +0 -0
- data/vagrantup-0.7.8.gem +0 -0
- data/vagrantup-0.8.0.gem +0 -0
- data/vagrantup-0.8.1.gem +0 -0
- data/vagrantup-0.8.10.gem +0 -0
- data/vagrantup-0.8.2.gem +0 -0
- data/vagrantup-0.8.3.gem +0 -0
- data/vagrantup-0.8.4.gem +0 -0
- data/vagrantup-0.8.5.gem +0 -0
- data/vagrantup-0.8.6.gem +0 -0
- data/vagrantup-0.8.7.gem +0 -0
- data/vagrantup-0.8.8.gem +0 -0
- data/vagrantup-0.8.9.gem +0 -0
- data/vagrantup-0.9.0.gem +0 -0
- data/vagrantup-0.9.1.gem +0 -0
- data/vagrantup-0.9.2.gem +0 -0
- data/vagrantup-0.9.3.gem +0 -0
- data/vagrantup-0.9.4.gem +0 -0
- data/vagrantup-0.9.5.gem +0 -0
- data/vagrantup-0.9.6.gem +0 -0
- data/vagrantup-0.9.7.gem +0 -0
- data/vagrantup-0.9.99.1.gem +0 -0
- data/vagrantup-0.9.99.2.gem +0 -0
- data/vagrantup-1.0.0.gem +0 -0
- data/vagrantup-1.0.1.gem +0 -0
- data/vagrantup-1.0.2.gem +0 -0
- data/vagrantup-1.0.3.gem +0 -0
- data/vagrantup-1.0.4.gem +0 -0
- data/vagrantup-1.0.5.gem +0 -0
- data/vagrantup-1.0.6.gem +0 -0
- data/vagrantup-1.1.4.gem +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
require "set"
|
|
2
|
+
|
|
3
|
+
require "vagrant/config/v2/util"
|
|
4
|
+
|
|
5
|
+
module Vagrant
|
|
6
|
+
module Config
|
|
7
|
+
module V2
|
|
8
|
+
# This is the root configuration class. An instance of this is what
|
|
9
|
+
# is passed into version 1 Vagrant configuration blocks.
|
|
10
|
+
class Root
|
|
11
|
+
# Initializes a root object that maps the given keys to specific
|
|
12
|
+
# configuration classes.
|
|
13
|
+
#
|
|
14
|
+
# @param [Hash] config_map Map of key to config class.
|
|
15
|
+
def initialize(config_map, keys=nil)
|
|
16
|
+
@keys = keys || {}
|
|
17
|
+
@config_map = config_map
|
|
18
|
+
@missing_key_calls = Set.new
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# We use method_missing as a way to get the configuration that is
|
|
22
|
+
# used for Vagrant and load the proper configuration classes for
|
|
23
|
+
# each.
|
|
24
|
+
def method_missing(name, *args)
|
|
25
|
+
return @keys[name] if @keys.has_key?(name)
|
|
26
|
+
|
|
27
|
+
config_klass = @config_map[name.to_sym]
|
|
28
|
+
if config_klass
|
|
29
|
+
# Instantiate the class and return the instance
|
|
30
|
+
@keys[name] = config_klass.new
|
|
31
|
+
return @keys[name]
|
|
32
|
+
else
|
|
33
|
+
# Record access to a missing key as an error
|
|
34
|
+
@missing_key_calls.add(name.to_s)
|
|
35
|
+
return DummyConfig.new
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Called to finalize this object just prior to it being used by
|
|
40
|
+
# the Vagrant system. The "!" signifies that this is expected to
|
|
41
|
+
# mutate itself.
|
|
42
|
+
def finalize!
|
|
43
|
+
@keys.each do |_key, instance|
|
|
44
|
+
instance.finalize!
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# This validates the configuration and returns a hash of error
|
|
49
|
+
# messages by section. If there are no errors, an empty hash
|
|
50
|
+
# is returned.
|
|
51
|
+
#
|
|
52
|
+
# @param [Environment] env
|
|
53
|
+
# @return [Hash]
|
|
54
|
+
def validate(machine)
|
|
55
|
+
# Go through each of the configuration keys and validate
|
|
56
|
+
errors = {}
|
|
57
|
+
@keys.each do |_key, instance|
|
|
58
|
+
if instance.respond_to?(:validate)
|
|
59
|
+
# Validate this single item, and if we have errors then
|
|
60
|
+
# we merge them into our total errors list.
|
|
61
|
+
result = instance.validate(machine)
|
|
62
|
+
if result && !result.empty?
|
|
63
|
+
errors = Util.merge_errors(errors, result)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Go through and delete empty keys
|
|
69
|
+
errors.keys.each do |key|
|
|
70
|
+
errors.delete(key) if errors[key].empty?
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# If we have missing keys, record those as errors
|
|
74
|
+
if !@missing_key_calls.empty?
|
|
75
|
+
errors["Vagrant"] = @missing_key_calls.to_a.sort.map do |key|
|
|
76
|
+
I18n.t("vagrant.config.root.bad_key", :key => key)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
errors
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Returns the internal state of the root object. This is used
|
|
84
|
+
# by outside classes when merging, and shouldn't be called directly.
|
|
85
|
+
# Note the strange method name is to attempt to avoid any name
|
|
86
|
+
# clashes with potential configuration keys.
|
|
87
|
+
def __internal_state
|
|
88
|
+
{
|
|
89
|
+
"config_map" => @config_map,
|
|
90
|
+
"keys" => @keys,
|
|
91
|
+
"missing_key_calls" => @missing_key_calls
|
|
92
|
+
}
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# This sets the internal state. This is used by the core to do some
|
|
96
|
+
# merging logic and shouldn't be used by the general public.
|
|
97
|
+
def __set_internal_state(state)
|
|
98
|
+
@config_map = state["config_map"] if state.has_key?("config_map")
|
|
99
|
+
@keys = state["keys"] if state.has_key?("keys")
|
|
100
|
+
@missing_key_calls = state["missing_key_calls"] if state.has_key?("missing_key_calls")
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Vagrant
|
|
2
|
+
module Config
|
|
3
|
+
module V2
|
|
4
|
+
class Util
|
|
5
|
+
# This merges two error hashes from validate methods.
|
|
6
|
+
#
|
|
7
|
+
# @param [Hash] first
|
|
8
|
+
# @param [Hash] second
|
|
9
|
+
# @return [Hash] Merged result
|
|
10
|
+
def self.merge_errors(first, second)
|
|
11
|
+
first.dup.tap do |result|
|
|
12
|
+
second.each do |key, value|
|
|
13
|
+
result[key] ||= []
|
|
14
|
+
result[key] += value
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
module Vagrant
|
|
2
|
+
module Config
|
|
3
|
+
# This is the base class for any configuration versions, and includes
|
|
4
|
+
# the stub methods that configuaration versions must implement. Vagrant
|
|
5
|
+
# supports configuration versioning so that backwards compatibility can be
|
|
6
|
+
# maintained for past Vagrantfiles while newer configurations are added.
|
|
7
|
+
# Vagrant only introduces new configuration versions for major versions
|
|
8
|
+
# of Vagrant.
|
|
9
|
+
class VersionBase
|
|
10
|
+
# Returns an empty configuration object. This can be any kind of object,
|
|
11
|
+
# since it is treated as an opaque value on the other side, used only
|
|
12
|
+
# for things like calling into {merge}.
|
|
13
|
+
#
|
|
14
|
+
# @return [Object]
|
|
15
|
+
def self.init
|
|
16
|
+
raise NotImplementedError
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# This is called just before configuration loading is complete of
|
|
20
|
+
# a potentially completely-merged value to perform final touch-ups
|
|
21
|
+
# to the configuration, if required.
|
|
22
|
+
#
|
|
23
|
+
# This is an optional method to implement. The default implementation
|
|
24
|
+
# will simply return the same object.
|
|
25
|
+
#
|
|
26
|
+
# This will ONLY be called if this is the version that is being
|
|
27
|
+
# used. In the case that an `upgrade` is called, this will never
|
|
28
|
+
# be called.
|
|
29
|
+
#
|
|
30
|
+
# @param [Object] obj Final configuration object.
|
|
31
|
+
# @param [Object] Finalized configuration object.
|
|
32
|
+
def self.finalize(obj)
|
|
33
|
+
obj
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Loads the configuration for the given proc and returns a configuration
|
|
37
|
+
# object. The return value is treated as an opaque object, so it can be
|
|
38
|
+
# anything you'd like. The return value is the object that is passed
|
|
39
|
+
# into methods like {merge}, so it should be something you expect.
|
|
40
|
+
#
|
|
41
|
+
# @param [Proc] proc The proc that is to be configured.
|
|
42
|
+
# @return [Object]
|
|
43
|
+
def self.load(proc)
|
|
44
|
+
raise NotImplementedError
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Merges two configuration objects, returning the merged object.
|
|
48
|
+
# The values of `old` and `new` are the opaque objects returned by
|
|
49
|
+
# {load} or {init}.
|
|
50
|
+
#
|
|
51
|
+
# Once again, the return object is treated as an opaque value by
|
|
52
|
+
# the Vagrant configuration loader, so it can be anything you'd like.
|
|
53
|
+
#
|
|
54
|
+
# @param [Object] old Old configuration object.
|
|
55
|
+
# @param [Object] new New configuration object.
|
|
56
|
+
# @return [Object] The merged configuration object.
|
|
57
|
+
def self.merge(old, new)
|
|
58
|
+
raise NotImplementedError
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# This is called if a previous version of configuration needs to be
|
|
62
|
+
# upgraded to this version. Each version of configuration should know
|
|
63
|
+
# how to upgrade the version immediately prior to it. This should be
|
|
64
|
+
# a best effort upgrade that makes many assumptions. The goal is for
|
|
65
|
+
# this to work in almost every case, but perhaps with some warnings.
|
|
66
|
+
# The return value for this is a 3-tuple: `[object, warnings, errors]`,
|
|
67
|
+
# where `object` is the upgraded configuration object, `warnings` is
|
|
68
|
+
# an array of warning messages, and `errors` is an array of error
|
|
69
|
+
# messages.
|
|
70
|
+
#
|
|
71
|
+
# @param [Object] old The version of the configuration object just
|
|
72
|
+
# prior to this one.
|
|
73
|
+
# @return [Array] The 3-tuple result. Please see the above documentation
|
|
74
|
+
# for more information on the exact structure of this object.
|
|
75
|
+
def self.upgrade(old)
|
|
76
|
+
raise NotImplementedError
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -14,9 +14,6 @@ module Vagrant
|
|
|
14
14
|
# handle.
|
|
15
15
|
def self.match?(url); false; end
|
|
16
16
|
|
|
17
|
-
# Called prior to execution so any error checks can be done
|
|
18
|
-
def prepare(source_url); end
|
|
19
|
-
|
|
20
17
|
# Downloads the source file to the destination file. It is up to
|
|
21
18
|
# implementors of this class to handle the logic.
|
|
22
19
|
def download!(source_url, destination_file); end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'fileutils'
|
|
2
|
+
require 'uri'
|
|
2
3
|
|
|
3
4
|
module Vagrant
|
|
4
5
|
module Downloaders
|
|
@@ -6,14 +7,19 @@ module Vagrant
|
|
|
6
7
|
# simply does a file copy.
|
|
7
8
|
class File < Base
|
|
8
9
|
def self.match?(uri)
|
|
9
|
-
|
|
10
|
-
end
|
|
10
|
+
extracted = URI.extract(uri, "file")
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
# We match if we got a file URI. It doesn't matter here if the file
|
|
13
|
+
# doesn't exist because we check again later as well.
|
|
14
|
+
return true if extracted && extracted.include?(uri)
|
|
15
|
+
|
|
16
|
+
# Otherwise we match if the file exists
|
|
17
|
+
return ::File.file?(::File.expand_path(uri))
|
|
14
18
|
end
|
|
15
19
|
|
|
16
20
|
def download!(source_url, destination_file)
|
|
21
|
+
raise Errors::DownloaderFileDoesntExist if !::File.file?(::File.expand_path(source_url))
|
|
22
|
+
|
|
17
23
|
@ui.info I18n.t("vagrant.downloaders.file.download")
|
|
18
24
|
FileUtils.cp(::File.expand_path(source_url), destination_file.path)
|
|
19
25
|
end
|
|
@@ -10,7 +10,7 @@ module Vagrant
|
|
|
10
10
|
class HTTP < Base
|
|
11
11
|
def self.match?(uri)
|
|
12
12
|
# URI.parse barfs on '<drive letter>:\\files \on\ windows'
|
|
13
|
-
extracted = URI.extract(uri).first
|
|
13
|
+
extracted = URI.extract(uri, ['http', 'https']).first
|
|
14
14
|
extracted && extracted.include?(uri)
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -69,6 +69,10 @@ module Vagrant
|
|
|
69
69
|
@ui.clear_line
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
|
+
rescue Errno::ECONNRESET
|
|
73
|
+
raise Errors::DownloaderHTTPConnectReset
|
|
74
|
+
rescue Errno::ETIMEDOUT
|
|
75
|
+
raise Errors::DownloaderHTTPConnectTimeout
|
|
72
76
|
rescue SocketError
|
|
73
77
|
raise Errors::DownloaderHTTPSocketError
|
|
74
78
|
end
|
|
@@ -78,19 +82,34 @@ module Vagrant
|
|
|
78
82
|
# This method respects the "http_proxy" and "no_proxy" environmental
|
|
79
83
|
# variables so that HTTP proxies can properly be used with Vagrant.
|
|
80
84
|
def resolve_proxy(source_uri)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
# Get the proper proxy key depending on the scheme of the box URL
|
|
86
|
+
proxy_key = "#{source_uri.scheme}_proxy".downcase
|
|
87
|
+
proxy_string = ENV[proxy_key] || ENV[proxy_key.upcase] || ""
|
|
88
|
+
|
|
89
|
+
if !proxy_string.empty?
|
|
90
|
+
# Make sure the proxy string starts with a protocol so that
|
|
91
|
+
# URI.parse works properly below.
|
|
92
|
+
proxy_string = "http://#{proxy_string}" if !proxy_string.include?("://")
|
|
93
|
+
|
|
94
|
+
if ENV.has_key?("no_proxy")
|
|
95
|
+
# Respect the "no_proxy" environmental variable which contains a list
|
|
96
|
+
# of hosts that a proxy should not be used for.
|
|
97
|
+
ENV["no_proxy"].split(",").each do |host|
|
|
98
|
+
if source_uri.host =~ /#{Regexp.quote(host.strip)}$/
|
|
99
|
+
proxy_string = ""
|
|
100
|
+
break
|
|
101
|
+
end
|
|
89
102
|
end
|
|
90
103
|
end
|
|
91
104
|
end
|
|
92
105
|
|
|
93
|
-
|
|
106
|
+
begin
|
|
107
|
+
URI.parse(proxy_string)
|
|
108
|
+
rescue URI::InvalidURIError
|
|
109
|
+
# If we have an invalid URI, we assume the proxy is invalid,
|
|
110
|
+
# so we don't use a proxy.
|
|
111
|
+
URI.parse("")
|
|
112
|
+
end
|
|
94
113
|
end
|
|
95
114
|
end
|
|
96
115
|
end
|
data/lib/vagrant/environment.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
require 'pathname'
|
|
2
1
|
require 'fileutils'
|
|
2
|
+
require 'json'
|
|
3
|
+
require 'pathname'
|
|
4
|
+
require 'set'
|
|
3
5
|
|
|
4
6
|
require 'log4r'
|
|
5
|
-
require 'rubygems' # This is needed for plugin loading below.
|
|
6
7
|
|
|
7
8
|
require 'vagrant/util/file_mode'
|
|
8
9
|
require 'vagrant/util/platform'
|
|
@@ -12,23 +13,36 @@ module Vagrant
|
|
|
12
13
|
# defined as basically a folder with a "Vagrantfile." This class allows
|
|
13
14
|
# access to the VMs, CLI, etc. all in the scope of this environment.
|
|
14
15
|
class Environment
|
|
15
|
-
HOME_SUBDIRS = ["tmp", "boxes", "gems"]
|
|
16
|
-
DEFAULT_VM = :default
|
|
17
16
|
DEFAULT_HOME = "~/.vagrant.d"
|
|
17
|
+
DEFAULT_LOCAL_DATA = ".vagrant"
|
|
18
18
|
|
|
19
19
|
# The `cwd` that this environment represents
|
|
20
20
|
attr_reader :cwd
|
|
21
21
|
|
|
22
|
+
# The persistent data directory where global data can be stored. It
|
|
23
|
+
# is up to the creator of the data in this directory to properly
|
|
24
|
+
# remove it when it is no longer needed.
|
|
25
|
+
#
|
|
26
|
+
# @return [Pathname]
|
|
27
|
+
attr_reader :data_dir
|
|
28
|
+
|
|
22
29
|
# The valid name for a Vagrantfile for this environment.
|
|
23
30
|
attr_reader :vagrantfile_name
|
|
24
31
|
|
|
25
32
|
# The {UI} object to communicate with the outside world.
|
|
26
33
|
attr_reader :ui
|
|
27
34
|
|
|
35
|
+
# This is the UI class to use when creating new UIs.
|
|
36
|
+
attr_reader :ui_class
|
|
37
|
+
|
|
28
38
|
# The directory to the "home" folder that Vagrant will use to store
|
|
29
39
|
# global state.
|
|
30
40
|
attr_reader :home_path
|
|
31
41
|
|
|
42
|
+
# The directory to the directory where local, environment-specific
|
|
43
|
+
# data is stored.
|
|
44
|
+
attr_reader :local_data_path
|
|
45
|
+
|
|
32
46
|
# The directory where temporary files for Vagrant go.
|
|
33
47
|
attr_reader :tmp_path
|
|
34
48
|
|
|
@@ -49,10 +63,11 @@ module Vagrant
|
|
|
49
63
|
def initialize(opts=nil)
|
|
50
64
|
opts = {
|
|
51
65
|
:cwd => nil,
|
|
52
|
-
:
|
|
66
|
+
:home_path => nil,
|
|
67
|
+
:local_data_path => nil,
|
|
53
68
|
:lock_path => nil,
|
|
54
69
|
:ui_class => nil,
|
|
55
|
-
:
|
|
70
|
+
:vagrantfile_name => nil
|
|
56
71
|
}.merge(opts || {})
|
|
57
72
|
|
|
58
73
|
# Set the default working directory to look for the vagrantfile
|
|
@@ -61,22 +76,25 @@ module Vagrant
|
|
|
61
76
|
opts[:cwd] = Pathname.new(opts[:cwd])
|
|
62
77
|
raise Errors::EnvironmentNonExistentCWD if !opts[:cwd].directory?
|
|
63
78
|
|
|
79
|
+
# Set the default ui class
|
|
80
|
+
opts[:ui_class] ||= UI::Silent
|
|
81
|
+
|
|
64
82
|
# Set the Vagrantfile name up. We append "Vagrantfile" and "vagrantfile" so that
|
|
65
83
|
# those continue to work as well, but anything custom will take precedence.
|
|
66
|
-
opts[:vagrantfile_name] ||= []
|
|
67
|
-
|
|
68
|
-
opts[:vagrantfile_name]
|
|
84
|
+
opts[:vagrantfile_name] ||= ENV["VAGRANT_VAGRANTFILE"] if \
|
|
85
|
+
ENV.has_key?("VAGRANT_VAGRANTFILE")
|
|
86
|
+
opts[:vagrantfile_name] ||= ["Vagrantfile", "vagrantfile"]
|
|
87
|
+
opts[:vagrantfile_name] = [opts[:vagrantfile_name]] if \
|
|
88
|
+
!opts[:vagrantfile_name].is_a?(Array)
|
|
69
89
|
|
|
70
90
|
# Set instance variables for all the configuration parameters.
|
|
71
|
-
@cwd
|
|
91
|
+
@cwd = opts[:cwd]
|
|
92
|
+
@home_path = opts[:home_path]
|
|
93
|
+
@lock_path = opts[:lock_path]
|
|
72
94
|
@vagrantfile_name = opts[:vagrantfile_name]
|
|
73
|
-
@
|
|
74
|
-
@
|
|
75
|
-
|
|
76
|
-
ui_class = opts[:ui_class] || UI::Silent
|
|
77
|
-
@ui = ui_class.new("vagrant")
|
|
95
|
+
@ui = opts[:ui_class].new
|
|
96
|
+
@ui_class = opts[:ui_class]
|
|
78
97
|
|
|
79
|
-
@loaded = false
|
|
80
98
|
@lock_acquired = false
|
|
81
99
|
|
|
82
100
|
@logger = Log4r::Logger.new("vagrant::environment")
|
|
@@ -85,9 +103,22 @@ module Vagrant
|
|
|
85
103
|
|
|
86
104
|
# Setup the home directory
|
|
87
105
|
setup_home_path
|
|
88
|
-
@tmp_path = @home_path.join("tmp")
|
|
89
106
|
@boxes_path = @home_path.join("boxes")
|
|
107
|
+
@data_dir = @home_path.join("data")
|
|
90
108
|
@gems_path = @home_path.join("gems")
|
|
109
|
+
@tmp_path = @home_path.join("tmp")
|
|
110
|
+
|
|
111
|
+
# Setup the local data directory. If a configuration path is given,
|
|
112
|
+
# then it is expanded relative to the working directory. Otherwise,
|
|
113
|
+
# we use the default which is expanded relative to the root path.
|
|
114
|
+
@local_data_path = nil
|
|
115
|
+
if opts[:local_data_path]
|
|
116
|
+
@local_data_path = Pathname.new(File.expand_path(opts[:local_data_path], @cwd))
|
|
117
|
+
elsif !root_path.nil?
|
|
118
|
+
@local_data_path = root_path.join(DEFAULT_LOCAL_DATA)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
setup_local_data_path
|
|
91
122
|
|
|
92
123
|
# Setup the default private key
|
|
93
124
|
@default_private_key_path = @home_path.join("insecure_private_key")
|
|
@@ -95,67 +126,275 @@ module Vagrant
|
|
|
95
126
|
|
|
96
127
|
# Load the plugins
|
|
97
128
|
load_plugins
|
|
129
|
+
|
|
130
|
+
# Call the environment load hooks
|
|
131
|
+
hook(:environment_load)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Return a human-friendly string for pretty printed or inspected
|
|
135
|
+
# instances.
|
|
136
|
+
#
|
|
137
|
+
# @return [String]
|
|
138
|
+
def inspect
|
|
139
|
+
"#<#{self.class}: #{@cwd}>"
|
|
98
140
|
end
|
|
99
141
|
|
|
100
142
|
#---------------------------------------------------------------
|
|
101
143
|
# Helpers
|
|
102
144
|
#---------------------------------------------------------------
|
|
103
145
|
|
|
104
|
-
#
|
|
105
|
-
#
|
|
146
|
+
# Returns a list of machines that this environment is currently
|
|
147
|
+
# managing that physically have been created.
|
|
106
148
|
#
|
|
107
|
-
#
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
149
|
+
# An "active" machine is a machine that Vagrant manages that has
|
|
150
|
+
# been created. The machine itself may be in any state such as running,
|
|
151
|
+
# suspended, etc. but if a machine is "active" then it exists.
|
|
152
|
+
#
|
|
153
|
+
# Note that the machines in this array may no longer be present in
|
|
154
|
+
# the Vagrantfile of this environment. In this case the machine can
|
|
155
|
+
# be considered an "orphan." Determining which machines are orphan
|
|
156
|
+
# and which aren't is not currently a supported feature, but will
|
|
157
|
+
# be in a future version.
|
|
158
|
+
#
|
|
159
|
+
# @return [Array<String, Symbol>]
|
|
160
|
+
def active_machines
|
|
161
|
+
machine_folder = @local_data_path.join("machines")
|
|
162
|
+
|
|
163
|
+
# If the machine folder is not a directory then we just return
|
|
164
|
+
# an empty array since no active machines exist.
|
|
165
|
+
return [] if !machine_folder.directory?
|
|
166
|
+
|
|
167
|
+
# Traverse the machines folder accumulate a result
|
|
168
|
+
result = []
|
|
169
|
+
|
|
170
|
+
machine_folder.children(true).each do |name_folder|
|
|
171
|
+
# If this isn't a directory then it isn't a machine
|
|
172
|
+
next if !name_folder.directory?
|
|
173
|
+
|
|
174
|
+
name = name_folder.basename.to_s.to_sym
|
|
175
|
+
name_folder.children(true).each do |provider_folder|
|
|
176
|
+
# If this isn't a directory then it isn't a provider
|
|
177
|
+
next if !provider_folder.directory?
|
|
178
|
+
|
|
179
|
+
# If this machine doesn't have an ID, then ignore
|
|
180
|
+
next if !provider_folder.join("id").file?
|
|
181
|
+
|
|
182
|
+
provider = provider_folder.basename.to_s.to_sym
|
|
183
|
+
result << [name, provider]
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Return the results
|
|
188
|
+
result
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# This returns the provider name for the default provider for this
|
|
192
|
+
# environment. The provider returned is currently hardcoded to "virtualbox"
|
|
193
|
+
# but one day should be a detected valid, best-case provider for this
|
|
194
|
+
# environment.
|
|
195
|
+
#
|
|
196
|
+
# @return [Symbol] Name of the default provider.
|
|
197
|
+
def default_provider
|
|
198
|
+
:virtualbox
|
|
111
199
|
end
|
|
112
200
|
|
|
113
201
|
# Returns the collection of boxes for the environment.
|
|
114
202
|
#
|
|
115
203
|
# @return [BoxCollection]
|
|
116
204
|
def boxes
|
|
117
|
-
@_boxes ||= BoxCollection.new(boxes_path
|
|
205
|
+
@_boxes ||= BoxCollection.new(boxes_path)
|
|
118
206
|
end
|
|
119
207
|
|
|
120
|
-
#
|
|
208
|
+
# This is the global config, comprised of loading configuration from
|
|
209
|
+
# the default, home, and root Vagrantfiles. This configuration is only
|
|
210
|
+
# really useful for reading the list of virtual machines, since each
|
|
211
|
+
# individual VM can override _most_ settings.
|
|
121
212
|
#
|
|
122
|
-
#
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
213
|
+
# This is lazy-loaded upon first use.
|
|
214
|
+
#
|
|
215
|
+
# @return [Object]
|
|
216
|
+
def config_global
|
|
217
|
+
return @config_global if @config_global
|
|
218
|
+
|
|
219
|
+
@logger.info("Initializing config...")
|
|
220
|
+
|
|
221
|
+
home_vagrantfile = nil
|
|
222
|
+
root_vagrantfile = nil
|
|
223
|
+
home_vagrantfile = find_vagrantfile(home_path) if home_path
|
|
224
|
+
root_vagrantfile = find_vagrantfile(root_path) if root_path
|
|
225
|
+
|
|
226
|
+
# Create the configuration loader and set the sources that are global.
|
|
227
|
+
# We use this to load the configuration, and the list of machines we are
|
|
228
|
+
# managing. Then, the actual individual configuration is loaded for
|
|
229
|
+
# each {#machine} call.
|
|
230
|
+
@config_loader = Config::Loader.new(Config::VERSIONS, Config::VERSIONS_ORDER)
|
|
231
|
+
@config_loader.set(:default, File.expand_path("config/default.rb", Vagrant.source_root))
|
|
232
|
+
@config_loader.set(:home, home_vagrantfile) if home_vagrantfile
|
|
233
|
+
@config_loader.set(:root, root_vagrantfile) if root_vagrantfile
|
|
234
|
+
|
|
235
|
+
# Make the initial call to get the "global" config. This is mostly
|
|
236
|
+
# only useful to get the list of machines that we are managing.
|
|
237
|
+
# Because of this, we ignore any warnings or errors.
|
|
238
|
+
@config_global, _ = @config_loader.load([:default, :home, :root])
|
|
239
|
+
|
|
240
|
+
# Return the config
|
|
241
|
+
@config_global
|
|
126
242
|
end
|
|
127
243
|
|
|
128
|
-
#
|
|
129
|
-
#
|
|
244
|
+
# This defines a hook point where plugin action hooks that are registered
|
|
245
|
+
# against the given name will be run in the context of this environment.
|
|
130
246
|
#
|
|
131
|
-
# @
|
|
132
|
-
def
|
|
133
|
-
|
|
134
|
-
|
|
247
|
+
# @param [Symbol] name Name of the hook.
|
|
248
|
+
def hook(name)
|
|
249
|
+
@logger.info("Running hook: #{name}")
|
|
250
|
+
callable = Action::Builder.new
|
|
251
|
+
action_runner.run(
|
|
252
|
+
callable,
|
|
253
|
+
:action_name => name,
|
|
254
|
+
:env => self)
|
|
135
255
|
end
|
|
136
256
|
|
|
137
|
-
#
|
|
138
|
-
#
|
|
139
|
-
# potentially be nil if no primary VM is specified.
|
|
257
|
+
# This returns a machine with the proper provider for this environment.
|
|
258
|
+
# The machine named by `name` must be in this environment.
|
|
140
259
|
#
|
|
141
|
-
# @
|
|
142
|
-
|
|
143
|
-
|
|
260
|
+
# @param [Symbol] name Name of the machine (as configured in the
|
|
261
|
+
# Vagrantfile).
|
|
262
|
+
# @param [Symbol] provider The provider that this machine should be
|
|
263
|
+
# backed by.
|
|
264
|
+
# @param [Boolean] refresh If true, then if there is a cached version
|
|
265
|
+
# it is reloaded.
|
|
266
|
+
# @return [Machine]
|
|
267
|
+
def machine(name, provider, refresh=false)
|
|
268
|
+
@logger.info("Getting machine: #{name} (#{provider})")
|
|
269
|
+
|
|
270
|
+
# Compose the cache key of the name and provider, and return from
|
|
271
|
+
# the cache if we have that.
|
|
272
|
+
cache_key = [name, provider]
|
|
273
|
+
@machines ||= {}
|
|
274
|
+
if refresh
|
|
275
|
+
@logger.info("Refreshing machine (busting cache): #{name} (#{provider})")
|
|
276
|
+
@machines.delete(cache_key)
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
if @machines.has_key?(cache_key)
|
|
280
|
+
@logger.info("Returning cached machine: #{name} (#{provider})")
|
|
281
|
+
return @machines[cache_key]
|
|
282
|
+
end
|
|
144
283
|
|
|
145
|
-
|
|
146
|
-
|
|
284
|
+
@logger.info("Uncached load of machine.")
|
|
285
|
+
sub_vm = config_global.vm.defined_vms[name]
|
|
286
|
+
if !sub_vm
|
|
287
|
+
raise Errors::MachineNotFound, :name => name, :provider => provider
|
|
147
288
|
end
|
|
148
289
|
|
|
290
|
+
provider_cls = Vagrant.plugin("2").manager.providers[provider]
|
|
291
|
+
if !provider_cls
|
|
292
|
+
raise Errors::ProviderNotFound, :machine => name, :provider => provider
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
# Build the machine configuration. This requires two passes: The first pass
|
|
296
|
+
# loads in the machine sub-configuration. Since this can potentially
|
|
297
|
+
# define a new box to base the machine from, we then make a second pass
|
|
298
|
+
# with the box Vagrantfile (if it has one).
|
|
299
|
+
vm_config_key = "vm_#{name}".to_sym
|
|
300
|
+
@config_loader.set(vm_config_key, sub_vm.config_procs)
|
|
301
|
+
config, config_warnings, config_errors = \
|
|
302
|
+
@config_loader.load([:default, :home, :root, vm_config_key])
|
|
303
|
+
|
|
304
|
+
box = nil
|
|
305
|
+
begin
|
|
306
|
+
box = boxes.find(config.vm.box, provider)
|
|
307
|
+
rescue Errors::BoxUpgradeRequired
|
|
308
|
+
# Upgrade the box if we must
|
|
309
|
+
@logger.info("Upgrading box during config load: #{config.vm.box}")
|
|
310
|
+
boxes.upgrade(config.vm.box)
|
|
311
|
+
retry
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
# If a box was found, then we attempt to load the Vagrantfile for
|
|
315
|
+
# that box. We don't require a box since we allow providers to download
|
|
316
|
+
# boxes and so on.
|
|
317
|
+
if box
|
|
318
|
+
box_vagrantfile = find_vagrantfile(box.directory)
|
|
319
|
+
if box_vagrantfile
|
|
320
|
+
# The box has a custom Vagrantfile, so we load that into the config
|
|
321
|
+
# as well.
|
|
322
|
+
@logger.info("Box exists with Vagrantfile. Reloading machine config.")
|
|
323
|
+
box_config_key = "box_#{box.name}_#{box.provider}".to_sym
|
|
324
|
+
@config_loader.set(box_config_key, box_vagrantfile)
|
|
325
|
+
config, config_warnings, config_errors = \
|
|
326
|
+
@config_loader.load([:default, box_config_key, :home, :root, vm_config_key])
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
# Get the provider configuration from the final loaded configuration
|
|
331
|
+
provider_config = config.vm.get_provider_config(provider)
|
|
332
|
+
|
|
333
|
+
# Determine the machine data directory and pass it to the machine.
|
|
334
|
+
# XXX: Permissions error here.
|
|
335
|
+
machine_data_path = @local_data_path.join("machines/#{name}/#{provider}")
|
|
336
|
+
FileUtils.mkdir_p(machine_data_path)
|
|
337
|
+
|
|
338
|
+
# If there were warnings or errors we want to output them
|
|
339
|
+
if !config_warnings.empty? || !config_errors.empty?
|
|
340
|
+
# The color of the output depends on whether we have warnings
|
|
341
|
+
# or errors...
|
|
342
|
+
level = config_errors.empty? ? :warn : :error
|
|
343
|
+
output = Util::TemplateRenderer.render(
|
|
344
|
+
"config/messages",
|
|
345
|
+
:warnings => config_warnings,
|
|
346
|
+
:errors => config_errors).chomp
|
|
347
|
+
@ui.send(level, I18n.t("vagrant.general.config_upgrade_messages",
|
|
348
|
+
:output => output))
|
|
349
|
+
|
|
350
|
+
# If we had errors, then we bail
|
|
351
|
+
raise Errors::ConfigUpgradeErrors if !config_errors.empty?
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
# Create the machine and cache it for future calls. This will also
|
|
355
|
+
# return the machine from this method.
|
|
356
|
+
@machines[cache_key] = Machine.new(name, provider, provider_cls, provider_config,
|
|
357
|
+
config, machine_data_path, box, self)
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# This returns a list of the configured machines for this environment.
|
|
361
|
+
# Each of the names returned by this method is valid to be used with
|
|
362
|
+
# the {#machine} method.
|
|
363
|
+
#
|
|
364
|
+
# @return [Array<Symbol>] Configured machine names.
|
|
365
|
+
def machine_names
|
|
366
|
+
config_global.vm.defined_vm_keys.dup
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
# This returns the name of the machine that is the "primary." In the
|
|
370
|
+
# case of a single-machine environment, this is just the single machine
|
|
371
|
+
# name. In the case of a multi-machine environment, then this can
|
|
372
|
+
# potentially be nil if no primary machine is specified.
|
|
373
|
+
#
|
|
374
|
+
# @return [Symbol]
|
|
375
|
+
def primary_machine_name
|
|
376
|
+
# If it is a single machine environment, then return the name
|
|
377
|
+
return machine_names.first if machine_names.length == 1
|
|
378
|
+
|
|
379
|
+
# If it is a multi-machine environment, then return the primary
|
|
380
|
+
config_global.vm.defined_vms.each do |name, subvm|
|
|
381
|
+
return name if subvm.options[:primary]
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
# If no primary was specified, nil it is
|
|
149
385
|
nil
|
|
150
386
|
end
|
|
151
387
|
|
|
152
|
-
#
|
|
153
|
-
#
|
|
154
|
-
#
|
|
388
|
+
# Unload the environment, running completion hooks. The environment
|
|
389
|
+
# should not be used after this (but CAN be, technically). It is
|
|
390
|
+
# recommended to always immediately set the variable to `nil` after
|
|
391
|
+
# running this so you can't accidentally run any more methods. Example:
|
|
392
|
+
#
|
|
393
|
+
# env.unload
|
|
394
|
+
# env = nil
|
|
155
395
|
#
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
vms.length > 1 || vms.keys.first != DEFAULT_VM
|
|
396
|
+
def unload
|
|
397
|
+
hook(:environment_unload)
|
|
159
398
|
end
|
|
160
399
|
|
|
161
400
|
# Makes a call to the CLI with the given arguments as if they
|
|
@@ -169,7 +408,7 @@ module Vagrant
|
|
|
169
408
|
|
|
170
409
|
# Returns the host object associated with this environment.
|
|
171
410
|
#
|
|
172
|
-
# @return [
|
|
411
|
+
# @return [Class]
|
|
173
412
|
def host
|
|
174
413
|
return @host if defined?(@host)
|
|
175
414
|
|
|
@@ -177,12 +416,16 @@ module Vagrant
|
|
|
177
416
|
# matters here, so please don't touch. Specifically: The symbol
|
|
178
417
|
# check is done after the detect check because the symbol check
|
|
179
418
|
# will return nil, and we don't want to trigger a detect load.
|
|
180
|
-
host_klass =
|
|
181
|
-
|
|
182
|
-
|
|
419
|
+
host_klass = config_global.vagrant.host
|
|
420
|
+
if host_klass.nil? || host_klass == :detect
|
|
421
|
+
hosts = Vagrant.plugin("2").manager.hosts.to_hash
|
|
422
|
+
|
|
423
|
+
# Get the flattened list of available hosts
|
|
424
|
+
host_klass = Hosts.detect(hosts)
|
|
425
|
+
end
|
|
183
426
|
|
|
184
427
|
# If no host class is detected, we use the base class.
|
|
185
|
-
host_klass ||=
|
|
428
|
+
host_klass ||= Vagrant.plugin("2", :host)
|
|
186
429
|
|
|
187
430
|
@host ||= host_klass.new(@ui)
|
|
188
431
|
end
|
|
@@ -191,12 +434,14 @@ module Vagrant
|
|
|
191
434
|
#
|
|
192
435
|
# @return [Action::Runner]
|
|
193
436
|
def action_runner
|
|
194
|
-
@action_runner ||= Action::Runner.new
|
|
437
|
+
@action_runner ||= Action::Runner.new do
|
|
195
438
|
{
|
|
196
439
|
:action_runner => action_runner,
|
|
197
440
|
:box_collection => boxes,
|
|
198
|
-
:global_config =>
|
|
441
|
+
:global_config => config_global,
|
|
199
442
|
:host => host,
|
|
443
|
+
:gems_path => gems_path,
|
|
444
|
+
:home_path => home_path,
|
|
200
445
|
:root_path => root_path,
|
|
201
446
|
:tmp_path => tmp_path,
|
|
202
447
|
:ui => @ui
|
|
@@ -204,37 +449,6 @@ module Vagrant
|
|
|
204
449
|
end
|
|
205
450
|
end
|
|
206
451
|
|
|
207
|
-
# Action registry for registering new actions with this environment.
|
|
208
|
-
#
|
|
209
|
-
# @return [Registry]
|
|
210
|
-
def action_registry
|
|
211
|
-
# For now we return the global built-in actions registry. In the future
|
|
212
|
-
# we may want to create an isolated registry that inherits from this
|
|
213
|
-
# global one, but for now there isn't a use case that calls for it.
|
|
214
|
-
Vagrant.actions
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
# Loads on initial access and reads data from the global data store.
|
|
218
|
-
# The global data store is global to Vagrant everywhere (in every environment),
|
|
219
|
-
# so it can be used to store system-wide information. Note that "system-wide"
|
|
220
|
-
# typically means "for this user" since the location of the global data
|
|
221
|
-
# store is in the home directory.
|
|
222
|
-
#
|
|
223
|
-
# @return [DataStore]
|
|
224
|
-
def global_data
|
|
225
|
-
@global_data ||= DataStore.new(File.expand_path("global_data.json", home_path))
|
|
226
|
-
end
|
|
227
|
-
|
|
228
|
-
# Loads (on initial access) and reads data from the local data
|
|
229
|
-
# store. This file is always at the root path as the file "~/.vagrant"
|
|
230
|
-
# and contains a JSON dump of a hash. See {DataStore} for more
|
|
231
|
-
# information.
|
|
232
|
-
#
|
|
233
|
-
# @return [DataStore]
|
|
234
|
-
def local_data
|
|
235
|
-
@local_data ||= DataStore.new(dotfile_path)
|
|
236
|
-
end
|
|
237
|
-
|
|
238
452
|
# The root path is the path where the top-most (loaded last)
|
|
239
453
|
# Vagrantfile resides. It can be considered the project root for
|
|
240
454
|
# this environment.
|
|
@@ -291,152 +505,10 @@ module Vagrant
|
|
|
291
505
|
end
|
|
292
506
|
end
|
|
293
507
|
|
|
294
|
-
#---------------------------------------------------------------
|
|
295
|
-
# Config Methods
|
|
296
|
-
#---------------------------------------------------------------
|
|
297
|
-
|
|
298
|
-
# The configuration object represented by this environment. This
|
|
299
|
-
# will trigger the environment to load if it hasn't loaded yet (see
|
|
300
|
-
# {#load!}).
|
|
301
|
-
#
|
|
302
|
-
# @return [Config::Container]
|
|
303
|
-
def config
|
|
304
|
-
load! if !loaded?
|
|
305
|
-
@config
|
|
306
|
-
end
|
|
307
|
-
|
|
308
508
|
#---------------------------------------------------------------
|
|
309
509
|
# Load Methods
|
|
310
510
|
#---------------------------------------------------------------
|
|
311
511
|
|
|
312
|
-
# Returns a boolean representing if the environment has been
|
|
313
|
-
# loaded or not.
|
|
314
|
-
#
|
|
315
|
-
# @return [Bool]
|
|
316
|
-
def loaded?
|
|
317
|
-
!!@loaded
|
|
318
|
-
end
|
|
319
|
-
|
|
320
|
-
# Loads this entire environment, setting up the instance variables
|
|
321
|
-
# such as `vm`, `config`, etc. on this environment. The order this
|
|
322
|
-
# method calls its other methods is very particular.
|
|
323
|
-
def load!
|
|
324
|
-
if !loaded?
|
|
325
|
-
@loaded = true
|
|
326
|
-
@logger.info("Loading configuration...")
|
|
327
|
-
load_config!
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
self
|
|
331
|
-
end
|
|
332
|
-
|
|
333
|
-
# Reloads the configuration of this environment.
|
|
334
|
-
def reload!
|
|
335
|
-
# Reload the configuration
|
|
336
|
-
load_config!
|
|
337
|
-
|
|
338
|
-
# Clear the VMs because this can now be diferent due to configuration
|
|
339
|
-
@vms = nil
|
|
340
|
-
end
|
|
341
|
-
|
|
342
|
-
# Loads this environment's configuration and stores it in the {#config}
|
|
343
|
-
# variable. The configuration loaded by this method is specified to
|
|
344
|
-
# this environment, meaning that it will use the given root directory
|
|
345
|
-
# to load the Vagrantfile into that context.
|
|
346
|
-
def load_config!
|
|
347
|
-
# Initialize the config loader
|
|
348
|
-
config_loader = Config::Loader.new
|
|
349
|
-
config_loader.load_order = [:default, :box, :home, :root, :vm]
|
|
350
|
-
|
|
351
|
-
inner_load = lambda do |*args|
|
|
352
|
-
# This is for Ruby 1.8.7 compatibility. Ruby 1.8.7 doesn't allow
|
|
353
|
-
# default arguments for lambdas, so we get around by doing a *args
|
|
354
|
-
# and setting the args here.
|
|
355
|
-
subvm = args[0]
|
|
356
|
-
box = args[1]
|
|
357
|
-
|
|
358
|
-
# Default Vagrantfile first. This is the Vagrantfile that ships
|
|
359
|
-
# with Vagrant.
|
|
360
|
-
config_loader.set(:default, File.expand_path("config/default.rb", Vagrant.source_root))
|
|
361
|
-
|
|
362
|
-
if box
|
|
363
|
-
# We load the box Vagrantfile
|
|
364
|
-
box_vagrantfile = find_vagrantfile(box.directory)
|
|
365
|
-
config_loader.set(:box, box_vagrantfile) if box_vagrantfile
|
|
366
|
-
end
|
|
367
|
-
|
|
368
|
-
if home_path
|
|
369
|
-
# Load the home Vagrantfile
|
|
370
|
-
home_vagrantfile = find_vagrantfile(home_path)
|
|
371
|
-
config_loader.set(:home, home_vagrantfile) if home_vagrantfile
|
|
372
|
-
end
|
|
373
|
-
|
|
374
|
-
if root_path
|
|
375
|
-
# Load the Vagrantfile in this directory
|
|
376
|
-
root_vagrantfile = find_vagrantfile(root_path)
|
|
377
|
-
config_loader.set(:root, root_vagrantfile) if root_vagrantfile
|
|
378
|
-
end
|
|
379
|
-
|
|
380
|
-
if subvm
|
|
381
|
-
# We have subvm configuration, so set that up as well.
|
|
382
|
-
config_loader.set(:vm, subvm.proc_stack)
|
|
383
|
-
end
|
|
384
|
-
|
|
385
|
-
# Execute the configuration stack and store the result as the final
|
|
386
|
-
# value in the config ivar.
|
|
387
|
-
config_loader.load
|
|
388
|
-
end
|
|
389
|
-
|
|
390
|
-
# For the global configuration, we only need to load the configuration
|
|
391
|
-
# in a single pass, since nothing is conditional on the configuration.
|
|
392
|
-
global = inner_load.call
|
|
393
|
-
|
|
394
|
-
# For each virtual machine represented by this environment, we have
|
|
395
|
-
# to load the configuration in two-passes. We do this because the
|
|
396
|
-
# first pass is used to determine the box for the VM. The second pass
|
|
397
|
-
# is used to also load the box Vagrantfile.
|
|
398
|
-
defined_vm_keys = global.vm.defined_vm_keys.dup
|
|
399
|
-
defined_vms = global.vm.defined_vms.dup
|
|
400
|
-
|
|
401
|
-
# If this isn't a multi-VM environment, then setup the default VM
|
|
402
|
-
# to simply be our configuration.
|
|
403
|
-
if defined_vm_keys.empty?
|
|
404
|
-
defined_vm_keys << DEFAULT_VM
|
|
405
|
-
defined_vms[DEFAULT_VM] = Config::VMConfig::SubVM.new
|
|
406
|
-
end
|
|
407
|
-
|
|
408
|
-
vm_configs = defined_vm_keys.map do |vm_name|
|
|
409
|
-
@logger.debug("Loading configuration for VM: #{vm_name}")
|
|
410
|
-
|
|
411
|
-
subvm = defined_vms[vm_name]
|
|
412
|
-
|
|
413
|
-
# First pass, first run.
|
|
414
|
-
config = inner_load[subvm]
|
|
415
|
-
|
|
416
|
-
# Second pass, with the box
|
|
417
|
-
config = inner_load[subvm, boxes.find(config.vm.box)]
|
|
418
|
-
config.vm.name = vm_name
|
|
419
|
-
|
|
420
|
-
# Return the final configuration for this VM
|
|
421
|
-
config
|
|
422
|
-
end
|
|
423
|
-
|
|
424
|
-
# Finally, we have our configuration. Set it and forget it.
|
|
425
|
-
@config = Config::Container.new(global, vm_configs)
|
|
426
|
-
end
|
|
427
|
-
|
|
428
|
-
# Loads the persisted VM (if it exists) for this environment.
|
|
429
|
-
def load_vms!
|
|
430
|
-
result = {}
|
|
431
|
-
|
|
432
|
-
# Load all the virtual machine instances.
|
|
433
|
-
config.vms.each do |name|
|
|
434
|
-
result[name] = Vagrant::VM.new(name, self, config.for_vm(name))
|
|
435
|
-
end
|
|
436
|
-
|
|
437
|
-
result
|
|
438
|
-
end
|
|
439
|
-
|
|
440
512
|
# This sets the `@home_path` variable properly.
|
|
441
513
|
#
|
|
442
514
|
# @return [Pathname]
|
|
@@ -446,14 +518,11 @@ module Vagrant
|
|
|
446
518
|
DEFAULT_HOME))
|
|
447
519
|
@logger.info("Home path: #{@home_path}")
|
|
448
520
|
|
|
449
|
-
#
|
|
450
|
-
#
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
# Setup the array of necessary home directories
|
|
455
|
-
dirs = [@home_path]
|
|
456
|
-
dirs += HOME_SUBDIRS.collect { |subdir| @home_path.join(subdir) }
|
|
521
|
+
# Setup the list of child directories that need to be created if they
|
|
522
|
+
# don't already exist.
|
|
523
|
+
dirs = [@home_path]
|
|
524
|
+
subdirs = ["boxes", "data", "gems", "rgloader", "tmp"]
|
|
525
|
+
dirs += subdirs.collect { |subdir| @home_path.join(subdir) }
|
|
457
526
|
|
|
458
527
|
# Go through each required directory, creating it if it doesn't exist
|
|
459
528
|
dirs.each do |dir|
|
|
@@ -466,6 +535,49 @@ module Vagrant
|
|
|
466
535
|
raise Errors::HomeDirectoryNotAccessible, :home_path => @home_path.to_s
|
|
467
536
|
end
|
|
468
537
|
end
|
|
538
|
+
|
|
539
|
+
# Create the version file to mark the version of the home directory
|
|
540
|
+
# we're using.
|
|
541
|
+
version_file = @home_path.join("setup_version")
|
|
542
|
+
if !version_file.file?
|
|
543
|
+
@logger.debug("Setting up the version file.")
|
|
544
|
+
version_file.open("w") do |f|
|
|
545
|
+
f.write("1.1")
|
|
546
|
+
end
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
# Create the rgloader/loader file so we can use encoded files.
|
|
550
|
+
loader_file = @home_path.join("rgloader", "loader.rb")
|
|
551
|
+
if !loader_file.file?
|
|
552
|
+
source_loader = Vagrant.source_root.join("templates/rgloader.rb")
|
|
553
|
+
FileUtils.cp(source_loader.to_s, loader_file.to_s)
|
|
554
|
+
end
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
# This creates the local data directory and show an error if it
|
|
558
|
+
# couldn't properly be created.
|
|
559
|
+
def setup_local_data_path
|
|
560
|
+
if @local_data_path.nil?
|
|
561
|
+
@logger.warn("No local data path is set. Local data cannot be stored.")
|
|
562
|
+
return
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
@logger.info("Local data path: #{@local_data_path}")
|
|
566
|
+
|
|
567
|
+
# If the local data path is a file, then we are probably seeing an
|
|
568
|
+
# old (V1) "dotfile." In this case, we upgrade it. The upgrade process
|
|
569
|
+
# will remove the old data file if it is successful.
|
|
570
|
+
if @local_data_path.file?
|
|
571
|
+
upgrade_v1_dotfile(@local_data_path)
|
|
572
|
+
end
|
|
573
|
+
|
|
574
|
+
begin
|
|
575
|
+
@logger.debug("Creating: #{@local_data_path}")
|
|
576
|
+
FileUtils.mkdir_p(@local_data_path)
|
|
577
|
+
rescue Errno::EACCES
|
|
578
|
+
raise Errors::LocalDataDirectoryNotAccessible,
|
|
579
|
+
:local_data_path => @local_data_path.to_s
|
|
580
|
+
end
|
|
469
581
|
end
|
|
470
582
|
|
|
471
583
|
protected
|
|
@@ -480,8 +592,17 @@ module Vagrant
|
|
|
480
592
|
def copy_insecure_private_key
|
|
481
593
|
if !@default_private_key_path.exist?
|
|
482
594
|
@logger.info("Copying private key to home directory")
|
|
483
|
-
|
|
484
|
-
|
|
595
|
+
|
|
596
|
+
source = File.expand_path("keys/vagrant", Vagrant.source_root)
|
|
597
|
+
destination = @default_private_key_path
|
|
598
|
+
|
|
599
|
+
begin
|
|
600
|
+
FileUtils.cp(source, destination)
|
|
601
|
+
rescue Errno::EACCES
|
|
602
|
+
raise Errors::CopyPrivateKeyFailed,
|
|
603
|
+
:source => source,
|
|
604
|
+
:destination => destination
|
|
605
|
+
end
|
|
485
606
|
end
|
|
486
607
|
|
|
487
608
|
if !Util::Platform.windows?
|
|
@@ -510,13 +631,99 @@ module Vagrant
|
|
|
510
631
|
# Loads the Vagrant plugins by properly setting up RubyGems so that
|
|
511
632
|
# our private gem repository is on the path.
|
|
512
633
|
def load_plugins
|
|
634
|
+
if ENV["VAGRANT_NO_PLUGINS"]
|
|
635
|
+
# If this key exists, then we don't load any plugins. It is a "safe
|
|
636
|
+
# mode" of sorts.
|
|
637
|
+
@logger.warn("VAGRANT_NO_PLUGINS is set. Not loading 3rd party plugins.")
|
|
638
|
+
return
|
|
639
|
+
end
|
|
640
|
+
|
|
513
641
|
# Add our private gem path to the gem path and reset the paths
|
|
514
642
|
# that Rubygems knows about.
|
|
515
643
|
ENV["GEM_PATH"] = "#{@gems_path}#{::File::PATH_SEPARATOR}#{ENV["GEM_PATH"]}"
|
|
516
644
|
::Gem.clear_paths
|
|
517
645
|
|
|
518
646
|
# Load the plugins
|
|
519
|
-
|
|
647
|
+
plugins_json_file = @home_path.join("plugins.json")
|
|
648
|
+
@logger.debug("Loading plugins from: #{plugins_json_file}")
|
|
649
|
+
if plugins_json_file.file?
|
|
650
|
+
data = JSON.parse(plugins_json_file.read)
|
|
651
|
+
data["installed"].each do |plugin|
|
|
652
|
+
@logger.info("Loading plugin from JSON: #{plugin}")
|
|
653
|
+
begin
|
|
654
|
+
Vagrant.require_plugin(plugin)
|
|
655
|
+
rescue Errors::PluginLoadError => e
|
|
656
|
+
@ui.error(e.message + "\n")
|
|
657
|
+
rescue Errors::PluginLoadFailed => e
|
|
658
|
+
@ui.error(e.message + "\n")
|
|
659
|
+
end
|
|
660
|
+
end
|
|
661
|
+
end
|
|
662
|
+
end
|
|
663
|
+
|
|
664
|
+
# This upgrades a Vagrant 1.0.x "dotfile" to the new V2 format.
|
|
665
|
+
#
|
|
666
|
+
# This is a destructive process. Once the upgrade is complete, the
|
|
667
|
+
# old dotfile is removed, and the environment becomes incompatible for
|
|
668
|
+
# Vagrant 1.0 environments.
|
|
669
|
+
#
|
|
670
|
+
# @param [Pathname] path The path to the dotfile
|
|
671
|
+
def upgrade_v1_dotfile(path)
|
|
672
|
+
@logger.info("Upgrading V1 dotfile to V2 directory structure...")
|
|
673
|
+
|
|
674
|
+
# First, verify the file isn't empty. If it is an empty file, we
|
|
675
|
+
# just delete it and go on with life.
|
|
676
|
+
contents = path.read.strip
|
|
677
|
+
if contents.strip == ""
|
|
678
|
+
@logger.info("V1 dotfile was empty. Removing and moving on.")
|
|
679
|
+
path.delete
|
|
680
|
+
return
|
|
681
|
+
end
|
|
682
|
+
|
|
683
|
+
# Otherwise, verify there is valid JSON in here since a Vagrant
|
|
684
|
+
# environment would always ensure valid JSON. This is a sanity check
|
|
685
|
+
# to make sure we don't nuke a dotfile that is not ours...
|
|
686
|
+
@logger.debug("Attempting to parse JSON of V1 file")
|
|
687
|
+
json_data = nil
|
|
688
|
+
begin
|
|
689
|
+
json_data = JSON.parse(contents)
|
|
690
|
+
@logger.debug("JSON parsed successfully. Things are okay.")
|
|
691
|
+
rescue JSON::ParserError
|
|
692
|
+
# The file could've been tampered with since Vagrant 1.0.x is
|
|
693
|
+
# supposed to ensure that the contents are valid JSON. Show an error.
|
|
694
|
+
raise Errors::DotfileUpgradeJSONError,
|
|
695
|
+
:state_file => path.to_s
|
|
696
|
+
end
|
|
697
|
+
|
|
698
|
+
# Alright, let's upgrade this guy to the new structure. Start by
|
|
699
|
+
# backing up the old dotfile.
|
|
700
|
+
backup_file = path.dirname.join(".vagrant.v1.#{Time.now.to_i}")
|
|
701
|
+
@logger.info("Renaming old dotfile to: #{backup_file}")
|
|
702
|
+
path.rename(backup_file)
|
|
703
|
+
|
|
704
|
+
# Now, we create the actual local data directory. This should succeed
|
|
705
|
+
# this time since we renamed the old conflicting V1.
|
|
706
|
+
setup_local_data_path
|
|
707
|
+
|
|
708
|
+
if json_data["active"]
|
|
709
|
+
@logger.debug("Upgrading to V2 style for each active VM")
|
|
710
|
+
json_data["active"].each do |name, id|
|
|
711
|
+
@logger.info("Upgrading dotfile: #{name} (#{id})")
|
|
712
|
+
|
|
713
|
+
# Create the machine configuration directory
|
|
714
|
+
directory = @local_data_path.join("machines/#{name}/virtualbox")
|
|
715
|
+
FileUtils.mkdir_p(directory)
|
|
716
|
+
|
|
717
|
+
# Write the ID file
|
|
718
|
+
directory.join("id").open("w+") do |f|
|
|
719
|
+
f.write(id)
|
|
720
|
+
end
|
|
721
|
+
end
|
|
722
|
+
end
|
|
723
|
+
|
|
724
|
+
# Upgrade complete! Let the user know
|
|
725
|
+
@ui.info(I18n.t("vagrant.general.upgraded_v1_dotfile",
|
|
726
|
+
:backup_path => backup_file.to_s))
|
|
520
727
|
end
|
|
521
728
|
end
|
|
522
729
|
end
|