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,606 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
|
3
|
+
require 'vagrant/driver/virtualbox_base'
|
4
|
+
require 'vagrant/util/platform'
|
5
|
+
|
6
|
+
module Vagrant
|
7
|
+
module Driver
|
8
|
+
# Driver for VirtualBox 4.2.x
|
9
|
+
class VirtualBox_4_2 < VirtualBoxBase
|
10
|
+
def initialize(uuid)
|
11
|
+
super()
|
12
|
+
|
13
|
+
@logger = Log4r::Logger.new("vagrant::driver::virtualbox_4_2")
|
14
|
+
@uuid = uuid
|
15
|
+
|
16
|
+
# "Jank mode." VirtualBox 4.2.0 has a horrendous bug where
|
17
|
+
# showvminfo with `--machinereadable` doesn't return proper output.
|
18
|
+
# In this case, Vagrant works around it by using equally horrendous
|
19
|
+
# regular expressions for the non-machine-readable output of
|
20
|
+
# showvminfo. This, ladies and gentlemen, is jank mode.
|
21
|
+
@jank_mode = false
|
22
|
+
if Util::Platform.windows?
|
23
|
+
if execute("--version").start_with?("4.2.0r")
|
24
|
+
@logger.info("Windows with v4.2.0. Jank mode engage.")
|
25
|
+
@jank_mode = true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def clear_forwarded_ports
|
31
|
+
args = []
|
32
|
+
read_forwarded_ports(@uuid).each do |nic, name, _, _|
|
33
|
+
args.concat(["--natpf#{nic}", "delete", name])
|
34
|
+
end
|
35
|
+
|
36
|
+
execute("modifyvm", @uuid, *args) if !args.empty?
|
37
|
+
end
|
38
|
+
|
39
|
+
def clear_shared_folders
|
40
|
+
return jank_clear_shared_folders if @jank_mode
|
41
|
+
|
42
|
+
info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
|
43
|
+
info.split("\n").each do |line|
|
44
|
+
if line =~ /^SharedFolderNameMachineMapping\d+="(.+?)"$/
|
45
|
+
execute("sharedfolder", "remove", @uuid, "--name", $1.to_s)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_dhcp_server(network, options)
|
51
|
+
execute("dhcpserver", "add", "--ifname", network,
|
52
|
+
"--ip", options[:dhcp_ip],
|
53
|
+
"--netmask", options[:netmask],
|
54
|
+
"--lowerip", options[:dhcp_lower],
|
55
|
+
"--upperip", options[:dhcp_upper],
|
56
|
+
"--enable")
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_host_only_network(options)
|
60
|
+
# Create the interface
|
61
|
+
execute("hostonlyif", "create") =~ /^Interface '(.+?)' was successfully created$/
|
62
|
+
name = $1.to_s
|
63
|
+
|
64
|
+
# Configure it
|
65
|
+
execute("hostonlyif", "ipconfig", name,
|
66
|
+
"--ip", options[:adapter_ip],
|
67
|
+
"--netmask", options[:netmask])
|
68
|
+
|
69
|
+
# Return the details
|
70
|
+
return {
|
71
|
+
:name => name,
|
72
|
+
:ip => options[:adapter_ip],
|
73
|
+
:netmask => options[:netmask],
|
74
|
+
:dhcp => nil
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
def delete
|
79
|
+
execute("unregistervm", @uuid, "--delete")
|
80
|
+
end
|
81
|
+
|
82
|
+
def delete_unused_host_only_networks
|
83
|
+
networks = []
|
84
|
+
execute("list", "hostonlyifs").split("\n").each do |line|
|
85
|
+
networks << $1.to_s if line =~ /^Name:\s+(.+?)$/
|
86
|
+
end
|
87
|
+
|
88
|
+
execute("list", "vms").split("\n").each do |line|
|
89
|
+
if line =~ /^".+?"\s+\{(.+?)\}$/
|
90
|
+
if @jank_mode
|
91
|
+
adapters = jank_read_hostonly_adapters($1.to_s)
|
92
|
+
adapters.each do |adapter|
|
93
|
+
networks.delete(adapter)
|
94
|
+
end
|
95
|
+
else
|
96
|
+
info = execute("showvminfo", $1.to_s, "--machinereadable", :retryable => true)
|
97
|
+
info.split("\n").each do |info_line|
|
98
|
+
if info_line =~ /^hostonlyadapter\d+="(.+?)"$/
|
99
|
+
networks.delete($1.to_s)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
networks.each do |name|
|
107
|
+
# First try to remove any DHCP servers attached. We use `raw` because
|
108
|
+
# it is okay if this fails. It usually means that a DHCP server was
|
109
|
+
# never attached.
|
110
|
+
raw("dhcpserver", "remove", "--ifname", name)
|
111
|
+
|
112
|
+
# Delete the actual host only network interface.
|
113
|
+
execute("hostonlyif", "remove", name)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def discard_saved_state
|
118
|
+
execute("discardstate", @uuid)
|
119
|
+
end
|
120
|
+
|
121
|
+
def enable_adapters(adapters)
|
122
|
+
args = []
|
123
|
+
adapters.each do |adapter|
|
124
|
+
args.concat(["--nic#{adapter[:adapter]}", adapter[:type].to_s])
|
125
|
+
|
126
|
+
if adapter[:bridge]
|
127
|
+
args.concat(["--bridgeadapter#{adapter[:adapter]}",
|
128
|
+
adapter[:bridge]])
|
129
|
+
end
|
130
|
+
|
131
|
+
if adapter[:hostonly]
|
132
|
+
args.concat(["--hostonlyadapter#{adapter[:adapter]}",
|
133
|
+
adapter[:hostonly]])
|
134
|
+
end
|
135
|
+
|
136
|
+
if adapter[:mac_address]
|
137
|
+
args.concat(["--macaddress#{adapter[:adapter]}",
|
138
|
+
adapter[:mac_address]])
|
139
|
+
end
|
140
|
+
|
141
|
+
if adapter[:nic_type]
|
142
|
+
args.concat(["--nictype#{adapter[:adapter]}", adapter[:nic_type].to_s])
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
execute("modifyvm", @uuid, *args)
|
147
|
+
end
|
148
|
+
|
149
|
+
def execute_command(command)
|
150
|
+
raw(*command)
|
151
|
+
end
|
152
|
+
|
153
|
+
def export(path)
|
154
|
+
# TODO: Progress
|
155
|
+
execute("export", @uuid, "--output", path.to_s)
|
156
|
+
end
|
157
|
+
|
158
|
+
def forward_ports(ports)
|
159
|
+
args = []
|
160
|
+
ports.each do |options|
|
161
|
+
pf_builder = [options[:name],
|
162
|
+
options[:protocol] || "tcp",
|
163
|
+
"",
|
164
|
+
options[:hostport],
|
165
|
+
"",
|
166
|
+
options[:guestport]]
|
167
|
+
|
168
|
+
args.concat(["--natpf#{options[:adapter] || 1}",
|
169
|
+
pf_builder.join(",")])
|
170
|
+
end
|
171
|
+
|
172
|
+
execute("modifyvm", @uuid, *args) if !args.empty?
|
173
|
+
end
|
174
|
+
|
175
|
+
def halt
|
176
|
+
execute("controlvm", @uuid, "poweroff")
|
177
|
+
end
|
178
|
+
|
179
|
+
def import(ovf)
|
180
|
+
output = ""
|
181
|
+
total = ""
|
182
|
+
last = 0
|
183
|
+
execute("import", ovf) do |type, data|
|
184
|
+
if type == :stdout
|
185
|
+
# Keep track of the stdout so that we can get the VM name
|
186
|
+
output << data
|
187
|
+
elsif type == :stderr
|
188
|
+
# Append the data so we can see the full view
|
189
|
+
total << data
|
190
|
+
|
191
|
+
# Break up the lines. We can't get the progress until we see an "OK"
|
192
|
+
lines = total.split("\n")
|
193
|
+
if lines.include?("OK.")
|
194
|
+
# The progress of the import will be in the last line. Do a greedy
|
195
|
+
# regular expression to find what we're looking for.
|
196
|
+
if lines.last =~ /.+(\d{2})%/
|
197
|
+
current = $1.to_i
|
198
|
+
if current > last
|
199
|
+
last = current
|
200
|
+
yield current if block_given?
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
# Find the name of the VM name
|
208
|
+
if output !~ /Suggested VM name "(.+?)"/
|
209
|
+
@logger.error("Couldn't find VM name in the output.")
|
210
|
+
return nil
|
211
|
+
end
|
212
|
+
|
213
|
+
name = $1.to_s
|
214
|
+
|
215
|
+
output = execute("list", "vms")
|
216
|
+
if output =~ /^"#{Regexp.escape(name)}" \{(.+?)\}$/
|
217
|
+
return $1.to_s
|
218
|
+
end
|
219
|
+
|
220
|
+
nil
|
221
|
+
end
|
222
|
+
|
223
|
+
def read_forwarded_ports(uuid=nil, active_only=false)
|
224
|
+
uuid ||= @uuid
|
225
|
+
@logger.debug("read_forward_ports: uuid=#{uuid} active_only=#{active_only}")
|
226
|
+
|
227
|
+
return jank_read_forwarded_ports(uuid, active_only) if @jank_mode
|
228
|
+
|
229
|
+
results = []
|
230
|
+
current_nic = nil
|
231
|
+
info = execute("showvminfo", uuid, "--machinereadable", :retryable => true)
|
232
|
+
info.split("\n").each do |line|
|
233
|
+
# This is how we find the nic that a FP is attached to,
|
234
|
+
# since this comes first.
|
235
|
+
current_nic = $1.to_i if line =~ /^nic(\d+)=".+?"$/
|
236
|
+
|
237
|
+
# If we care about active VMs only, then we check the state
|
238
|
+
# to verify the VM is running.
|
239
|
+
if active_only && line =~ /^VMState="(.+?)"$/ && $1.to_s != "running"
|
240
|
+
return []
|
241
|
+
end
|
242
|
+
|
243
|
+
# Parse out the forwarded port information
|
244
|
+
if line =~ /^Forwarding.+?="(.+?),.+?,.*?,(.+?),.*?,(.+?)"$/
|
245
|
+
result = [current_nic, $1.to_s, $2.to_i, $3.to_i]
|
246
|
+
@logger.debug(" - #{result.inspect}")
|
247
|
+
results << result
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
results
|
252
|
+
end
|
253
|
+
|
254
|
+
def read_bridged_interfaces
|
255
|
+
execute("list", "bridgedifs").split("\n\n").collect do |block|
|
256
|
+
info = {}
|
257
|
+
|
258
|
+
block.split("\n").each do |line|
|
259
|
+
if line =~ /^Name:\s+(.+?)$/
|
260
|
+
info[:name] = $1.to_s
|
261
|
+
elsif line =~ /^IPAddress:\s+(.+?)$/
|
262
|
+
info[:ip] = $1.to_s
|
263
|
+
elsif line =~ /^NetworkMask:\s+(.+?)$/
|
264
|
+
info[:netmask] = $1.to_s
|
265
|
+
elsif line =~ /^Status:\s+(.+?)$/
|
266
|
+
info[:status] = $1.to_s
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
# Return the info to build up the results
|
271
|
+
info
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
def read_guest_additions_version
|
276
|
+
output = execute("guestproperty", "get", @uuid, "/VirtualBox/GuestAdd/Version",
|
277
|
+
:retryable => true)
|
278
|
+
if output =~ /^Value: (.+?)$/
|
279
|
+
# Split the version by _ since some distro versions modify it
|
280
|
+
# to look like this: 4.1.2_ubuntu, and the distro part isn't
|
281
|
+
# too important.
|
282
|
+
value = $1.to_s
|
283
|
+
return value.split("_").first
|
284
|
+
end
|
285
|
+
|
286
|
+
return nil
|
287
|
+
end
|
288
|
+
|
289
|
+
def read_host_only_interfaces
|
290
|
+
dhcp = {}
|
291
|
+
execute("list", "dhcpservers", :retryable => true).split("\n\n").each do |block|
|
292
|
+
info = {}
|
293
|
+
|
294
|
+
block.split("\n").each do |line|
|
295
|
+
if line =~ /^NetworkName:\s+HostInterfaceNetworking-(.+?)$/
|
296
|
+
info[:network] = $1.to_s
|
297
|
+
elsif line =~ /^IP:\s+(.+?)$/
|
298
|
+
info[:ip] = $1.to_s
|
299
|
+
elsif line =~ /^lowerIPAddress:\s+(.+?)$/
|
300
|
+
info[:lower] = $1.to_s
|
301
|
+
elsif line =~ /^upperIPAddress:\s+(.+?)$/
|
302
|
+
info[:upper] = $1.to_s
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
# Set the DHCP info
|
307
|
+
dhcp[info[:network]] = info
|
308
|
+
end
|
309
|
+
|
310
|
+
execute("list", "hostonlyifs", :retryable => true).split("\n\n").collect do |block|
|
311
|
+
info = {}
|
312
|
+
|
313
|
+
block.split("\n").each do |line|
|
314
|
+
if line =~ /^Name:\s+(.+?)$/
|
315
|
+
info[:name] = $1.to_s
|
316
|
+
elsif line =~ /^IPAddress:\s+(.+?)$/
|
317
|
+
info[:ip] = $1.to_s
|
318
|
+
elsif line =~ /^NetworkMask:\s+(.+?)$/
|
319
|
+
info[:netmask] = $1.to_s
|
320
|
+
elsif line =~ /^Status:\s+(.+?)$/
|
321
|
+
info[:status] = $1.to_s
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
# Set the DHCP info if it exists
|
326
|
+
info[:dhcp] = dhcp[info[:name]] if dhcp[info[:name]]
|
327
|
+
|
328
|
+
info
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
def read_mac_address
|
333
|
+
return jank_read_mac_address if @jank_mode
|
334
|
+
|
335
|
+
info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
|
336
|
+
info.split("\n").each do |line|
|
337
|
+
return $1.to_s if line =~ /^macaddress1="(.+?)"$/
|
338
|
+
end
|
339
|
+
|
340
|
+
nil
|
341
|
+
end
|
342
|
+
|
343
|
+
def read_machine_folder
|
344
|
+
execute("list", "systemproperties", :retryable => true).split("\n").each do |line|
|
345
|
+
if line =~ /^Default machine folder:\s+(.+?)$/i
|
346
|
+
return $1.to_s
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
nil
|
351
|
+
end
|
352
|
+
|
353
|
+
def read_network_interfaces
|
354
|
+
return jank_read_network_interfaces if @jank_mode
|
355
|
+
|
356
|
+
nics = {}
|
357
|
+
info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
|
358
|
+
info.split("\n").each do |line|
|
359
|
+
if line =~ /^nic(\d+)="(.+?)"$/
|
360
|
+
adapter = $1.to_i
|
361
|
+
type = $2.to_sym
|
362
|
+
|
363
|
+
nics[adapter] ||= {}
|
364
|
+
nics[adapter][:type] = type
|
365
|
+
elsif line =~ /^hostonlyadapter(\d+)="(.+?)"$/
|
366
|
+
adapter = $1.to_i
|
367
|
+
network = $2.to_s
|
368
|
+
|
369
|
+
nics[adapter] ||= {}
|
370
|
+
nics[adapter][:hostonly] = network
|
371
|
+
elsif line =~ /^bridgeadapter(\d+)="(.+?)"$/
|
372
|
+
adapter = $1.to_i
|
373
|
+
network = $2.to_s
|
374
|
+
|
375
|
+
nics[adapter] ||= {}
|
376
|
+
nics[adapter][:bridge] = network
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
nics
|
381
|
+
end
|
382
|
+
|
383
|
+
def read_state
|
384
|
+
return jank_read_state if @jank_mode
|
385
|
+
|
386
|
+
output = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
|
387
|
+
if output =~ /^name="<inaccessible>"$/
|
388
|
+
return :inaccessible
|
389
|
+
elsif output =~ /^VMState="(.+?)"$/
|
390
|
+
return $1.to_sym
|
391
|
+
end
|
392
|
+
|
393
|
+
nil
|
394
|
+
end
|
395
|
+
|
396
|
+
def read_used_ports
|
397
|
+
ports = []
|
398
|
+
execute("list", "vms", :retryable => true).split("\n").each do |line|
|
399
|
+
if line =~ /^".+?" \{(.+?)\}$/
|
400
|
+
uuid = $1.to_s
|
401
|
+
|
402
|
+
# Ignore our own used ports
|
403
|
+
next if uuid == @uuid
|
404
|
+
|
405
|
+
read_forwarded_ports(uuid, true).each do |_, _, hostport, _|
|
406
|
+
ports << hostport
|
407
|
+
end
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
411
|
+
ports
|
412
|
+
end
|
413
|
+
|
414
|
+
def read_vms
|
415
|
+
results = []
|
416
|
+
execute("list", "vms", :retryable => true).split("\n").each do |line|
|
417
|
+
if line =~ /^".+?" \{(.+?)\}$/
|
418
|
+
results << $1.to_s
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
422
|
+
results
|
423
|
+
end
|
424
|
+
|
425
|
+
def set_mac_address(mac)
|
426
|
+
execute("modifyvm", @uuid, "--macaddress1", mac)
|
427
|
+
end
|
428
|
+
|
429
|
+
def set_name(name)
|
430
|
+
execute("modifyvm", @uuid, "--name", name)
|
431
|
+
end
|
432
|
+
|
433
|
+
def share_folders(folders)
|
434
|
+
folders.each do |folder|
|
435
|
+
args = ["--name",
|
436
|
+
folder[:name],
|
437
|
+
"--hostpath",
|
438
|
+
folder[:hostpath]]
|
439
|
+
args << "--transient" if folder.has_key?(:transient) && folder[:transient]
|
440
|
+
execute("sharedfolder", "add", @uuid, *args)
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
def ssh_port(expected_port)
|
445
|
+
@logger.debug("Searching for SSH port: #{expected_port.inspect}")
|
446
|
+
|
447
|
+
# Look for the forwarded port only by comparing the guest port
|
448
|
+
read_forwarded_ports.each do |_, _, hostport, guestport|
|
449
|
+
return hostport if guestport == expected_port
|
450
|
+
end
|
451
|
+
|
452
|
+
nil
|
453
|
+
end
|
454
|
+
|
455
|
+
def start(mode)
|
456
|
+
command = ["startvm", @uuid, "--type", mode.to_s]
|
457
|
+
r = raw(*command)
|
458
|
+
|
459
|
+
if r.exit_code == 0 || r.stdout =~ /VM ".+?" has been successfully started/
|
460
|
+
# Some systems return an exit code 1 for some reason. For that
|
461
|
+
# we depend on the output.
|
462
|
+
return true
|
463
|
+
end
|
464
|
+
|
465
|
+
# If we reached this point then it didn't work out.
|
466
|
+
raise Errors::VBoxManageError, :command => command.inspect
|
467
|
+
end
|
468
|
+
|
469
|
+
def suspend
|
470
|
+
execute("controlvm", @uuid, "savestate")
|
471
|
+
end
|
472
|
+
|
473
|
+
def verify!
|
474
|
+
# This command sometimes fails if kernel drivers aren't properly loaded
|
475
|
+
# so we just run the command and verify that it succeeded.
|
476
|
+
execute("list", "hostonlyifs")
|
477
|
+
end
|
478
|
+
|
479
|
+
def verify_image(path)
|
480
|
+
r = raw("import", path.to_s, "--dry-run")
|
481
|
+
return r.exit_code == 0
|
482
|
+
end
|
483
|
+
|
484
|
+
def vm_exists?(uuid)
|
485
|
+
raw("showvminfo", uuid).exit_code == 0
|
486
|
+
end
|
487
|
+
|
488
|
+
protected
|
489
|
+
|
490
|
+
# JANK MODE METHODS:
|
491
|
+
#
|
492
|
+
# All the methods below are created to work around a horrendous
|
493
|
+
# bug in VirtualBox 4.2.0 on Windows where "showvminfo --machinereadable"
|
494
|
+
# doesn't output enough data. So, instead, on Windows we use the plain
|
495
|
+
# "showvminfo" and parse the human readable output.
|
496
|
+
|
497
|
+
def jank_clear_shared_folders
|
498
|
+
info = execute("showvminfo", @uuid, :retryable => true)
|
499
|
+
|
500
|
+
# Get the shared folders part
|
501
|
+
info = info.split("\n")
|
502
|
+
info = info.drop_while { |line| line !~ /^Shared folders:/i }
|
503
|
+
info = info.take_while { |line| line != "" && line !~ /^Name:/i }
|
504
|
+
|
505
|
+
# Find all the shared folders and delete them all
|
506
|
+
info.each do |line|
|
507
|
+
if line =~ /^Name: '(.+?)'/
|
508
|
+
execute("sharedfolder", "remove", @uuid, "--name", $1.to_s)
|
509
|
+
end
|
510
|
+
end
|
511
|
+
end
|
512
|
+
|
513
|
+
def jank_read_forwarded_ports(uuid, active_only)
|
514
|
+
results = []
|
515
|
+
|
516
|
+
info = execute("showvminfo", uuid, :retryable => true)
|
517
|
+
info.split("\n").each do |line|
|
518
|
+
# If we care about active VMs only, then we check the state
|
519
|
+
# to verify the VM is running.
|
520
|
+
if active_only && line =~ /^State:\s+(.+?) \(.+?\)$/ && $1.to_s != "running"
|
521
|
+
return []
|
522
|
+
end
|
523
|
+
|
524
|
+
# Parse out the forwarded port information
|
525
|
+
if line =~ /^NIC (\d) Rule\(\d\):\s+name = (.+?), protocol = .+?, host ip = .*?, host port = (.+?), guest ip = .*?, guest port = (.+?)$/
|
526
|
+
result = [$1.to_i, $2.to_s, $3.to_i, $4.to_i]
|
527
|
+
@logger.debug(" - #{result.inspect}")
|
528
|
+
results << result
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
results
|
533
|
+
end
|
534
|
+
|
535
|
+
def jank_read_hostonly_adapters(uuid)
|
536
|
+
adapters = []
|
537
|
+
|
538
|
+
nics = jank_read_network_interfaces(uuid)
|
539
|
+
nics.each do |adapter, data|
|
540
|
+
if data[:type] == :hostonly
|
541
|
+
adapters << data[:hostonly]
|
542
|
+
end
|
543
|
+
end
|
544
|
+
|
545
|
+
adapters
|
546
|
+
end
|
547
|
+
|
548
|
+
def jank_read_mac_address
|
549
|
+
info = execute("showvminfo", @uuid, :retryable => true)
|
550
|
+
info.split("\n").each do |line|
|
551
|
+
return $1.to_s if line =~ /^NIC 1:\s+MAC: (.+?),/
|
552
|
+
end
|
553
|
+
|
554
|
+
nil
|
555
|
+
end
|
556
|
+
|
557
|
+
def jank_read_network_interfaces(uuid=nil)
|
558
|
+
uuid ||= @uuid
|
559
|
+
nics = {}
|
560
|
+
info = execute("showvminfo", uuid, :retryable => true)
|
561
|
+
info.split("\n").each do |line|
|
562
|
+
if line =~ /^NIC (\d):\s+MAC: .+?, Attachment: (.+?), Cable/
|
563
|
+
adapter = $1.to_i
|
564
|
+
long_type = $2.to_s
|
565
|
+
|
566
|
+
type = nil
|
567
|
+
data = nil
|
568
|
+
if long_type == "NAT"
|
569
|
+
type = :nat
|
570
|
+
elsif long_type =~ /^Host-only Interface '(.+?)'$/i
|
571
|
+
type = :hostonly
|
572
|
+
data = $1.to_s
|
573
|
+
elsif long_type =~ /^Bridged Interface '(.+?)'$/i
|
574
|
+
type = :bridge
|
575
|
+
data = $1.to_s
|
576
|
+
end
|
577
|
+
|
578
|
+
nics[adapter] ||= {}
|
579
|
+
nics[adapter][:type] = type
|
580
|
+
nics[adapter][:hostonly] = data if type == :hostonly
|
581
|
+
nics[adapter][:bridge] = data if type == :bridge
|
582
|
+
end
|
583
|
+
end
|
584
|
+
|
585
|
+
nics
|
586
|
+
end
|
587
|
+
|
588
|
+
def jank_read_state
|
589
|
+
output = execute("showvminfo", @uuid, :retryable => true)
|
590
|
+
if output =~ /^Name:\s+<inaccessible>$/
|
591
|
+
return :inaccessible
|
592
|
+
elsif output =~ /^State:\s+(.+?) \(.+?\)$/
|
593
|
+
# Silly edge cases for a jank mode. This probably doesn't
|
594
|
+
# cover every case, but if we can get Vagrant MOSTLY working
|
595
|
+
# with this buggy version of VirtualBox on Windows, I'll be
|
596
|
+
# quite happy.
|
597
|
+
state = $1.to_s.downcase.gsub(" ", "")
|
598
|
+
state = "poweroff" if state == "poweredoff"
|
599
|
+
return state.to_sym
|
600
|
+
end
|
601
|
+
|
602
|
+
nil
|
603
|
+
end
|
604
|
+
end
|
605
|
+
end
|
606
|
+
end
|