vagrant-vsphere 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -6
- data/Gemfile +10 -10
- data/LICENSE.txt +23 -23
- data/README.md +180 -175
- data/Rakefile +16 -16
- data/example_box/metadata.json +2 -2
- data/lib/vSphere/action.rb +172 -172
- data/lib/vSphere/action/clone.rb +131 -127
- data/lib/vSphere/action/close_vsphere.rb +23 -23
- data/lib/vSphere/action/connect_vsphere.rb +25 -25
- data/lib/vSphere/action/destroy.rb +37 -37
- data/lib/vSphere/action/get_ssh_info.rb +37 -37
- data/lib/vSphere/action/get_state.rb +45 -45
- data/lib/vSphere/action/is_created.rb +15 -15
- data/lib/vSphere/action/is_running.rb +20 -20
- data/lib/vSphere/action/message_already_created.rb +17 -17
- data/lib/vSphere/action/message_not_created.rb +17 -17
- data/lib/vSphere/action/message_not_running.rb +18 -18
- data/lib/vSphere/action/power_off.rb +27 -27
- data/lib/vSphere/action/power_on.rb +31 -31
- data/lib/vSphere/action/sync_folders.rb +94 -97
- data/lib/vSphere/config.rb +37 -37
- data/lib/vSphere/errors.rb +14 -11
- data/lib/vSphere/plugin.rb +29 -29
- data/lib/vSphere/provider.rb +38 -38
- data/lib/vSphere/util/machine_helpers.rb +15 -15
- data/lib/vSphere/util/vim_helpers.rb +37 -37
- data/lib/vSphere/version.rb +5 -5
- data/lib/vagrant-vsphere.rb +17 -17
- data/locales/en.yml +66 -65
- data/spec/action_spec.rb +116 -116
- data/spec/clone_spec.rb +31 -31
- data/spec/connect_vsphere_spec.rb +23 -23
- data/spec/destroy_spec.rb +30 -30
- data/spec/get_ssh_info_spec.rb +30 -30
- data/spec/get_state_spec.rb +54 -54
- data/spec/is_created_spec.rb +28 -28
- data/spec/spec_helper.rb +98 -98
- data/vSphere.gemspec +29 -28
- metadata +14 -8
data/spec/action_spec.rb
CHANGED
@@ -1,116 +1,116 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'vagrant'
|
3
|
-
|
4
|
-
describe VagrantPlugins::VSphere::Action do
|
5
|
-
def run(action)
|
6
|
-
Vagrant::Action::Runner.new.run described_class.send("action_#{action}"), @env
|
7
|
-
end
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
@machine.stub(:id).and_return(EXISTING_UUID)
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'up' do
|
14
|
-
def run_up
|
15
|
-
run :up
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should connect to vSphere' do
|
19
|
-
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
20
|
-
|
21
|
-
run_up
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should check if the VM exits' do
|
25
|
-
VagrantPlugins::VSphere::Action::IsCreated.any_instance.should_receive(:call)
|
26
|
-
|
27
|
-
run_up
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should create the VM when the VM does already not exist' do
|
31
|
-
@machine.state.stub(:id).and_return(:not_created)
|
32
|
-
|
33
|
-
VagrantPlugins::VSphere::Action::Clone.any_instance.should_receive(:call)
|
34
|
-
|
35
|
-
run_up
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should not create the VM when the VM already exists' do
|
39
|
-
@machine.state.stub(:id).and_return(:running)
|
40
|
-
|
41
|
-
VagrantPlugins::VSphere::Action::Clone.any_instance.should_not_receive(:call)
|
42
|
-
|
43
|
-
run_up
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe 'destroy' do
|
48
|
-
def run_destroy
|
49
|
-
run :destroy
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should connect to vSphere' do
|
53
|
-
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
54
|
-
|
55
|
-
run_destroy
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should power off the VM' do
|
59
|
-
VagrantPlugins::VSphere::Action::PowerOff.any_instance.should_receive(:call)
|
60
|
-
|
61
|
-
run_destroy
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'should destroy the VM' do
|
65
|
-
VagrantPlugins::VSphere::Action::Destroy.any_instance.should_receive(:call)
|
66
|
-
|
67
|
-
run_destroy
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe 'halt' do
|
72
|
-
it 'should power off the VM' do
|
73
|
-
@machine.state.stub(:id).and_return(:running)
|
74
|
-
|
75
|
-
VagrantPlugins::VSphere::Action::PowerOff.any_instance.should_receive(:call)
|
76
|
-
|
77
|
-
run :halt
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe 'get state' do
|
82
|
-
def run_get_state
|
83
|
-
run :get_state
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'should connect to vSphere' do
|
87
|
-
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
88
|
-
|
89
|
-
run_get_state
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'should get the power state' do
|
93
|
-
VagrantPlugins::VSphere::Action::GetState.any_instance.should_receive(:call)
|
94
|
-
|
95
|
-
run_get_state
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe 'get ssh info' do
|
100
|
-
def run_get_ssh_info
|
101
|
-
run :get_ssh_info
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'should connect to vSphere' do
|
105
|
-
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
106
|
-
|
107
|
-
run_get_ssh_info
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'should get the power state' do
|
111
|
-
VagrantPlugins::VSphere::Action::GetSshInfo.any_instance.should_receive(:call)
|
112
|
-
|
113
|
-
run_get_ssh_info
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vagrant'
|
3
|
+
|
4
|
+
describe VagrantPlugins::VSphere::Action do
|
5
|
+
def run(action)
|
6
|
+
Vagrant::Action::Runner.new.run described_class.send("action_#{action}"), @env
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@machine.stub(:id).and_return(EXISTING_UUID)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'up' do
|
14
|
+
def run_up
|
15
|
+
run :up
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should connect to vSphere' do
|
19
|
+
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
20
|
+
|
21
|
+
run_up
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should check if the VM exits' do
|
25
|
+
VagrantPlugins::VSphere::Action::IsCreated.any_instance.should_receive(:call)
|
26
|
+
|
27
|
+
run_up
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should create the VM when the VM does already not exist' do
|
31
|
+
@machine.state.stub(:id).and_return(:not_created)
|
32
|
+
|
33
|
+
VagrantPlugins::VSphere::Action::Clone.any_instance.should_receive(:call)
|
34
|
+
|
35
|
+
run_up
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should not create the VM when the VM already exists' do
|
39
|
+
@machine.state.stub(:id).and_return(:running)
|
40
|
+
|
41
|
+
VagrantPlugins::VSphere::Action::Clone.any_instance.should_not_receive(:call)
|
42
|
+
|
43
|
+
run_up
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'destroy' do
|
48
|
+
def run_destroy
|
49
|
+
run :destroy
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should connect to vSphere' do
|
53
|
+
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
54
|
+
|
55
|
+
run_destroy
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should power off the VM' do
|
59
|
+
VagrantPlugins::VSphere::Action::PowerOff.any_instance.should_receive(:call)
|
60
|
+
|
61
|
+
run_destroy
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should destroy the VM' do
|
65
|
+
VagrantPlugins::VSphere::Action::Destroy.any_instance.should_receive(:call)
|
66
|
+
|
67
|
+
run_destroy
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe 'halt' do
|
72
|
+
it 'should power off the VM' do
|
73
|
+
@machine.state.stub(:id).and_return(:running)
|
74
|
+
|
75
|
+
VagrantPlugins::VSphere::Action::PowerOff.any_instance.should_receive(:call)
|
76
|
+
|
77
|
+
run :halt
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'get state' do
|
82
|
+
def run_get_state
|
83
|
+
run :get_state
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should connect to vSphere' do
|
87
|
+
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
88
|
+
|
89
|
+
run_get_state
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should get the power state' do
|
93
|
+
VagrantPlugins::VSphere::Action::GetState.any_instance.should_receive(:call)
|
94
|
+
|
95
|
+
run_get_state
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe 'get ssh info' do
|
100
|
+
def run_get_ssh_info
|
101
|
+
run :get_ssh_info
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should connect to vSphere' do
|
105
|
+
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
106
|
+
|
107
|
+
run_get_ssh_info
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should get the power state' do
|
111
|
+
VagrantPlugins::VSphere::Action::GetSshInfo.any_instance.should_receive(:call)
|
112
|
+
|
113
|
+
run_get_ssh_info
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
data/spec/clone_spec.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe VagrantPlugins::VSphere::Action::Clone do
|
4
|
-
before :each do
|
5
|
-
@env[:vSphere_connection] = @vim
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should create a CloneVM task' do
|
9
|
-
call
|
10
|
-
@template.should have_received(:CloneVM_Task).with({
|
11
|
-
:folder => @data_center,
|
12
|
-
:name => NAME,
|
13
|
-
:spec => {}
|
14
|
-
})
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should set the machine id to be the new UUID' do
|
18
|
-
call
|
19
|
-
@machine.should have_received(:id=).with(NEW_UUID)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should call the next item in the middleware stack' do
|
23
|
-
call
|
24
|
-
@app.should have_received :call
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should set static IP when given config spec' do
|
28
|
-
@machine.provider_config.stub(:customization_spec_name).and_return('spec')
|
29
|
-
call
|
30
|
-
@ip.should have_received(:ipAddress=).with('0.0.0.0')
|
31
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VagrantPlugins::VSphere::Action::Clone do
|
4
|
+
before :each do
|
5
|
+
@env[:vSphere_connection] = @vim
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should create a CloneVM task' do
|
9
|
+
call
|
10
|
+
@template.should have_received(:CloneVM_Task).with({
|
11
|
+
:folder => @data_center,
|
12
|
+
:name => NAME,
|
13
|
+
:spec => {}
|
14
|
+
})
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should set the machine id to be the new UUID' do
|
18
|
+
call
|
19
|
+
@machine.should have_received(:id=).with(NEW_UUID)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should call the next item in the middleware stack' do
|
23
|
+
call
|
24
|
+
@app.should have_received :call
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should set static IP when given config spec' do
|
28
|
+
@machine.provider_config.stub(:customization_spec_name).and_return('spec')
|
29
|
+
call
|
30
|
+
@ip.should have_received(:ipAddress=).with('0.0.0.0')
|
31
|
+
end
|
32
32
|
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe VagrantPlugins::VSphere::Action::ConnectVSphere do
|
4
|
-
before :each do
|
5
|
-
described_class.new(@app, @env).call(@env)
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should connect to vSphere' do
|
9
|
-
VIM.should have_received(:connect).with({
|
10
|
-
:host => @env[:machine].provider_config.host,
|
11
|
-
:user => @env[:machine].provider_config.user,
|
12
|
-
:password => @env[:machine].provider_config.password,
|
13
|
-
:insecure => @env[:machine].provider_config.insecure,
|
14
|
-
})
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should add the vSphere connection to the environment' do
|
18
|
-
@env[:vSphere_connection].should be @vim
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should call the next item in the middleware stack' do
|
22
|
-
@app.should have_received :call
|
23
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VagrantPlugins::VSphere::Action::ConnectVSphere do
|
4
|
+
before :each do
|
5
|
+
described_class.new(@app, @env).call(@env)
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should connect to vSphere' do
|
9
|
+
VIM.should have_received(:connect).with({
|
10
|
+
:host => @env[:machine].provider_config.host,
|
11
|
+
:user => @env[:machine].provider_config.user,
|
12
|
+
:password => @env[:machine].provider_config.password,
|
13
|
+
:insecure => @env[:machine].provider_config.insecure,
|
14
|
+
})
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should add the vSphere connection to the environment' do
|
18
|
+
@env[:vSphere_connection].should be @vim
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should call the next item in the middleware stack' do
|
22
|
+
@app.should have_received :call
|
23
|
+
end
|
24
24
|
end
|
data/spec/destroy_spec.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe VagrantPlugins::VSphere::Action::Destroy do
|
4
|
-
before :each do
|
5
|
-
@env[:vSphere_connection] = @vim
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should set the machine id to nil' do
|
9
|
-
@env[:machine].stub(:id).and_return(MISSING_UUID)
|
10
|
-
|
11
|
-
call
|
12
|
-
|
13
|
-
@env[:machine].should have_received(:id=).with(nil)
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should not create a Destroy task if VM is not found' do
|
17
|
-
@env[:machine].stub(:id).and_return(MISSING_UUID)
|
18
|
-
|
19
|
-
call
|
20
|
-
|
21
|
-
@vm.should_not have_received :Destroy_Task
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should create a VM Destroy task if the VM exists' do
|
25
|
-
@env[:machine].stub(:id).and_return(EXISTING_UUID)
|
26
|
-
|
27
|
-
call
|
28
|
-
|
29
|
-
@vm.should have_received :Destroy_Task
|
30
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VagrantPlugins::VSphere::Action::Destroy do
|
4
|
+
before :each do
|
5
|
+
@env[:vSphere_connection] = @vim
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should set the machine id to nil' do
|
9
|
+
@env[:machine].stub(:id).and_return(MISSING_UUID)
|
10
|
+
|
11
|
+
call
|
12
|
+
|
13
|
+
@env[:machine].should have_received(:id=).with(nil)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should not create a Destroy task if VM is not found' do
|
17
|
+
@env[:machine].stub(:id).and_return(MISSING_UUID)
|
18
|
+
|
19
|
+
call
|
20
|
+
|
21
|
+
@vm.should_not have_received :Destroy_Task
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should create a VM Destroy task if the VM exists' do
|
25
|
+
@env[:machine].stub(:id).and_return(EXISTING_UUID)
|
26
|
+
|
27
|
+
call
|
28
|
+
|
29
|
+
@vm.should have_received :Destroy_Task
|
30
|
+
end
|
31
31
|
end
|
data/spec/get_ssh_info_spec.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe VagrantPlugins::VSphere::Action::GetSshInfo do
|
4
|
-
before :each do
|
5
|
-
@env[:vSphere_connection] = @vim
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should set the ssh info to nil if machine ID is not set' do
|
9
|
-
call
|
10
|
-
|
11
|
-
@env.has_key?(:machine_ssh_info).should be true
|
12
|
-
@env[:machine_ssh_info].should be nil
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should set the ssh info to nil for a VM that does not exist' do
|
16
|
-
@env[:machine].stub(:id).and_return(MISSING_UUID)
|
17
|
-
|
18
|
-
call
|
19
|
-
|
20
|
-
@env.has_key?(:machine_ssh_info).should be true
|
21
|
-
@env[:machine_ssh_info].should be nil
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should set the ssh info host to the IP an existing VM' do
|
25
|
-
@env[:machine].stub(:id).and_return(EXISTING_UUID)
|
26
|
-
|
27
|
-
call
|
28
|
-
|
29
|
-
@env[:machine_ssh_info][:host].should be IP_ADDRESS
|
30
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VagrantPlugins::VSphere::Action::GetSshInfo do
|
4
|
+
before :each do
|
5
|
+
@env[:vSphere_connection] = @vim
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should set the ssh info to nil if machine ID is not set' do
|
9
|
+
call
|
10
|
+
|
11
|
+
@env.has_key?(:machine_ssh_info).should be true
|
12
|
+
@env[:machine_ssh_info].should be nil
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should set the ssh info to nil for a VM that does not exist' do
|
16
|
+
@env[:machine].stub(:id).and_return(MISSING_UUID)
|
17
|
+
|
18
|
+
call
|
19
|
+
|
20
|
+
@env.has_key?(:machine_ssh_info).should be true
|
21
|
+
@env[:machine_ssh_info].should be nil
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should set the ssh info host to the IP an existing VM' do
|
25
|
+
@env[:machine].stub(:id).and_return(EXISTING_UUID)
|
26
|
+
|
27
|
+
call
|
28
|
+
|
29
|
+
@env[:machine_ssh_info][:host].should be IP_ADDRESS
|
30
|
+
end
|
31
31
|
end
|