vagrant-openstack-provider 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/lib/vagrant-openstack-provider/action/connect_openstack.rb +0 -1
- data/lib/vagrant-openstack-provider/action/create_server.rb +3 -2
- data/lib/vagrant-openstack-provider/action/create_stack.rb +3 -2
- data/lib/vagrant-openstack-provider/action/delete_server.rb +3 -2
- data/lib/vagrant-openstack-provider/action/delete_stack.rb +3 -2
- data/lib/vagrant-openstack-provider/action/wait_active.rb +3 -3
- data/lib/vagrant-openstack-provider/action/wait_stop.rb +3 -3
- data/lib/vagrant-openstack-provider/catalog/openstack_catalog.rb +6 -5
- data/lib/vagrant-openstack-provider/client/cinder.rb +0 -1
- data/lib/vagrant-openstack-provider/client/domain.rb +0 -1
- data/lib/vagrant-openstack-provider/client/glance.rb +5 -3
- data/lib/vagrant-openstack-provider/client/heat.rb +0 -1
- data/lib/vagrant-openstack-provider/client/http_utils.rb +7 -6
- data/lib/vagrant-openstack-provider/client/keystone.rb +5 -4
- data/lib/vagrant-openstack-provider/client/neutron.rb +0 -1
- data/lib/vagrant-openstack-provider/client/nova.rb +0 -1
- data/lib/vagrant-openstack-provider/client/openstack.rb +0 -1
- data/lib/vagrant-openstack-provider/client/request_logger.rb +0 -1
- data/lib/vagrant-openstack-provider/client/rest_utils.rb +25 -0
- data/lib/vagrant-openstack-provider/command/abstract_command.rb +4 -1
- data/lib/vagrant-openstack-provider/command/flavor_list.rb +3 -5
- data/lib/vagrant-openstack-provider/command/floatingip_list.rb +3 -5
- data/lib/vagrant-openstack-provider/command/image_list.rb +3 -5
- data/lib/vagrant-openstack-provider/command/network_list.rb +3 -5
- data/lib/vagrant-openstack-provider/command/openstack_command.rb +16 -0
- data/lib/vagrant-openstack-provider/command/reset.rb +1 -2
- data/lib/vagrant-openstack-provider/command/subnet_list.rb +2 -5
- data/lib/vagrant-openstack-provider/command/volume_list.rb +3 -5
- data/lib/vagrant-openstack-provider/config.rb +59 -2
- data/lib/vagrant-openstack-provider/config/http.rb +39 -0
- data/lib/vagrant-openstack-provider/config_resolver.rb +13 -9
- data/lib/vagrant-openstack-provider/utils.rb +11 -6
- data/lib/vagrant-openstack-provider/version.rb +1 -1
- data/locales/en.yml +4 -0
- data/spec/vagrant-openstack-provider/action/connect_openstack_spec.rb +226 -4
- data/spec/vagrant-openstack-provider/action/create_server_spec.rb +6 -3
- data/spec/vagrant-openstack-provider/action/create_stack_spec.rb +7 -3
- data/spec/vagrant-openstack-provider/action/delete_server_spec.rb +13 -4
- data/spec/vagrant-openstack-provider/action/read_ssh_info_spec.rb +24 -3
- data/spec/vagrant-openstack-provider/action/wait_active_spec.rb +9 -2
- data/spec/vagrant-openstack-provider/action/wait_stop_spec.rb +9 -2
- data/spec/vagrant-openstack-provider/client/cinder_spec.rb +17 -1
- data/spec/vagrant-openstack-provider/client/glance_spec.rb +18 -2
- data/spec/vagrant-openstack-provider/client/heat_spec.rb +8 -0
- data/spec/vagrant-openstack-provider/client/keystone_spec.rb +8 -0
- data/spec/vagrant-openstack-provider/client/neutron_spec.rb +18 -2
- data/spec/vagrant-openstack-provider/client/nova_spec.rb +8 -0
- data/spec/vagrant-openstack-provider/config_resolver_spec.rb +10 -0
- data/spec/vagrant-openstack-provider/config_spec.rb +39 -4
- data/spec/vagrant-openstack-provider/utils_spec.rb +17 -17
- metadata +5 -2
@@ -195,17 +195,20 @@ describe VagrantPlugins::Openstack::Action::CreateServer do
|
|
195
195
|
it 'become active after one retry' do
|
196
196
|
nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' }, { 'status' => 'ACTIVE' })
|
197
197
|
nova.should_receive(:get_server_details).with(env, 'server-01').exactly(2).times
|
198
|
-
|
198
|
+
config.stub(:server_create_timeout) { 5 }
|
199
|
+
@action.waiting_for_server_to_be_built(env, 'server-01', 1)
|
199
200
|
end
|
200
201
|
it 'timeout before the server become active' do
|
201
202
|
nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' }, { 'status' => 'BUILD' })
|
202
203
|
nova.should_receive(:get_server_details).with(env, 'server-01').at_least(2).times
|
203
|
-
|
204
|
+
config.stub(:server_create_timeout) { 3 }
|
205
|
+
expect { @action.waiting_for_server_to_be_built(env, 'server-01', 1) }.to raise_error Errors::Timeout
|
204
206
|
end
|
205
207
|
it 'raise an error after one retry' do
|
206
208
|
nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' }, { 'status' => 'ERROR' })
|
207
209
|
nova.should_receive(:get_server_details).with(env, 'server-01').exactly(2).times
|
208
|
-
|
210
|
+
config.stub(:server_create_timeout) { 3 }
|
211
|
+
expect { @action.waiting_for_server_to_be_built(env, 'server-01', 1) }.to raise_error Errors::ServerStatusError
|
209
212
|
end
|
210
213
|
end
|
211
214
|
end
|
@@ -22,6 +22,7 @@ describe VagrantPlugins::Openstack::Action::CreateStack do
|
|
22
22
|
}
|
23
23
|
]
|
24
24
|
end
|
25
|
+
config.stub(:stack_create_timeout) { 200 }
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
@@ -80,17 +81,20 @@ describe VagrantPlugins::Openstack::Action::CreateStack do
|
|
80
81
|
it 'become active after one retry' do
|
81
82
|
heat.stub(:get_stack_details).and_return({ 'stack_status' => 'CREATE_IN_PROGRESS' }, { 'stack_status' => 'CREATE_COMPLETE' })
|
82
83
|
heat.should_receive(:get_stack_details).with(env, 'stack1', 'id-01').exactly(2).times
|
83
|
-
|
84
|
+
config.stub(:stack_create_timeout) { 5 }
|
85
|
+
@action.waiting_for_stack_to_be_created(env, 'stack1', 'id-01', 1)
|
84
86
|
end
|
85
87
|
it 'timeout before the server become active' do
|
86
88
|
heat.stub(:get_stack_details).and_return({ 'stack_status' => 'CREATE_IN_PROGRESS' }, { 'stack_status' => 'CREATE_IN_PROGRESS' })
|
87
89
|
heat.should_receive(:get_stack_details).with(env, 'stack1', 'id-01').at_least(2).times
|
88
|
-
|
90
|
+
config.stub(:stack_create_timeout) { 3 }
|
91
|
+
expect { @action.waiting_for_stack_to_be_created(env, 'stack1', 'id-01', 1) }.to raise_error Errors::Timeout
|
89
92
|
end
|
90
93
|
it 'raise an error after one retry' do
|
91
94
|
heat.stub(:get_stack_details).and_return({ 'stack_status' => 'CREATE_IN_PROGRESS' }, { 'stack_status' => 'CREATE_FAILED' })
|
92
95
|
heat.should_receive(:get_stack_details).with(env, 'stack1', 'id-01').exactly(2).times
|
93
|
-
|
96
|
+
config.stub(:stack_create_timeout) { 3 }
|
97
|
+
expect { @action.waiting_for_stack_to_be_created(env, 'stack1', 'id-01', 1) }.to raise_error Errors::StackStatusError
|
94
98
|
end
|
95
99
|
end
|
96
100
|
end
|
@@ -15,6 +15,10 @@ describe VagrantPlugins::Openstack::Action::DeleteServer do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
let(:config) do
|
19
|
+
double('config')
|
20
|
+
end
|
21
|
+
|
18
22
|
let(:env) do
|
19
23
|
Hash.new.tap do |env|
|
20
24
|
env[:ui] = double('ui')
|
@@ -22,6 +26,7 @@ describe VagrantPlugins::Openstack::Action::DeleteServer do
|
|
22
26
|
env[:ui].stub(:error).with(anything)
|
23
27
|
env[:openstack_client] = openstack_client
|
24
28
|
env[:machine] = OpenStruct.new.tap do |m|
|
29
|
+
m.provider_config = config
|
25
30
|
m.id = 'server_id'
|
26
31
|
end
|
27
32
|
end
|
@@ -59,22 +64,26 @@ describe VagrantPlugins::Openstack::Action::DeleteServer do
|
|
59
64
|
nova.stub(:get_server_details).once.and_return('status' => 'ACTIVE')
|
60
65
|
nova.stub(:get_server_details).once.and_raise(Errors::InstanceNotFound)
|
61
66
|
nova.should_receive(:get_server_details).with(env, 'server-01').exactly(1).times
|
62
|
-
|
67
|
+
config.stub(:server_delete_timeout) { 5 }
|
68
|
+
@action.waiting_for_instance_to_be_deleted(env, 'server-01', 1)
|
63
69
|
end
|
64
70
|
it 'become deleted after one retry' do
|
65
71
|
nova.stub(:get_server_details).and_return({ 'status' => 'ACTIVE' }, { 'status' => 'DELETED' })
|
66
72
|
nova.should_receive(:get_server_details).with(env, 'server-01').exactly(2).times
|
67
|
-
|
73
|
+
config.stub(:server_delete_timeout) { 5 }
|
74
|
+
@action.waiting_for_instance_to_be_deleted(env, 'server-01', 1)
|
68
75
|
end
|
69
76
|
it 'timeout before the server become active' do
|
70
77
|
nova.stub(:get_server_details).and_return({ 'status' => 'ACTIVE' }, { 'status' => 'ACTIVE' })
|
71
78
|
nova.should_receive(:get_server_details).with(env, 'server-01').at_least(2).times
|
72
|
-
|
79
|
+
config.stub(:server_delete_timeout) { 3 }
|
80
|
+
expect { @action.waiting_for_instance_to_be_deleted(env, 'server-01', 1) }.to raise_error Errors::Timeout
|
73
81
|
end
|
74
82
|
it 'raise an error after one retry' do
|
75
83
|
nova.stub(:get_server_details).and_return({ 'status' => 'ACTIVE' }, { 'status' => 'ERROR' })
|
76
84
|
nova.should_receive(:get_server_details).with(env, 'server-01').exactly(2).times
|
77
|
-
|
85
|
+
config.stub(:server_delete_timeout) { 3 }
|
86
|
+
expect { @action.waiting_for_instance_to_be_deleted(env, 'server-01', 1) }.to raise_error Errors::ServerStatusError
|
78
87
|
end
|
79
88
|
end
|
80
89
|
end
|
@@ -25,8 +25,17 @@ describe VagrantPlugins::Openstack::Action::ReadSSHInfo do
|
|
25
25
|
|
26
26
|
let(:nova) do
|
27
27
|
double('nova').tap do |nova|
|
28
|
-
nova.stub(:
|
29
|
-
|
28
|
+
nova.stub(:get_server_details).with(env, '1234') do
|
29
|
+
{
|
30
|
+
'addresses' => {
|
31
|
+
'net' => [
|
32
|
+
{
|
33
|
+
'addr' => '80.80.80.80',
|
34
|
+
'OS-EXT-IPS:type' => 'floating'
|
35
|
+
}
|
36
|
+
]
|
37
|
+
}
|
38
|
+
}
|
30
39
|
end
|
31
40
|
end
|
32
41
|
end
|
@@ -136,7 +145,19 @@ describe VagrantPlugins::Openstack::Action::ReadSSHInfo do
|
|
136
145
|
config.stub(:floating_ip) { '80.80.80.80' }
|
137
146
|
config.stub(:keypair_name) { nil }
|
138
147
|
config.stub(:public_key_path) { nil }
|
139
|
-
nova.stub(:get_server_details)
|
148
|
+
nova.stub(:get_server_details) do
|
149
|
+
{
|
150
|
+
'key_name' => 'my_keypair_name',
|
151
|
+
'addresses' => {
|
152
|
+
'net' => [
|
153
|
+
{
|
154
|
+
'addr' => '80.80.80.80',
|
155
|
+
'OS-EXT-IPS:type' => 'floating'
|
156
|
+
}
|
157
|
+
]
|
158
|
+
}
|
159
|
+
}
|
160
|
+
end
|
140
161
|
expect(nova).to receive(:get_server_details).with(env, '1234')
|
141
162
|
@action.read_ssh_info(env).should eq(
|
142
163
|
host: '80.80.80.80',
|
@@ -6,6 +6,10 @@ describe VagrantPlugins::Openstack::Action::WaitForServerToBeActive do
|
|
6
6
|
double('nova')
|
7
7
|
end
|
8
8
|
|
9
|
+
let(:config) do
|
10
|
+
double('config')
|
11
|
+
end
|
12
|
+
|
9
13
|
let(:env) do
|
10
14
|
Hash.new.tap do |env|
|
11
15
|
env[:ui] = double('ui').tap do |ui|
|
@@ -16,6 +20,7 @@ describe VagrantPlugins::Openstack::Action::WaitForServerToBeActive do
|
|
16
20
|
os.stub(:nova) { nova }
|
17
21
|
end
|
18
22
|
env[:machine] = OpenStruct.new.tap do |m|
|
23
|
+
m.provider_config = config
|
19
24
|
m.id = 'server_id'
|
20
25
|
end
|
21
26
|
end
|
@@ -33,13 +38,15 @@ describe VagrantPlugins::Openstack::Action::WaitForServerToBeActive do
|
|
33
38
|
nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' }, { 'status' => 'ACTIVE' })
|
34
39
|
expect(nova).to receive(:get_server_details).with(env, 'server_id').exactly(2).times
|
35
40
|
expect(app).to receive(:call)
|
36
|
-
|
41
|
+
config.stub(:server_active_timeout) { 5 }
|
42
|
+
@action = WaitForServerToBeActive.new(app, nil, 1)
|
37
43
|
@action.call(env)
|
38
44
|
end
|
39
45
|
it 'timeout after one retry' do
|
40
46
|
nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' }, { 'status' => 'BUILD' })
|
41
47
|
expect(nova).to receive(:get_server_details).with(env, 'server_id').at_least(2).times
|
42
|
-
|
48
|
+
config.stub(:server_active_timeout) { 2 }
|
49
|
+
@action = WaitForServerToBeActive.new(app, nil, 1)
|
43
50
|
expect { @action.call(env) }.to raise_error Errors::Timeout
|
44
51
|
end
|
45
52
|
end
|
@@ -6,6 +6,10 @@ describe VagrantPlugins::Openstack::Action::WaitForServerToStop do
|
|
6
6
|
double('nova')
|
7
7
|
end
|
8
8
|
|
9
|
+
let(:config) do
|
10
|
+
double('config')
|
11
|
+
end
|
12
|
+
|
9
13
|
let(:env) do
|
10
14
|
Hash.new.tap do |env|
|
11
15
|
env[:ui] = double('ui').tap do |ui|
|
@@ -16,6 +20,7 @@ describe VagrantPlugins::Openstack::Action::WaitForServerToStop do
|
|
16
20
|
os.stub(:nova) { nova }
|
17
21
|
end
|
18
22
|
env[:machine] = OpenStruct.new.tap do |m|
|
23
|
+
m.provider_config = config
|
19
24
|
m.id = 'server_id'
|
20
25
|
end
|
21
26
|
end
|
@@ -33,13 +38,15 @@ describe VagrantPlugins::Openstack::Action::WaitForServerToStop do
|
|
33
38
|
nova.stub(:get_server_details).and_return({ 'status' => 'ACTIVE' }, { 'status' => 'SHUTOFF' })
|
34
39
|
expect(nova).to receive(:get_server_details).with(env, 'server_id').exactly(2).times
|
35
40
|
expect(app).to receive(:call)
|
36
|
-
|
41
|
+
config.stub(:server_stop_timeout) { 5 }
|
42
|
+
@action = WaitForServerToStop.new(app, nil, 1)
|
37
43
|
@action.call(env)
|
38
44
|
end
|
39
45
|
it 'timeout after one retry' do
|
40
46
|
nova.stub(:get_server_details).and_return({ 'status' => 'ACTIVE' }, { 'status' => 'ACTIVE' })
|
41
47
|
expect(nova).to receive(:get_server_details).with(env, 'server_id').at_least(2).times
|
42
|
-
|
48
|
+
config.stub(:server_stop_timeout) { 2 }
|
49
|
+
@action = WaitForServerToStop.new(app, nil, 1)
|
43
50
|
expect { @action.call(env) }.to raise_error Errors::Timeout
|
44
51
|
end
|
45
52
|
end
|
@@ -2,8 +2,24 @@ require 'vagrant-openstack-provider/spec_helper'
|
|
2
2
|
|
3
3
|
describe VagrantPlugins::Openstack::CinderClient do
|
4
4
|
|
5
|
+
let(:http) do
|
6
|
+
double('http').tap do |http|
|
7
|
+
http.stub(:read_timeout) { 42 }
|
8
|
+
http.stub(:open_timeout) { 43 }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:config) do
|
13
|
+
double('config').tap do |config|
|
14
|
+
config.stub(:http) { http }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
5
18
|
let(:env) do
|
6
|
-
Hash.new
|
19
|
+
Hash.new.tap do |env|
|
20
|
+
env[:machine] = double('machine')
|
21
|
+
env[:machine].stub(:provider_config) { config }
|
22
|
+
end
|
7
23
|
end
|
8
24
|
|
9
25
|
let(:session) do
|
@@ -2,8 +2,24 @@ require 'vagrant-openstack-provider/spec_helper'
|
|
2
2
|
|
3
3
|
describe VagrantPlugins::Openstack::GlanceClient do
|
4
4
|
|
5
|
+
let(:http) do
|
6
|
+
double('http').tap do |http|
|
7
|
+
http.stub(:read_timeout) { 42 }
|
8
|
+
http.stub(:open_timeout) { 43 }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:config) do
|
13
|
+
double('config').tap do |config|
|
14
|
+
config.stub(:http) { http }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
5
18
|
let(:env) do
|
6
|
-
Hash.new
|
19
|
+
Hash.new.tap do |env|
|
20
|
+
env[:machine] = double('machine')
|
21
|
+
env[:machine].stub(:provider_config) { config }
|
22
|
+
end
|
7
23
|
end
|
8
24
|
|
9
25
|
let(:session) do
|
@@ -120,7 +136,7 @@ describe VagrantPlugins::Openstack::GlanceClient do
|
|
120
136
|
}
|
121
137
|
]}')
|
122
138
|
|
123
|
-
versions = @glance_client.get_api_version_list(
|
139
|
+
versions = @glance_client.get_api_version_list(env)
|
124
140
|
|
125
141
|
expect(versions.size).to eq(2)
|
126
142
|
end
|
@@ -3,6 +3,13 @@ require 'vagrant-openstack-provider/spec_helper'
|
|
3
3
|
describe VagrantPlugins::Openstack::NovaClient do
|
4
4
|
include FakeFS::SpecHelpers::All
|
5
5
|
|
6
|
+
let(:http) do
|
7
|
+
double('http').tap do |http|
|
8
|
+
http.stub(:read_timeout) { 42 }
|
9
|
+
http.stub(:open_timeout) { 43 }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
6
13
|
let(:config) do
|
7
14
|
double('config').tap do |config|
|
8
15
|
config.stub(:openstack_auth_url) { 'http://heatAuthV2' }
|
@@ -10,6 +17,7 @@ describe VagrantPlugins::Openstack::NovaClient do
|
|
10
17
|
config.stub(:tenant_name) { 'testTenant' }
|
11
18
|
config.stub(:username) { 'username' }
|
12
19
|
config.stub(:password) { 'password' }
|
20
|
+
config.stub(:http) { http }
|
13
21
|
end
|
14
22
|
end
|
15
23
|
|
@@ -2,6 +2,13 @@ require 'vagrant-openstack-provider/spec_helper'
|
|
2
2
|
|
3
3
|
describe VagrantPlugins::Openstack::KeystoneClient do
|
4
4
|
|
5
|
+
let(:http) do
|
6
|
+
double('http').tap do |http|
|
7
|
+
http.stub(:read_timeout) { 42 }
|
8
|
+
http.stub(:open_timeout) { 43 }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
5
12
|
let(:config) do
|
6
13
|
double('config').tap do |config|
|
7
14
|
config.stub(:openstack_auth_url) { 'http://keystoneAuthV2' }
|
@@ -10,6 +17,7 @@ describe VagrantPlugins::Openstack::KeystoneClient do
|
|
10
17
|
config.stub(:tenant_name) { 'testTenant' }
|
11
18
|
config.stub(:username) { 'username' }
|
12
19
|
config.stub(:password) { 'password' }
|
20
|
+
config.stub(:http) { http }
|
13
21
|
end
|
14
22
|
end
|
15
23
|
|
@@ -2,8 +2,24 @@ require 'vagrant-openstack-provider/spec_helper'
|
|
2
2
|
|
3
3
|
describe VagrantPlugins::Openstack::NeutronClient do
|
4
4
|
|
5
|
+
let(:http) do
|
6
|
+
double('http').tap do |http|
|
7
|
+
http.stub(:read_timeout) { 42 }
|
8
|
+
http.stub(:open_timeout) { 43 }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:config) do
|
13
|
+
double('config').tap do |config|
|
14
|
+
config.stub(:http) { http }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
5
18
|
let(:env) do
|
6
|
-
Hash.new
|
19
|
+
Hash.new.tap do |env|
|
20
|
+
env[:machine] = double('machine')
|
21
|
+
env[:machine].stub(:provider_config) { config }
|
22
|
+
end
|
7
23
|
end
|
8
24
|
|
9
25
|
let(:session) do
|
@@ -150,7 +166,7 @@ describe VagrantPlugins::Openstack::NeutronClient do
|
|
150
166
|
}
|
151
167
|
]}')
|
152
168
|
|
153
|
-
versions = @neutron_client.get_api_version_list(:network)
|
169
|
+
versions = @neutron_client.get_api_version_list(env, :network)
|
154
170
|
|
155
171
|
expect(versions.size).to eq(2)
|
156
172
|
end
|
@@ -6,6 +6,13 @@ describe VagrantPlugins::Openstack::NovaClient do
|
|
6
6
|
let(:filename) { 'key.pub' }
|
7
7
|
let(:ssh_key_content) { 'my public key' }
|
8
8
|
|
9
|
+
let(:http) do
|
10
|
+
double('http').tap do |http|
|
11
|
+
http.stub(:read_timeout) { 42 }
|
12
|
+
http.stub(:open_timeout) { 43 }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
9
16
|
let(:config) do
|
10
17
|
double('config').tap do |config|
|
11
18
|
config.stub(:openstack_auth_url) { 'http://novaAuthV2' }
|
@@ -13,6 +20,7 @@ describe VagrantPlugins::Openstack::NovaClient do
|
|
13
20
|
config.stub(:tenant_name) { 'testTenant' }
|
14
21
|
config.stub(:username) { 'username' }
|
15
22
|
config.stub(:password) { 'password' }
|
23
|
+
config.stub(:http) { http }
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
@@ -160,6 +160,16 @@ describe VagrantPlugins::Openstack::ConfigResolver do
|
|
160
160
|
@action.resolve_flavor(env).should eq(Flavor.new('fl-002', 'flavor-02', 4, 2048, 50))
|
161
161
|
end
|
162
162
|
end
|
163
|
+
context 'with list' do
|
164
|
+
it 'returns the first matching flavor' do
|
165
|
+
config.stub(:flavor) { %w(not-existing flavor-02 flavor-01) }
|
166
|
+
nova.stub(:get_all_flavors).with(anything) do
|
167
|
+
[Flavor.new('fl-001', 'flavor-01', 2, 1024, 10),
|
168
|
+
Flavor.new('fl-002', 'flavor-02', 4, 2048, 50)]
|
169
|
+
end
|
170
|
+
@action.resolve_flavor(env).should eq(Flavor.new('fl-002', 'flavor-02', 4, 2048, 50))
|
171
|
+
end
|
172
|
+
end
|
163
173
|
context 'with invalid identifier' do
|
164
174
|
it 'raise an error' do
|
165
175
|
config.stub(:flavor) { 'not-existing' }
|
@@ -75,7 +75,7 @@ describe VagrantPlugins::Openstack::Config do
|
|
75
75
|
|
76
76
|
subject { foo_class.new }
|
77
77
|
|
78
|
-
context 'with original network not empty' do
|
78
|
+
context 'with original network not empty array' do
|
79
79
|
it 'should overidde the config' do
|
80
80
|
one = foo_class.new
|
81
81
|
one.networks = ['foo']
|
@@ -88,7 +88,7 @@ describe VagrantPlugins::Openstack::Config do
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
context 'with original network empty' do
|
91
|
+
context 'with original network empty array' do
|
92
92
|
it 'should add the network to the existing list' do
|
93
93
|
one = foo_class.new
|
94
94
|
one.networks = []
|
@@ -101,7 +101,7 @@ describe VagrantPlugins::Openstack::Config do
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
context 'with original network not empty and new empty' do
|
104
|
+
context 'with original network not empty array and new empty array' do
|
105
105
|
it 'should keep the original network' do
|
106
106
|
one = foo_class.new
|
107
107
|
one.networks = ['foo']
|
@@ -114,6 +114,32 @@ describe VagrantPlugins::Openstack::Config do
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
context 'with original network is a string and new empty array' do
|
118
|
+
it 'should keep the original network and wrap it into an array' do
|
119
|
+
one = foo_class.new
|
120
|
+
one.networks = 'foo'
|
121
|
+
|
122
|
+
two = foo_class.new
|
123
|
+
two.networks = []
|
124
|
+
|
125
|
+
result = one.merge(two)
|
126
|
+
result.networks.should =~ ['foo']
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'with original network is a string and new is a string' do
|
131
|
+
it 'should overidde the config and wrap it into an array' do
|
132
|
+
one = foo_class.new
|
133
|
+
one.networks = 'foo'
|
134
|
+
|
135
|
+
two = foo_class.new
|
136
|
+
two.networks = 'bar'
|
137
|
+
|
138
|
+
result = one.merge(two)
|
139
|
+
result.networks.should =~ ['bar']
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
117
143
|
context 'with original floating_ip_pool as string' do
|
118
144
|
context 'and new as empty array' do
|
119
145
|
it 'should put original string in a single entry array' do
|
@@ -222,6 +248,7 @@ describe VagrantPlugins::Openstack::Config do
|
|
222
248
|
machine.stub(:config) { config }
|
223
249
|
subject.username = 'foo'
|
224
250
|
subject.password = 'bar'
|
251
|
+
subject.tenant_name = 'tenant'
|
225
252
|
subject.keypair_name = 'keypair'
|
226
253
|
end
|
227
254
|
|
@@ -299,7 +326,7 @@ describe VagrantPlugins::Openstack::Config do
|
|
299
326
|
end
|
300
327
|
end
|
301
328
|
|
302
|
-
context 'the
|
329
|
+
context 'the password' do
|
303
330
|
it 'should error if not given' do
|
304
331
|
subject.password = nil
|
305
332
|
I18n.should_receive(:t).with('vagrant_openstack.config.password_required').and_return error_message
|
@@ -315,6 +342,14 @@ describe VagrantPlugins::Openstack::Config do
|
|
315
342
|
end
|
316
343
|
end
|
317
344
|
|
345
|
+
context 'the tenant name' do
|
346
|
+
it 'should error if not given' do
|
347
|
+
subject.tenant_name = nil
|
348
|
+
I18n.should_receive(:t).with('vagrant_openstack.config.tenant_name_required').and_return error_message
|
349
|
+
validation_errors.first.should == error_message
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
318
353
|
context 'the ssh_timeout' do
|
319
354
|
it 'should error if do not represent an integer' do
|
320
355
|
subject.ssh_timeout = 'timeout'
|