vagrant-openstack-illuin-provider 0.12.0
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 +7 -0
- data/.gitignore +22 -0
- data/.rubocop.yml +40 -0
- data/CHANGELOG.md +282 -0
- data/Gemfile +18 -0
- data/RELEASE.md +15 -0
- data/Rakefile +25 -0
- data/Vagrantfile +20 -0
- data/dummy.box +0 -0
- data/example_box/README.md +13 -0
- data/example_box/metadata.json +3 -0
- data/functional_tests/Vagrantfile +58 -0
- data/functional_tests/keys/vagrant-openstack +27 -0
- data/functional_tests/keys/vagrant-openstack.pub +1 -0
- data/functional_tests/run_tests.sh +142 -0
- data/lib/vagrant-openstack-illuin-provider.rb +29 -0
- data/lib/vagrant-openstack-illuin-provider/action.rb +344 -0
- data/lib/vagrant-openstack-illuin-provider/action/abstract_action.rb +22 -0
- data/lib/vagrant-openstack-illuin-provider/action/connect_openstack.rb +60 -0
- data/lib/vagrant-openstack-illuin-provider/action/create_server.rb +187 -0
- data/lib/vagrant-openstack-illuin-provider/action/create_stack.rb +76 -0
- data/lib/vagrant-openstack-illuin-provider/action/delete_server.rb +53 -0
- data/lib/vagrant-openstack-illuin-provider/action/delete_stack.rb +73 -0
- data/lib/vagrant-openstack-illuin-provider/action/message.rb +19 -0
- data/lib/vagrant-openstack-illuin-provider/action/provision.rb +60 -0
- data/lib/vagrant-openstack-illuin-provider/action/read_ssh_info.rb +74 -0
- data/lib/vagrant-openstack-illuin-provider/action/read_state.rb +43 -0
- data/lib/vagrant-openstack-illuin-provider/action/resume.rb +24 -0
- data/lib/vagrant-openstack-illuin-provider/action/snapshot_cleanup.rb +32 -0
- data/lib/vagrant-openstack-illuin-provider/action/snapshot_delete.rb +32 -0
- data/lib/vagrant-openstack-illuin-provider/action/snapshot_list.rb +22 -0
- data/lib/vagrant-openstack-illuin-provider/action/snapshot_restore.rb +29 -0
- data/lib/vagrant-openstack-illuin-provider/action/snapshot_save.rb +51 -0
- data/lib/vagrant-openstack-illuin-provider/action/start_server.rb +24 -0
- data/lib/vagrant-openstack-illuin-provider/action/stop_server.rb +25 -0
- data/lib/vagrant-openstack-illuin-provider/action/suspend.rb +24 -0
- data/lib/vagrant-openstack-illuin-provider/action/sync_folders.rb +138 -0
- data/lib/vagrant-openstack-illuin-provider/action/wait_active.rb +33 -0
- data/lib/vagrant-openstack-illuin-provider/action/wait_stop.rb +33 -0
- data/lib/vagrant-openstack-illuin-provider/cap/snapshot_list.rb +15 -0
- data/lib/vagrant-openstack-illuin-provider/catalog/openstack_catalog.rb +90 -0
- data/lib/vagrant-openstack-illuin-provider/client/cinder.rb +39 -0
- data/lib/vagrant-openstack-illuin-provider/client/domain.rb +163 -0
- data/lib/vagrant-openstack-illuin-provider/client/glance.rb +65 -0
- data/lib/vagrant-openstack-illuin-provider/client/heat.rb +49 -0
- data/lib/vagrant-openstack-illuin-provider/client/http_utils.rb +116 -0
- data/lib/vagrant-openstack-illuin-provider/client/keystone.rb +128 -0
- data/lib/vagrant-openstack-illuin-provider/client/neutron.rb +48 -0
- data/lib/vagrant-openstack-illuin-provider/client/nova.rb +303 -0
- data/lib/vagrant-openstack-illuin-provider/client/openstack.rb +59 -0
- data/lib/vagrant-openstack-illuin-provider/client/request_logger.rb +23 -0
- data/lib/vagrant-openstack-illuin-provider/client/rest_utils.rb +28 -0
- data/lib/vagrant-openstack-illuin-provider/command/abstract_command.rb +51 -0
- data/lib/vagrant-openstack-illuin-provider/command/flavor_list.rb +24 -0
- data/lib/vagrant-openstack-illuin-provider/command/floatingip_list.rb +32 -0
- data/lib/vagrant-openstack-illuin-provider/command/image_list.rb +29 -0
- data/lib/vagrant-openstack-illuin-provider/command/main.rb +52 -0
- data/lib/vagrant-openstack-illuin-provider/command/network_list.rb +25 -0
- data/lib/vagrant-openstack-illuin-provider/command/openstack_command.rb +16 -0
- data/lib/vagrant-openstack-illuin-provider/command/reset.rb +20 -0
- data/lib/vagrant-openstack-illuin-provider/command/subnet_list.rb +22 -0
- data/lib/vagrant-openstack-illuin-provider/command/utils.rb +22 -0
- data/lib/vagrant-openstack-illuin-provider/command/volume_list.rb +25 -0
- data/lib/vagrant-openstack-illuin-provider/config.rb +505 -0
- data/lib/vagrant-openstack-illuin-provider/config/http.rb +39 -0
- data/lib/vagrant-openstack-illuin-provider/config_resolver.rb +334 -0
- data/lib/vagrant-openstack-illuin-provider/errors.rb +187 -0
- data/lib/vagrant-openstack-illuin-provider/logging.rb +39 -0
- data/lib/vagrant-openstack-illuin-provider/plugin.rb +58 -0
- data/lib/vagrant-openstack-illuin-provider/provider.rb +50 -0
- data/lib/vagrant-openstack-illuin-provider/utils.rb +81 -0
- data/lib/vagrant-openstack-illuin-provider/version.rb +15 -0
- data/lib/vagrant-openstack-illuin-provider/version_checker.rb +76 -0
- data/locales/en.yml +412 -0
- data/spec/vagrant-openstack-illuin-provider/action/connect_openstack_spec.rb +770 -0
- data/spec/vagrant-openstack-illuin-provider/action/create_server_spec.rb +260 -0
- data/spec/vagrant-openstack-illuin-provider/action/create_stack_spec.rb +99 -0
- data/spec/vagrant-openstack-illuin-provider/action/delete_server_spec.rb +89 -0
- data/spec/vagrant-openstack-illuin-provider/action/delete_stack_spec.rb +63 -0
- data/spec/vagrant-openstack-illuin-provider/action/message_spec.rb +33 -0
- data/spec/vagrant-openstack-illuin-provider/action/provision_spec.rb +97 -0
- data/spec/vagrant-openstack-illuin-provider/action/read_ssh_info_spec.rb +202 -0
- data/spec/vagrant-openstack-illuin-provider/action/read_state_spec.rb +81 -0
- data/spec/vagrant-openstack-illuin-provider/action/resume_server_spec.rb +49 -0
- data/spec/vagrant-openstack-illuin-provider/action/start_server_spec.rb +49 -0
- data/spec/vagrant-openstack-illuin-provider/action/stop_server_spec.rb +49 -0
- data/spec/vagrant-openstack-illuin-provider/action/suspend_server_spec.rb +49 -0
- data/spec/vagrant-openstack-illuin-provider/action/sync_folders_spec.rb +155 -0
- data/spec/vagrant-openstack-illuin-provider/action/wait_active_spec.rb +53 -0
- data/spec/vagrant-openstack-illuin-provider/action/wait_stop_spec.rb +53 -0
- data/spec/vagrant-openstack-illuin-provider/action_spec.rb +120 -0
- data/spec/vagrant-openstack-illuin-provider/client/cinder_spec.rb +129 -0
- data/spec/vagrant-openstack-illuin-provider/client/glance_spec.rb +145 -0
- data/spec/vagrant-openstack-illuin-provider/client/heat_spec.rb +130 -0
- data/spec/vagrant-openstack-illuin-provider/client/keystone_spec.rb +226 -0
- data/spec/vagrant-openstack-illuin-provider/client/neutron_spec.rb +173 -0
- data/spec/vagrant-openstack-illuin-provider/client/nova_spec.rb +760 -0
- data/spec/vagrant-openstack-illuin-provider/client/utils_spec.rb +176 -0
- data/spec/vagrant-openstack-illuin-provider/command/flavor_list_spec.rb +43 -0
- data/spec/vagrant-openstack-illuin-provider/command/floatingip_list_spec.rb +74 -0
- data/spec/vagrant-openstack-illuin-provider/command/image_list_spec.rb +95 -0
- data/spec/vagrant-openstack-illuin-provider/command/network_list_spec.rb +65 -0
- data/spec/vagrant-openstack-illuin-provider/command/reset_spec.rb +24 -0
- data/spec/vagrant-openstack-illuin-provider/command/subnet_list_spec.rb +45 -0
- data/spec/vagrant-openstack-illuin-provider/command/volume_list_spec.rb +40 -0
- data/spec/vagrant-openstack-illuin-provider/config_resolver_spec.rb +879 -0
- data/spec/vagrant-openstack-illuin-provider/config_spec.rb +416 -0
- data/spec/vagrant-openstack-illuin-provider/e2e_spec.rb.save +27 -0
- data/spec/vagrant-openstack-illuin-provider/provider_spec.rb +13 -0
- data/spec/vagrant-openstack-illuin-provider/spec_helper.rb +37 -0
- data/spec/vagrant-openstack-illuin-provider/utils_spec.rb +197 -0
- data/spec/vagrant-openstack-illuin-provider/version_checker_spec.rb +39 -0
- data/stackrc +25 -0
- data/vagrant-openstack-illuin-provider.gemspec +35 -0
- metadata +379 -0
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
require 'vagrant-openstack-illuin-provider/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe VagrantPlugins::Openstack::Config do
|
|
4
|
+
describe 'defaults' do
|
|
5
|
+
let(:vagrant_public_key) { Vagrant.source_root.join('keys/vagrant.pub') }
|
|
6
|
+
|
|
7
|
+
subject do
|
|
8
|
+
super().tap(&:finalize!)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
its(:password) { should be_nil }
|
|
12
|
+
its(:openstack_compute_url) { should be_nil }
|
|
13
|
+
its(:openstack_auth_url) { should be_nil }
|
|
14
|
+
its(:openstack_orchestration_url) { should be_nil }
|
|
15
|
+
its(:flavor) { should be_nil }
|
|
16
|
+
its(:image) { should be_nil }
|
|
17
|
+
its(:server_name) { should be_nil }
|
|
18
|
+
its(:username) { should be_nil }
|
|
19
|
+
its(:use_legacy_synced_folders) { should eq(false) }
|
|
20
|
+
its(:rsync_includes) { should be_nil }
|
|
21
|
+
its(:rsync_ignore_files) { should be_nil }
|
|
22
|
+
its(:sync_method) { should be_nil }
|
|
23
|
+
its(:keypair_name) { should be_nil }
|
|
24
|
+
its(:public_key_path) { should be_nil }
|
|
25
|
+
its(:availability_zone) { should be_nil }
|
|
26
|
+
its(:ssh_username) { should be_nil }
|
|
27
|
+
its(:floating_ip_pool_always_allocate) { should eq(false) }
|
|
28
|
+
its(:scheduler_hints) { should be_nil }
|
|
29
|
+
its(:security_groups) { should be_nil }
|
|
30
|
+
its(:user_data) { should be_nil }
|
|
31
|
+
its(:metadata) { should be_nil }
|
|
32
|
+
its(:ssl_ca_file) { should eq nil }
|
|
33
|
+
its(:ip_version) { should be_nil }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe 'overriding defaults' do
|
|
37
|
+
[
|
|
38
|
+
:password,
|
|
39
|
+
:openstack_compute_url,
|
|
40
|
+
:openstack_auth_url,
|
|
41
|
+
:flavor,
|
|
42
|
+
:image,
|
|
43
|
+
:server_name,
|
|
44
|
+
:username,
|
|
45
|
+
:keypair_name,
|
|
46
|
+
:ssh_username,
|
|
47
|
+
:floating_ip_pool_always_allocate,
|
|
48
|
+
:scheduler_hints,
|
|
49
|
+
:security_groups,
|
|
50
|
+
:openstack_orchestration_url,
|
|
51
|
+
:stacks,
|
|
52
|
+
:user_data,
|
|
53
|
+
:metadata,
|
|
54
|
+
:availability_zone,
|
|
55
|
+
:public_key_path,
|
|
56
|
+
:ssl_ca_file,
|
|
57
|
+
:ip_version].each do |attribute|
|
|
58
|
+
it "should not default #{attribute} if overridden" do
|
|
59
|
+
subject.send("#{attribute}=".to_sym, 'foo')
|
|
60
|
+
subject.finalize!
|
|
61
|
+
subject.send(attribute).should == 'foo'
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe 'use_legacy_synced_folders' do
|
|
66
|
+
it 'should default to true if sync_method is set' do
|
|
67
|
+
subject.sync_method = 'rsync'
|
|
68
|
+
subject.finalize!
|
|
69
|
+
|
|
70
|
+
expect(subject.use_legacy_synced_folders).to eq(true)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'should default to true if rsync_includes is non-empty' do
|
|
74
|
+
subject.rsync_includes = ['some/file']
|
|
75
|
+
subject.finalize!
|
|
76
|
+
|
|
77
|
+
expect(subject.use_legacy_synced_folders).to eq(true)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'should default to true if rsync_ignore_files is non-empty' do
|
|
81
|
+
subject.rsync_ignore_files = ['some/file']
|
|
82
|
+
subject.finalize!
|
|
83
|
+
|
|
84
|
+
expect(subject.use_legacy_synced_folders).to eq(true)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it 'should not default rsync_includes if overridden' do
|
|
89
|
+
inc = 'core'
|
|
90
|
+
subject.send(:rsync_include, inc)
|
|
91
|
+
subject.finalize!
|
|
92
|
+
|
|
93
|
+
expect(subject.rsync_includes).to include(inc)
|
|
94
|
+
expect(subject.use_legacy_synced_folders).to eq(true)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe 'merge' do
|
|
99
|
+
let(:foo_class) do
|
|
100
|
+
Class.new(described_class) do
|
|
101
|
+
attr_accessor :networks
|
|
102
|
+
attr_accessor :floating_ip_pool
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
subject { foo_class.new }
|
|
107
|
+
|
|
108
|
+
context 'with original network not empty array' do
|
|
109
|
+
it 'should overidde the config' do
|
|
110
|
+
one = foo_class.new
|
|
111
|
+
one.networks = ['foo']
|
|
112
|
+
|
|
113
|
+
two = foo_class.new
|
|
114
|
+
two.networks = ['bar']
|
|
115
|
+
|
|
116
|
+
result = one.merge(two)
|
|
117
|
+
result.networks.should =~ ['bar']
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
context 'with original network empty array' do
|
|
122
|
+
it 'should add the network to the existing list' do
|
|
123
|
+
one = foo_class.new
|
|
124
|
+
one.networks = []
|
|
125
|
+
|
|
126
|
+
two = foo_class.new
|
|
127
|
+
two.networks = ['bar']
|
|
128
|
+
|
|
129
|
+
result = one.merge(two)
|
|
130
|
+
result.networks.should =~ ['bar']
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
context 'with original network not empty array and new empty array' do
|
|
135
|
+
it 'should keep the original network' do
|
|
136
|
+
one = foo_class.new
|
|
137
|
+
one.networks = ['foo']
|
|
138
|
+
|
|
139
|
+
two = foo_class.new
|
|
140
|
+
two.networks = []
|
|
141
|
+
|
|
142
|
+
result = one.merge(two)
|
|
143
|
+
result.networks.should =~ ['foo']
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
context 'with original network is a string and new empty array' do
|
|
148
|
+
it 'should keep the original network and wrap it into an array' do
|
|
149
|
+
one = foo_class.new
|
|
150
|
+
one.networks = 'foo'
|
|
151
|
+
|
|
152
|
+
two = foo_class.new
|
|
153
|
+
two.networks = []
|
|
154
|
+
|
|
155
|
+
result = one.merge(two)
|
|
156
|
+
result.networks.should =~ ['foo']
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
context 'with original network is a string and new is a string' do
|
|
161
|
+
it 'should overidde the config and wrap it into an array' do
|
|
162
|
+
one = foo_class.new
|
|
163
|
+
one.networks = 'foo'
|
|
164
|
+
|
|
165
|
+
two = foo_class.new
|
|
166
|
+
two.networks = 'bar'
|
|
167
|
+
|
|
168
|
+
result = one.merge(two)
|
|
169
|
+
result.networks.should =~ ['bar']
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
context 'with original floating_ip_pool as string' do
|
|
174
|
+
context 'and new as empty array' do
|
|
175
|
+
it 'should put original string in a single entry array' do
|
|
176
|
+
one = foo_class.new
|
|
177
|
+
one.floating_ip_pool = 'pool'
|
|
178
|
+
|
|
179
|
+
two = foo_class.new
|
|
180
|
+
two.floating_ip_pool = []
|
|
181
|
+
|
|
182
|
+
result = one.merge(two)
|
|
183
|
+
result.floating_ip_pool.should =~ ['pool']
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
context 'and new as empty string' do
|
|
187
|
+
it 'should put original string in a single entry array' do
|
|
188
|
+
one = foo_class.new
|
|
189
|
+
one.floating_ip_pool = 'pool'
|
|
190
|
+
|
|
191
|
+
two = foo_class.new
|
|
192
|
+
two.floating_ip_pool = ''
|
|
193
|
+
|
|
194
|
+
result = one.merge(two)
|
|
195
|
+
result.floating_ip_pool.should =~ ['']
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
context 'and new as string' do
|
|
199
|
+
it 'should put new string in a single entry array' do
|
|
200
|
+
one = foo_class.new
|
|
201
|
+
one.floating_ip_pool = 'pool'
|
|
202
|
+
|
|
203
|
+
two = foo_class.new
|
|
204
|
+
two.floating_ip_pool = 'new-pool'
|
|
205
|
+
|
|
206
|
+
result = one.merge(two)
|
|
207
|
+
result.floating_ip_pool.should =~ ['new-pool']
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
context 'and new as array' do
|
|
211
|
+
it 'should put new array' do
|
|
212
|
+
one = foo_class.new
|
|
213
|
+
one.floating_ip_pool = 'pool'
|
|
214
|
+
|
|
215
|
+
two = foo_class.new
|
|
216
|
+
two.floating_ip_pool = %w(pool-1 pool-2)
|
|
217
|
+
|
|
218
|
+
result = one.merge(two)
|
|
219
|
+
result.floating_ip_pool.should =~ %w(pool-1 pool-2)
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
context 'with original floating_ip_pool as array' do
|
|
225
|
+
context 'and new empty' do
|
|
226
|
+
it 'should put original array' do
|
|
227
|
+
one = foo_class.new
|
|
228
|
+
one.floating_ip_pool = %w(pool-1 pool-2)
|
|
229
|
+
|
|
230
|
+
two = foo_class.new
|
|
231
|
+
two.floating_ip_pool = []
|
|
232
|
+
|
|
233
|
+
result = one.merge(two)
|
|
234
|
+
result.floating_ip_pool.should =~ %w(pool-1 pool-2)
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
context 'and new as string' do
|
|
238
|
+
it 'should put new string in a single entry array' do
|
|
239
|
+
one = foo_class.new
|
|
240
|
+
one.floating_ip_pool = %w(pool-1 pool-2)
|
|
241
|
+
|
|
242
|
+
two = foo_class.new
|
|
243
|
+
two.floating_ip_pool = 'pool'
|
|
244
|
+
|
|
245
|
+
result = one.merge(two)
|
|
246
|
+
result.floating_ip_pool.should =~ ['pool']
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
context 'and new as array' do
|
|
250
|
+
it 'should put new array' do
|
|
251
|
+
one = foo_class.new
|
|
252
|
+
one.floating_ip_pool = %w(pool-1 pool-2)
|
|
253
|
+
|
|
254
|
+
two = foo_class.new
|
|
255
|
+
two.floating_ip_pool = %w(new-pool-1 new-pool-2)
|
|
256
|
+
|
|
257
|
+
result = one.merge(two)
|
|
258
|
+
result.floating_ip_pool.should =~ %w(new-pool-1 new-pool-2)
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
describe 'validation' do
|
|
265
|
+
let(:machine) { double('machine') }
|
|
266
|
+
let(:validation_errors) { subject.validate(machine)['Openstack Provider'] }
|
|
267
|
+
let(:error_message) { double('error message') }
|
|
268
|
+
|
|
269
|
+
let(:config) { double('config') }
|
|
270
|
+
let(:ssh) { double('ssh') }
|
|
271
|
+
|
|
272
|
+
before(:each) do
|
|
273
|
+
error_message.stub(:yellow) { 'Yellowed Error message ' }
|
|
274
|
+
machine.stub_chain(:env, :root_path).and_return '/'
|
|
275
|
+
ssh.stub(:private_key_path) { 'private key path' }
|
|
276
|
+
ssh.stub(:username) { 'ssh username' }
|
|
277
|
+
ssh.stub(:insert_key) { true }
|
|
278
|
+
config.stub(:ssh) { ssh }
|
|
279
|
+
machine.stub(:config) { config }
|
|
280
|
+
subject.username = 'foo'
|
|
281
|
+
subject.password = 'bar'
|
|
282
|
+
subject.tenant_name = 'tenant'
|
|
283
|
+
subject.keypair_name = 'keypair'
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
subject do
|
|
287
|
+
super().tap(&:finalize!)
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
context 'with invalid stack' do
|
|
291
|
+
it 'should raise an error' do
|
|
292
|
+
subject.stacks = [
|
|
293
|
+
{
|
|
294
|
+
name: 'test1'
|
|
295
|
+
}
|
|
296
|
+
]
|
|
297
|
+
I18n.should_receive(:t).with('vagrant_openstack.config.invalid_stack').and_return error_message
|
|
298
|
+
validation_errors.first.should == error_message
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
it 'should raise an error' do
|
|
302
|
+
subject.stacks = [
|
|
303
|
+
{
|
|
304
|
+
name: 'test1',
|
|
305
|
+
tempslate: 'tes1'
|
|
306
|
+
}
|
|
307
|
+
]
|
|
308
|
+
I18n.should_receive(:t).with('vagrant_openstack.config.invalid_stack').and_return error_message
|
|
309
|
+
validation_errors.first.should == error_message
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
it 'should not raise an error' do
|
|
313
|
+
subject.stacks = [
|
|
314
|
+
{
|
|
315
|
+
name: 'test1',
|
|
316
|
+
template: 'tes1'
|
|
317
|
+
}
|
|
318
|
+
]
|
|
319
|
+
expect(validation_errors).to be_empty
|
|
320
|
+
end
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
context 'with invalid key' do
|
|
324
|
+
it 'should raise an error' do
|
|
325
|
+
subject.nonsense1 = true
|
|
326
|
+
subject.nonsense2 = false
|
|
327
|
+
I18n.should_receive(:t).with('vagrant.config.common.bad_field', fields: 'nonsense1, nonsense2').and_return error_message
|
|
328
|
+
validation_errors.first.should == error_message
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
context 'with no ssh username provider' do
|
|
333
|
+
it 'should raise an error' do
|
|
334
|
+
ssh.stub(:username) { nil }
|
|
335
|
+
subject.ssh_username = nil
|
|
336
|
+
I18n.should_receive(:t).with('vagrant_openstack.config.ssh_username_required').and_return error_message
|
|
337
|
+
validation_errors.first.should == error_message
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
context 'with good values' do
|
|
342
|
+
it 'should validate' do
|
|
343
|
+
validation_errors.should be_empty
|
|
344
|
+
end
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
context 'private_key_path is not set' do
|
|
348
|
+
context 'keypair_name or public_key_path is set' do
|
|
349
|
+
it 'should error if not given' do
|
|
350
|
+
ssh.stub(:private_key_path) { nil }
|
|
351
|
+
subject.public_key_path = 'public_key'
|
|
352
|
+
I18n.should_receive(:t).with('vagrant_openstack.config.private_key_missing').and_return error_message
|
|
353
|
+
validation_errors.first.should == error_message
|
|
354
|
+
end
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
context 'keypair_name or public_key_path is set and ssh.insert_key is false' do
|
|
358
|
+
it 'should not error' do
|
|
359
|
+
ssh.stub(:private_key_path) { nil }
|
|
360
|
+
ssh.stub(:insert_key) { false }
|
|
361
|
+
subject.public_key_path = 'public_key'
|
|
362
|
+
I18n.should_not_receive(:t)
|
|
363
|
+
validation_errors.should be_empty
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
context 'the password' do
|
|
369
|
+
it 'should error if not given' do
|
|
370
|
+
subject.password = nil
|
|
371
|
+
I18n.should_receive(:t).with('vagrant_openstack.config.password_required').and_return error_message
|
|
372
|
+
validation_errors.first.should == error_message
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
context 'the username' do
|
|
377
|
+
it 'should error if not given' do
|
|
378
|
+
subject.username = nil
|
|
379
|
+
I18n.should_receive(:t).with('vagrant_openstack.config.username_required').and_return error_message
|
|
380
|
+
validation_errors.first.should == error_message
|
|
381
|
+
end
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
context 'the tenant name' do
|
|
385
|
+
it 'should error if not given' do
|
|
386
|
+
subject.tenant_name = nil
|
|
387
|
+
I18n.should_receive(:t).with('vagrant_openstack.config.tenant_name_required').and_return error_message
|
|
388
|
+
validation_errors.first.should == error_message
|
|
389
|
+
end
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
context 'the ssh_timeout' do
|
|
393
|
+
it 'should error if do not represent an integer' do
|
|
394
|
+
subject.ssh_timeout = 'timeout'
|
|
395
|
+
I18n.should_receive(:t).with('vagrant_openstack.config.invalid_value_for_parameter',
|
|
396
|
+
parameter: 'ssh_timeout', value: 'timeout').and_return error_message
|
|
397
|
+
validation_errors.first.should == error_message
|
|
398
|
+
end
|
|
399
|
+
it 'should be parsed as integer if is a string that represent an integer' do
|
|
400
|
+
subject.ssh_timeout = '100'
|
|
401
|
+
validation_errors.size.should eq(0)
|
|
402
|
+
expect(subject.ssh_timeout).to eq(100)
|
|
403
|
+
end
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
[:openstack_compute_url, :openstack_auth_url, :openstack_orchestration_url].each do |url|
|
|
407
|
+
context "the #{url}" do
|
|
408
|
+
it 'should not validate if the URL is invalid' do
|
|
409
|
+
subject.send "#{url}=", 'baz'
|
|
410
|
+
I18n.should_receive(:t).with('vagrant_openstack.config.invalid_uri', key: url, uri: 'baz').and_return error_message
|
|
411
|
+
validation_errors.first.should == error_message
|
|
412
|
+
end
|
|
413
|
+
end
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'vagrant-openstack-provider/spec_helper'
|
|
2
|
+
|
|
3
|
+
require 'aruba'
|
|
4
|
+
require 'aruba/api'
|
|
5
|
+
|
|
6
|
+
include Aruba::Api
|
|
7
|
+
|
|
8
|
+
# spec/template_spec.rb
|
|
9
|
+
require 'pathname'
|
|
10
|
+
|
|
11
|
+
root = Pathname.new(__FILE__).parent.parent
|
|
12
|
+
|
|
13
|
+
# Allows us to run commands directly, without worrying about the CWD
|
|
14
|
+
ENV['PATH'] = "#{root.join('bin').to_s}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
|
15
|
+
|
|
16
|
+
describe "genud" do
|
|
17
|
+
context "YAML templates" do
|
|
18
|
+
it "should emit valid YAML to STDOUT", :focus do
|
|
19
|
+
|
|
20
|
+
puts '#####################'
|
|
21
|
+
# Run the command with Aruba's run_simple helper
|
|
22
|
+
run_simple "bundle exec vagrant openstack", false, 10
|
|
23
|
+
|
|
24
|
+
# assert_exit_status(0)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'vagrant-openstack-illuin-provider/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe VagrantPlugins::Openstack::Provider do
|
|
4
|
+
before :each do
|
|
5
|
+
@provider = VagrantPlugins::Openstack::Provider.new :machine
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe 'to string' do
|
|
9
|
+
it 'should give the provider name' do
|
|
10
|
+
@provider.to_s.should eq('Openstack Cloud')
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|