vagrantup 0.4.3.dev → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/config/default.rb +6 -6
- data/lib/vagrant.rb +6 -3
- data/lib/vagrant/action.rb +77 -0
- data/lib/vagrant/action/action_exception.rb +16 -0
- data/lib/vagrant/action/box/destroy.rb +19 -0
- data/lib/vagrant/action/box/download.rb +78 -0
- data/lib/vagrant/action/box/unpackage.rb +58 -0
- data/lib/vagrant/action/box/verify.rb +23 -0
- data/lib/vagrant/action/builder.rb +151 -0
- data/lib/vagrant/action/builtin.rb +114 -0
- data/lib/vagrant/action/env/error_halt.rb +16 -0
- data/lib/vagrant/action/env/set.rb +18 -0
- data/lib/vagrant/action/environment.rb +98 -0
- data/lib/vagrant/action/exception_catcher.rb +14 -0
- data/lib/vagrant/action/vm/boot.rb +54 -0
- data/lib/vagrant/action/vm/check_box.rb +27 -0
- data/lib/vagrant/action/vm/check_guest_additions.rb +32 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +43 -0
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +39 -0
- data/lib/vagrant/action/vm/clear_nfs_exports.rb +20 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +32 -0
- data/lib/vagrant/action/vm/customize.rb +21 -0
- data/lib/vagrant/action/vm/destroy.rb +20 -0
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +35 -0
- data/lib/vagrant/action/vm/disable_networks.rb +26 -0
- data/lib/vagrant/action/vm/export.rb +53 -0
- data/lib/vagrant/action/vm/forward_ports.rb +121 -0
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +28 -0
- data/lib/vagrant/action/vm/halt.rb +34 -0
- data/lib/vagrant/action/vm/import.rb +33 -0
- data/lib/vagrant/action/vm/match_mac_address.rb +19 -0
- data/lib/vagrant/{actions → action}/vm/network.rb +47 -55
- data/lib/vagrant/action/vm/nfs.rb +161 -0
- data/lib/vagrant/action/vm/nfs_helpers.rb +11 -0
- data/lib/vagrant/action/vm/package.rb +99 -0
- data/lib/vagrant/action/vm/persist.rb +22 -0
- data/lib/vagrant/action/vm/provision.rb +50 -0
- data/lib/vagrant/action/vm/resume.rb +20 -0
- data/lib/vagrant/{actions/vm/shared_folders.rb → action/vm/share_folders.rb} +48 -45
- data/lib/vagrant/action/vm/suspend.rb +20 -0
- data/lib/vagrant/box.rb +3 -7
- data/lib/vagrant/commands/base.rb +1 -3
- data/lib/vagrant/commands/package.rb +4 -9
- data/lib/vagrant/commands/up.rb +0 -2
- data/lib/vagrant/config.rb +15 -1
- data/lib/vagrant/downloaders/file.rb +1 -1
- data/lib/vagrant/downloaders/http.rb +2 -1
- data/lib/vagrant/environment.rb +18 -14
- data/lib/vagrant/hosts/base.rb +77 -0
- data/lib/vagrant/hosts/bsd.rb +53 -0
- data/lib/vagrant/hosts/linux.rb +52 -0
- data/lib/vagrant/provisioners/base.rb +17 -9
- data/lib/vagrant/provisioners/chef.rb +1 -1
- data/lib/vagrant/provisioners/chef_server.rb +4 -8
- data/lib/vagrant/provisioners/chef_solo.rb +1 -2
- data/lib/vagrant/ssh.rb +12 -4
- data/lib/vagrant/systems/base.rb +4 -0
- data/lib/vagrant/systems/linux.rb +12 -1
- data/lib/vagrant/util.rb +16 -0
- data/lib/vagrant/util/busy.rb +59 -0
- data/lib/vagrant/util/plain_logger.rb +11 -0
- data/lib/vagrant/util/platform.rb +18 -0
- data/lib/vagrant/util/resource_logger.rb +128 -0
- data/lib/vagrant/version.rb +6 -0
- data/lib/vagrant/vm.rb +10 -12
- data/templates/chef_solo_solo.erb +2 -1
- data/templates/nfs/exports.erb +3 -0
- data/templates/nfs/exports_linux.erb +3 -0
- data/templates/strings.yml +23 -3
- metadata +121 -196
- data/.gitignore +0 -11
- data/Gemfile +0 -18
- data/Rakefile +0 -41
- data/VERSION +0 -1
- data/bin/.gitignore +0 -0
- data/lib/vagrant/actions/base.rb +0 -130
- data/lib/vagrant/actions/box/add.rb +0 -23
- data/lib/vagrant/actions/box/destroy.rb +0 -14
- data/lib/vagrant/actions/box/download.rb +0 -67
- data/lib/vagrant/actions/box/unpackage.rb +0 -42
- data/lib/vagrant/actions/box/verify.rb +0 -32
- data/lib/vagrant/actions/collection.rb +0 -36
- data/lib/vagrant/actions/runner.rb +0 -131
- data/lib/vagrant/actions/vm/boot.rb +0 -43
- data/lib/vagrant/actions/vm/customize.rb +0 -19
- data/lib/vagrant/actions/vm/destroy.rb +0 -24
- data/lib/vagrant/actions/vm/down.rb +0 -22
- data/lib/vagrant/actions/vm/export.rb +0 -45
- data/lib/vagrant/actions/vm/forward_ports.rb +0 -134
- data/lib/vagrant/actions/vm/halt.rb +0 -24
- data/lib/vagrant/actions/vm/import.rb +0 -23
- data/lib/vagrant/actions/vm/move_hard_drive.rb +0 -51
- data/lib/vagrant/actions/vm/package.rb +0 -94
- data/lib/vagrant/actions/vm/provision.rb +0 -49
- data/lib/vagrant/actions/vm/reload.rb +0 -17
- data/lib/vagrant/actions/vm/resume.rb +0 -16
- data/lib/vagrant/actions/vm/start.rb +0 -26
- data/lib/vagrant/actions/vm/suspend.rb +0 -16
- data/lib/vagrant/actions/vm/up.rb +0 -53
- data/lib/vagrant/busy.rb +0 -79
- data/lib/vagrant/resource_logger.rb +0 -126
- data/lib/vagrant/util/error_helper.rb +0 -13
- data/lib/vagrant/util/output_helper.rb +0 -9
- data/test/test_helper.rb +0 -149
- data/test/vagrant/actions/base_test.rb +0 -32
- data/test/vagrant/actions/box/add_test.rb +0 -36
- data/test/vagrant/actions/box/destroy_test.rb +0 -17
- data/test/vagrant/actions/box/download_test.rb +0 -137
- data/test/vagrant/actions/box/unpackage_test.rb +0 -99
- data/test/vagrant/actions/box/verify_test.rb +0 -44
- data/test/vagrant/actions/collection_test.rb +0 -113
- data/test/vagrant/actions/runner_test.rb +0 -268
- data/test/vagrant/actions/vm/boot_test.rb +0 -49
- data/test/vagrant/actions/vm/customize_test.rb +0 -21
- data/test/vagrant/actions/vm/destroy_test.rb +0 -37
- data/test/vagrant/actions/vm/down_test.rb +0 -39
- data/test/vagrant/actions/vm/export_test.rb +0 -88
- data/test/vagrant/actions/vm/forward_ports_test.rb +0 -253
- data/test/vagrant/actions/vm/halt_test.rb +0 -65
- data/test/vagrant/actions/vm/import_test.rb +0 -45
- data/test/vagrant/actions/vm/move_hard_drive_test.rb +0 -106
- data/test/vagrant/actions/vm/network_test.rb +0 -291
- data/test/vagrant/actions/vm/package_test.rb +0 -254
- data/test/vagrant/actions/vm/provision_test.rb +0 -99
- data/test/vagrant/actions/vm/reload_test.rb +0 -46
- data/test/vagrant/actions/vm/resume_test.rb +0 -26
- data/test/vagrant/actions/vm/shared_folders_test.rb +0 -211
- data/test/vagrant/actions/vm/start_test.rb +0 -73
- data/test/vagrant/actions/vm/suspend_test.rb +0 -26
- data/test/vagrant/actions/vm/up_test.rb +0 -96
- data/test/vagrant/active_list_test.rb +0 -173
- data/test/vagrant/box_test.rb +0 -154
- data/test/vagrant/busy_test.rb +0 -78
- data/test/vagrant/command_test.rb +0 -53
- data/test/vagrant/commands/base_test.rb +0 -139
- data/test/vagrant/commands/box/add_test.rb +0 -34
- data/test/vagrant/commands/box/list_test.rb +0 -32
- data/test/vagrant/commands/box/remove_test.rb +0 -41
- data/test/vagrant/commands/destroy_test.rb +0 -44
- data/test/vagrant/commands/halt_test.rb +0 -50
- data/test/vagrant/commands/init_test.rb +0 -55
- data/test/vagrant/commands/package_test.rb +0 -104
- data/test/vagrant/commands/provision_test.rb +0 -60
- data/test/vagrant/commands/reload_test.rb +0 -44
- data/test/vagrant/commands/resume_test.rb +0 -44
- data/test/vagrant/commands/ssh_config_test.rb +0 -77
- data/test/vagrant/commands/ssh_test.rb +0 -129
- data/test/vagrant/commands/status_test.rb +0 -40
- data/test/vagrant/commands/suspend_test.rb +0 -44
- data/test/vagrant/commands/up_test.rb +0 -47
- data/test/vagrant/config_test.rb +0 -287
- data/test/vagrant/downloaders/base_test.rb +0 -28
- data/test/vagrant/downloaders/file_test.rb +0 -33
- data/test/vagrant/downloaders/http_test.rb +0 -62
- data/test/vagrant/environment_test.rb +0 -770
- data/test/vagrant/provisioners/base_test.rb +0 -33
- data/test/vagrant/provisioners/chef_server_test.rb +0 -176
- data/test/vagrant/provisioners/chef_solo_test.rb +0 -183
- data/test/vagrant/provisioners/chef_test.rb +0 -175
- data/test/vagrant/resource_logger_test.rb +0 -145
- data/test/vagrant/ssh_session_test.rb +0 -46
- data/test/vagrant/ssh_test.rb +0 -296
- data/test/vagrant/systems/linux_test.rb +0 -179
- data/test/vagrant/util/error_helper_test.rb +0 -5
- data/test/vagrant/util/output_helper_test.rb +0 -5
- data/test/vagrant/util/plain_logger_test.rb +0 -17
- data/test/vagrant/util/platform_test.rb +0 -18
- data/test/vagrant/util/stacked_proc_runner_test.rb +0 -43
- data/test/vagrant/util/template_renderer_test.rb +0 -144
- data/test/vagrant/util/translator_test.rb +0 -61
- data/test/vagrant/util_test.rb +0 -27
- data/test/vagrant/vm_test.rb +0 -235
- data/vagrant.gemspec +0 -291
@@ -1,55 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
2
|
-
|
3
|
-
class CommandsInitTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Commands::Init
|
6
|
-
|
7
|
-
@env = mock_environment
|
8
|
-
@instance = @klass.new(@env)
|
9
|
-
end
|
10
|
-
|
11
|
-
context "execute" do
|
12
|
-
should "create the vagrantfile with the first arg" do
|
13
|
-
args = [:foo]
|
14
|
-
@instance.expects(:create_vagrantfile).with(args.first)
|
15
|
-
@instance.execute(args)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context "creating the vagrantfile" do
|
20
|
-
setup do
|
21
|
-
@file = mock("file")
|
22
|
-
@file.stubs(:write)
|
23
|
-
File.stubs(:open).yields(@file)
|
24
|
-
@rootfile_path = File.join(Dir.pwd, Vagrant::Environment::ROOTFILE_NAME)
|
25
|
-
|
26
|
-
Vagrant::Util::TemplateRenderer.stubs(:render)
|
27
|
-
end
|
28
|
-
|
29
|
-
should "error and exit if a rootfile already exists" do
|
30
|
-
File.expects(:exist?).with(@rootfile_path).returns(true)
|
31
|
-
@instance.expects(:error_and_exit).with(:rootfile_already_exists).once
|
32
|
-
@instance.create_vagrantfile
|
33
|
-
end
|
34
|
-
|
35
|
-
should "write to the rootfile path using the template renderer" do
|
36
|
-
result = "foo"
|
37
|
-
Vagrant::Util::TemplateRenderer.expects(:render).returns(result).once
|
38
|
-
@file.expects(:write).with(result).once
|
39
|
-
File.expects(:open).with(@rootfile_path, 'w+').yields(@file)
|
40
|
-
|
41
|
-
@instance.create_vagrantfile
|
42
|
-
end
|
43
|
-
|
44
|
-
should "use the given base box if given" do
|
45
|
-
box = "zooo"
|
46
|
-
Vagrant::Util::TemplateRenderer.expects(:render).with(Vagrant::Environment::ROOTFILE_NAME, :default_box => box)
|
47
|
-
@instance.create_vagrantfile(box)
|
48
|
-
end
|
49
|
-
|
50
|
-
should "use the default `base` if no box is given" do
|
51
|
-
Vagrant::Util::TemplateRenderer.expects(:render).with(Vagrant::Environment::ROOTFILE_NAME, :default_box => "base")
|
52
|
-
@instance.create_vagrantfile
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
2
|
-
|
3
|
-
class CommandsPackageTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Commands::Package
|
6
|
-
|
7
|
-
@env = mock_environment
|
8
|
-
@instance = @klass.new(@env)
|
9
|
-
end
|
10
|
-
|
11
|
-
context "executing" do
|
12
|
-
should "package base if a base is given" do
|
13
|
-
@instance.expects(:package_base).once
|
14
|
-
@instance.execute(["--base","foo"])
|
15
|
-
end
|
16
|
-
|
17
|
-
should "package single if no name is given" do
|
18
|
-
@instance.expects(:package_single).with(nil).once
|
19
|
-
@instance.execute
|
20
|
-
end
|
21
|
-
|
22
|
-
should "package single if a name is given" do
|
23
|
-
@instance.expects(:package_single).with("foo").once
|
24
|
-
@instance.execute(["foo"])
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "packaging base" do
|
29
|
-
should "error and exit if no VM is found" do
|
30
|
-
Vagrant::VM.expects(:find).with("foo", @instance.env).returns(nil)
|
31
|
-
@instance.expects(:error_and_exit).with(:vm_base_not_found, :name => "foo").once
|
32
|
-
@instance.execute(["--base", "foo"])
|
33
|
-
end
|
34
|
-
|
35
|
-
should "package the VM like any other VM" do
|
36
|
-
vm = mock("vm")
|
37
|
-
Vagrant::VM.expects(:find).with("foo", @instance.env).returns(vm)
|
38
|
-
@instance.expects(:package_vm).with(vm).once
|
39
|
-
@instance.execute(["--base", "foo"])
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context "packaging a single VM" do
|
44
|
-
setup do
|
45
|
-
@vm = mock("vm")
|
46
|
-
@vm.stubs(:created?).returns(true)
|
47
|
-
|
48
|
-
@vms = {:bar => @vm}
|
49
|
-
@env.stubs(:vms).returns(@vms)
|
50
|
-
@env.stubs(:multivm?).returns(false)
|
51
|
-
end
|
52
|
-
|
53
|
-
should "error and exit if no name is given in a multi-vm env" do
|
54
|
-
@env.stubs(:multivm?).returns(true)
|
55
|
-
@instance.expects(:error_and_exit).with(:package_multivm).once
|
56
|
-
@instance.package_single(nil)
|
57
|
-
end
|
58
|
-
|
59
|
-
should "error and exit if the VM doesn't exist" do
|
60
|
-
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
61
|
-
@instance.package_single(:foo)
|
62
|
-
end
|
63
|
-
|
64
|
-
should "error and exit if the VM is not created" do
|
65
|
-
@vm.stubs(:created?).returns(false)
|
66
|
-
@instance.expects(:error_and_exit).with(:environment_not_created).once
|
67
|
-
@instance.package_single(:bar)
|
68
|
-
end
|
69
|
-
|
70
|
-
should "use the first VM is no name is given in a single VM environment" do
|
71
|
-
@instance.expects(:package_vm).with(@vm).once
|
72
|
-
@instance.package_single(nil)
|
73
|
-
end
|
74
|
-
|
75
|
-
should "package the VM" do
|
76
|
-
@instance.expects(:package_vm).with(@vm).once
|
77
|
-
@instance.package_single(:bar)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "packaging a VM" do
|
82
|
-
setup do
|
83
|
-
@vm = mock("vm")
|
84
|
-
@vm.stubs(:powered_off?).returns(true)
|
85
|
-
|
86
|
-
@options = {}
|
87
|
-
@instance.stubs(:options).returns(@options)
|
88
|
-
end
|
89
|
-
|
90
|
-
should "error and exit if VM is not powered off" do
|
91
|
-
@vm.stubs(:powered_off?).returns(false)
|
92
|
-
@instance.expects(:error_and_exit).with(:vm_power_off_to_package).once
|
93
|
-
@instance.package_vm(@vm)
|
94
|
-
end
|
95
|
-
|
96
|
-
should "package the VM with the proper arguments" do
|
97
|
-
@options[:output] = "foo.box"
|
98
|
-
@options[:include] = :bar
|
99
|
-
|
100
|
-
@vm.expects(:package).with(@options).once
|
101
|
-
@instance.package_vm(@vm)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
2
|
-
|
3
|
-
class CommandsProvisionTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Commands::Provision
|
6
|
-
@env = mock_environment
|
7
|
-
@instance = @klass.new(@env)
|
8
|
-
end
|
9
|
-
|
10
|
-
context "executing" do
|
11
|
-
should "provision all if no name is given" do
|
12
|
-
@instance.expects(:all_or_single).with([], :provision).once
|
13
|
-
@instance.execute
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context "provisioning a single VM" do
|
18
|
-
setup do
|
19
|
-
@foo_vm = mock("vm")
|
20
|
-
@foo_vm.stubs(:env).returns(@env)
|
21
|
-
@foo_vm.stubs(:created?).returns(true)
|
22
|
-
|
23
|
-
@vm_for_real = mock("vm for real")
|
24
|
-
@foo_vm.stubs(:vm).returns(@vm_for_real)
|
25
|
-
vms = { :foo => @foo_vm }
|
26
|
-
@env.stubs(:vms).returns(vms)
|
27
|
-
end
|
28
|
-
|
29
|
-
should "error and exit if the VM doesn't exist" do
|
30
|
-
@env.stubs(:vms).returns({})
|
31
|
-
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => 'foo').once
|
32
|
-
@instance.execute(["foo"])
|
33
|
-
end
|
34
|
-
|
35
|
-
should "reload if it's running" do
|
36
|
-
@vm_for_real.stubs(:running?).returns(true)
|
37
|
-
@foo_vm.expects(:provision).once
|
38
|
-
@instance.execute(["foo"])
|
39
|
-
end
|
40
|
-
|
41
|
-
should "do log to info if it's not running" do
|
42
|
-
logger = mock("logger")
|
43
|
-
logger.expects(:info)
|
44
|
-
@env.stubs(:logger).returns(logger)
|
45
|
-
@vm_for_real.stubs(:running?).returns(false)
|
46
|
-
@foo_vm.expects(:provision).never
|
47
|
-
@instance.execute(["foo"])
|
48
|
-
end
|
49
|
-
|
50
|
-
should "do log to info if it's not created" do
|
51
|
-
logger = mock("logger")
|
52
|
-
logger.expects(:info)
|
53
|
-
@env.stubs(:logger).returns(logger)
|
54
|
-
@foo_vm.stubs(:created?).returns(false)
|
55
|
-
@foo_vm.expects(:provision).never
|
56
|
-
@instance.execute(["foo"])
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
2
|
-
|
3
|
-
class CommandsReloadTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Commands::Reload
|
6
|
-
|
7
|
-
@env = mock_environment
|
8
|
-
@instance = @klass.new(@env)
|
9
|
-
end
|
10
|
-
|
11
|
-
context "executing" do
|
12
|
-
should "call all or single for the method" do
|
13
|
-
@instance.expects(:all_or_single).with([], :reload)
|
14
|
-
@instance.execute
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context "reloading a single VM" do
|
19
|
-
setup do
|
20
|
-
@foo_vm = mock("vm")
|
21
|
-
@foo_vm.stubs(:env).returns(@env)
|
22
|
-
vms = { :foo => @foo_vm }
|
23
|
-
@env.stubs(:vms).returns(vms)
|
24
|
-
end
|
25
|
-
|
26
|
-
should "error and exit if the VM doesn't exist" do
|
27
|
-
@env.stubs(:vms).returns({})
|
28
|
-
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
29
|
-
@instance.reload_single(:foo)
|
30
|
-
end
|
31
|
-
|
32
|
-
should "reload if its created" do
|
33
|
-
@foo_vm.stubs(:created?).returns(true)
|
34
|
-
@foo_vm.expects(:reload).once
|
35
|
-
@instance.execute(["foo"])
|
36
|
-
end
|
37
|
-
|
38
|
-
should "do nothing if its not created" do
|
39
|
-
@foo_vm.stubs(:created?).returns(false)
|
40
|
-
@foo_vm.expects(:reload).never
|
41
|
-
@instance.reload_single(:foo)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
2
|
-
|
3
|
-
class CommandsResumeTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Commands::Resume
|
6
|
-
|
7
|
-
@env = mock_environment
|
8
|
-
@instance = @klass.new(@env)
|
9
|
-
end
|
10
|
-
|
11
|
-
context "executing" do
|
12
|
-
should "call all or single for the method" do
|
13
|
-
@instance.expects(:all_or_single).with([], :resume)
|
14
|
-
@instance.execute
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context "resuming a single VM" do
|
19
|
-
setup do
|
20
|
-
@foo_vm = mock("vm")
|
21
|
-
@foo_vm.stubs(:env).returns(@env)
|
22
|
-
vms = { :foo => @foo_vm }
|
23
|
-
@env.stubs(:vms).returns(vms)
|
24
|
-
end
|
25
|
-
|
26
|
-
should "error and exit if the VM doesn't exist" do
|
27
|
-
@env.stubs(:vms).returns({})
|
28
|
-
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
29
|
-
@instance.resume_single(:foo)
|
30
|
-
end
|
31
|
-
|
32
|
-
should "resume if its created" do
|
33
|
-
@foo_vm.stubs(:created?).returns(true)
|
34
|
-
@foo_vm.expects(:resume).once
|
35
|
-
@instance.execute(["foo"])
|
36
|
-
end
|
37
|
-
|
38
|
-
should "do nothing if its not created" do
|
39
|
-
@foo_vm.stubs(:created?).returns(false)
|
40
|
-
@foo_vm.expects(:resume).never
|
41
|
-
@instance.resume_single(:foo)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
2
|
-
|
3
|
-
class CommandsSSHConfigTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Commands::SSHConfig
|
6
|
-
|
7
|
-
@env = mock_environment
|
8
|
-
@env.stubs(:require_root_path)
|
9
|
-
@instance = @klass.new(@env)
|
10
|
-
end
|
11
|
-
|
12
|
-
context "executing" do
|
13
|
-
setup do
|
14
|
-
@instance.stubs(:show_single)
|
15
|
-
end
|
16
|
-
|
17
|
-
should "require root path" do
|
18
|
-
@env.expects(:require_root_path).once
|
19
|
-
@instance.execute
|
20
|
-
end
|
21
|
-
|
22
|
-
should "call show_single with given argument" do
|
23
|
-
@instance.expects(:show_single).with("foo").once
|
24
|
-
@instance.execute(["foo"])
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "showing a single entry" do
|
29
|
-
setup do
|
30
|
-
@ssh = mock("ssh")
|
31
|
-
@ssh.stubs(:port).returns(2197)
|
32
|
-
|
33
|
-
@bar = mock("vm")
|
34
|
-
@bar.stubs(:env).returns(mock_environment)
|
35
|
-
@bar.stubs(:ssh).returns(@ssh)
|
36
|
-
|
37
|
-
@vms = {:bar => @bar}
|
38
|
-
@env.stubs(:multivm?).returns(true)
|
39
|
-
@env.stubs(:vms).returns(@vms)
|
40
|
-
|
41
|
-
@data = {
|
42
|
-
:host_key => "vagrant",
|
43
|
-
:ssh_user => @bar.env.config.ssh.username,
|
44
|
-
:ssh_port => @bar.ssh.port,
|
45
|
-
:private_key_path => @bar.env.config.ssh.private_key_path
|
46
|
-
}
|
47
|
-
|
48
|
-
@instance.stubs(:puts)
|
49
|
-
end
|
50
|
-
|
51
|
-
should "error if name is nil and multivm" do
|
52
|
-
@env.stubs(:multivm?).returns(true)
|
53
|
-
@instance.expects(:error_and_exit).with(:ssh_config_multivm).once
|
54
|
-
@instance.show_single(nil)
|
55
|
-
end
|
56
|
-
|
57
|
-
should "error if the VM is not found" do
|
58
|
-
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => "foo").once
|
59
|
-
@instance.show_single("foo")
|
60
|
-
end
|
61
|
-
|
62
|
-
should "output rendered template" do
|
63
|
-
result = mock("result")
|
64
|
-
Vagrant::Util::TemplateRenderer.expects(:render).with("ssh_config", @data).returns(result)
|
65
|
-
|
66
|
-
@instance.expects(:puts).with(result).once
|
67
|
-
@instance.show_single(:bar)
|
68
|
-
end
|
69
|
-
|
70
|
-
should "render with the given host name if given" do
|
71
|
-
host = "foo"
|
72
|
-
@data[:host_key] = host
|
73
|
-
Vagrant::Util::TemplateRenderer.expects(:render).with("ssh_config", @data)
|
74
|
-
@instance.execute(["bar", "--host", host])
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,129 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
2
|
-
|
3
|
-
class CommandsSSHTest < Test::Unit::TestCase
|
4
|
-
setup do
|
5
|
-
@klass = Vagrant::Commands::SSH
|
6
|
-
|
7
|
-
@env = mock_environment
|
8
|
-
@instance = @klass.new(@env)
|
9
|
-
end
|
10
|
-
|
11
|
-
context "executing" do
|
12
|
-
should "connect to the given argument" do
|
13
|
-
@instance.expects(:ssh_connect).with("foo").once
|
14
|
-
@instance.execute(["foo"])
|
15
|
-
end
|
16
|
-
|
17
|
-
should "connect with nil name if none is given" do
|
18
|
-
@instance.expects(:ssh_connect).with(nil).once
|
19
|
-
@instance.execute
|
20
|
-
end
|
21
|
-
|
22
|
-
should "execute if commands are given" do
|
23
|
-
@env.stubs(:vms).returns(:foo => mock("foo"))
|
24
|
-
@instance.expects(:ssh_execute).with("foo", @env.vms[:foo]).once
|
25
|
-
@instance.execute(["foo","-e","bar"])
|
26
|
-
end
|
27
|
-
|
28
|
-
should "execute over every VM if none is specified with a command" do
|
29
|
-
vms = {
|
30
|
-
:foo => mock("foo"),
|
31
|
-
:bar => mock("bar")
|
32
|
-
}
|
33
|
-
|
34
|
-
@env.stubs(:vms).returns(vms)
|
35
|
-
vms.each do |key, vm|
|
36
|
-
@instance.expects(:ssh_execute).with(key, vm).once
|
37
|
-
end
|
38
|
-
|
39
|
-
@instance.execute(["--execute", "bar"])
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context "ssh executing" do
|
44
|
-
setup do
|
45
|
-
@name = :foo
|
46
|
-
|
47
|
-
@ssh_conn = mock("connection")
|
48
|
-
@ssh_conn.stubs(:exec!)
|
49
|
-
|
50
|
-
@ssh = mock("ssh")
|
51
|
-
@ssh.stubs(:execute).yields(@ssh_conn)
|
52
|
-
|
53
|
-
@vm = mock("vm")
|
54
|
-
@vm.stubs(:created?).returns(true)
|
55
|
-
@vm.stubs(:ssh).returns(@ssh)
|
56
|
-
@vm.stubs(:env).returns(@env)
|
57
|
-
end
|
58
|
-
|
59
|
-
should "error and exit if invalid VM given" do
|
60
|
-
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => @name).once
|
61
|
-
@instance.ssh_execute(@name, nil)
|
62
|
-
end
|
63
|
-
|
64
|
-
should "error and exit if VM isn't created" do
|
65
|
-
@vm.stubs(:created?).returns(false)
|
66
|
-
@instance.expects(:error_and_exit).with(:environment_not_created).once
|
67
|
-
@instance.ssh_execute(@name, @vm)
|
68
|
-
end
|
69
|
-
|
70
|
-
should "execute each command" do
|
71
|
-
commands = [:a,:b,:c]
|
72
|
-
@instance.stubs(:options).returns(:execute => commands)
|
73
|
-
commands.each do |cmd|
|
74
|
-
@ssh_conn.expects(:exec!).with(cmd).once
|
75
|
-
end
|
76
|
-
|
77
|
-
@instance.ssh_execute(@name, @vm)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "ssh connecting" do
|
82
|
-
setup do
|
83
|
-
@vm = mock("vm")
|
84
|
-
@vm.stubs(:created?).returns(true)
|
85
|
-
|
86
|
-
@vms = {:bar => @vm}
|
87
|
-
@env.stubs(:vms).returns(@vms)
|
88
|
-
@env.stubs(:multivm?).returns(false)
|
89
|
-
end
|
90
|
-
|
91
|
-
should "error and exit if no VM is specified and multivm and no primary VM" do
|
92
|
-
@env.stubs(:multivm?).returns(true)
|
93
|
-
@env.stubs(:primary_vm).returns(nil)
|
94
|
-
@instance.expects(:error_and_exit).with(:ssh_multivm).once
|
95
|
-
@instance.ssh_connect(nil)
|
96
|
-
end
|
97
|
-
|
98
|
-
should "use the primary VM if it exists and no name is specified" do
|
99
|
-
vm = mock("vm")
|
100
|
-
ssh = mock("ssh")
|
101
|
-
vm.stubs(:created?).returns(true)
|
102
|
-
vm.stubs(:ssh).returns(ssh)
|
103
|
-
|
104
|
-
@env.stubs(:multivm?).returns(true)
|
105
|
-
@env.stubs(:primary_vm).returns(vm)
|
106
|
-
ssh.expects(:connect).once
|
107
|
-
@instance.ssh_connect(nil)
|
108
|
-
end
|
109
|
-
|
110
|
-
should "error and exit if VM is nil" do
|
111
|
-
@instance.expects(:error_and_exit).with(:unknown_vm, :vm => :foo).once
|
112
|
-
@instance.ssh_connect(:foo)
|
113
|
-
end
|
114
|
-
|
115
|
-
should "error and exit if VM isn't created" do
|
116
|
-
@vm.stubs(:created?).returns(false)
|
117
|
-
@instance.expects(:error_and_exit).with(:environment_not_created).once
|
118
|
-
@instance.ssh_connect(:bar)
|
119
|
-
end
|
120
|
-
|
121
|
-
should "ssh connect" do
|
122
|
-
ssh = mock("ssh")
|
123
|
-
@vm.stubs(:ssh).returns(ssh)
|
124
|
-
ssh.expects(:connect)
|
125
|
-
|
126
|
-
@instance.ssh_connect(:bar)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|