vagrantup 0.8.10 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +77 -1
- data/Gemfile +0 -14
- data/LICENSE +1 -1
- data/bin/vagrant +47 -20
- data/config/default.rb +6 -14
- data/lib/vagrant/action/box/destroy.rb +7 -3
- data/lib/vagrant/action/box/download.rb +8 -8
- data/lib/vagrant/action/box/package.rb +2 -2
- data/lib/vagrant/action/box/unpackage.rb +13 -7
- data/lib/vagrant/action/box/verify.rb +5 -5
- data/lib/vagrant/action/builder.rb +23 -19
- data/lib/vagrant/action/builtin.rb +117 -79
- data/lib/vagrant/action/env/set.rb +7 -4
- data/lib/vagrant/action/environment.rb +3 -41
- data/lib/vagrant/action/general/package.rb +14 -29
- data/lib/vagrant/action/general/validate.rb +2 -2
- data/lib/vagrant/action/runner.rb +53 -0
- data/lib/vagrant/action/vm/boot.rb +9 -9
- data/lib/vagrant/action/vm/check_accessible.rb +2 -2
- data/lib/vagrant/action/vm/check_box.rb +10 -12
- data/lib/vagrant/action/vm/check_guest_additions.rb +8 -8
- data/lib/vagrant/action/vm/check_port_collisions.rb +85 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +4 -4
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +3 -11
- data/lib/vagrant/action/vm/clear_network_interfaces.rb +31 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +2 -11
- data/lib/vagrant/action/vm/customize.rb +19 -9
- data/lib/vagrant/action/vm/destroy.rb +4 -4
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +2 -12
- data/lib/vagrant/action/vm/discard_state.rb +4 -4
- data/lib/vagrant/action/vm/export.rb +13 -8
- data/lib/vagrant/action/vm/forward_ports.rb +55 -102
- data/lib/vagrant/action/vm/halt.rb +9 -6
- data/lib/vagrant/action/vm/host_name.rb +4 -4
- data/lib/vagrant/action/vm/import.rb +19 -10
- data/lib/vagrant/action/vm/match_mac_address.rb +4 -9
- data/lib/vagrant/action/vm/network.rb +300 -94
- data/lib/vagrant/action/vm/nfs.rb +41 -26
- data/lib/vagrant/action/vm/package.rb +1 -1
- data/lib/vagrant/action/vm/package_vagrantfile.rb +5 -2
- data/lib/vagrant/action/vm/provision.rb +42 -13
- data/lib/vagrant/action/vm/provisioner_cleanup.rb +2 -2
- data/lib/vagrant/action/vm/{clear_nfs_exports.rb → prune_nfs_exports.rb} +7 -7
- data/lib/vagrant/action/vm/resume.rb +4 -4
- data/lib/vagrant/action/vm/setup_package_files.rb +54 -0
- data/lib/vagrant/action/vm/share_folders.rb +63 -39
- data/lib/vagrant/action/vm/suspend.rb +4 -4
- data/lib/vagrant/action/warden.rb +13 -6
- data/lib/vagrant/action.rb +45 -123
- data/lib/vagrant/box.rb +9 -55
- data/lib/vagrant/box_collection.rb +22 -17
- data/lib/vagrant/cli.rb +62 -47
- data/lib/vagrant/command/base.rb +135 -90
- data/lib/vagrant/command/box.rb +46 -21
- data/lib/vagrant/command/box_add.rb +33 -0
- data/lib/vagrant/command/box_list.rb +25 -0
- data/lib/vagrant/command/box_remove.rb +23 -0
- data/lib/vagrant/command/box_repackage.rb +23 -0
- data/lib/vagrant/command/destroy.rb +16 -5
- data/lib/vagrant/command/halt.rb +25 -7
- data/lib/vagrant/command/init.rb +30 -7
- data/lib/vagrant/command/package.rb +49 -18
- data/lib/vagrant/command/provision.rb +22 -9
- data/lib/vagrant/command/reload.rb +18 -5
- data/lib/vagrant/command/resume.rb +18 -5
- data/lib/vagrant/command/ssh.rb +69 -31
- data/lib/vagrant/command/ssh_config.rb +37 -22
- data/lib/vagrant/command/status.rb +22 -20
- data/lib/vagrant/command/suspend.rb +18 -5
- data/lib/vagrant/command/up.rb +41 -8
- data/lib/vagrant/command.rb +18 -20
- data/lib/vagrant/communication/base.rb +56 -0
- data/lib/vagrant/communication/ssh.rb +200 -0
- data/lib/vagrant/communication.rb +7 -0
- data/lib/vagrant/config/base.rb +18 -26
- data/lib/vagrant/config/container.rb +37 -0
- data/lib/vagrant/config/error_recorder.rb +1 -1
- data/lib/vagrant/config/loader.rb +125 -0
- data/lib/vagrant/config/nfs.rb +1 -3
- data/lib/vagrant/config/package.rb +1 -3
- data/lib/vagrant/config/ssh.rb +31 -16
- data/lib/vagrant/config/top.rb +36 -25
- data/lib/vagrant/config/vagrant.rb +2 -5
- data/lib/vagrant/config/vm/provisioner.rb +16 -20
- data/lib/vagrant/config/vm/sub_vm.rb +1 -1
- data/lib/vagrant/config/vm.rb +115 -56
- data/lib/vagrant/config.rb +29 -103
- data/lib/vagrant/data_store.rb +23 -15
- data/lib/vagrant/downloaders/base.rb +7 -5
- data/lib/vagrant/downloaders/file.rb +4 -4
- data/lib/vagrant/downloaders/http.rb +4 -5
- data/lib/vagrant/driver/virtualbox.rb +121 -0
- data/lib/vagrant/driver/virtualbox_4_0.rb +411 -0
- data/lib/vagrant/driver/virtualbox_4_1.rb +411 -0
- data/lib/vagrant/driver/virtualbox_base.rb +284 -0
- data/lib/vagrant/driver.rb +7 -0
- data/lib/vagrant/environment.rb +221 -240
- data/lib/vagrant/errors.rb +74 -25
- data/lib/vagrant/guest/arch.rb +48 -0
- data/lib/vagrant/{systems → guest}/base.rb +30 -18
- data/lib/vagrant/guest/debian.rb +61 -0
- data/lib/vagrant/{systems → guest}/freebsd.rb +11 -18
- data/lib/vagrant/guest/gentoo.rb +32 -0
- data/lib/vagrant/{systems → guest}/linux/config.rb +2 -4
- data/lib/vagrant/guest/linux/error.rb +9 -0
- data/lib/vagrant/guest/linux.rb +78 -0
- data/lib/vagrant/guest/redhat.rb +66 -0
- data/lib/vagrant/guest/solaris.rb +114 -0
- data/lib/vagrant/{systems → guest}/suse.rb +2 -2
- data/lib/vagrant/guest/ubuntu.rb +23 -0
- data/lib/vagrant/guest.rb +16 -0
- data/lib/vagrant/hosts/arch.rb +7 -3
- data/lib/vagrant/hosts/base.rb +36 -46
- data/lib/vagrant/hosts/bsd.rb +53 -16
- data/lib/vagrant/hosts/fedora.rb +14 -0
- data/lib/vagrant/hosts/freebsd.rb +6 -36
- data/lib/vagrant/hosts/linux.rb +45 -20
- data/lib/vagrant/hosts/windows.rb +16 -0
- data/lib/vagrant/hosts.rb +23 -6
- data/lib/vagrant/provisioners/base.rb +11 -34
- data/lib/vagrant/provisioners/chef.rb +30 -26
- data/lib/vagrant/provisioners/chef_client.rb +37 -23
- data/lib/vagrant/provisioners/chef_solo.rb +61 -16
- data/lib/vagrant/provisioners/puppet.rb +70 -38
- data/lib/vagrant/provisioners/puppet_server.rb +12 -13
- data/lib/vagrant/provisioners/shell.rb +24 -24
- data/lib/vagrant/provisioners.rb +10 -7
- data/lib/vagrant/registry.rb +49 -0
- data/lib/vagrant/ssh.rb +82 -153
- data/lib/vagrant/ui.rb +118 -50
- data/lib/vagrant/util/busy.rb +1 -1
- data/lib/vagrant/util/file_mode.rb +12 -0
- data/lib/vagrant/util/network_ip.rb +28 -0
- data/lib/vagrant/util/platform.rb +1 -0
- data/lib/vagrant/util/subprocess.rb +227 -0
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +111 -97
- data/lib/vagrant.rb +132 -5
- data/tasks/acceptance.rake +3 -3
- data/tasks/test.rake +7 -2
- data/templates/commands/init/Vagrantfile.erb +11 -4
- data/templates/{ssh_config.erb → commands/ssh_config/config.erb} +0 -0
- data/templates/guests/arch/network_dhcp.erb +7 -0
- data/templates/guests/arch/network_static.erb +7 -0
- data/templates/guests/debian/network_dhcp.erb +6 -0
- data/templates/guests/debian/network_static.erb +7 -0
- data/templates/guests/gentoo/network_dhcp.erb +4 -0
- data/templates/guests/gentoo/network_static.erb +4 -0
- data/templates/guests/redhat/network_dhcp.erb +6 -0
- data/templates/guests/redhat/network_static.erb +7 -0
- data/templates/locales/en.yml +241 -122
- data/templates/{chef_server_client.erb → provisioners/chef_client/client.erb} +0 -0
- data/templates/{chef_solo_solo.erb → provisioners/chef_solo/solo.erb} +0 -0
- data/test/acceptance/base.rb +10 -10
- data/test/acceptance/box_test.rb +28 -6
- data/test/acceptance/destroy_test.rb +1 -1
- data/test/acceptance/halt_test.rb +4 -4
- data/test/acceptance/init_test.rb +3 -3
- data/test/acceptance/networking/host_only_test.rb +37 -0
- data/test/acceptance/networking/port_forward_test.rb +125 -0
- data/test/acceptance/package_test.rb +46 -0
- data/test/acceptance/provisioning/basic_test.rb +61 -0
- data/test/acceptance/provisioning/chef_solo_test.rb +37 -0
- data/test/acceptance/provisioning/shell_test.rb +53 -0
- data/test/acceptance/resume_test.rb +1 -1
- data/test/acceptance/skeletons/chef_solo_basic/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/skeletons/chef_solo_json/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_json/cookbooks/basic/recipes/default.rb +6 -0
- data/test/acceptance/skeletons/provisioner_multi/README.md +3 -0
- data/test/acceptance/skeletons/provisioner_multi/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/ssh_test.rb +7 -2
- data/test/acceptance/support/config.rb +1 -1
- data/test/acceptance/support/isolated_environment.rb +41 -150
- data/test/acceptance/support/matchers/match_output.rb +1 -1
- data/test/acceptance/support/matchers/succeed.rb +14 -0
- data/test/acceptance/support/network_tests.rb +29 -0
- data/test/acceptance/support/output.rb +9 -1
- data/test/acceptance/support/shared/base_context.rb +16 -9
- data/test/acceptance/support/shared/command_examples.rb +4 -4
- data/test/acceptance/suspend_test.rb +1 -1
- data/test/acceptance/up_basic_test.rb +26 -7
- data/test/acceptance/up_with_box_url.rb +1 -1
- data/test/acceptance/vagrant_test.rb +1 -1
- data/test/acceptance/version_test.rb +0 -5
- data/test/support/isolated_environment.rb +46 -0
- data/test/{acceptance/support → support}/tempdir.rb +0 -0
- data/test/unit/base.rb +21 -0
- data/test/unit/support/isolated_environment.rb +39 -0
- data/test/unit/support/shared/base_context.rb +30 -0
- data/test/unit/vagrant/action/builder_test.rb +126 -177
- data/test/unit/vagrant/action/environment_test.rb +10 -21
- data/test/unit/vagrant/action/runner_test.rb +65 -0
- data/test/unit/vagrant/action/warden_test.rb +64 -97
- data/test/unit/vagrant/box_collection_test.rb +44 -33
- data/test/unit/vagrant/box_test.rb +25 -65
- data/test/unit/vagrant/command/base_test.rb +141 -14
- data/test/unit/vagrant/config/base_test.rb +16 -43
- data/test/unit/vagrant/config/loader_test.rb +79 -0
- data/test/unit/vagrant/config/top_test.rb +69 -0
- data/test/unit/vagrant/config/vm_test.rb +62 -47
- data/test/unit/vagrant/config_test.rb +16 -151
- data/test/unit/vagrant/data_store_test.rb +43 -61
- data/test/unit/vagrant/downloaders/base_test.rb +12 -22
- data/test/unit/vagrant/downloaders/file_test.rb +58 -31
- data/test/unit/vagrant/downloaders/http_test.rb +12 -86
- data/test/unit/vagrant/environment_test.rb +107 -536
- data/test/unit/vagrant/hosts_test.rb +36 -0
- data/test/unit/vagrant/registry_test.rb +56 -0
- data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
- data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +23 -24
- data/test/unit/vagrant/util/network_ip_test.rb +17 -0
- data/test/unit/vagrant/util/retryable_test.rb +90 -34
- data/test/unit/vagrant_test.rb +27 -0
- data/test/{unit → unit_legacy}/locales/en.yml +0 -0
- data/test/{unit → unit_legacy}/test_helper.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/destroy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/download_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/unpackage_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/verify_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/env/set_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/general/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/general/validate_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/boot_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_accessible_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_box_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_guest_additions_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clean_machine_folder_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_forwarded_ports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_nfs_exports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_shared_folders_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/customize_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/discard_state_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/export_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/halt_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/host_name_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/import_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/match_mac_address_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/modify_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/network_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/package_vagrantfile_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/provision_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/provisioner_cleanup_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/resume_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/share_folders_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/suspend_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action_test.rb +0 -0
- data/test/unit_legacy/vagrant/box_collection_test.rb +45 -0
- data/test/unit_legacy/vagrant/box_test.rb +74 -0
- data/test/{unit → unit_legacy}/vagrant/cli_test.rb +0 -0
- data/test/unit_legacy/vagrant/command/base_test.rb +23 -0
- data/test/{unit → unit_legacy}/vagrant/command/group_base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/init_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/package_test.rb +0 -0
- data/test/unit_legacy/vagrant/config/base_test.rb +52 -0
- data/test/{unit → unit_legacy}/vagrant/config/error_recorder_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/ssh_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/vagrant_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/vm/provisioner_test.rb +0 -0
- data/test/unit_legacy/vagrant/config/vm_test.rb +47 -0
- data/test/unit_legacy/vagrant/config_test.rb +148 -0
- data/test/unit_legacy/vagrant/downloaders/http_test.rb +93 -0
- data/test/unit_legacy/vagrant/environment_test.rb +539 -0
- data/test/{unit → unit_legacy}/vagrant/errors_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/bsd_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/linux_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/plugin_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_client_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_solo_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_server_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/shell_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/ssh/session_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/ssh_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/systems/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/systems/linux_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/busy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/counter_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/platform_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/stacked_proc_runner_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/template_renderer_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/vm_test.rb +0 -0
- data/vagrant.gemspec +7 -9
- metadata +183 -179
- data/keys/vagrant.ppk +0 -26
- data/lib/vagrant/action/box.rb +0 -11
- data/lib/vagrant/action/env.rb +0 -7
- data/lib/vagrant/action/general.rb +0 -8
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +0 -28
- data/lib/vagrant/action/vm/modify.rb +0 -37
- data/lib/vagrant/action/vm/nfs_helpers.rb +0 -11
- data/lib/vagrant/action/vm.rb +0 -34
- data/lib/vagrant/command/group_base.rb +0 -107
- data/lib/vagrant/command/helpers.rb +0 -33
- data/lib/vagrant/command/named_base.rb +0 -14
- data/lib/vagrant/command/upgrade_to_060.rb +0 -45
- data/lib/vagrant/command/version.rb +0 -13
- data/lib/vagrant/ssh/session.rb +0 -136
- data/lib/vagrant/systems/arch.rb +0 -34
- data/lib/vagrant/systems/debian.rb +0 -36
- data/lib/vagrant/systems/gentoo.rb +0 -27
- data/lib/vagrant/systems/linux/error.rb +0 -9
- data/lib/vagrant/systems/linux.rb +0 -82
- data/lib/vagrant/systems/redhat.rb +0 -48
- data/lib/vagrant/systems/solaris.rb +0 -113
- data/lib/vagrant/systems/ubuntu.rb +0 -17
- data/lib/vagrant/systems.rb +0 -13
- data/templates/network_entry_arch.erb +0 -9
- data/templates/network_entry_debian.erb +0 -8
- data/templates/network_entry_gentoo.erb +0 -5
- data/templates/network_entry_redhat.erb +0 -9
- data/test/unit/vagrant/ui_test.rb +0 -29
@@ -0,0 +1,539 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "pathname"
|
3
|
+
require "tempfile"
|
4
|
+
|
5
|
+
class EnvironmentTest < Test::Unit::TestCase
|
6
|
+
setup do
|
7
|
+
@klass = Vagrant::Environment
|
8
|
+
|
9
|
+
clean_paths
|
10
|
+
end
|
11
|
+
|
12
|
+
context "class method check virtualbox version" do
|
13
|
+
setup do
|
14
|
+
VirtualBox.stubs(:version).returns("4.1.0")
|
15
|
+
end
|
16
|
+
|
17
|
+
should "not error and exit if everything is good" do
|
18
|
+
VirtualBox.expects(:version).returns("4.1.0")
|
19
|
+
assert_nothing_raised { @klass.check_virtualbox! }
|
20
|
+
end
|
21
|
+
|
22
|
+
should "error and exit if VirtualBox is not installed or detected" do
|
23
|
+
VirtualBox.expects(:version).returns(nil)
|
24
|
+
assert_raises(Vagrant::Errors::VirtualBoxNotDetected) { @klass.check_virtualbox! }
|
25
|
+
end
|
26
|
+
|
27
|
+
should "error and exit if VirtualBox is lower than version 4.0" do
|
28
|
+
version = "3.2.12r1041"
|
29
|
+
VirtualBox.expects(:version).returns(version)
|
30
|
+
assert_raises(Vagrant::Errors::VirtualBoxInvalidVersion) { @klass.check_virtualbox! }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "initialization" do
|
35
|
+
should "set the cwd if given" do
|
36
|
+
cwd = "foobarbaz"
|
37
|
+
env = @klass.new(:cwd => cwd)
|
38
|
+
assert_equal Pathname.new(cwd), env.cwd
|
39
|
+
end
|
40
|
+
|
41
|
+
should "default to pwd if cwd is nil" do
|
42
|
+
env = @klass.new
|
43
|
+
assert_equal Pathname.new(Dir.pwd), env.cwd
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "paths" do
|
48
|
+
setup do
|
49
|
+
@env = vagrant_env
|
50
|
+
end
|
51
|
+
|
52
|
+
context "dotfile path" do
|
53
|
+
should "build up the dotfile out of the root path and the dotfile name" do
|
54
|
+
assert_equal @env.root_path.join(@env.config.vagrant.dotfile_name), @env.dotfile_path
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "home path" do
|
59
|
+
setup do
|
60
|
+
@env = @klass.new
|
61
|
+
|
62
|
+
# Make a fake home directory for helping with tests
|
63
|
+
@home_path = tmp_path.join("home")
|
64
|
+
ENV["HOME"] = @home_path.to_s
|
65
|
+
FileUtils.rm_rf(@home_path)
|
66
|
+
FileUtils.mkdir_p(@home_path)
|
67
|
+
end
|
68
|
+
|
69
|
+
should "return the home path if it loaded" do
|
70
|
+
ENV["VAGRANT_HOME"] = nil
|
71
|
+
|
72
|
+
expected = Pathname.new(File.expand_path(@klass::DEFAULT_HOME))
|
73
|
+
assert_equal expected, @env.home_path
|
74
|
+
end
|
75
|
+
|
76
|
+
should "return the home path set by the environmental variable" do
|
77
|
+
ENV["VAGRANT_HOME"] = "foo"
|
78
|
+
|
79
|
+
expected = Pathname.new(File.expand_path(ENV["VAGRANT_HOME"]))
|
80
|
+
assert_equal expected, @env.home_path
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "temp path" do
|
85
|
+
should "return the home path joined with 'tmp'" do
|
86
|
+
assert_equal @env.home_path.join("tmp"), @env.tmp_path
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "boxes path" do
|
91
|
+
should "return the home path joined with 'tmp'" do
|
92
|
+
assert_equal @env.home_path.join("boxes"), @env.boxes_path
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context "resource" do
|
98
|
+
setup do
|
99
|
+
@env = vagrant_env
|
100
|
+
end
|
101
|
+
|
102
|
+
should "return 'vagrant' as a default" do
|
103
|
+
assert_equal 'vagrant', @env.resource
|
104
|
+
end
|
105
|
+
|
106
|
+
should "return the VM name if it is specified" do
|
107
|
+
@env.stubs(:vm).returns(mock("vm", :name => "foo"))
|
108
|
+
assert_equal "foo", @env.resource
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "primary VM helper" do
|
113
|
+
should "return the first VM if not multivm" do
|
114
|
+
env = vagrant_env
|
115
|
+
assert_equal env.vms[@klass::DEFAULT_VM], env.primary_vm
|
116
|
+
end
|
117
|
+
|
118
|
+
should "call and return the primary VM from the parent if has one" do
|
119
|
+
env = vagrant_env(vagrantfile(<<-vf))
|
120
|
+
config.vm.define(:web, :primary => true) do; end
|
121
|
+
config.vm.define :db do; end
|
122
|
+
vf
|
123
|
+
|
124
|
+
assert_equal :web, env.primary_vm.name
|
125
|
+
end
|
126
|
+
|
127
|
+
should "return nil if no VM is marked as primary" do
|
128
|
+
env = vagrant_env(vagrantfile(<<-vf))
|
129
|
+
config.vm.define :web
|
130
|
+
config.vm.define :db
|
131
|
+
config.vm.define :utility
|
132
|
+
vf
|
133
|
+
|
134
|
+
assert env.primary_vm.nil?
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context "multivm? helper" do
|
139
|
+
should "return true if VM length greater than 1" do
|
140
|
+
env = vagrant_env(vagrantfile(<<-vf))
|
141
|
+
config.vm.define :web
|
142
|
+
config.vm.define :db
|
143
|
+
vf
|
144
|
+
|
145
|
+
assert env.multivm?
|
146
|
+
end
|
147
|
+
|
148
|
+
should "return true if VM length is 1 and a sub-VM is defined" do
|
149
|
+
env = vagrant_env(vagrantfile(<<-vf))
|
150
|
+
config.vm.define :web
|
151
|
+
vf
|
152
|
+
|
153
|
+
assert env.multivm?
|
154
|
+
end
|
155
|
+
|
156
|
+
should "return false if only default VM exists" do
|
157
|
+
assert !vagrant_env.multivm?
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
context "local data" do
|
162
|
+
should "lazy load the data store only once" do
|
163
|
+
result = { :foo => :bar }
|
164
|
+
Vagrant::DataStore.expects(:new).returns(result).once
|
165
|
+
env = vagrant_env
|
166
|
+
assert_equal result, env.local_data
|
167
|
+
assert_equal result, env.local_data
|
168
|
+
assert_equal result, env.local_data
|
169
|
+
end
|
170
|
+
|
171
|
+
should "return the parent's local data if a parent exists" do
|
172
|
+
env = vagrant_env(vagrantfile(<<-vf))
|
173
|
+
config.vm.define :web
|
174
|
+
config.vm.define :db
|
175
|
+
vf
|
176
|
+
|
177
|
+
env.local_data[:foo] = :bar
|
178
|
+
|
179
|
+
Vagrant::DataStore.expects(:new).never
|
180
|
+
assert_equal :bar, env.vms[:web].env.local_data[:foo]
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
context "accessing host" do
|
185
|
+
should "load the host once" do
|
186
|
+
env = @klass.new(:cwd => vagrantfile)
|
187
|
+
result = mock("result")
|
188
|
+
Vagrant::Hosts::Base.expects(:load).with(env, env.config.vagrant.host).once.returns(result)
|
189
|
+
assert_equal result, env.host
|
190
|
+
assert_equal result, env.host
|
191
|
+
assert_equal result, env.host
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
context "accessing actions" do
|
196
|
+
should "initialize the Action object with the given environment" do
|
197
|
+
env = @klass.new(:cwd => vagrant_app)
|
198
|
+
result = mock("result")
|
199
|
+
Vagrant::Action.expects(:new).with(env).returns(result).once
|
200
|
+
assert_equal result, env.actions
|
201
|
+
assert_equal result, env.actions
|
202
|
+
assert_equal result, env.actions
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
context "global data" do
|
207
|
+
should "lazy load the data store only once" do
|
208
|
+
env = vagrant_env
|
209
|
+
store = env.global_data
|
210
|
+
|
211
|
+
assert env.global_data.equal?(store)
|
212
|
+
assert env.global_data.equal?(store)
|
213
|
+
assert env.global_data.equal?(store)
|
214
|
+
end
|
215
|
+
|
216
|
+
should "return the parent's global data if a parent exists" do
|
217
|
+
env = vagrant_env(vagrantfile(<<-vf))
|
218
|
+
config.vm.define :web
|
219
|
+
config.vm.define :db
|
220
|
+
vf
|
221
|
+
|
222
|
+
result = env.global_data
|
223
|
+
assert env.vms[:web].env.global_data.equal?(result)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
context "loading the root path" do
|
228
|
+
should "should walk the parent directories looking for rootfile" do
|
229
|
+
paths = [Pathname.new("/foo/bar/baz"),
|
230
|
+
Pathname.new("/foo/bar"),
|
231
|
+
Pathname.new("/foo"),
|
232
|
+
Pathname.new("/")
|
233
|
+
]
|
234
|
+
|
235
|
+
rootfile = "Foo"
|
236
|
+
|
237
|
+
search_seq = sequence("search_seq")
|
238
|
+
paths.each do |path|
|
239
|
+
File.expects(:exist?).with(path.join(rootfile).to_s).returns(false).in_sequence(search_seq)
|
240
|
+
File.expects(:exist?).with(path).returns(true).in_sequence(search_seq) if !path.root?
|
241
|
+
end
|
242
|
+
|
243
|
+
assert !@klass.new(:cwd => paths.first, :vagrantfile_name => rootfile).root_path
|
244
|
+
end
|
245
|
+
|
246
|
+
should "should set the path for the rootfile" do
|
247
|
+
rootfile = "Foo"
|
248
|
+
path = Pathname.new(File.expand_path("/foo"))
|
249
|
+
File.expects(:exist?).with(path.join(rootfile).to_s).returns(true)
|
250
|
+
|
251
|
+
assert_equal path, @klass.new(:cwd => path, :vagrantfile_name => rootfile).root_path
|
252
|
+
end
|
253
|
+
|
254
|
+
should "not infinite loop on relative paths" do
|
255
|
+
assert @klass.new(:cwd => "../test").root_path.nil?
|
256
|
+
end
|
257
|
+
|
258
|
+
should "only load the root path once" do
|
259
|
+
rootfile = "foo"
|
260
|
+
env = @klass.new(:vagrantfile_name => rootfile)
|
261
|
+
File.expects(:exist?).with(env.cwd.join(rootfile).to_s).returns(true).once
|
262
|
+
|
263
|
+
assert_equal env.cwd, env.root_path
|
264
|
+
assert_equal env.cwd, env.root_path
|
265
|
+
assert_equal env.cwd, env.root_path
|
266
|
+
end
|
267
|
+
|
268
|
+
should "only load the root path once even if nil" do
|
269
|
+
File.stubs(:exist?).returns(false)
|
270
|
+
|
271
|
+
env = @klass.new
|
272
|
+
assert env.root_path.nil?
|
273
|
+
assert env.root_path.nil?
|
274
|
+
assert env.root_path.nil?
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
context "locking" do
|
279
|
+
setup do
|
280
|
+
@instance = @klass.new(:lock_path => Tempfile.new('vagrant-test').path)
|
281
|
+
end
|
282
|
+
|
283
|
+
should "allow nesting locks" do
|
284
|
+
assert_nothing_raised do
|
285
|
+
@instance.lock do
|
286
|
+
@instance.lock do
|
287
|
+
# Nothing
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
should "raise an exception if an environment already has a lock" do
|
294
|
+
@another = @klass.new(:lock_path => @instance.lock_path)
|
295
|
+
|
296
|
+
# Create first locked thread which should succeed
|
297
|
+
first = Thread.new do
|
298
|
+
begin
|
299
|
+
@instance.lock do
|
300
|
+
Thread.current[:locked] = true
|
301
|
+
loop { sleep 1000 }
|
302
|
+
end
|
303
|
+
rescue Vagrant::Errors::EnvironmentLockedError
|
304
|
+
Thread.current[:locked] = false
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
# Wait until the first thread has acquired the lock
|
309
|
+
loop do
|
310
|
+
break if first[:locked] || !first.alive?
|
311
|
+
Thread.pass
|
312
|
+
end
|
313
|
+
|
314
|
+
# Verify that the fist got the lock
|
315
|
+
assert first[:locked]
|
316
|
+
|
317
|
+
# Create second locked thread which should fail
|
318
|
+
second = Thread.new do
|
319
|
+
begin
|
320
|
+
@another.lock do
|
321
|
+
Thread.current[:error] = false
|
322
|
+
end
|
323
|
+
rescue Vagrant::Errors::EnvironmentLockedError
|
324
|
+
Thread.current[:error] = true
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
# Wait for the second to end and verify it failed
|
329
|
+
second.join
|
330
|
+
assert second[:error]
|
331
|
+
|
332
|
+
# Make sure both threads are killed
|
333
|
+
first.kill
|
334
|
+
second.kill
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
context "accessing the configuration" do
|
339
|
+
should "load the environment if its not already loaded" do
|
340
|
+
env = @klass.new(:cwd => vagrantfile)
|
341
|
+
env.expects(:load!).once
|
342
|
+
env.config
|
343
|
+
end
|
344
|
+
|
345
|
+
should "not load the environment if its already loaded" do
|
346
|
+
env = vagrant_env
|
347
|
+
env.expects(:load!).never
|
348
|
+
env.config
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
context "accessing the box collection" do
|
353
|
+
should "create a box collection representing the environment" do
|
354
|
+
env = vagrant_env
|
355
|
+
assert env.boxes.is_a?(Vagrant::BoxCollection)
|
356
|
+
assert_equal env, env.boxes.env
|
357
|
+
end
|
358
|
+
|
359
|
+
should "not load the environment if its already loaded" do
|
360
|
+
env = vagrant_env
|
361
|
+
env.expects(:load!).never
|
362
|
+
env.boxes
|
363
|
+
end
|
364
|
+
|
365
|
+
should "return the parent's box collection if it has one" do
|
366
|
+
env = vagrant_env(vagrantfile(<<-vf))
|
367
|
+
config.vm.define :web
|
368
|
+
config.vm.define :db
|
369
|
+
vf
|
370
|
+
|
371
|
+
assert env.vms[:web].env.boxes.equal?(env.boxes)
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
context "accessing the VMs hash" do
|
376
|
+
should "load the environment if its not already loaded" do
|
377
|
+
env = @klass.new(:cwd => vagrantfile)
|
378
|
+
assert !env.loaded?
|
379
|
+
env.vms
|
380
|
+
assert env.loaded?
|
381
|
+
end
|
382
|
+
|
383
|
+
should "not load the environment if its already loaded" do
|
384
|
+
env = vagrant_env
|
385
|
+
env.expects(:load!).never
|
386
|
+
env.vms
|
387
|
+
end
|
388
|
+
|
389
|
+
should "return the parent's VMs hash if it has one" do
|
390
|
+
env = vagrant_env(vagrantfile(<<-vf))
|
391
|
+
config.vm.define :web
|
392
|
+
config.vm.define :db
|
393
|
+
vf
|
394
|
+
|
395
|
+
assert env.vms[:web].env.vms.equal?(env.vms)
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
context "loading" do
|
400
|
+
context "overall load method" do
|
401
|
+
should "load! should call proper sequence and return itself" do
|
402
|
+
env = @klass.new(:cwd => vagrantfile)
|
403
|
+
call_seq = sequence("call_sequence")
|
404
|
+
@klass.expects(:check_virtualbox!).once.in_sequence(call_seq)
|
405
|
+
env.expects(:load_config!).once.in_sequence(call_seq)
|
406
|
+
assert_equal env, env.load!
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
context "loading config" do
|
411
|
+
setup do
|
412
|
+
clean_paths
|
413
|
+
@env = @klass.new(:cwd => vagrantfile)
|
414
|
+
end
|
415
|
+
|
416
|
+
def create_box_vagrantfile
|
417
|
+
vagrantfile(vagrant_box("box"), <<-FILE)
|
418
|
+
config.package.name = "box.box"
|
419
|
+
config.vm.base_mac = "set"
|
420
|
+
FILE
|
421
|
+
end
|
422
|
+
|
423
|
+
def create_home_vagrantfile
|
424
|
+
vagrantfile(home_path, 'config.package.name = "home.box"')
|
425
|
+
end
|
426
|
+
|
427
|
+
def create_root_vagrantfile
|
428
|
+
vagrantfile(@env.root_path, 'config.package.name = "root.box"')
|
429
|
+
end
|
430
|
+
|
431
|
+
should "load from the project root" do
|
432
|
+
assert_equal "package.box", @env.config.package.name
|
433
|
+
end
|
434
|
+
|
435
|
+
should "load from box if specified" do
|
436
|
+
create_box_vagrantfile
|
437
|
+
vagrantfile(@env.root_path, "config.vm.box = 'box'")
|
438
|
+
|
439
|
+
assert_equal "box.box", @env.primary_vm.env.config.package.name
|
440
|
+
end
|
441
|
+
|
442
|
+
should "load from home path if exists" do
|
443
|
+
create_home_vagrantfile
|
444
|
+
assert_equal "home.box", @env.config.package.name
|
445
|
+
end
|
446
|
+
|
447
|
+
should "load from root path" do
|
448
|
+
create_home_vagrantfile
|
449
|
+
create_root_vagrantfile
|
450
|
+
assert_equal "root.box", @env.config.package.name
|
451
|
+
end
|
452
|
+
|
453
|
+
should "load from a sub-vm configuration if environment represents a VM" do
|
454
|
+
create_home_vagrantfile
|
455
|
+
create_box_vagrantfile
|
456
|
+
vagrantfile(@env.root_path, <<-vf)
|
457
|
+
config.package.name = "root.box"
|
458
|
+
config.vm.define :web do |web|
|
459
|
+
web.vm.box = "box"
|
460
|
+
web.package.name = "web.box"
|
461
|
+
end
|
462
|
+
vf
|
463
|
+
|
464
|
+
assert_equal "root.box", @env.config.package.name
|
465
|
+
assert_equal "web.box", @env.vms[:web].env.config.package.name
|
466
|
+
assert_equal "set", @env.vms[:web].env.config.vm.base_mac
|
467
|
+
end
|
468
|
+
|
469
|
+
should "be able to reload config" do
|
470
|
+
vagrantfile(@env.root_path, "config.vm.box = 'box'")
|
471
|
+
|
472
|
+
# First load the config normally
|
473
|
+
@env.load_config!
|
474
|
+
assert_equal "box", @env.config.vm.box
|
475
|
+
assert_not_equal "set", @env.config.vm.base_mac
|
476
|
+
|
477
|
+
# Modify the Vagrantfile and reload it, then verify new results
|
478
|
+
# are available
|
479
|
+
vagrantfile(@env.root_path, "config.vm.base_mac = 'set'")
|
480
|
+
@env.reload_config!
|
481
|
+
assert_equal "set", @env.config.vm.base_mac
|
482
|
+
end
|
483
|
+
end
|
484
|
+
|
485
|
+
context "loading home directory" do
|
486
|
+
setup do
|
487
|
+
@env = vagrant_env
|
488
|
+
|
489
|
+
File.stubs(:directory?).returns(true)
|
490
|
+
FileUtils.stubs(:mkdir_p)
|
491
|
+
end
|
492
|
+
|
493
|
+
should "create each directory if it doesn't exist" do
|
494
|
+
create_seq = sequence("create_seq")
|
495
|
+
File.stubs(:directory?).returns(false)
|
496
|
+
@klass::HOME_SUBDIRS.each do |subdir|
|
497
|
+
FileUtils.expects(:mkdir_p).with(@env.home_path.join(subdir)).in_sequence(create_seq)
|
498
|
+
end
|
499
|
+
|
500
|
+
@env.load_home_directory!
|
501
|
+
end
|
502
|
+
|
503
|
+
should "not create directories if they exist" do
|
504
|
+
File.stubs(:directory?).returns(true)
|
505
|
+
FileUtils.expects(:mkdir_p).never
|
506
|
+
@env.load_home_directory!
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
510
|
+
context "loading the UUID out from the persisted dotfile" do
|
511
|
+
setup do
|
512
|
+
@env = vagrant_env
|
513
|
+
end
|
514
|
+
|
515
|
+
should "load all the VMs from the dotfile" do
|
516
|
+
@env.local_data[:active] = { "foo" => "bar", "bar" => "baz" }
|
517
|
+
|
518
|
+
results = {}
|
519
|
+
@env.local_data[:active].each do |key, value|
|
520
|
+
vm = mock("vm#{key}")
|
521
|
+
Vagrant::VM.expects(:find).with(value, @env, key.to_sym).returns(vm)
|
522
|
+
results[key.to_sym] = vm
|
523
|
+
end
|
524
|
+
|
525
|
+
returned = @env.load_vms!
|
526
|
+
|
527
|
+
results.each do |key, value|
|
528
|
+
assert_equal value, returned[key]
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
should "uuid should be nil if local data contains nothing" do
|
533
|
+
assert @env.local_data.empty? # sanity
|
534
|
+
@env.load_vms!
|
535
|
+
assert_nil @env.vm
|
536
|
+
end
|
537
|
+
end
|
538
|
+
end
|
539
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/vagrant.gemspec
CHANGED
@@ -15,24 +15,22 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rubyforge_project = "vagrant"
|
16
16
|
|
17
17
|
s.add_dependency "archive-tar-minitar", "= 0.5.2"
|
18
|
+
s.add_dependency "childprocess", "~> 0.3.0"
|
18
19
|
s.add_dependency "erubis", "~> 2.7.0"
|
19
20
|
s.add_dependency "json", "~> 1.5.1"
|
20
|
-
s.add_dependency "
|
21
|
+
s.add_dependency "log4r", "~> 1.1.9"
|
22
|
+
s.add_dependency "net-ssh", "~> 2.2.2"
|
21
23
|
s.add_dependency "net-scp", "~> 1.0.4"
|
22
24
|
s.add_dependency "i18n", "~> 0.6.0"
|
23
|
-
s.add_dependency "thor", "~> 0.14.6"
|
24
|
-
s.add_dependency "virtualbox", "~> 0.9.1"
|
25
25
|
|
26
26
|
s.add_development_dependency "rake"
|
27
27
|
s.add_development_dependency "contest", ">= 0.1.2"
|
28
|
-
s.add_development_dependency "log4r", "~> 1.1.9"
|
29
28
|
s.add_development_dependency "minitest", "~> 2.5.1"
|
30
29
|
s.add_development_dependency "mocha"
|
31
|
-
s.add_development_dependency "
|
32
|
-
s.add_development_dependency "
|
33
|
-
s.add_development_dependency "rspec-
|
34
|
-
s.add_development_dependency "rspec-
|
35
|
-
s.add_development_dependency "rspec-mocks", "~> 2.7.0"
|
30
|
+
#s.add_development_dependency "sys-proctable", "~> 0.9.0"
|
31
|
+
s.add_development_dependency "rspec-core", "~> 2.8.0"
|
32
|
+
s.add_development_dependency "rspec-expectations", "~> 2.8.0"
|
33
|
+
s.add_development_dependency "rspec-mocks", "~> 2.8.0"
|
36
34
|
|
37
35
|
s.files = `git ls-files`.split("\n")
|
38
36
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|