vagrant-lxc 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +29 -0
- data/.gitmodules +3 -0
- data/.rspec +2 -0
- data/.travis.yml +8 -0
- data/.vimrc +1 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +89 -0
- data/Guardfile +34 -0
- data/LICENSE.txt +22 -0
- data/README.md +209 -0
- data/Rakefile +5 -0
- data/bin/vagrant-lxc +9 -0
- data/boxes/quantal64/download-ubuntu +103 -0
- data/boxes/quantal64/lxc-template +567 -0
- data/boxes/quantal64/metadata.json +9 -0
- data/development/Vagrantfile.1.0 +35 -0
- data/development/Vagrantfile.1.1 +55 -0
- data/development/lxc-configs/lxc-dev-box +37 -0
- data/development/lxc-configs/vbox +37 -0
- data/development/shell-provisioning/upgrade-kernel +14 -0
- data/development/site.pp +125 -0
- data/example/Vagrantfile +42 -0
- data/example/puppet/manifests/site.pp +5 -0
- data/example/puppet/modules/hello_world/manifests/init.pp +3 -0
- data/lib/vagrant-lxc.rb +6 -0
- data/lib/vagrant-lxc/action.rb +188 -0
- data/lib/vagrant-lxc/action/base_action.rb +11 -0
- data/lib/vagrant-lxc/action/boot.rb +55 -0
- data/lib/vagrant-lxc/action/check_created.rb +17 -0
- data/lib/vagrant-lxc/action/check_running.rb +17 -0
- data/lib/vagrant-lxc/action/create.rb +14 -0
- data/lib/vagrant-lxc/action/created.rb +16 -0
- data/lib/vagrant-lxc/action/destroy.rb +14 -0
- data/lib/vagrant-lxc/action/forced_halt.rb +22 -0
- data/lib/vagrant-lxc/action/handle_box_metadata.rb +47 -0
- data/lib/vagrant-lxc/action/is_running.rb +15 -0
- data/lib/vagrant-lxc/action/network.rb +21 -0
- data/lib/vagrant-lxc/action/share_folders.rb +65 -0
- data/lib/vagrant-lxc/config.rb +14 -0
- data/lib/vagrant-lxc/container.rb +170 -0
- data/lib/vagrant-lxc/container/cli.rb +124 -0
- data/lib/vagrant-lxc/errors.rb +12 -0
- data/lib/vagrant-lxc/machine_state.rb +25 -0
- data/lib/vagrant-lxc/plugin.rb +23 -0
- data/lib/vagrant-lxc/provider.rb +74 -0
- data/lib/vagrant-lxc/version.rb +5 -0
- data/lib/vendored_vagrant.rb +9 -0
- data/locales/en.yml +17 -0
- data/spec/fixtures/sample-arp-output +4 -0
- data/spec/fixtures/sample-config +47 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/unit_example_group.rb +28 -0
- data/spec/unit/action/handle_box_metadata_spec.rb +44 -0
- data/spec/unit/container/cli_spec.rb +148 -0
- data/spec/unit/container_spec.rb +151 -0
- data/spec/unit/machine_state_spec.rb +39 -0
- data/spec/unit_helper.rb +9 -0
- data/tasks/boxes.rake +17 -0
- data/tasks/spec.rake +30 -0
- data/vagrant-lxc.gemspec +32 -0
- data/vendor/.gitkeep +0 -0
- data/vendor/vagrant/.gitignore +31 -0
- data/vendor/vagrant/.travis.yml +7 -0
- data/vendor/vagrant/.yardopts +1 -0
- data/vendor/vagrant/CHANGELOG.md +803 -0
- data/vendor/vagrant/Gemfile +3 -0
- data/vendor/vagrant/LICENSE +21 -0
- data/vendor/vagrant/README.md +89 -0
- data/vendor/vagrant/Rakefile +18 -0
- data/vendor/vagrant/bin/vagrant +84 -0
- data/vendor/vagrant/config/default.rb +35 -0
- data/vendor/vagrant/contrib/README.md +12 -0
- data/vendor/vagrant/contrib/bash/completion.sh +3 -0
- data/vendor/vagrant/contrib/emacs/vagrant.el +8 -0
- data/vendor/vagrant/contrib/vim/vagrantfile.vim +9 -0
- data/vendor/vagrant/keys/README.md +17 -0
- data/vendor/vagrant/keys/vagrant +27 -0
- data/vendor/vagrant/keys/vagrant.pub +1 -0
- data/vendor/vagrant/lib/vagrant.rb +251 -0
- data/vendor/vagrant/lib/vagrant/action.rb +42 -0
- data/vendor/vagrant/lib/vagrant/action/builder.rb +154 -0
- data/vendor/vagrant/lib/vagrant/action/builtin/box_add.rb +79 -0
- data/vendor/vagrant/lib/vagrant/action/builtin/call.rb +67 -0
- data/vendor/vagrant/lib/vagrant/action/builtin/config_validate.rb +30 -0
- data/vendor/vagrant/lib/vagrant/action/builtin/confirm.rb +38 -0
- data/vendor/vagrant/lib/vagrant/action/builtin/env_set.rb +24 -0
- data/vendor/vagrant/lib/vagrant/action/builtin/graceful_halt.rb +73 -0
- data/vendor/vagrant/lib/vagrant/action/builtin/handle_box_url.rb +43 -0
- data/vendor/vagrant/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +117 -0
- data/vendor/vagrant/lib/vagrant/action/builtin/lock.rb +57 -0
- data/vendor/vagrant/lib/vagrant/action/builtin/nfs.rb +117 -0
- data/vendor/vagrant/lib/vagrant/action/builtin/provision.rb +70 -0
- data/vendor/vagrant/lib/vagrant/action/builtin/set_hostname.rb +27 -0
- data/vendor/vagrant/lib/vagrant/action/builtin/ssh_exec.rb +42 -0
- data/vendor/vagrant/lib/vagrant/action/builtin/ssh_run.rb +43 -0
- data/vendor/vagrant/lib/vagrant/action/general/package.rb +102 -0
- data/vendor/vagrant/lib/vagrant/action/hook.rb +103 -0
- data/vendor/vagrant/lib/vagrant/action/runner.rb +69 -0
- data/vendor/vagrant/lib/vagrant/action/warden.rb +103 -0
- data/vendor/vagrant/lib/vagrant/box.rb +93 -0
- data/vendor/vagrant/lib/vagrant/box_collection.rb +315 -0
- data/vendor/vagrant/lib/vagrant/cli.rb +82 -0
- data/vendor/vagrant/lib/vagrant/config.rb +63 -0
- data/vendor/vagrant/lib/vagrant/config/container.rb +37 -0
- data/vendor/vagrant/lib/vagrant/config/loader.rb +222 -0
- data/vendor/vagrant/lib/vagrant/config/v1.rb +9 -0
- data/vendor/vagrant/lib/vagrant/config/v1/dummy_config.rb +13 -0
- data/vendor/vagrant/lib/vagrant/config/v1/loader.rb +105 -0
- data/vendor/vagrant/lib/vagrant/config/v1/root.rb +60 -0
- data/vendor/vagrant/lib/vagrant/config/v2.rb +9 -0
- data/vendor/vagrant/lib/vagrant/config/v2/dummy_config.rb +13 -0
- data/vendor/vagrant/lib/vagrant/config/v2/loader.rb +141 -0
- data/vendor/vagrant/lib/vagrant/config/v2/root.rb +105 -0
- data/vendor/vagrant/lib/vagrant/config/v2/util.rb +21 -0
- data/vendor/vagrant/lib/vagrant/config/version_base.rb +80 -0
- data/vendor/vagrant/lib/vagrant/downloaders.rb +7 -0
- data/vendor/vagrant/lib/vagrant/downloaders/base.rb +22 -0
- data/vendor/vagrant/lib/vagrant/downloaders/file.rb +28 -0
- data/vendor/vagrant/lib/vagrant/downloaders/http.rb +116 -0
- data/vendor/vagrant/lib/vagrant/environment.rb +729 -0
- data/vendor/vagrant/lib/vagrant/errors.rb +486 -0
- data/vendor/vagrant/lib/vagrant/hosts.rb +28 -0
- data/vendor/vagrant/lib/vagrant/machine.rb +325 -0
- data/vendor/vagrant/lib/vagrant/machine_state.rb +45 -0
- data/vendor/vagrant/lib/vagrant/plugin.rb +6 -0
- data/vendor/vagrant/lib/vagrant/plugin/v1.rb +19 -0
- data/vendor/vagrant/lib/vagrant/plugin/v1/command.rb +169 -0
- data/vendor/vagrant/lib/vagrant/plugin/v1/communicator.rb +98 -0
- data/vendor/vagrant/lib/vagrant/plugin/v1/config.rb +112 -0
- data/vendor/vagrant/lib/vagrant/plugin/v1/errors.rb +15 -0
- data/vendor/vagrant/lib/vagrant/plugin/v1/guest.rb +92 -0
- data/vendor/vagrant/lib/vagrant/plugin/v1/host.rb +66 -0
- data/vendor/vagrant/lib/vagrant/plugin/v1/manager.rb +131 -0
- data/vendor/vagrant/lib/vagrant/plugin/v1/plugin.rb +229 -0
- data/vendor/vagrant/lib/vagrant/plugin/v1/provider.rb +68 -0
- data/vendor/vagrant/lib/vagrant/plugin/v1/provisioner.rb +50 -0
- data/vendor/vagrant/lib/vagrant/plugin/v2.rb +22 -0
- data/vendor/vagrant/lib/vagrant/plugin/v2/command.rb +234 -0
- data/vendor/vagrant/lib/vagrant/plugin/v2/communicator.rb +98 -0
- data/vendor/vagrant/lib/vagrant/plugin/v2/components.rb +29 -0
- data/vendor/vagrant/lib/vagrant/plugin/v2/config.rb +101 -0
- data/vendor/vagrant/lib/vagrant/plugin/v2/errors.rb +15 -0
- data/vendor/vagrant/lib/vagrant/plugin/v2/guest.rb +92 -0
- data/vendor/vagrant/lib/vagrant/plugin/v2/host.rb +66 -0
- data/vendor/vagrant/lib/vagrant/plugin/v2/manager.rb +158 -0
- data/vendor/vagrant/lib/vagrant/plugin/v2/plugin.rb +217 -0
- data/vendor/vagrant/lib/vagrant/plugin/v2/provider.rb +69 -0
- data/vendor/vagrant/lib/vagrant/plugin/v2/provisioner.rb +47 -0
- data/vendor/vagrant/lib/vagrant/registry.rb +78 -0
- data/vendor/vagrant/lib/vagrant/ssh.rb +132 -0
- data/vendor/vagrant/lib/vagrant/test_helpers.rb +154 -0
- data/vendor/vagrant/lib/vagrant/ui.rb +170 -0
- data/vendor/vagrant/lib/vagrant/util.rb +12 -0
- data/vendor/vagrant/lib/vagrant/util/ansi_escape_code_remover.rb +34 -0
- data/vendor/vagrant/lib/vagrant/util/busy.rb +59 -0
- data/vendor/vagrant/lib/vagrant/util/counter.rb +24 -0
- data/vendor/vagrant/lib/vagrant/util/file_checksum.rb +38 -0
- data/vendor/vagrant/lib/vagrant/util/file_mode.rb +12 -0
- data/vendor/vagrant/lib/vagrant/util/hash_with_indifferent_access.rb +63 -0
- data/vendor/vagrant/lib/vagrant/util/is_port_open.rb +38 -0
- data/vendor/vagrant/lib/vagrant/util/line_ending_helpers.rb +14 -0
- data/vendor/vagrant/lib/vagrant/util/network_ip.rb +28 -0
- data/vendor/vagrant/lib/vagrant/util/platform.rb +68 -0
- data/vendor/vagrant/lib/vagrant/util/retryable.rb +31 -0
- data/vendor/vagrant/lib/vagrant/util/safe_exec.rb +36 -0
- data/vendor/vagrant/lib/vagrant/util/safe_puts.rb +31 -0
- data/vendor/vagrant/lib/vagrant/util/scoped_hash_override.rb +45 -0
- data/vendor/vagrant/lib/vagrant/util/ssh.rb +126 -0
- data/vendor/vagrant/lib/vagrant/util/stacked_proc_runner.rb +35 -0
- data/vendor/vagrant/lib/vagrant/util/string_block_editor.rb +75 -0
- data/vendor/vagrant/lib/vagrant/util/subprocess.rb +270 -0
- data/vendor/vagrant/lib/vagrant/util/template_renderer.rb +83 -0
- data/vendor/vagrant/lib/vagrant/util/which.rb +43 -0
- data/vendor/vagrant/lib/vagrant/version.rb +6 -0
- data/vendor/vagrant/plugins/README.md +5 -0
- data/vendor/vagrant/plugins/commands/box/command/add.rb +52 -0
- data/vendor/vagrant/plugins/commands/box/command/list.rb +41 -0
- data/vendor/vagrant/plugins/commands/box/command/remove.rb +37 -0
- data/vendor/vagrant/plugins/commands/box/command/repackage.rb +43 -0
- data/vendor/vagrant/plugins/commands/box/command/root.rb +75 -0
- data/vendor/vagrant/plugins/commands/box/plugin.rb +15 -0
- data/vendor/vagrant/plugins/commands/destroy/command.rb +31 -0
- data/vendor/vagrant/plugins/commands/destroy/plugin.rb +18 -0
- data/vendor/vagrant/plugins/commands/halt/command.rb +33 -0
- data/vendor/vagrant/plugins/commands/halt/plugin.rb +18 -0
- data/vendor/vagrant/plugins/commands/init/command.rb +40 -0
- data/vendor/vagrant/plugins/commands/init/plugin.rb +18 -0
- data/vendor/vagrant/plugins/commands/package/command.rb +78 -0
- data/vendor/vagrant/plugins/commands/package/plugin.rb +18 -0
- data/vendor/vagrant/plugins/commands/plugin/action.rb +52 -0
- data/vendor/vagrant/plugins/commands/plugin/action/bundler_check.rb +25 -0
- data/vendor/vagrant/plugins/commands/plugin/action/install_gem.rb +70 -0
- data/vendor/vagrant/plugins/commands/plugin/action/license_plugin.rb +54 -0
- data/vendor/vagrant/plugins/commands/plugin/action/list_plugins.rb +54 -0
- data/vendor/vagrant/plugins/commands/plugin/action/prune_gems.rb +149 -0
- data/vendor/vagrant/plugins/commands/plugin/action/uninstall_plugin.rb +23 -0
- data/vendor/vagrant/plugins/commands/plugin/command/base.rb +22 -0
- data/vendor/vagrant/plugins/commands/plugin/command/install.rb +39 -0
- data/vendor/vagrant/plugins/commands/plugin/command/license.rb +31 -0
- data/vendor/vagrant/plugins/commands/plugin/command/list.rb +28 -0
- data/vendor/vagrant/plugins/commands/plugin/command/root.rb +75 -0
- data/vendor/vagrant/plugins/commands/plugin/command/uninstall.rb +28 -0
- data/vendor/vagrant/plugins/commands/plugin/gem_helper.rb +74 -0
- data/vendor/vagrant/plugins/commands/plugin/plugin.rb +22 -0
- data/vendor/vagrant/plugins/commands/plugin/state_file.rb +57 -0
- data/vendor/vagrant/plugins/commands/provision/command.rb +34 -0
- data/vendor/vagrant/plugins/commands/provision/plugin.rb +18 -0
- data/vendor/vagrant/plugins/commands/reload/command.rb +37 -0
- data/vendor/vagrant/plugins/commands/reload/plugin.rb +18 -0
- data/vendor/vagrant/plugins/commands/resume/command.rb +25 -0
- data/vendor/vagrant/plugins/commands/resume/plugin.rb +17 -0
- data/vendor/vagrant/plugins/commands/ssh/command.rb +66 -0
- data/vendor/vagrant/plugins/commands/ssh/plugin.rb +17 -0
- data/vendor/vagrant/plugins/commands/ssh_config/command.rb +49 -0
- data/vendor/vagrant/plugins/commands/ssh_config/plugin.rb +18 -0
- data/vendor/vagrant/plugins/commands/status/command.rb +39 -0
- data/vendor/vagrant/plugins/commands/status/plugin.rb +18 -0
- data/vendor/vagrant/plugins/commands/suspend/command.rb +25 -0
- data/vendor/vagrant/plugins/commands/suspend/plugin.rb +18 -0
- data/vendor/vagrant/plugins/commands/up/command.rb +45 -0
- data/vendor/vagrant/plugins/commands/up/plugin.rb +17 -0
- data/vendor/vagrant/plugins/commands/up/start_mixins.rb +26 -0
- data/vendor/vagrant/plugins/communicators/ssh/communicator.rb +317 -0
- data/vendor/vagrant/plugins/communicators/ssh/plugin.rb +19 -0
- data/vendor/vagrant/plugins/guests/arch/guest.rb +41 -0
- data/vendor/vagrant/plugins/guests/arch/plugin.rb +15 -0
- data/vendor/vagrant/plugins/guests/debian/guest.rb +72 -0
- data/vendor/vagrant/plugins/guests/debian/plugin.rb +15 -0
- data/vendor/vagrant/plugins/guests/fedora/guest.rb +71 -0
- data/vendor/vagrant/plugins/guests/fedora/plugin.rb +15 -0
- data/vendor/vagrant/plugins/guests/freebsd/config.rb +13 -0
- data/vendor/vagrant/plugins/guests/freebsd/guest.rb +70 -0
- data/vendor/vagrant/plugins/guests/freebsd/plugin.rb +20 -0
- data/vendor/vagrant/plugins/guests/gentoo/guest.rb +51 -0
- data/vendor/vagrant/plugins/guests/gentoo/plugin.rb +15 -0
- data/vendor/vagrant/plugins/guests/linux/config.rb +13 -0
- data/vendor/vagrant/plugins/guests/linux/guest.rb +118 -0
- data/vendor/vagrant/plugins/guests/linux/plugin.rb +20 -0
- data/vendor/vagrant/plugins/guests/openbsd/guest.rb +13 -0
- data/vendor/vagrant/plugins/guests/openbsd/plugin.rb +15 -0
- data/vendor/vagrant/plugins/guests/redhat/guest.rb +74 -0
- data/vendor/vagrant/plugins/guests/redhat/plugin.rb +15 -0
- data/vendor/vagrant/plugins/guests/solaris/config.rb +18 -0
- data/vendor/vagrant/plugins/guests/solaris/guest.rb +73 -0
- data/vendor/vagrant/plugins/guests/solaris/plugin.rb +20 -0
- data/vendor/vagrant/plugins/guests/suse/guest.rb +24 -0
- data/vendor/vagrant/plugins/guests/suse/plugin.rb +15 -0
- data/vendor/vagrant/plugins/guests/ubuntu/guest.rb +44 -0
- data/vendor/vagrant/plugins/guests/ubuntu/plugin.rb +15 -0
- data/vendor/vagrant/plugins/hosts/arch/host.rb +68 -0
- data/vendor/vagrant/plugins/hosts/arch/plugin.rb +15 -0
- data/vendor/vagrant/plugins/hosts/bsd/host.rb +102 -0
- data/vendor/vagrant/plugins/hosts/bsd/plugin.rb +15 -0
- data/vendor/vagrant/plugins/hosts/fedora/host.rb +51 -0
- data/vendor/vagrant/plugins/hosts/fedora/plugin.rb +15 -0
- data/vendor/vagrant/plugins/hosts/freebsd/host.rb +43 -0
- data/vendor/vagrant/plugins/hosts/freebsd/plugin.rb +15 -0
- data/vendor/vagrant/plugins/hosts/gentoo/host.rb +24 -0
- data/vendor/vagrant/plugins/hosts/gentoo/plugin.rb +15 -0
- data/vendor/vagrant/plugins/hosts/linux/host.rb +95 -0
- data/vendor/vagrant/plugins/hosts/linux/plugin.rb +15 -0
- data/vendor/vagrant/plugins/hosts/opensuse/host.rb +34 -0
- data/vendor/vagrant/plugins/hosts/opensuse/plugin.rb +15 -0
- data/vendor/vagrant/plugins/hosts/windows/host.rb +17 -0
- data/vendor/vagrant/plugins/hosts/windows/plugin.rb +15 -0
- data/vendor/vagrant/plugins/kernel_v1/config/nfs.rb +20 -0
- data/vendor/vagrant/plugins/kernel_v1/config/package.rb +17 -0
- data/vendor/vagrant/plugins/kernel_v1/config/ssh.rb +46 -0
- data/vendor/vagrant/plugins/kernel_v1/config/vagrant.rb +31 -0
- data/vendor/vagrant/plugins/kernel_v1/config/vm.rb +184 -0
- data/vendor/vagrant/plugins/kernel_v1/plugin.rb +44 -0
- data/vendor/vagrant/plugins/kernel_v2/config/nfs.rb +10 -0
- data/vendor/vagrant/plugins/kernel_v2/config/package.rb +9 -0
- data/vendor/vagrant/plugins/kernel_v2/config/ssh.rb +35 -0
- data/vendor/vagrant/plugins/kernel_v2/config/vagrant.rb +9 -0
- data/vendor/vagrant/plugins/kernel_v2/config/vm.rb +314 -0
- data/vendor/vagrant/plugins/kernel_v2/config/vm_provisioner.rb +40 -0
- data/vendor/vagrant/plugins/kernel_v2/config/vm_subvm.rb +30 -0
- data/vendor/vagrant/plugins/kernel_v2/plugin.rb +44 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action.rb +308 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/boot.rb +49 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/check_accessible.rb +23 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/check_created.rb +21 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/check_guest_additions.rb +45 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/check_running.rb +21 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/check_virtualbox.rb +22 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/clean_machine_folder.rb +43 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/clear_forwarded_ports.rb +18 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/clear_network_interfaces.rb +31 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/clear_shared_folders.rb +17 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/created.rb +20 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/customize.rb +36 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/destroy.rb +19 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/destroy_confirm.rb +17 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/destroy_unused_network_interfaces.rb +16 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/discard_state.rb +20 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/export.rb +57 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/forced_halt.rb +25 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/forward_ports.rb +79 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/import.rb +51 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/is_paused.rb +20 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/is_running.rb +20 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/is_saved.rb +20 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/match_mac_address.rb +21 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/message_not_created.rb +16 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/message_not_running.rb +16 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/message_will_not_destroy.rb +17 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/network.rb +366 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/package.rb +20 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/package_vagrantfile.rb +33 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb +35 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/prepare_nfs_settings.rb +51 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/prune_nfs_exports.rb +20 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/resume.rb +25 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/sane_defaults.rb +87 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/set_name.rb +40 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/setup_package_files.rb +51 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/share_folders.rb +113 -0
- data/vendor/vagrant/plugins/providers/virtualbox/action/suspend.rb +20 -0
- data/vendor/vagrant/plugins/providers/virtualbox/config.rb +82 -0
- data/vendor/vagrant/plugins/providers/virtualbox/driver/base.rb +344 -0
- data/vendor/vagrant/plugins/providers/virtualbox/driver/meta.rb +141 -0
- data/vendor/vagrant/plugins/providers/virtualbox/driver/version_4_0.rb +481 -0
- data/vendor/vagrant/plugins/providers/virtualbox/driver/version_4_1.rb +481 -0
- data/vendor/vagrant/plugins/providers/virtualbox/driver/version_4_2.rb +471 -0
- data/vendor/vagrant/plugins/providers/virtualbox/model/forwarded_port.rb +58 -0
- data/vendor/vagrant/plugins/providers/virtualbox/plugin.rb +42 -0
- data/vendor/vagrant/plugins/providers/virtualbox/provider.rb +92 -0
- data/vendor/vagrant/plugins/providers/virtualbox/util/compile_forwarded_ports.rb +31 -0
- data/vendor/vagrant/plugins/provisioners/chef/config/base.rb +65 -0
- data/vendor/vagrant/plugins/provisioners/chef/config/chef_client.rb +39 -0
- data/vendor/vagrant/plugins/provisioners/chef/config/chef_solo.rb +87 -0
- data/vendor/vagrant/plugins/provisioners/chef/plugin.rb +33 -0
- data/vendor/vagrant/plugins/provisioners/chef/provisioner/base.rb +91 -0
- data/vendor/vagrant/plugins/provisioners/chef/provisioner/chef_client.rb +103 -0
- data/vendor/vagrant/plugins/provisioners/chef/provisioner/chef_solo.rb +182 -0
- data/vendor/vagrant/plugins/provisioners/puppet/config/puppet.rb +70 -0
- data/vendor/vagrant/plugins/provisioners/puppet/config/puppet_server.rb +16 -0
- data/vendor/vagrant/plugins/provisioners/puppet/plugin.rb +33 -0
- data/vendor/vagrant/plugins/provisioners/puppet/provisioner/puppet.rb +110 -0
- data/vendor/vagrant/plugins/provisioners/puppet/provisioner/puppet_server.rb +67 -0
- data/vendor/vagrant/plugins/provisioners/shell/config.rb +46 -0
- data/vendor/vagrant/plugins/provisioners/shell/plugin.rb +23 -0
- data/vendor/vagrant/plugins/provisioners/shell/provisioner.rb +66 -0
- data/vendor/vagrant/tasks/acceptance.rake +113 -0
- data/vendor/vagrant/tasks/bundler.rake +3 -0
- data/vendor/vagrant/tasks/test.rake +20 -0
- data/vendor/vagrant/templates/commands/init/Vagrantfile.erb +111 -0
- data/vendor/vagrant/templates/commands/ssh_config/config.erb +16 -0
- data/vendor/vagrant/templates/config/messages.erb +14 -0
- data/vendor/vagrant/templates/config/validation_failed.erb +7 -0
- data/vendor/vagrant/templates/guests/arch/network_dhcp.erb +4 -0
- data/vendor/vagrant/templates/guests/arch/network_static.erb +6 -0
- data/vendor/vagrant/templates/guests/debian/network_dhcp.erb +11 -0
- data/vendor/vagrant/templates/guests/debian/network_static.erb +7 -0
- data/vendor/vagrant/templates/guests/fedora/network_dhcp.erb +6 -0
- data/vendor/vagrant/templates/guests/fedora/network_static.erb +13 -0
- data/vendor/vagrant/templates/guests/freebsd/network_dhcp.erb +3 -0
- data/vendor/vagrant/templates/guests/freebsd/network_static.erb +3 -0
- data/vendor/vagrant/templates/guests/gentoo/network_dhcp.erb +4 -0
- data/vendor/vagrant/templates/guests/gentoo/network_static.erb +4 -0
- data/vendor/vagrant/templates/guests/redhat/network_dhcp.erb +6 -0
- data/vendor/vagrant/templates/guests/redhat/network_static.erb +7 -0
- data/vendor/vagrant/templates/locales/en.yml +993 -0
- data/vendor/vagrant/templates/nfs/exports.erb +5 -0
- data/vendor/vagrant/templates/nfs/exports_freebsd.erb +5 -0
- data/vendor/vagrant/templates/nfs/exports_linux.erb +5 -0
- data/vendor/vagrant/templates/package_Vagrantfile.erb +11 -0
- data/vendor/vagrant/templates/provisioners/chef_client/client.erb +32 -0
- data/vendor/vagrant/templates/provisioners/chef_solo/solo.erb +25 -0
- data/vendor/vagrant/templates/rgloader.rb +9 -0
- data/vendor/vagrant/test/acceptance/base.rb +48 -0
- data/vendor/vagrant/test/acceptance/box_test.rb +99 -0
- data/vendor/vagrant/test/acceptance/destroy_test.rb +37 -0
- data/vendor/vagrant/test/acceptance/halt_test.rb +72 -0
- data/vendor/vagrant/test/acceptance/init_test.rb +33 -0
- data/vendor/vagrant/test/acceptance/networking/host_only_test.rb +37 -0
- data/vendor/vagrant/test/acceptance/networking/port_forward_test.rb +125 -0
- data/vendor/vagrant/test/acceptance/package_test.rb +46 -0
- data/vendor/vagrant/test/acceptance/provisioning/basic_test.rb +61 -0
- data/vendor/vagrant/test/acceptance/provisioning/chef_solo_test.rb +37 -0
- data/vendor/vagrant/test/acceptance/provisioning/shell_test.rb +53 -0
- data/vendor/vagrant/test/acceptance/resume_test.rb +17 -0
- data/vendor/vagrant/test/acceptance/shared_folders_test.rb +84 -0
- data/vendor/vagrant/test/acceptance/skeletons/chef_solo_basic/README.md +3 -0
- data/vendor/vagrant/test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb +5 -0
- data/vendor/vagrant/test/acceptance/skeletons/chef_solo_json/README.md +3 -0
- data/vendor/vagrant/test/acceptance/skeletons/chef_solo_json/cookbooks/basic/recipes/default.rb +6 -0
- data/vendor/vagrant/test/acceptance/skeletons/provisioner_multi/README.md +3 -0
- data/vendor/vagrant/test/acceptance/skeletons/provisioner_multi/cookbooks/basic/recipes/default.rb +5 -0
- data/vendor/vagrant/test/acceptance/ssh_test.rb +46 -0
- data/vendor/vagrant/test/acceptance/support/config.rb +42 -0
- data/vendor/vagrant/test/acceptance/support/isolated_environment.rb +118 -0
- data/vendor/vagrant/test/acceptance/support/matchers/have_color.rb +9 -0
- data/vendor/vagrant/test/acceptance/support/matchers/match_output.rb +14 -0
- data/vendor/vagrant/test/acceptance/support/matchers/succeed.rb +14 -0
- data/vendor/vagrant/test/acceptance/support/network_tests.rb +29 -0
- data/vendor/vagrant/test/acceptance/support/output.rb +95 -0
- data/vendor/vagrant/test/acceptance/support/shared/base_context.rb +72 -0
- data/vendor/vagrant/test/acceptance/support/shared/command_examples.rb +33 -0
- data/vendor/vagrant/test/acceptance/support/virtualbox.rb +36 -0
- data/vendor/vagrant/test/acceptance/suspend_test.rb +56 -0
- data/vendor/vagrant/test/acceptance/up_basic_test.rb +33 -0
- data/vendor/vagrant/test/acceptance/up_with_box_url.rb +40 -0
- data/vendor/vagrant/test/acceptance/vagrant_test.rb +47 -0
- data/vendor/vagrant/test/acceptance/version_test.rb +15 -0
- data/vendor/vagrant/test/config/acceptance_boxes.yml +7 -0
- data/vendor/vagrant/test/support/isolated_environment.rb +46 -0
- data/vendor/vagrant/test/support/tempdir.rb +43 -0
- data/vendor/vagrant/test/unit/base.rb +27 -0
- data/vendor/vagrant/test/unit/support/dummy_provider.rb +16 -0
- data/vendor/vagrant/test/unit/support/isolated_environment.rb +177 -0
- data/vendor/vagrant/test/unit/support/shared/base_context.rb +104 -0
- data/vendor/vagrant/test/unit/vagrant/action/builder_test.rb +196 -0
- data/vendor/vagrant/test/unit/vagrant/action/builtin/call_test.rb +145 -0
- data/vendor/vagrant/test/unit/vagrant/action/builtin/confirm_test.rb +36 -0
- data/vendor/vagrant/test/unit/vagrant/action/builtin/env_set_test.rb +20 -0
- data/vendor/vagrant/test/unit/vagrant/action/builtin/graceful_halt_test.rb +61 -0
- data/vendor/vagrant/test/unit/vagrant/action/builtin/lock_test.rb +98 -0
- data/vendor/vagrant/test/unit/vagrant/action/builtin/ssh_exec_test.rb +57 -0
- data/vendor/vagrant/test/unit/vagrant/action/hook_test.rb +101 -0
- data/vendor/vagrant/test/unit/vagrant/action/runner_test.rb +71 -0
- data/vendor/vagrant/test/unit/vagrant/action/warden_test.rb +92 -0
- data/vendor/vagrant/test/unit/vagrant/box_collection_test.rb +224 -0
- data/vendor/vagrant/test/unit/vagrant/box_test.rb +109 -0
- data/vendor/vagrant/test/unit/vagrant/cli_test.rb +27 -0
- data/vendor/vagrant/test/unit/vagrant/config/loader_test.rb +184 -0
- data/vendor/vagrant/test/unit/vagrant/config/v1/dummy_config_test.rb +24 -0
- data/vendor/vagrant/test/unit/vagrant/config/v1/loader_test.rb +145 -0
- data/vendor/vagrant/test/unit/vagrant/config/v1/root_test.rb +40 -0
- data/vendor/vagrant/test/unit/vagrant/config/v2/dummy_config_test.rb +24 -0
- data/vendor/vagrant/test/unit/vagrant/config/v2/loader_test.rb +151 -0
- data/vendor/vagrant/test/unit/vagrant/config/v2/root_test.rb +97 -0
- data/vendor/vagrant/test/unit/vagrant/config/v2/util_test.rb +21 -0
- data/vendor/vagrant/test/unit/vagrant/config_test.rb +66 -0
- data/vendor/vagrant/test/unit/vagrant/downloaders/base_test.rb +14 -0
- data/vendor/vagrant/test/unit/vagrant/downloaders/file_test.rb +87 -0
- data/vendor/vagrant/test/unit/vagrant/downloaders/http_test.rb +23 -0
- data/vendor/vagrant/test/unit/vagrant/environment_test.rb +571 -0
- data/vendor/vagrant/test/unit/vagrant/hosts_test.rb +37 -0
- data/vendor/vagrant/test/unit/vagrant/machine_state_test.rb +26 -0
- data/vendor/vagrant/test/unit/vagrant/machine_test.rb +418 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v1/command_test.rb +143 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v1/communicator_test.rb +9 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v1/config_test.rb +50 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v1/host_test.rb +5 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v1/manager_test.rb +114 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v1/plugin_test.rb +267 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v1/provider_test.rb +18 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v2/command_test.rb +238 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v2/communicator_test.rb +9 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v2/components_test.rb +17 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v2/config_test.rb +60 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v2/host_test.rb +5 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v2/manager_test.rb +157 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v2/plugin_test.rb +287 -0
- data/vendor/vagrant/test/unit/vagrant/plugin/v2/provider_test.rb +18 -0
- data/vendor/vagrant/test/unit/vagrant/registry_test.rb +128 -0
- data/vendor/vagrant/test/unit/vagrant/util/ansi_escape_code_remover_test.rb +16 -0
- data/vendor/vagrant/test/unit/vagrant/util/file_checksum_test.rb +23 -0
- data/vendor/vagrant/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +38 -0
- data/vendor/vagrant/test/unit/vagrant/util/is_port_open_test.rb +53 -0
- data/vendor/vagrant/test/unit/vagrant/util/line_endings_helper_test.rb +16 -0
- data/vendor/vagrant/test/unit/vagrant/util/network_ip_test.rb +17 -0
- data/vendor/vagrant/test/unit/vagrant/util/retryable_test.rb +106 -0
- data/vendor/vagrant/test/unit/vagrant/util/scoped_hash_override_test.rb +48 -0
- data/vendor/vagrant/test/unit/vagrant/util/ssh_test.rb +30 -0
- data/vendor/vagrant/test/unit/vagrant/util/string_block_editor_test.rb +98 -0
- data/vendor/vagrant/test/unit/vagrant/util/which_test.rb +43 -0
- data/vendor/vagrant/test/unit/vagrant_test.rb +56 -0
- data/vendor/vagrant/vagrant.gemspec +69 -0
- metadata +642 -0
@@ -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
|
@@ -0,0 +1,170 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
require "vagrant/util/safe_puts"
|
4
|
+
|
5
|
+
module Vagrant
|
6
|
+
module UI
|
7
|
+
# Vagrant UIs handle communication with the outside world (typically
|
8
|
+
# through a shell). They must respond to the following methods:
|
9
|
+
#
|
10
|
+
# * `info`
|
11
|
+
# * `warn`
|
12
|
+
# * `error`
|
13
|
+
# * `success`
|
14
|
+
class Interface
|
15
|
+
attr_accessor :resource
|
16
|
+
|
17
|
+
def initialize(resource=nil)
|
18
|
+
@logger = Log4r::Logger.new("vagrant::ui::interface")
|
19
|
+
@resource = resource
|
20
|
+
end
|
21
|
+
|
22
|
+
[:ask, :warn, :error, :info, :success].each do |method|
|
23
|
+
define_method(method) do |message, *opts|
|
24
|
+
# Log normal console messages
|
25
|
+
@logger.info { "#{method}: #{message}" }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
[:clear_line, :report_progress].each do |method|
|
30
|
+
# By default do nothing, these aren't logged
|
31
|
+
define_method(method) { |*args| }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# This is a UI implementation that does nothing.
|
36
|
+
class Silent < Interface
|
37
|
+
def ask(*args)
|
38
|
+
super
|
39
|
+
|
40
|
+
# Silent can't do this, obviously.
|
41
|
+
raise Errors::UIExpectsTTY
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# This is a UI implementation that outputs the text as is. It
|
46
|
+
# doesn't add any color.
|
47
|
+
class Basic < Interface
|
48
|
+
include Util::SafePuts
|
49
|
+
|
50
|
+
# Use some light meta-programming to create the various methods to
|
51
|
+
# output text to the UI. These all delegate the real functionality
|
52
|
+
# to `say`.
|
53
|
+
[:info, :warn, :error, :success].each do |method|
|
54
|
+
class_eval <<-CODE
|
55
|
+
def #{method}(message, *args)
|
56
|
+
super(message)
|
57
|
+
say(#{method.inspect}, message, *args)
|
58
|
+
end
|
59
|
+
CODE
|
60
|
+
end
|
61
|
+
|
62
|
+
def ask(message, opts=nil)
|
63
|
+
super(message)
|
64
|
+
|
65
|
+
# We can't ask questions when the output isn't a TTY.
|
66
|
+
raise Errors::UIExpectsTTY if !$stdin.tty?
|
67
|
+
|
68
|
+
# Setup the options so that the new line is suppressed
|
69
|
+
opts ||= {}
|
70
|
+
opts[:new_line] = false if !opts.has_key?(:new_line)
|
71
|
+
opts[:prefix] = false if !opts.has_key?(:prefix)
|
72
|
+
|
73
|
+
# Output the data
|
74
|
+
say(:info, message, opts)
|
75
|
+
|
76
|
+
# Get the results and chomp off the newline. We do a logical OR
|
77
|
+
# here because `gets` can return a nil, for example in the case
|
78
|
+
# that ctrl-D is pressed on the input.
|
79
|
+
input = $stdin.gets || ""
|
80
|
+
input.chomp
|
81
|
+
end
|
82
|
+
|
83
|
+
# This is used to output progress reports to the UI.
|
84
|
+
# Send this method progress/total and it will output it
|
85
|
+
# to the UI. Send `clear_line` to clear the line to show
|
86
|
+
# a continuous progress meter.
|
87
|
+
def report_progress(progress, total, show_parts=true)
|
88
|
+
if total && total > 0
|
89
|
+
percent = (progress.to_f / total.to_f) * 100
|
90
|
+
line = "Progress: #{percent.to_i}%"
|
91
|
+
line << " (#{progress} / #{total})" if show_parts
|
92
|
+
else
|
93
|
+
line = "Progress: #{progress}"
|
94
|
+
end
|
95
|
+
|
96
|
+
info(line, :new_line => false)
|
97
|
+
end
|
98
|
+
|
99
|
+
def clear_line
|
100
|
+
reset = "\r"
|
101
|
+
reset += "\e[0K" unless Util::Platform.windows?
|
102
|
+
|
103
|
+
info(reset, :new_line => false)
|
104
|
+
end
|
105
|
+
|
106
|
+
# This method handles actually outputting a message of a given type
|
107
|
+
# to the console.
|
108
|
+
def say(type, message, opts=nil)
|
109
|
+
defaults = { :new_line => true, :prefix => true }
|
110
|
+
opts = defaults.merge(opts || {})
|
111
|
+
|
112
|
+
# Determine whether we're expecting to output our
|
113
|
+
# own new line or not.
|
114
|
+
printer = opts[:new_line] ? :puts : :print
|
115
|
+
|
116
|
+
# Determine the proper IO channel to send this message
|
117
|
+
# to based on the type of the message
|
118
|
+
channel = type == :error || opts[:channel] == :error ? $stderr : $stdout
|
119
|
+
|
120
|
+
# Output!
|
121
|
+
safe_puts(format_message(type, message, opts),
|
122
|
+
:io => channel, :printer => printer)
|
123
|
+
end
|
124
|
+
|
125
|
+
# This is called by `say` to format the message for output.
|
126
|
+
def format_message(type, message, opts=nil)
|
127
|
+
opts ||= {}
|
128
|
+
message = "[#{@resource}] #{message}" if @resource && opts[:prefix]
|
129
|
+
message
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# This is a UI implementation that outputs color for various types
|
134
|
+
# of messages. This should only be used with a TTY that supports color,
|
135
|
+
# but is up to the user of the class to verify this is the case.
|
136
|
+
class Colored < Basic
|
137
|
+
# Terminal colors
|
138
|
+
COLORS = {
|
139
|
+
:clear => "\e[0m",
|
140
|
+
:red => "\e[31m",
|
141
|
+
:green => "\e[32m",
|
142
|
+
:yellow => "\e[33m"
|
143
|
+
}
|
144
|
+
|
145
|
+
# Mapping between type of message and the color to output
|
146
|
+
COLOR_MAP = {
|
147
|
+
:warn => COLORS[:yellow],
|
148
|
+
:error => COLORS[:red],
|
149
|
+
:success => COLORS[:green]
|
150
|
+
}
|
151
|
+
|
152
|
+
# This is called by `say` to format the message for output.
|
153
|
+
def format_message(type, message, opts=nil)
|
154
|
+
# Get the format of the message before adding color.
|
155
|
+
message = super
|
156
|
+
|
157
|
+
# Colorize the message if there is a color for this type of message,
|
158
|
+
# either specified by the options or via the default color map.
|
159
|
+
if opts.has_key?(:color)
|
160
|
+
color = COLORS[opts[:color]]
|
161
|
+
message = "#{color}#{message}#{COLORS[:clear]}"
|
162
|
+
else
|
163
|
+
message = "#{COLOR_MAP[type]}#{message}#{COLORS[:clear]}" if COLOR_MAP[type]
|
164
|
+
end
|
165
|
+
|
166
|
+
message
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Util
|
3
|
+
autoload :Busy, 'vagrant/util/busy'
|
4
|
+
autoload :Counter, 'vagrant/util/counter'
|
5
|
+
autoload :HashWithIndifferentAccess, 'vagrant/util/hash_with_indifferent_access'
|
6
|
+
autoload :Platform, 'vagrant/util/platform'
|
7
|
+
autoload :Retryable, 'vagrant/util/retryable'
|
8
|
+
autoload :SafeExec, 'vagrant/util/safe_exec'
|
9
|
+
autoload :StackedProcRunner, 'vagrant/util/stacked_proc_runner'
|
10
|
+
autoload :TemplateRenderer, 'vagrant/util/template_renderer'
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Util
|
3
|
+
module ANSIEscapeCodeRemover
|
4
|
+
# Removes ANSI escape code sequences from the text and returns
|
5
|
+
# it.
|
6
|
+
#
|
7
|
+
# This removes all the ANSI escape codes listed here along with
|
8
|
+
# the escape codes for VT100 terminals:
|
9
|
+
#
|
10
|
+
# http://ascii-table.com/ansi-escape-sequences.php
|
11
|
+
def remove_ansi_escape_codes(text)
|
12
|
+
# An array of regular expressions which match various kinds
|
13
|
+
# of escape sequences. I can't think of a better single regular
|
14
|
+
# expression or any faster way to do this.
|
15
|
+
matchers = [/\e\[\d*[ABCD]/, # Matches things like \e[4D
|
16
|
+
/\e\[(\d*;)?\d*[HF]/, # Matches \e[1;2H or \e[H
|
17
|
+
/\e\[(s|u|2J|K)/, # Matches \e[s, \e[2J, etc.
|
18
|
+
/\e\[=\d*[hl]/, # Matches \e[=24h
|
19
|
+
/\e\[\?[1-9][hl]/, # Matches \e[?2h
|
20
|
+
/\e\[20[hl]/, # Matches \e[20l]
|
21
|
+
/\e[DME78H]/, # Matches \eD, \eH, etc.
|
22
|
+
/\e\[[0-2]?[JK]/, # Matches \e[0J, \e[K, etc.
|
23
|
+
]
|
24
|
+
|
25
|
+
# Take each matcher and replace it with emptiness.
|
26
|
+
matchers.each do |matcher|
|
27
|
+
text.gsub!(matcher, "")
|
28
|
+
end
|
29
|
+
|
30
|
+
text
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Util
|
3
|
+
# Utility class which allows blocks of code to be marked as "busy"
|
4
|
+
# with a specified interrupt handler. During busy areas of code, it
|
5
|
+
# is often undesirable for SIGINTs to immediately kill the application.
|
6
|
+
# This class is a helper to cleanly register callbacks to handle this
|
7
|
+
# situation.
|
8
|
+
class Busy
|
9
|
+
@@registered = []
|
10
|
+
@@mutex = Mutex.new
|
11
|
+
|
12
|
+
class << self
|
13
|
+
# Mark a given block of code as a "busy" block of code, which will
|
14
|
+
# register a SIGINT handler for the duration of the block. When a
|
15
|
+
# SIGINT occurs, the `sig_callback` proc will be called. It is up
|
16
|
+
# to the callback to behave properly and exit the application.
|
17
|
+
def busy(sig_callback)
|
18
|
+
register(sig_callback)
|
19
|
+
yield
|
20
|
+
ensure
|
21
|
+
unregister(sig_callback)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Registers a SIGINT handler. This typically is called from {busy}.
|
25
|
+
# Callbacks are only registered once, so calling this multiple times
|
26
|
+
# with the same callback has no consequence.
|
27
|
+
def register(sig_callback)
|
28
|
+
@@mutex.synchronize do
|
29
|
+
registered << sig_callback
|
30
|
+
registered.uniq!
|
31
|
+
|
32
|
+
# Register the handler if this is our first callback.
|
33
|
+
Signal.trap("INT") { fire_callbacks } if registered.length == 1
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Unregisters a SIGINT handler.
|
38
|
+
def unregister(sig_callback)
|
39
|
+
@@mutex.synchronize do
|
40
|
+
registered.delete(sig_callback)
|
41
|
+
|
42
|
+
# Remove the signal trap if no more registered callbacks exist
|
43
|
+
Signal.trap("INT", "DEFAULT") if registered.empty?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Fires all the registered callbacks.
|
48
|
+
def fire_callbacks
|
49
|
+
registered.reverse.each { |r| r.call }
|
50
|
+
end
|
51
|
+
|
52
|
+
# Helper method to get access to the class variable. This is mostly
|
53
|
+
# exposed for tests. This shouldn't be mucked with directly, since it's
|
54
|
+
# structure may change at any time.
|
55
|
+
def registered; @@registered; end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'thread'
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module Util
|
5
|
+
# Atomic counter implementation. This is useful for incrementing
|
6
|
+
# a counter which is guaranteed to only be used once in its class.
|
7
|
+
module Counter
|
8
|
+
def get_and_update_counter(name=nil)
|
9
|
+
name ||= :global
|
10
|
+
|
11
|
+
mutex.synchronize do
|
12
|
+
@__counter ||= Hash.new(1)
|
13
|
+
result = @__counter[name]
|
14
|
+
@__counter[name] += 1
|
15
|
+
result
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def mutex
|
20
|
+
@__counter_mutex ||= Mutex.new
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|