boxcar 0.10005.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +48 -0
- data/.gitsetup.yml +6 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +696 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +40 -0
- data/LICENSE +21 -0
- data/README.md +91 -0
- data/Rakefile +18 -0
- data/VERSION +1 -0
- data/bin/_bump +126 -0
- data/bin/_jason +172 -0
- data/bin/_log4sh +3840 -0
- data/bin/_meat +172 -0
- data/bin/_prime +8 -0
- data/bin/_shflags +1012 -0
- data/bin/_shunit +1048 -0
- data/bin/_sub +37 -0
- data/bin/_treadstone +8 -0
- data/bin/_versions +174 -0
- data/bin/build +15 -0
- data/bin/bump +15 -0
- data/bin/edit +15 -0
- data/bin/publish +15 -0
- data/bin/stub +15 -0
- data/bin/vagrant +60 -0
- data/boxcar.gemspec +32 -0
- data/config/default.rb +30 -0
- data/contrib/README.md +12 -0
- data/contrib/emacs/vagrant.el +8 -0
- data/contrib/vim/vagrantfile.vim +9 -0
- data/keys/README.md +17 -0
- data/keys/vagrant +27 -0
- data/keys/vagrant.pub +1 -0
- data/lib/development.rb +25 -0
- data/lib/vagrant.rb +197 -0
- data/lib/vagrant/action.rb +63 -0
- data/lib/vagrant/action/box/destroy.rb +25 -0
- data/lib/vagrant/action/box/download.rb +84 -0
- data/lib/vagrant/action/box/package.rb +19 -0
- data/lib/vagrant/action/box/unpackage.rb +61 -0
- data/lib/vagrant/action/box/verify.rb +23 -0
- data/lib/vagrant/action/builder.rb +128 -0
- data/lib/vagrant/action/builtin.rb +171 -0
- data/lib/vagrant/action/env/set.rb +21 -0
- data/lib/vagrant/action/environment.rb +12 -0
- data/lib/vagrant/action/general/check_virtualbox.rb +28 -0
- data/lib/vagrant/action/general/package.rb +101 -0
- data/lib/vagrant/action/general/validate.rb +18 -0
- data/lib/vagrant/action/runner.rb +53 -0
- data/lib/vagrant/action/vm/boot.rb +53 -0
- data/lib/vagrant/action/vm/check_accessible.rb +23 -0
- data/lib/vagrant/action/vm/check_box.rb +33 -0
- data/lib/vagrant/action/vm/check_guest_additions.rb +38 -0
- data/lib/vagrant/action/vm/check_port_collisions.rb +89 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +43 -0
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +18 -0
- data/lib/vagrant/action/vm/clear_network_interfaces.rb +31 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +18 -0
- data/lib/vagrant/action/vm/customize.rb +36 -0
- data/lib/vagrant/action/vm/default_name.rb +22 -0
- data/lib/vagrant/action/vm/destroy.rb +19 -0
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +20 -0
- data/lib/vagrant/action/vm/discard_state.rb +22 -0
- data/lib/vagrant/action/vm/export.rb +57 -0
- data/lib/vagrant/action/vm/forward_ports.rb +92 -0
- data/lib/vagrant/action/vm/halt.rb +32 -0
- data/lib/vagrant/action/vm/host_name.rb +21 -0
- data/lib/vagrant/action/vm/import.rb +48 -0
- data/lib/vagrant/action/vm/match_mac_address.rb +21 -0
- data/lib/vagrant/action/vm/network.rb +403 -0
- data/lib/vagrant/action/vm/nfs.rb +196 -0
- data/lib/vagrant/action/vm/package.rb +23 -0
- data/lib/vagrant/action/vm/package_vagrantfile.rb +36 -0
- data/lib/vagrant/action/vm/provision.rb +61 -0
- data/lib/vagrant/action/vm/provisioner_cleanup.rb +26 -0
- data/lib/vagrant/action/vm/prune_nfs_exports.rb +20 -0
- data/lib/vagrant/action/vm/resume.rb +20 -0
- data/lib/vagrant/action/vm/sane_defaults.rb +78 -0
- data/lib/vagrant/action/vm/setup_package_files.rb +54 -0
- data/lib/vagrant/action/vm/share_folders.rb +114 -0
- data/lib/vagrant/action/vm/suspend.rb +20 -0
- data/lib/vagrant/action/warden.rb +92 -0
- data/lib/vagrant/box.rb +44 -0
- data/lib/vagrant/box_collection.rb +58 -0
- data/lib/vagrant/cli.rb +76 -0
- data/lib/vagrant/command.rb +24 -0
- data/lib/vagrant/command/base.rb +167 -0
- data/lib/vagrant/command/box.rb +58 -0
- data/lib/vagrant/command/box_add.rb +37 -0
- data/lib/vagrant/command/box_list.rb +28 -0
- data/lib/vagrant/command/box_remove.rb +27 -0
- data/lib/vagrant/command/box_repackage.rb +27 -0
- data/lib/vagrant/command/destroy.rb +64 -0
- data/lib/vagrant/command/gem.rb +39 -0
- data/lib/vagrant/command/halt.rb +39 -0
- data/lib/vagrant/command/init.rb +40 -0
- data/lib/vagrant/command/package.rb +75 -0
- data/lib/vagrant/command/provision.rb +40 -0
- data/lib/vagrant/command/reload.rb +39 -0
- data/lib/vagrant/command/resume.rb +33 -0
- data/lib/vagrant/command/ssh.rb +90 -0
- data/lib/vagrant/command/ssh_config.rb +51 -0
- data/lib/vagrant/command/start_mixins.rb +26 -0
- data/lib/vagrant/command/status.rb +36 -0
- data/lib/vagrant/command/suspend.rb +33 -0
- data/lib/vagrant/command/up.rb +40 -0
- data/lib/vagrant/communication.rb +7 -0
- data/lib/vagrant/communication/base.rb +56 -0
- data/lib/vagrant/communication/ssh.rb +229 -0
- data/lib/vagrant/config.rb +49 -0
- data/lib/vagrant/config/base.rb +82 -0
- data/lib/vagrant/config/container.rb +37 -0
- data/lib/vagrant/config/error_recorder.rb +19 -0
- data/lib/vagrant/config/loader.rb +127 -0
- data/lib/vagrant/config/nfs.rb +8 -0
- data/lib/vagrant/config/package.rb +7 -0
- data/lib/vagrant/config/ssh.rb +27 -0
- data/lib/vagrant/config/top.rb +72 -0
- data/lib/vagrant/config/vagrant.rb +14 -0
- data/lib/vagrant/config/vm.rb +168 -0
- data/lib/vagrant/config/vm/provisioner.rb +52 -0
- data/lib/vagrant/config/vm/sub_vm.rb +17 -0
- data/lib/vagrant/data_store.rb +92 -0
- data/lib/vagrant/downloaders.rb +7 -0
- data/lib/vagrant/downloaders/base.rb +25 -0
- data/lib/vagrant/downloaders/file.rb +22 -0
- data/lib/vagrant/downloaders/http.rb +97 -0
- data/lib/vagrant/driver.rb +8 -0
- data/lib/vagrant/driver/virtualbox.rb +134 -0
- data/lib/vagrant/driver/virtualbox_4_0.rb +459 -0
- data/lib/vagrant/driver/virtualbox_4_1.rb +459 -0
- data/lib/vagrant/driver/virtualbox_4_2.rb +606 -0
- data/lib/vagrant/driver/virtualbox_base.rb +309 -0
- data/lib/vagrant/environment.rb +517 -0
- data/lib/vagrant/errors.rb +441 -0
- data/lib/vagrant/guest.rb +18 -0
- data/lib/vagrant/guest/arch.rb +56 -0
- data/lib/vagrant/guest/base.rb +99 -0
- data/lib/vagrant/guest/debian.rb +64 -0
- data/lib/vagrant/guest/fedora.rb +66 -0
- data/lib/vagrant/guest/freebsd.rb +86 -0
- data/lib/vagrant/guest/gentoo.rb +46 -0
- data/lib/vagrant/guest/linux.rb +118 -0
- data/lib/vagrant/guest/linux/config.rb +19 -0
- data/lib/vagrant/guest/linux/error.rb +9 -0
- data/lib/vagrant/guest/openbsd.rb +20 -0
- data/lib/vagrant/guest/redhat.rb +67 -0
- data/lib/vagrant/guest/solaris.rb +118 -0
- data/lib/vagrant/guest/suse.rb +9 -0
- data/lib/vagrant/guest/ubuntu.rb +23 -0
- data/lib/vagrant/hosts.rb +37 -0
- data/lib/vagrant/hosts/arch.rb +55 -0
- data/lib/vagrant/hosts/base.rb +66 -0
- data/lib/vagrant/hosts/bsd.rb +97 -0
- data/lib/vagrant/hosts/fedora.rb +47 -0
- data/lib/vagrant/hosts/freebsd.rb +41 -0
- data/lib/vagrant/hosts/gentoo.rb +20 -0
- data/lib/vagrant/hosts/linux.rb +94 -0
- data/lib/vagrant/hosts/opensuse.rb +30 -0
- data/lib/vagrant/hosts/windows.rb +16 -0
- data/lib/vagrant/plugin.rb +81 -0
- data/lib/vagrant/provisioners.rb +12 -0
- data/lib/vagrant/provisioners/base.rb +44 -0
- data/lib/vagrant/provisioners/chef.rb +168 -0
- data/lib/vagrant/provisioners/chef_client.rb +132 -0
- data/lib/vagrant/provisioners/chef_solo.rb +234 -0
- data/lib/vagrant/provisioners/puppet.rb +175 -0
- data/lib/vagrant/provisioners/puppet_server.rb +78 -0
- data/lib/vagrant/provisioners/shell.rb +96 -0
- data/lib/vagrant/registry.rb +52 -0
- data/lib/vagrant/ssh.rb +126 -0
- data/lib/vagrant/test_helpers.rb +154 -0
- data/lib/vagrant/ui.rb +168 -0
- data/lib/vagrant/util.rb +12 -0
- data/lib/vagrant/util/ansi_escape_code_remover.rb +34 -0
- data/lib/vagrant/util/busy.rb +59 -0
- data/lib/vagrant/util/counter.rb +24 -0
- data/lib/vagrant/util/file_checksum.rb +38 -0
- data/lib/vagrant/util/file_mode.rb +12 -0
- data/lib/vagrant/util/hash_with_indifferent_access.rb +63 -0
- data/lib/vagrant/util/is_port_open.rb +38 -0
- data/lib/vagrant/util/line_ending_helpers.rb +14 -0
- data/lib/vagrant/util/network_ip.rb +28 -0
- data/lib/vagrant/util/platform.rb +68 -0
- data/lib/vagrant/util/retryable.rb +25 -0
- data/lib/vagrant/util/safe_exec.rb +36 -0
- data/lib/vagrant/util/safe_puts.rb +31 -0
- data/lib/vagrant/util/stacked_proc_runner.rb +35 -0
- data/lib/vagrant/util/subprocess.rb +247 -0
- data/lib/vagrant/util/template_renderer.rb +83 -0
- data/lib/vagrant/version.rb +7 -0
- data/lib/vagrant/vm.rb +195 -0
- data/libexec/build +30 -0
- data/libexec/build-gem +30 -0
- data/libexec/bump +32 -0
- data/libexec/edit-gem +81 -0
- data/libexec/publish +58 -0
- data/libexec/publish-gem +58 -0
- data/libexec/stub-prepare +37 -0
- data/tasks/acceptance.rake +113 -0
- data/tasks/bundler.rake +3 -0
- data/tasks/test.rake +20 -0
- data/templates/commands/init/Vagrantfile.erb +99 -0
- data/templates/commands/ssh_config/config.erb +15 -0
- data/templates/config/validation_failed.erb +7 -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/fedora/network_dhcp.erb +6 -0
- data/templates/guests/fedora/network_static.erb +13 -0
- data/templates/guests/freebsd/network_dhcp.erb +3 -0
- data/templates/guests/freebsd/network_static.erb +3 -0
- data/templates/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 +747 -0
- data/templates/nfs/exports.erb +5 -0
- data/templates/nfs/exports_freebsd.erb +5 -0
- data/templates/nfs/exports_linux.erb +5 -0
- data/templates/package_Vagrantfile.erb +11 -0
- data/templates/provisioners/chef_client/client.erb +32 -0
- data/templates/provisioners/chef_solo/solo.erb +25 -0
- data/test/acceptance/base.rb +48 -0
- data/test/acceptance/box_test.rb +99 -0
- data/test/acceptance/destroy_test.rb +37 -0
- data/test/acceptance/halt_test.rb +72 -0
- data/test/acceptance/init_test.rb +33 -0
- 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 +17 -0
- data/test/acceptance/shared_folders_test.rb +84 -0
- 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 +46 -0
- data/test/acceptance/support/config.rb +42 -0
- data/test/acceptance/support/isolated_environment.rb +117 -0
- data/test/acceptance/support/matchers/have_color.rb +9 -0
- data/test/acceptance/support/matchers/match_output.rb +14 -0
- data/test/acceptance/support/matchers/succeed.rb +14 -0
- data/test/acceptance/support/network_tests.rb +29 -0
- data/test/acceptance/support/output.rb +95 -0
- data/test/acceptance/support/shared/base_context.rb +72 -0
- data/test/acceptance/support/shared/command_examples.rb +33 -0
- data/test/acceptance/support/virtualbox.rb +36 -0
- data/test/acceptance/suspend_test.rb +56 -0
- data/test/acceptance/up_basic_test.rb +33 -0
- data/test/acceptance/up_with_box_url.rb +40 -0
- data/test/acceptance/vagrant_test.rb +47 -0
- data/test/acceptance/version_test.rb +15 -0
- data/test/buildbot/README.md +72 -0
- 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 +24 -0
- data/test/buildbot/buildbot_config/config/master.py +24 -0
- data/test/buildbot/buildbot_config/config/slave.py +22 -0
- data/test/buildbot/buildbot_config/master/__init__.py +6 -0
- data/test/buildbot/buildbot_config/master/builders.py +78 -0
- data/test/buildbot/buildbot_config/master/buildsteps.py +100 -0
- data/test/buildbot/buildbot_config/master/change_sources.py +8 -0
- data/test/buildbot/buildbot_config/master/schedulers.py +32 -0
- data/test/buildbot/buildbot_config/master/slaves.py +60 -0
- data/test/buildbot/buildbot_config/master/status.py +52 -0
- data/test/buildbot/master/Makefile.sample +28 -0
- data/test/buildbot/master/buildbot.tac +36 -0
- data/test/buildbot/master/master.cfg +67 -0
- data/test/buildbot/master/public_html/bg_gradient.jpg +0 -0
- data/test/buildbot/master/public_html/default.css +545 -0
- data/test/buildbot/master/public_html/favicon.ico +0 -0
- data/test/buildbot/master/public_html/robots.txt +10 -0
- data/test/buildbot/master/public_html/static/css/bootstrap-1.4.0.min.css +356 -0
- data/test/buildbot/master/public_html/static/css/prettify.css +97 -0
- data/test/buildbot/master/public_html/static/css/syntax.css +60 -0
- data/test/buildbot/master/public_html/static/css/vagrant.base.css +205 -0
- 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 +80 -0
- data/test/buildbot/master/public_html/static/js/jquery-1.7.min.js +4 -0
- data/test/buildbot/master/templates/authfail.html +9 -0
- data/test/buildbot/master/templates/build.html +205 -0
- data/test/buildbot/master/templates/builder.html +118 -0
- data/test/buildbot/master/templates/builders.html +33 -0
- data/test/buildbot/master/templates/buildslave.html +72 -0
- data/test/buildbot/master/templates/buildslaves.html +70 -0
- data/test/buildbot/master/templates/change.html +15 -0
- data/test/buildbot/master/templates/layouts/base.html +58 -0
- data/test/buildbot/master/templates/macros/box.html +37 -0
- data/test/buildbot/master/templates/macros/build_line.html +50 -0
- data/test/buildbot/master/templates/macros/change.html +81 -0
- data/test/buildbot/master/templates/macros/forms.html +300 -0
- data/test/buildbot/master/templates/root.html +42 -0
- data/test/buildbot/master/templates/waterfall.html +53 -0
- data/test/buildbot/requirements.txt +4 -0
- data/test/buildbot/scripts/deploy.sh +38 -0
- data/test/buildbot/scripts/setup.sh +107 -0
- data/test/buildbot/slave/buildbot.tac +43 -0
- data/test/buildbot/slave/info/admin +1 -0
- data/test/buildbot/slave/info/host +1 -0
- 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 +41 -0
- data/test/buildbot/vendor/choices-0.4.0.tar.gz +0 -0
- data/test/config/acceptance_boxes.yml +7 -0
- data/test/support/isolated_environment.rb +46 -0
- data/test/support/tempdir.rb +34 -0
- data/test/unit/base.rb +21 -0
- data/test/unit/support/isolated_environment.rb +47 -0
- data/test/unit/support/shared/base_context.rb +30 -0
- data/test/unit/vagrant/action/builder_test.rb +156 -0
- data/test/unit/vagrant/action/environment_test.rb +16 -0
- data/test/unit/vagrant/action/runner_test.rb +65 -0
- data/test/unit/vagrant/action/warden_test.rb +92 -0
- data/test/unit/vagrant/box_collection_test.rb +56 -0
- data/test/unit/vagrant/box_test.rb +34 -0
- data/test/unit/vagrant/command/base_test.rb +150 -0
- data/test/unit/vagrant/config/base_test.rb +48 -0
- data/test/unit/vagrant/config/loader_test.rb +79 -0
- data/test/unit/vagrant/config/ssh_test.rb +17 -0
- data/test/unit/vagrant/config/top_test.rb +69 -0
- data/test/unit/vagrant/config/vm_test.rb +71 -0
- data/test/unit/vagrant/config_test.rb +27 -0
- data/test/unit/vagrant/data_store_test.rb +79 -0
- data/test/unit/vagrant/downloaders/base_test.rb +18 -0
- data/test/unit/vagrant/downloaders/file_test.rb +75 -0
- data/test/unit/vagrant/downloaders/http_test.rb +19 -0
- data/test/unit/vagrant/environment_test.rb +212 -0
- data/test/unit/vagrant/hosts_test.rb +36 -0
- data/test/unit/vagrant/registry_test.rb +74 -0
- data/test/unit/vagrant/util/ansi_escape_code_remover_test.rb +16 -0
- data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
- data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +38 -0
- data/test/unit/vagrant/util/is_port_open_test.rb +53 -0
- data/test/unit/vagrant/util/line_endings_helper_test.rb +16 -0
- data/test/unit/vagrant/util/network_ip_test.rb +17 -0
- data/test/unit/vagrant/util/retryable_test.rb +106 -0
- data/test/unit/vagrant_test.rb +27 -0
- data/test/unit_legacy/locales/en.yml +8 -0
- data/test/unit_legacy/test_helper.rb +32 -0
- data/test/unit_legacy/vagrant/action/box/destroy_test.rb +18 -0
- data/test/unit_legacy/vagrant/action/box/download_test.rb +125 -0
- data/test/unit_legacy/vagrant/action/box/package_test.rb +25 -0
- data/test/unit_legacy/vagrant/action/box/unpackage_test.rb +84 -0
- data/test/unit_legacy/vagrant/action/box/verify_test.rb +30 -0
- data/test/unit_legacy/vagrant/action/env/set_test.rb +24 -0
- data/test/unit_legacy/vagrant/action/general/package_test.rb +268 -0
- data/test/unit_legacy/vagrant/action/general/validate_test.rb +31 -0
- data/test/unit_legacy/vagrant/action/vm/boot_test.rb +66 -0
- data/test/unit_legacy/vagrant/action/vm/check_accessible_test.rb +61 -0
- data/test/unit_legacy/vagrant/action/vm/check_box_test.rb +61 -0
- data/test/unit_legacy/vagrant/action/vm/check_guest_additions_test.rb +9 -0
- data/test/unit_legacy/vagrant/action/vm/clean_machine_folder_test.rb +84 -0
- data/test/unit_legacy/vagrant/action/vm/clear_forwarded_ports_test.rb +52 -0
- data/test/unit_legacy/vagrant/action/vm/clear_nfs_exports_test.rb +22 -0
- data/test/unit_legacy/vagrant/action/vm/clear_shared_folders_test.rb +40 -0
- data/test/unit_legacy/vagrant/action/vm/customize_test.rb +37 -0
- data/test/unit_legacy/vagrant/action/vm/destroy_test.rb +25 -0
- data/test/unit_legacy/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +49 -0
- data/test/unit_legacy/vagrant/action/vm/discard_state_test.rb +45 -0
- data/test/unit_legacy/vagrant/action/vm/export_test.rb +107 -0
- data/test/unit_legacy/vagrant/action/vm/forward_ports_helpers_test.rb +77 -0
- data/test/unit_legacy/vagrant/action/vm/forward_ports_test.rb +197 -0
- data/test/unit_legacy/vagrant/action/vm/halt_test.rb +79 -0
- data/test/unit_legacy/vagrant/action/vm/host_name_test.rb +36 -0
- data/test/unit_legacy/vagrant/action/vm/import_test.rb +66 -0
- data/test/unit_legacy/vagrant/action/vm/match_mac_address_test.rb +40 -0
- data/test/unit_legacy/vagrant/action/vm/modify_test.rb +38 -0
- data/test/unit_legacy/vagrant/action/vm/network_test.rb +286 -0
- data/test/unit_legacy/vagrant/action/vm/nfs_helpers_test.rb +26 -0
- data/test/unit_legacy/vagrant/action/vm/nfs_test.rb +260 -0
- data/test/unit_legacy/vagrant/action/vm/package_test.rb +25 -0
- data/test/unit_legacy/vagrant/action/vm/package_vagrantfile_test.rb +46 -0
- data/test/unit_legacy/vagrant/action/vm/provision_test.rb +65 -0
- data/test/unit_legacy/vagrant/action/vm/provisioner_cleanup_test.rb +56 -0
- data/test/unit_legacy/vagrant/action/vm/resume_test.rb +35 -0
- data/test/unit_legacy/vagrant/action/vm/share_folders_test.rb +144 -0
- data/test/unit_legacy/vagrant/action/vm/suspend_test.rb +35 -0
- data/test/unit_legacy/vagrant/action_test.rb +89 -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_legacy/vagrant/cli_test.rb +35 -0
- data/test/unit_legacy/vagrant/command/base_test.rb +23 -0
- data/test/unit_legacy/vagrant/command/group_base_test.rb +15 -0
- data/test/unit_legacy/vagrant/command/helpers_test.rb +88 -0
- data/test/unit_legacy/vagrant/command/init_test.rb +10 -0
- data/test/unit_legacy/vagrant/command/package_test.rb +27 -0
- data/test/unit_legacy/vagrant/config/base_test.rb +52 -0
- data/test/unit_legacy/vagrant/config/error_recorder_test.rb +18 -0
- data/test/unit_legacy/vagrant/config/ssh_test.rb +12 -0
- data/test/unit_legacy/vagrant/config/vagrant_test.rb +35 -0
- data/test/unit_legacy/vagrant/config/vm/provisioner_test.rb +92 -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_legacy/vagrant/errors_test.rb +42 -0
- data/test/unit_legacy/vagrant/hosts/base_test.rb +46 -0
- data/test/unit_legacy/vagrant/hosts/bsd_test.rb +53 -0
- data/test/unit_legacy/vagrant/hosts/linux_test.rb +54 -0
- data/test/unit_legacy/vagrant/plugin_test.rb +9 -0
- data/test/unit_legacy/vagrant/provisioners/base_test.rb +63 -0
- data/test/unit_legacy/vagrant/provisioners/chef_client_test.rb +190 -0
- data/test/unit_legacy/vagrant/provisioners/chef_solo_test.rb +115 -0
- data/test/unit_legacy/vagrant/provisioners/chef_test.rb +209 -0
- data/test/unit_legacy/vagrant/provisioners/puppet_server_test.rb +68 -0
- data/test/unit_legacy/vagrant/provisioners/puppet_test.rb +182 -0
- data/test/unit_legacy/vagrant/provisioners/shell_test.rb +79 -0
- data/test/unit_legacy/vagrant/ssh/session_test.rb +40 -0
- data/test/unit_legacy/vagrant/ssh_test.rb +304 -0
- data/test/unit_legacy/vagrant/systems/base_test.rb +18 -0
- data/test/unit_legacy/vagrant/systems/linux_test.rb +104 -0
- data/test/unit_legacy/vagrant/util/busy_test.rb +106 -0
- data/test/unit_legacy/vagrant/util/counter_test.rb +29 -0
- data/test/unit_legacy/vagrant/util/platform_test.rb +18 -0
- data/test/unit_legacy/vagrant/util/stacked_proc_runner_test.rb +43 -0
- data/test/unit_legacy/vagrant/util/template_renderer_test.rb +145 -0
- data/test/unit_legacy/vagrant/vm_test.rb +300 -0
- data/vagrant.gemspec +39 -0
- data/vendor/cache/contest-0.1.3.gem +0 -0
- data/vendor/cache/diff-lcs-1.1.3.gem +0 -0
- data/vendor/cache/erubis-2.7.0.gem +0 -0
- data/vendor/cache/i18n-0.6.1.gem +0 -0
- data/vendor/cache/json-1.5.4.gem +0 -0
- data/vendor/cache/log4r-1.1.10.gem +0 -0
- data/vendor/cache/metaclass-0.0.1.gem +0 -0
- data/vendor/cache/minitest-2.5.1.gem +0 -0
- data/vendor/cache/mocha-0.13.1.gem +0 -0
- data/vendor/cache/rake-10.0.2.gem +0 -0
- data/vendor/cache/rspec-core-2.8.0.gem +0 -0
- data/vendor/cache/rspec-expectations-2.8.0.gem +0 -0
- data/vendor/cache/rspec-mocks-2.8.0.gem +0 -0
- metadata +676 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Provisioners
|
3
|
+
class PuppetServerError < Vagrant::Errors::VagrantError
|
4
|
+
error_namespace("vagrant.provisioners.puppet_server")
|
5
|
+
end
|
6
|
+
|
7
|
+
class PuppetServer < Base
|
8
|
+
class Config < Vagrant::Config::Base
|
9
|
+
attr_accessor :puppet_server
|
10
|
+
attr_accessor :puppet_node
|
11
|
+
attr_accessor :options
|
12
|
+
attr_accessor :facter
|
13
|
+
|
14
|
+
def facter; @facter ||= {}; end
|
15
|
+
def puppet_server; @puppet_server || "puppet"; end
|
16
|
+
def options; @options ||= []; end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.config_class
|
20
|
+
Config
|
21
|
+
end
|
22
|
+
|
23
|
+
def provision!
|
24
|
+
verify_binary("puppetd")
|
25
|
+
run_puppetd_client
|
26
|
+
end
|
27
|
+
|
28
|
+
def verify_binary(binary)
|
29
|
+
env[:vm].channel.sudo("which #{binary}",
|
30
|
+
:error_class => PuppetServerError,
|
31
|
+
:error_key => :not_detected,
|
32
|
+
:binary => binary)
|
33
|
+
end
|
34
|
+
|
35
|
+
def run_puppetd_client
|
36
|
+
options = config.options
|
37
|
+
options = [options] if !options.is_a?(Array)
|
38
|
+
|
39
|
+
# Intelligently set the puppet node cert name based on certain
|
40
|
+
# external parameters.
|
41
|
+
cn = nil
|
42
|
+
if config.puppet_node
|
43
|
+
# If a node name is given, we use that directly for the certname
|
44
|
+
cn = config.puppet_node
|
45
|
+
elsif env[:vm].config.vm.host_name
|
46
|
+
# If a host name is given, we explicitly set the certname to
|
47
|
+
# nil so that the hostname becomes the cert name.
|
48
|
+
cn = nil
|
49
|
+
else
|
50
|
+
# Otherwise, we default to the name of the box.
|
51
|
+
cn = env[:vm].config.vm.box
|
52
|
+
end
|
53
|
+
|
54
|
+
# Add the certname option if there is one
|
55
|
+
options += ["--certname", cn] if cn
|
56
|
+
options = options.join(" ")
|
57
|
+
|
58
|
+
# Build up the custom facts if we have any
|
59
|
+
facter = ""
|
60
|
+
if !config.facter.empty?
|
61
|
+
facts = []
|
62
|
+
config.facter.each do |key, value|
|
63
|
+
facts << "FACTER_#{key}='#{value}'"
|
64
|
+
end
|
65
|
+
|
66
|
+
facter = "#{facts.join(" ")} "
|
67
|
+
end
|
68
|
+
|
69
|
+
command = "#{facter}puppetd #{options} --server #{config.puppet_server}"
|
70
|
+
|
71
|
+
env[:ui].info I18n.t("vagrant.provisioners.puppet_server.running_puppetd")
|
72
|
+
env[:vm].channel.sudo(command) do |type, data|
|
73
|
+
env[:ui].info(data.chomp, :prefix => false)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module Provisioners
|
5
|
+
class Shell < Base
|
6
|
+
class Config < Vagrant::Config::Base
|
7
|
+
attr_accessor :inline
|
8
|
+
attr_accessor :path
|
9
|
+
attr_accessor :upload_path
|
10
|
+
attr_accessor :args
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@upload_path = "/tmp/vagrant-shell"
|
14
|
+
end
|
15
|
+
|
16
|
+
def validate(env, errors)
|
17
|
+
# Validate that the parameters are properly set
|
18
|
+
if path && inline
|
19
|
+
errors.add(I18n.t("vagrant.provisioners.shell.path_and_inline_set"))
|
20
|
+
elsif !path && !inline
|
21
|
+
errors.add(I18n.t("vagrant.provisioners.shell.no_path_or_inline"))
|
22
|
+
end
|
23
|
+
|
24
|
+
# Validate the existence of a script to upload
|
25
|
+
if path
|
26
|
+
expanded_path = Pathname.new(path).expand_path(env.root_path)
|
27
|
+
if !expanded_path.file?
|
28
|
+
errors.add(I18n.t("vagrant.provisioners.shell.path_invalid",
|
29
|
+
:path => expanded_path))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# There needs to be a path to upload the script to
|
34
|
+
if !upload_path
|
35
|
+
errors.add(I18n.t("vagrant.provisioners.shell.upload_path_not_set"))
|
36
|
+
end
|
37
|
+
|
38
|
+
# If there are args and its not a string, that is a problem
|
39
|
+
if args && !args.is_a?(String)
|
40
|
+
errors.add(I18n.t("vagrant.provisioners.shell.args_not_string"))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.config_class
|
46
|
+
Config
|
47
|
+
end
|
48
|
+
|
49
|
+
# This method yields the path to a script to upload and execute
|
50
|
+
# on the remote server. This method will properly clean up the
|
51
|
+
# script file if needed.
|
52
|
+
def with_script_file
|
53
|
+
if config.path
|
54
|
+
# Just yield the path to that file...
|
55
|
+
yield Pathname.new(config.path).expand_path(env[:root_path])
|
56
|
+
return
|
57
|
+
end
|
58
|
+
|
59
|
+
# Otherwise we have an inline script, we need to Tempfile it,
|
60
|
+
# and handle it specially...
|
61
|
+
file = Tempfile.new('vagrant-shell')
|
62
|
+
begin
|
63
|
+
file.write(config.inline)
|
64
|
+
file.fsync
|
65
|
+
yield file.path
|
66
|
+
ensure
|
67
|
+
file.close
|
68
|
+
file.unlink
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def provision!
|
73
|
+
args = ""
|
74
|
+
args = " #{config.args}" if config.args
|
75
|
+
command = "chmod +x #{config.upload_path} && #{config.upload_path}#{args}"
|
76
|
+
|
77
|
+
with_script_file do |path|
|
78
|
+
# Upload the script to the VM
|
79
|
+
env[:vm].channel.upload(path.to_s, config.upload_path)
|
80
|
+
|
81
|
+
# Execute it with sudo
|
82
|
+
env[:vm].channel.sudo(command) do |type, data|
|
83
|
+
if [:stderr, :stdout].include?(type)
|
84
|
+
# Output the data with the proper color based on the stream.
|
85
|
+
color = type == :stdout ? :green : :red
|
86
|
+
|
87
|
+
# Note: Be sure to chomp the data to avoid the newlines that the
|
88
|
+
# Chef outputs.
|
89
|
+
env[:ui].info(data.chomp, :color => color, :prefix => false)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Vagrant
|
2
|
+
# Register components in a single location that can be queried.
|
3
|
+
#
|
4
|
+
# This allows certain components (such as guest systems, configuration
|
5
|
+
# pieces, etc.) to be registered and queried.
|
6
|
+
class Registry
|
7
|
+
def initialize
|
8
|
+
@actions = {}
|
9
|
+
@results_cache = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
# Register a callable by key.
|
13
|
+
#
|
14
|
+
# The callable should be given in a block which will be lazily evaluated
|
15
|
+
# when the action is needed.
|
16
|
+
#
|
17
|
+
# If an action by the given name already exists then it will be
|
18
|
+
# overwritten.
|
19
|
+
def register(key, value=nil, &block)
|
20
|
+
block = lambda { value } if value
|
21
|
+
@actions[key] = block
|
22
|
+
end
|
23
|
+
|
24
|
+
# Get an action by the given key.
|
25
|
+
#
|
26
|
+
# This will evaluate the block given to `register` and return the resulting
|
27
|
+
# action stack.
|
28
|
+
def get(key)
|
29
|
+
return nil if !@actions.has_key?(key)
|
30
|
+
return @results_cache[key] if @results_cache.has_key?(key)
|
31
|
+
@results_cache[key] = @actions[key].call
|
32
|
+
end
|
33
|
+
alias :[] :get
|
34
|
+
|
35
|
+
# Iterate over the keyspace.
|
36
|
+
def each(&block)
|
37
|
+
@actions.each do |key, _|
|
38
|
+
yield key, get(key)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Converts this registry to a hash
|
43
|
+
def to_hash
|
44
|
+
result = {}
|
45
|
+
self.each do |key, value|
|
46
|
+
result[key] = value
|
47
|
+
end
|
48
|
+
|
49
|
+
result
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/vagrant/ssh.rb
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
|
3
|
+
require 'vagrant/util/file_mode'
|
4
|
+
require 'vagrant/util/platform'
|
5
|
+
require 'vagrant/util/safe_exec'
|
6
|
+
|
7
|
+
module Vagrant
|
8
|
+
# Manages SSH connection information as well as allows opening an
|
9
|
+
# SSH connection.
|
10
|
+
class SSH
|
11
|
+
include Util::SafeExec
|
12
|
+
|
13
|
+
def initialize(vm)
|
14
|
+
@vm = vm
|
15
|
+
@logger = Log4r::Logger.new("vagrant::ssh")
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns a hash of information necessary for accessing this
|
19
|
+
# virtual machine via SSH.
|
20
|
+
#
|
21
|
+
# @return [Hash]
|
22
|
+
def info
|
23
|
+
results = {
|
24
|
+
:host => @vm.config.ssh.host,
|
25
|
+
:port => @vm.config.ssh.port || @vm.driver.ssh_port(@vm.config.ssh.guest_port),
|
26
|
+
:username => @vm.config.ssh.username,
|
27
|
+
:forward_agent => @vm.config.ssh.forward_agent,
|
28
|
+
:forward_x11 => @vm.config.ssh.forward_x11
|
29
|
+
}
|
30
|
+
|
31
|
+
# This can happen if no port is set and for some reason Vagrant
|
32
|
+
# can't detect an SSH port.
|
33
|
+
raise Errors::SSHPortNotDetected if !results[:port]
|
34
|
+
|
35
|
+
# Determine the private key path, which is either set by the
|
36
|
+
# configuration or uses just the built-in insecure key.
|
37
|
+
pk_path = @vm.config.ssh.private_key_path || @vm.env.default_private_key_path
|
38
|
+
results[:private_key_path] = File.expand_path(pk_path, @vm.env.root_path)
|
39
|
+
|
40
|
+
# We need to check and fix the private key permissions
|
41
|
+
# to make sure that SSH gets a key with 0600 perms.
|
42
|
+
check_key_permissions(results[:private_key_path])
|
43
|
+
|
44
|
+
# Return the results
|
45
|
+
return results
|
46
|
+
end
|
47
|
+
|
48
|
+
# Connects to the environment's virtual machine, replacing the ruby
|
49
|
+
# process with an SSH process.
|
50
|
+
#
|
51
|
+
# @param [Hash] opts Options hash
|
52
|
+
# @options opts [Boolean] :plain_mode If True, doesn't authenticate with
|
53
|
+
# the machine, only connects, allowing the user to connect.
|
54
|
+
def exec(opts={})
|
55
|
+
# Get the SSH information and cache it here
|
56
|
+
ssh_info = info
|
57
|
+
|
58
|
+
if Util::Platform.windows?
|
59
|
+
raise Errors::SSHUnavailableWindows, :host => ssh_info[:host],
|
60
|
+
:port => ssh_info[:port],
|
61
|
+
:username => ssh_info[:username],
|
62
|
+
:key_path => ssh_info[:private_key_path]
|
63
|
+
end
|
64
|
+
|
65
|
+
raise Errors::SSHUnavailable if !Kernel.system("which ssh > /dev/null 2>&1")
|
66
|
+
|
67
|
+
# If plain mode is enabled then we don't do any authentication (we don't
|
68
|
+
# set a user or an identity file)
|
69
|
+
plain_mode = opts[:plain_mode]
|
70
|
+
|
71
|
+
options = {}
|
72
|
+
options[:host] = ssh_info[:host]
|
73
|
+
options[:port] = ssh_info[:port]
|
74
|
+
options[:username] = ssh_info[:username]
|
75
|
+
options[:private_key_path] = ssh_info[:private_key_path]
|
76
|
+
|
77
|
+
# Command line options
|
78
|
+
command_options = ["-p", options[:port].to_s, "-o", "UserKnownHostsFile=/dev/null",
|
79
|
+
"-o", "StrictHostKeyChecking=no", "-o", "LogLevel=ERROR"]
|
80
|
+
|
81
|
+
# Solaris/OpenSolaris/Illumos uses SunSSH which doesn't support the IdentitiesOnly option
|
82
|
+
command_options += ["-o", "IdentitiesOnly=yes"] unless Util::Platform.solaris?
|
83
|
+
|
84
|
+
command_options += ["-i", options[:private_key_path]] if !plain_mode
|
85
|
+
command_options += ["-o", "ForwardAgent=yes"] if ssh_info[:forward_agent]
|
86
|
+
|
87
|
+
# If there are extra options, then we append those
|
88
|
+
command_options.concat(opts[:extra_args]) if opts[:extra_args]
|
89
|
+
|
90
|
+
if ssh_info[:forward_x11]
|
91
|
+
# Both are required so that no warnings are shown regarding X11
|
92
|
+
command_options += ["-o", "ForwardX11=yes"]
|
93
|
+
command_options += ["-o", "ForwardX11Trusted=yes"]
|
94
|
+
end
|
95
|
+
|
96
|
+
host_string = options[:host]
|
97
|
+
host_string = "#{options[:username]}@#{host_string}" if !plain_mode
|
98
|
+
command_options << host_string
|
99
|
+
@logger.info("Invoking SSH: #{command_options.inspect}")
|
100
|
+
safe_exec("ssh", *command_options)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Checks the file permissions for a private key, resetting them
|
104
|
+
# if needed.
|
105
|
+
def check_key_permissions(key_path)
|
106
|
+
# Windows systems don't have this issue
|
107
|
+
return if Util::Platform.windows?
|
108
|
+
|
109
|
+
@logger.debug("Checking key permissions: #{key_path}")
|
110
|
+
stat = File.stat(key_path)
|
111
|
+
|
112
|
+
if stat.owned? && Util::FileMode.from_octal(stat.mode) != "600"
|
113
|
+
@logger.info("Attempting to correct key permissions to 0600")
|
114
|
+
File.chmod(0600, key_path)
|
115
|
+
|
116
|
+
if Util::FileMode.from_octal(stat.mode) != "600"
|
117
|
+
raise Errors::SSHKeyBadPermissions, :key_path => key_path
|
118
|
+
end
|
119
|
+
end
|
120
|
+
rescue Errno::EPERM
|
121
|
+
# This shouldn't happen since we verified we own the file, but
|
122
|
+
# it is possible in theory, so we raise an error.
|
123
|
+
raise Errors::SSHKeyBadPermissions, :key_path => key_path
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
module Vagrant
|
2
|
+
# Test helpers provided by Vagrant to allow for plugin developers
|
3
|
+
# to write automated tests for their code. This module simply provides
|
4
|
+
# methods which can be included into any test framework (`test/unit`,
|
5
|
+
# RSpec, Shoulda, etc.)
|
6
|
+
module TestHelpers
|
7
|
+
#------------------------------------------------------------
|
8
|
+
# Environment creation helpers
|
9
|
+
#------------------------------------------------------------
|
10
|
+
# Creates a "vagrant_app" directory in the test tmp folder
|
11
|
+
# which can be used for creating test Vagrant environments.
|
12
|
+
# Returns the root directory of the app. This typically doesn't need
|
13
|
+
# to be called directly unless you're setting up a custom application.
|
14
|
+
# See the examples for common use cases.
|
15
|
+
def vagrant_app(*path)
|
16
|
+
root = tmp_path.join("vagrant_app")
|
17
|
+
FileUtils.rm_rf(root)
|
18
|
+
FileUtils.mkdir_p(root)
|
19
|
+
root.join(*path)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Creates a Vagrantfile with the given contents in the given
|
23
|
+
# app directory. If no app directory is specified, then a default
|
24
|
+
# Vagrant app is used.
|
25
|
+
def vagrantfile(*args)
|
26
|
+
path = args.shift.join("Vagrantfile") if Pathname === args.first
|
27
|
+
path ||= vagrant_app("Vagrantfile")
|
28
|
+
|
29
|
+
# Create this box so that it exists
|
30
|
+
vagrant_box("base")
|
31
|
+
|
32
|
+
str = args.shift || ""
|
33
|
+
File.open(path.to_s, "w") do |f|
|
34
|
+
f.puts "ENV['VAGRANT_HOME'] = '#{home_path}'"
|
35
|
+
f.puts "Vagrant::Config.run do |config|"
|
36
|
+
f.puts "config.vm.base_mac = 'foo' if !config.vm.base_mac"
|
37
|
+
f.puts "config.vm.box = 'base'"
|
38
|
+
f.puts str
|
39
|
+
f.puts "end"
|
40
|
+
end
|
41
|
+
|
42
|
+
path.parent
|
43
|
+
end
|
44
|
+
|
45
|
+
# Creates and _loads_ a Vagrant environment at the given path.
|
46
|
+
# If no path is given, then a default {#vagrantfile} is used.
|
47
|
+
def vagrant_env(*args)
|
48
|
+
path = args.shift if Pathname === args.first
|
49
|
+
path ||= vagrantfile
|
50
|
+
Vagrant::Environment.new(:cwd => path).load!
|
51
|
+
end
|
52
|
+
|
53
|
+
# Creates the folder to contain a vagrant box. This allows for
|
54
|
+
# "fake" boxes to be made with the specified name.
|
55
|
+
#
|
56
|
+
# @param [String] name
|
57
|
+
# @return [Pathname]
|
58
|
+
def vagrant_box(name)
|
59
|
+
result = boxes_path.join(name)
|
60
|
+
FileUtils.mkdir_p(result)
|
61
|
+
result
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns an instantiated downloader with a mocked tempfile
|
65
|
+
# which can be passed into it.
|
66
|
+
#
|
67
|
+
# @param [Class] klass The downloader class
|
68
|
+
# @return [Array] Returns an array of `downloader` `tempfile`
|
69
|
+
def vagrant_mock_downloader(klass)
|
70
|
+
tempfile = mock("tempfile")
|
71
|
+
tempfile.stubs(:write)
|
72
|
+
|
73
|
+
_, env = action_env
|
74
|
+
[klass.new(env), tempfile]
|
75
|
+
end
|
76
|
+
|
77
|
+
# Returns a blank app (callable) and action environment with the
|
78
|
+
# given vagrant environment. This allows for testing of middlewares.
|
79
|
+
def action_env(v_env = nil)
|
80
|
+
v_env ||= vagrant_env
|
81
|
+
# duplicate the Vagrant::Environment ui and get the default vm object
|
82
|
+
# for the new action environment from the first pair in the vms list
|
83
|
+
opts = {:ui => v_env.ui.dup, :vm => v_env.vms.first.last}
|
84
|
+
app = lambda { |env| }
|
85
|
+
env = Vagrant::Action::Environment.new(opts)
|
86
|
+
env["vagrant.test"] = true
|
87
|
+
[app, env]
|
88
|
+
end
|
89
|
+
|
90
|
+
# Utility method for capturing output streams.
|
91
|
+
# @example Evaluate the output
|
92
|
+
# output = capture(:stdout){ env.cli("foo") }
|
93
|
+
# assert_equal "bar", output
|
94
|
+
# @example Silence the output
|
95
|
+
# silence(:stdout){ env.cli("init") }
|
96
|
+
# @param [:stdout, :stderr] stream The stream to capture
|
97
|
+
# @yieldreturn String
|
98
|
+
# @see https://github.com/wycats/thor/blob/master/spec/spec_helper.rb
|
99
|
+
def capture(stream)
|
100
|
+
begin
|
101
|
+
stream = stream.to_s
|
102
|
+
eval "$#{stream} = StringIO.new"
|
103
|
+
yield
|
104
|
+
result = eval("$#{stream}").string
|
105
|
+
ensure
|
106
|
+
eval("$#{stream} = #{stream.upcase}")
|
107
|
+
end
|
108
|
+
|
109
|
+
result
|
110
|
+
end
|
111
|
+
alias :silence :capture
|
112
|
+
|
113
|
+
#------------------------------------------------------------
|
114
|
+
# Path helpers
|
115
|
+
#------------------------------------------------------------
|
116
|
+
# Path to the tmp directory for the tests.
|
117
|
+
#
|
118
|
+
# @return [Pathname]
|
119
|
+
def tmp_path
|
120
|
+
result = Vagrant.source_root.join("test", "tmp")
|
121
|
+
FileUtils.mkdir_p(result)
|
122
|
+
result
|
123
|
+
end
|
124
|
+
|
125
|
+
# Path to the "home" directory for the tests
|
126
|
+
#
|
127
|
+
# @return [Pathname]
|
128
|
+
def home_path
|
129
|
+
result = tmp_path.join("home")
|
130
|
+
FileUtils.mkdir_p(result)
|
131
|
+
result
|
132
|
+
end
|
133
|
+
|
134
|
+
# Path to the boxes directory in the home directory
|
135
|
+
#
|
136
|
+
# @return [Pathname]
|
137
|
+
def boxes_path
|
138
|
+
result = home_path.join("boxes")
|
139
|
+
FileUtils.mkdir_p(result)
|
140
|
+
result
|
141
|
+
end
|
142
|
+
|
143
|
+
# Cleans all the test temp paths, which includes the boxes path,
|
144
|
+
# home path, etc. This allows for cleaning between tests.
|
145
|
+
def clean_paths
|
146
|
+
FileUtils.rm_rf(tmp_path)
|
147
|
+
|
148
|
+
# Call these methods only to rebuild the directories
|
149
|
+
tmp_path
|
150
|
+
home_path
|
151
|
+
boxes_path
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|