knife-openstack 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/lib/chef/knife/cloud/openstack_server_create_options.rb +16 -1
  3. data/lib/chef/knife/cloud/openstack_service.rb +14 -2
  4. data/lib/chef/knife/cloud/openstack_service_options.rb +17 -1
  5. data/lib/chef/knife/openstack_flavor_list.rb +16 -2
  6. data/lib/chef/knife/openstack_floating_ip_allocate.rb +16 -2
  7. data/lib/chef/knife/openstack_floating_ip_associate.rb +17 -3
  8. data/lib/chef/knife/openstack_floating_ip_disassociate.rb +17 -3
  9. data/lib/chef/knife/openstack_floating_ip_list.rb +16 -2
  10. data/lib/chef/knife/openstack_floating_ip_release.rb +14 -2
  11. data/lib/chef/knife/openstack_group_list.rb +18 -1
  12. data/lib/chef/knife/openstack_helpers.rb +17 -1
  13. data/lib/chef/knife/openstack_image_list.rb +16 -2
  14. data/lib/chef/knife/openstack_network_list.rb +16 -2
  15. data/lib/chef/knife/openstack_server_create.rb +3 -4
  16. data/lib/chef/knife/openstack_server_delete.rb +14 -2
  17. data/lib/chef/knife/openstack_server_list.rb +3 -4
  18. data/lib/chef/knife/openstack_server_show.rb +1 -2
  19. data/lib/chef/knife/openstack_volume_list.rb +4 -4
  20. data/lib/knife-openstack/version.rb +2 -2
  21. metadata +8 -207
  22. data/.github/ISSUE_TEMPLATE.md +0 -21
  23. data/.gitignore +0 -32
  24. data/.travis.yml +0 -18
  25. data/CHANGELOG.md +0 -339
  26. data/CONTRIBUTING.MD +0 -164
  27. data/Gemfile +0 -5
  28. data/README.md +0 -179
  29. data/Rakefile +0 -29
  30. data/knife-openstack.gemspec +0 -41
  31. data/spec/functional/flavor_list_func_spec.rb +0 -47
  32. data/spec/functional/floating_ip_list_func_spec.rb +0 -48
  33. data/spec/functional/group_list_func_spec.rb +0 -65
  34. data/spec/functional/image_list_func_spec.rb +0 -53
  35. data/spec/functional/network_list_func_spec.rb +0 -46
  36. data/spec/functional/server_create_func_spec.rb +0 -118
  37. data/spec/functional/server_delete_func_spec.rb +0 -84
  38. data/spec/functional/server_list_func_spec.rb +0 -98
  39. data/spec/functional/server_show_func_spec.rb +0 -46
  40. data/spec/functional/volume_list_func_spec.rb +0 -46
  41. data/spec/integration/cleanup.rb +0 -89
  42. data/spec/integration/config/environment.yml.sample +0 -13
  43. data/spec/integration/openstack_spec.rb +0 -649
  44. data/spec/spec_context.rb +0 -56
  45. data/spec/spec_helper.rb +0 -128
  46. data/spec/unit/openstack_flavor_list_spec.rb +0 -30
  47. data/spec/unit/openstack_floating_ip_allocate_spec.rb +0 -56
  48. data/spec/unit/openstack_floating_ip_associate_spec.rb +0 -40
  49. data/spec/unit/openstack_floating_ip_disassociate_spec.rb +0 -39
  50. data/spec/unit/openstack_floating_ip_list_spec.rb +0 -27
  51. data/spec/unit/openstack_floating_ip_release_spec.rb +0 -49
  52. data/spec/unit/openstack_group_list_spec.rb +0 -44
  53. data/spec/unit/openstack_image_list_spec.rb +0 -32
  54. data/spec/unit/openstack_network_list_spec.rb +0 -39
  55. data/spec/unit/openstack_server_create_spec.rb +0 -449
  56. data/spec/unit/openstack_server_delete_spec.rb +0 -43
  57. data/spec/unit/openstack_server_list_spec.rb +0 -32
  58. data/spec/unit/openstack_server_show_spec.rb +0 -42
  59. data/spec/unit/openstack_service_spec.rb +0 -128
  60. data/spec/unit/openstack_volume_list_spec.rb +0 -30
@@ -1,13 +0,0 @@
1
- # FIXME For now we will fetch the creds from a config file
2
- OPENSTACK_KEY_PAIR: OPENSTACK_KEY_PAIR
3
- OS_SSH_USER: OS_SSH_USER
4
- OS_WINDOWS_SSH_USER: OS_WINDOWS_SSH_USER
5
- OS_WINDOWS_SSH_PASSWORD: OS_WINDOWS_SSH_PASSWORD
6
- OS_WINRM_USER: OS_WINRM_USER
7
- OS_WINRM_PASSWORD: OS_WINRM_PASSWORD
8
- OS_LINUX_IMAGE: OS_LINUX_IMAGE
9
- OS_WINDOWS_IMAGE: OS_WINDOWS_IMAGE
10
- OS_WINDOWS_SSH_IMAGE: OS_WINDOWS_SSH_IMAGE
11
- OS_LINUX_FLAVOR: OS_LINUX_FLAVOR
12
- OS_WINDOWS_FLAVOR: OS_WINDOWS_FLAVOR
13
- OS_INVALID_FLAVOR: OS_INVALID_FLAVOR
@@ -1,649 +0,0 @@
1
- # frozen_string_literal: true
2
- # Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
3
- # License: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
-
17
- # Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
18
- # Author:: Ameya Varade (<ameya.varade@clogeny.com>)
19
- # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
20
-
21
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
22
-
23
- def append_openstack_creds(is_list_cmd = false)
24
- openstack_creds_cmd = " --openstack-username '#{ENV['OPENSTACK_USERNAME']}' --openstack-password '#{ENV['OPENSTACK_PASSWORD']}' --openstack-api-endpoint #{ENV['OPENSTACK_AUTH_URL']}"
25
- openstack_creds_cmd += " -c #{temp_dir}/knife.rb"
26
- unless is_list_cmd
27
- openstack_creds_cmd += " --openstack-tenant #{ENV['OPENSTACK_TENANT']}"
28
- end
29
- openstack_creds_cmd
30
- end
31
-
32
- def append_openstack_creds_for_windows
33
- openstack_creds_cmd = " --openstack-username '#{ENV['OPENSTACK_USERNAME']}' --openstack-password '#{ENV['OPENSTACK_PASSWORD']}' --openstack-api-endpoint #{ENV['OPENSTACK_AUTH_URL']} "
34
- openstack_creds_cmd += " -c #{temp_dir}/knife.rb"
35
- openstack_creds_cmd += " --openstack-tenant #{ENV['OPENSTACK_TENANT']}"
36
- openstack_creds_cmd
37
- end
38
-
39
- def get_ssh_credentials
40
- " --ssh-user #{@os_ssh_user}"\
41
- " --openstack-ssh-key-id #{@openstack_key_pair}"
42
- end
43
-
44
- def get_ssh_credentials_for_windows_image
45
- " --ssh-user #{@os_windows_ssh_user}"\
46
- " --ssh-password #{@os_windows_ssh_password}"\
47
- " --openstack-ssh-key-id #{@openstack_key_pair}"
48
- end
49
-
50
- def get_winrm_credentials
51
- " --winrm-user #{@os_winrm_user}"\
52
- " --winrm-password #{@os_winrm_password}"\
53
- " --openstack-ssh-key-id #{@openstack_key_pair}"
54
- end
55
-
56
- # get openstack active instance_id for knife openstack show command run
57
- def get_active_instance_id
58
- server_list_output = run("knife openstack server list " + append_openstack_creds(is_list_cmd = true))
59
- # Check command exitstatus. Non zero exitstatus indicates command execution fails.
60
- if server_list_output.exitstatus != 0
61
- puts "Please check Openstack user name, password and auth url are correct. Error: #{list_output.stderr}."
62
- return false
63
- else
64
- servers = server_list_output.stdout
65
- end
66
-
67
- servers.each_line do |line|
68
- if line.include?("ACTIVE")
69
- instance_id = line.split(" ").first
70
- return instance_id
71
- end
72
- end
73
- false
74
- end
75
-
76
- describe "knife-openstack integration test", if: is_config_present do
77
- include KnifeTestBed
78
- include RSpec::KnifeTestUtils
79
-
80
- before(:all) do
81
- expect(run("gem build knife-openstack.gemspec").exitstatus).to be(0)
82
- expect(run("gem install #{get_gem_file_name}").exitstatus).to be(0)
83
- init_openstack_test
84
- end
85
-
86
- after(:all) do
87
- run("gem uninstall knife-openstack -v '#{Knife::OpenStack::VERSION}'")
88
- cleanup_test_data
89
- end
90
-
91
- describe "display help for command" do
92
- %w{flavor\ list server\ create server\ delete server\ list group\ list image\ list network\ list }.each do |command|
93
- context "when --help option used with #{command} command" do
94
- let(:command) { "knife openstack #{command} --help" }
95
- run_cmd_check_stdout("--help")
96
- end
97
- end
98
- end
99
-
100
- describe "display server list" do
101
- context "when standard options specified" do
102
- let(:command) { "knife openstack server list" + append_openstack_creds(is_list_cmd = true) }
103
- run_cmd_check_status_and_output("succeed", "Instance ID")
104
- end
105
-
106
- context "when --chef-data CLI option specified" do
107
- let(:command) { "knife openstack server list" + append_openstack_creds(is_list_cmd = true) + " --chef-data" }
108
- it { skip("setup a chef-zero on workspace node") }
109
- end
110
-
111
- context "when --chef-data and valid --chef-node-attribute CLI option specified" do
112
- let(:command) { "knife openstack server list" + append_openstack_creds(is_list_cmd = true) + " --chef-data --chef-node-attribute platform_family" }
113
- it { skip("setup a chef-zero on workspace node") }
114
- end
115
-
116
- context "when --chef-data and In valid --chef-node-attribute CLI option specified" do
117
- let(:command) { "knife openstack server list" + append_openstack_creds(is_list_cmd = true) + " --chef-data --chef-node-attribute invalid" }
118
- it { skip("setup a chef-zero on workspace node") }
119
- end
120
- end
121
-
122
- describe "display flavor list" do
123
- context "when standard options specified" do
124
- let(:command) { "knife openstack flavor list" + append_openstack_creds(is_list_cmd = true) }
125
- run_cmd_check_status_and_output("succeed", "ID")
126
- end
127
- end
128
-
129
- describe "display image list" do
130
- context "when standard options specified" do
131
- let(:command) { "knife openstack image list" + append_openstack_creds(is_list_cmd = true) }
132
- run_cmd_check_status_and_output("succeed", "ID")
133
- end
134
- end
135
-
136
- describe "display group list" do
137
- context "when standard options specified" do
138
- let(:command) { "knife openstack group list" + append_openstack_creds(is_list_cmd = true) }
139
- run_cmd_check_status_and_output("succeed", "Name")
140
- end
141
- end
142
-
143
- describe "display network list" do
144
- context "when standard options specified" do
145
- let(:command) { "knife openstack network list" + append_openstack_creds(is_list_cmd = true) }
146
- it { skip "Chef openstack setup not support this functionality" }
147
- end
148
- end
149
-
150
- describe "server show" do
151
- context "with valid instance_id" do
152
- before(:each) do
153
- @instance_id = get_active_instance_id
154
- end
155
- let(:command) { "knife openstack server show #{@instance_id}" + append_openstack_creds(is_list_cmd = true) }
156
- run_cmd_check_status_and_output("succeed", "Instance ID")
157
- end
158
-
159
- context "with invalid instance_id" do
160
- let(:command) { "knife openstack server show invalid_instance_id" + append_openstack_creds(is_list_cmd = true) }
161
-
162
- run_cmd_check_status_and_output("fail", "ERROR: Server doesn't exists for this invalid_instance_id instance id")
163
- end
164
- end
165
-
166
- describe "create and bootstrap Linux Server" do
167
- before(:each) { rm_known_host }
168
- context "when standard options specified" do
169
- cmd_out = ""
170
-
171
- before(:each) { create_node_name("linux") }
172
-
173
- after { cmd_out = "#{cmd_output}" }
174
-
175
- let(:command) do
176
- "knife openstack server create -N #{@name_node}"\
177
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
178
- " --template-file " + get_linux_template_file_path +
179
- " --server-url http://localhost:8889" \
180
- " --yes --server-create-timeout 1800" +
181
- get_ssh_credentials +
182
- " --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
183
- end
184
-
185
- run_cmd_check_status_and_output("succeed", "#{@name_node}")
186
-
187
- context "delete server after create" do
188
- let(:command) { delete_instance_cmd(cmd_out) }
189
- run_cmd_check_status_and_output("succeed", "#{@name_node}")
190
- end
191
- end
192
-
193
- context "when standard options and chef node name prefix is default value(i.e openstack)" do
194
- let(:command) do
195
- "knife openstack server create "\
196
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
197
- " --template-file " + get_linux_template_file_path +
198
- " --server-url http://localhost:8889" \
199
- " --yes --server-create-timeout 1800" +
200
- get_ssh_credentials +
201
- " --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
202
- end
203
-
204
- after { run(delete_instance_cmd("#{cmd_output}")) }
205
-
206
- run_cmd_check_status_and_output("succeed", "Bootstrapping Chef on")
207
- end
208
-
209
- context "when standard options and chef node name prefix is user specified value" do
210
- let(:command) do
211
- "knife openstack server create "\
212
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
213
- " --template-file " + get_linux_template_file_path +
214
- " --server-url http://localhost:8889" \
215
- " --yes --server-create-timeout 1800" \
216
- " --chef-node-name-prefix os-integration-test-" +
217
- get_ssh_credentials +
218
- " --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
219
- end
220
-
221
- after { run(delete_instance_cmd("#{cmd_output}")) }
222
-
223
- run_cmd_check_status_and_output("succeed", "os-integration-test-")
224
- end
225
-
226
- context "when standard options and delete-server-on-failure specified" do
227
- nodename = ""
228
- before(:each) { create_node_name("linux") }
229
-
230
- after { nodename = @name_node }
231
-
232
- let(:command) do
233
- "knife openstack server create -N #{@name_node}"\
234
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
235
- " --template-file " + get_linux_template_file_path +
236
- " --server-url http://localhost:8889" \
237
- " --yes --server-create-timeout 1800" \
238
- " --delete-server-on-failure" +
239
- get_ssh_credentials +
240
- " --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
241
- end
242
-
243
- run_cmd_check_status_and_output("succeed", "#{@name_node}")
244
-
245
- context "delete server by using name after create" do
246
- let(:command) { "knife openstack server delete #{nodename} " + append_openstack_creds(is_list_cmd = true) + " --yes" }
247
- run_cmd_check_status_and_output("succeed", "#{@name_node}")
248
- end
249
- end
250
-
251
- context "when delete-server-on-failure specified and bootstrap fails" do
252
- before(:each) { create_node_name("linux") }
253
-
254
- let(:command) do
255
- "knife openstack server create -N #{@name_node}"\
256
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
257
- " --template-file " + get_linux_template_file_path +
258
- " --server-url http://localhost:8889" \
259
- " --yes --server-create-timeout 1800" \
260
- " --delete-server-on-failure" +
261
- get_ssh_credentials +
262
- " --identity-file #{temp_dir}/incorrect_openstack.pem" + append_openstack_creds + " --sudo"
263
- end
264
-
265
- run_cmd_check_status_and_output("fail", "FATAL: Authentication Failed during bootstrapping")
266
- end
267
-
268
- context "when openstack credentials not specified" do
269
- before(:each) { create_node_name("linux") }
270
-
271
- let(:command) do
272
- "knife openstack server create -N #{@name_node}"\
273
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
274
- " --template-file " + get_linux_template_file_path +
275
- " --server-url http://localhost:8889" \
276
- " --yes --server-create-timeout 1800" +
277
- get_ssh_credentials +
278
- " --identity-file #{temp_dir}/openstack.pem --sudo"
279
- end
280
-
281
- run_cmd_check_status_and_output("fail", "ERROR: You did not provide a valid 'Openstack Username' value")
282
- end
283
-
284
- context "when ssh-password and identity-file parameters not specified" do
285
- before(:each) { create_node_name("linux") }
286
-
287
- let(:command) do
288
- "knife openstack server create -N #{@name_node}"\
289
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
290
- " --template-file " + get_linux_template_file_path +
291
- " --server-url http://localhost:8889" \
292
- " --yes" +
293
- append_openstack_creds + " --sudo"
294
- end
295
-
296
- it { skip "Chef openstack setup not support this functionality." }
297
- end
298
-
299
- context "when standard options and invalid openstack security group specified" do
300
- before(:each) { create_node_name("linux") }
301
-
302
- let(:command) do
303
- "knife openstack server create -N #{@name_node}"\
304
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
305
- " --template-file " + get_linux_template_file_path +
306
- " --server-url http://localhost:8889" \
307
- " --yes" +
308
- get_ssh_credentials +
309
- " --identity-file #{temp_dir}/openstack.pem"\
310
- " --openstack-groups invalid-invalid-1212" + append_openstack_creds + " --sudo"
311
- end
312
-
313
- run_cmd_check_status_and_output("fail", "Security group invalid-invalid-1212 not found")
314
- end
315
-
316
- context "when standard options and invalid image id specified" do
317
- before(:each) { create_node_name("linux") }
318
-
319
- let(:command) do
320
- "knife openstack server create -N #{@name_node}"\
321
- " -I #{SecureRandom.hex(18)} -f #{@os_linux_flavor} "\
322
- " --template-file " + get_linux_template_file_path +
323
- " --server-url http://localhost:8889" \
324
- " --yes" +
325
- get_ssh_credentials +
326
- " --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
327
- end
328
-
329
- run_cmd_check_status_and_output("fail", "ERROR: You have not provided a valid image ID. Please note the options for this value are -I or --image")
330
- end
331
-
332
- context "when standard options and invalid flavor id specified" do
333
- before(:each) { create_node_name("linux") }
334
-
335
- let(:command) do
336
- "knife openstack server create -N #{@name_node}"\
337
- " -I #{@os_linux_image} -f #{@os_invalid_flavor} "\
338
- " --template-file " + get_linux_template_file_path +
339
- " --server-url http://localhost:8889" \
340
- " --yes" +
341
- get_ssh_credentials +
342
- " --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
343
- end
344
-
345
- run_cmd_check_status_and_output("fail", "ERROR: You have not provided a valid flavor ID. Please note the options for this value are -f or --flavor")
346
- end
347
-
348
- context "when standard options and invalid floating ip specified" do
349
- before(:each) { create_node_name("linux") }
350
-
351
- let(:command) do
352
- "knife openstack server create -N #{@name_node}"\
353
- " -I #{@os_linux_image} --openstack-floating-ip #{@os_invalid_floating_ip} "\
354
- " --template-file " + get_linux_template_file_path +
355
- " --server-url http://localhost:8889" \
356
- " --yes" +
357
- get_ssh_credentials +
358
- " --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
359
- end
360
-
361
- run_cmd_check_status_and_output("fail", "ERROR: You have either requested an invalid floating IP address or none are available")
362
- end
363
-
364
- context "when invalid key_pair specified" do
365
- before(:each) { create_node_name("linux") }
366
-
367
- let(:command) do
368
- "knife openstack server create -N #{@name_node}"\
369
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
370
- " --template-file " + get_linux_template_file_path +
371
- " --server-url http://localhost:8889" \
372
- " --yes" \
373
- " --ssh-user #{@os_ssh_user}"\
374
- " --openstack-ssh-key-id #{SecureRandom.hex(6)}"\
375
- " --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
376
- end
377
-
378
- run_cmd_check_status_and_output("fail", "Invalid key_name provided")
379
- end
380
-
381
- context "when incorrect openstack private_key.pem file is used" do
382
- server_create_common_bfr_aftr
383
-
384
- let(:command) do
385
- "knife openstack server create -N #{@name_node}"\
386
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
387
- " --template-file " + get_linux_template_file_path +
388
- " --server-url http://localhost:8889" \
389
- " --yes" \
390
- " --ssh-user #{@os_ssh_user}"\
391
- " --openstack-ssh-key-id #{@openstack_key_pair}"\
392
- " --identity-file #{temp_dir}/incorrect_openstack.pem" + append_openstack_creds + " --sudo"
393
- end
394
-
395
- run_cmd_check_status_and_output("fail", "FATAL: Authentication Failed during bootstrapping")
396
- end
397
-
398
- context "when standard options and --openstack-private-network option specified" do
399
- server_create_common_bfr_aftr
400
-
401
- let(:command) do
402
- "knife openstack server create -N #{@name_node}"\
403
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
404
- " --template-file " + get_linux_template_file_path +
405
- " --server-url http://localhost:8889" \
406
- " --yes" +
407
- get_ssh_credentials +
408
- " --identity-file #{temp_dir}/openstack.pem"\
409
- " --openstack-private-network" + append_openstack_creds + " --sudo"
410
- end
411
-
412
- it { skip "not yet supported" }
413
- end
414
-
415
- context "when standard options and --openstack-floating-ip option specified" do
416
- server_create_common_bfr_aftr
417
-
418
- let(:command) do
419
- "knife openstack server create -N #{@name_node}"\
420
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
421
- " --template-file " + get_linux_template_file_path +
422
- " --server-url http://localhost:8889" \
423
- " --yes" +
424
- get_ssh_credentials +
425
- " --identity-file #{temp_dir}/openstack.pem"\
426
- " --openstack-floating-ip" + append_openstack_creds + " --sudo"
427
- end
428
-
429
- it { skip "empty floating ip pool" }
430
- end
431
-
432
- context "when standard options and user data specified" do
433
- before(:each) do
434
- create_node_name("linux")
435
- @user_data_file = create_sh_user_data_file
436
- end
437
-
438
- after do
439
- # check user_data exists in server def
440
- expect(cmd_output).to include("user_data=>\"#{@user_data_file.read}\"")
441
- delete_sh_user_data_file(@user_data_file)
442
- run(delete_instance_cmd("#{cmd_output}"))
443
- end
444
-
445
- let(:command) do
446
- "knife openstack server create -N #{@name_node}"\
447
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
448
- " --template-file " + get_linux_template_file_path +
449
- " --server-url http://localhost:8889" \
450
- " --yes --server-create-timeout 1800" +
451
- get_ssh_credentials +
452
- " --identity-file #{temp_dir}/openstack.pem" \
453
- " --user-data #{@user_data_file.path}" +
454
- append_openstack_creds + " --sudo -VV"
455
- end
456
-
457
- run_cmd_check_status_and_output("succeed", "#{@name_node}")
458
- end
459
-
460
- context "when standard options and no network option specified" do
461
- server_create_common_bfr_aftr
462
-
463
- let(:command) do
464
- "knife openstack server create -N #{@name_node}"\
465
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
466
- " --template-file " + get_linux_template_file_path +
467
- " --server-url http://localhost:8889" \
468
- " --yes --server-create-timeout 1800" \
469
- " --no-network" +
470
- get_ssh_credentials +
471
- " --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
472
- end
473
-
474
- run_cmd_check_status_and_output("succeed", "#{@name_node}")
475
- end
476
-
477
- context "when standard options and openstack endpoint type option is specified" do
478
- server_create_common_bfr_aftr
479
-
480
- let(:command) do
481
- "knife openstack server create -N #{@name_node}"\
482
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
483
- " --template-file " + get_linux_template_file_path +
484
- " --server-url http://localhost:8889" \
485
- " --yes --server-create-timeout 1800" \
486
- " --openstack-endpoint-type publicURL" +
487
- get_ssh_credentials +
488
- " --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
489
- end
490
-
491
- run_cmd_check_status_and_output("succeed", "#{@name_node}")
492
- end
493
-
494
- context "when standard options and openstack metadata option is specified" do
495
- server_create_common_bfr_aftr
496
-
497
- let(:command) do
498
- "knife openstack server create -N #{@name_node}"\
499
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
500
- " --template-file " + get_linux_template_file_path +
501
- " --server-url http://localhost:8889" \
502
- " --yes --server-create-timeout 1800" \
503
- " --metadata testdataone='testmetadata'" +
504
- get_ssh_credentials +
505
- " --identity-file #{temp_dir}/openstack.pem"\
506
- " --metadata testdatatwo='testmetadata'" +
507
- append_openstack_creds + " --sudo"
508
- end
509
-
510
- run_cmd_check_status_and_output("succeed", "#{@name_node}")
511
- end
512
-
513
- context "when standard options and openstack network-ids option is specified" do
514
- server_create_common_bfr_aftr
515
-
516
- let(:command) do
517
- "knife openstack server create -N #{@name_node}"\
518
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
519
- " --template-file " + get_linux_template_file_path +
520
- " --server-url http://localhost:8889" \
521
- " --yes --server-create-timeout 1800" \
522
- " --network-ids #{@os_network_ids} " +
523
- get_ssh_credentials +
524
- " --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
525
- end
526
-
527
- it { skip "Chef openstack setup not support this functionality" }
528
- end
529
-
530
- context "when standard options and openstack availability-zone option is specified" do
531
- server_create_common_bfr_aftr
532
-
533
- let(:command) do
534
- "knife openstack server create -N #{@name_node}"\
535
- " -I #{@os_linux_image} -f #{@os_linux_flavor} "\
536
- " --template-file " + get_linux_template_file_path +
537
- " --server-url http://localhost:8889" \
538
- " --yes --server-create-timeout 1800" \
539
- " --availability-zone #{@os_availability_zone} " +
540
- get_ssh_credentials +
541
- " --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
542
- end
543
-
544
- it { skip "Chef openstack setup not support this functionality" }
545
- end
546
- end
547
-
548
- describe "create and bootstrap Windows Server" do
549
- before(:each) { rm_known_host }
550
-
551
- context "when standard options specified" do
552
- cmd_out = ""
553
-
554
- before(:each) { create_node_name("windows") }
555
-
556
- let(:command) do
557
- "knife openstack server create -N #{@name_node}" \
558
- " -I #{@os_windows_image} " \
559
- " -f #{@os_windows_flavor} " \
560
- " --template-file " + get_windows_msi_template_file_path +
561
- " --server-url http://localhost:8889" \
562
- " --bootstrap-protocol winrm" \
563
- " --yes --server-create-timeout 1800" +
564
- get_winrm_credentials + append_openstack_creds_for_windows
565
- end
566
-
567
- after { cmd_out = "#{cmd_output}" }
568
-
569
- run_cmd_check_status_and_output("succeed", "#{@name_node}")
570
-
571
- context "delete server after create" do
572
- let(:command) { delete_instance_cmd(cmd_out) }
573
- run_cmd_check_status_and_output("succeed")
574
- end
575
- end
576
-
577
- context "when invalid winrm user specified" do
578
- server_create_common_bfr_aftr("windows")
579
-
580
- let(:command) do
581
- "knife openstack server create -N #{@name_node}" \
582
- " -I #{@os_windows_image} " \
583
- " -f #{@os_windows_flavor} " \
584
- " --template-file " + get_windows_msi_template_file_path +
585
- " --server-url http://localhost:8889" \
586
- " --bootstrap-protocol winrm" \
587
- " --yes --server-create-timeout 1800" \
588
- " --winrm-user #{SecureRandom.hex(6)}"\
589
- " --winrm-password #{@os_winrm_password}" +
590
- append_openstack_creds_for_windows
591
- end
592
- it { skip "Fails due to OC-9708 bug in knife-windows." }
593
- end
594
-
595
- context "when invalid winrm password specified" do
596
- server_create_common_bfr_aftr("windows")
597
-
598
- let(:command) do
599
- "knife openstack server create -N #{@name_node}" \
600
- " -I #{@os_windows_image} " \
601
- " -f #{@os_windows_flavor} " \
602
- " --template-file " + get_windows_msi_template_file_path +
603
- " --server-url http://localhost:8889" \
604
- " --bootstrap-protocol winrm" \
605
- " --yes --server-create-timeout 1800" \
606
- " --winrm-user #{@os_winrm_user}"\
607
- " --winrm-password #{SecureRandom.hex(6)}" +
608
- append_openstack_creds_for_windows
609
- end
610
- after(:each) { run(delete_instance_cmd("#{cmd_output}")) }
611
-
612
- it { skip "Fails due to OC-9708 bug in knife-windows." }
613
- end
614
-
615
- context "when standard options ssh bootstrap and valid image-os-type protocol specified" do
616
- server_create_common_bfr_aftr("windows")
617
-
618
- let(:command) do
619
- "knife openstack server create -N #{@name_node}"\
620
- " -I #{@os_windows_ssh_image}"\
621
- " -f #{@os_windows_flavor} "\
622
- " --template-file " + get_windows_msi_template_file_path +
623
- " --server-url http://localhost:8889" \
624
- " --yes --server-create-timeout 1800" \
625
- " --identity-file #{temp_dir}/openstack.pem"\
626
- " --openstack-ssh-key-id #{@openstack_key_pair}" + get_ssh_credentials_for_windows_image + append_openstack_creds + " --image-os-type windows"
627
- end
628
-
629
- run_cmd_check_status_and_output("succeed", "#{@name_node}")
630
- end
631
-
632
- context "when standard options ssh bootstrap and invalid image-os-type protocol specified" do
633
- before(:each) { create_node_name("windows") }
634
-
635
- let(:command) do
636
- "knife openstack server create -N #{@name_node}"\
637
- " -I #{@os_windows_ssh_image}"\
638
- " -f #{@os_windows_flavor} "\
639
- " --template-file " + get_windows_msi_template_file_path +
640
- " --server-url http://localhost:8889" \
641
- " --yes --server-create-timeout 1800" \
642
- " --identity-file #{temp_dir}/openstack.pem"\
643
- " --openstack-ssh-key-id #{@openstack_key_pair}" + get_ssh_credentials_for_windows_image + append_openstack_creds + " --image-os-type invalid"
644
- end
645
-
646
- run_cmd_check_status_and_output("fail", "ERROR: You must provide --image-os-type option [windows/linux]")
647
- end
648
- end
649
- end