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,56 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
4
- # Copyright:: Copyright (c) 2014 Chef Software, Inc.
5
- # License:: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- shared_context "#validate!" do |instance|
20
- before(:each) do
21
- Chef::Config[:knife][:openstack_username] = "testuser"
22
- Chef::Config[:knife][:openstack_password] = "testpassword"
23
- Chef::Config[:knife][:openstack_auth_url] = "tsturl"
24
- Chef::Config[:knife][:openstack_region] = "test-region"
25
- allow(instance).to receive(:exit)
26
- end
27
-
28
- after(:all) do
29
- Chef::Config[:knife].delete(:openstack_username)
30
- Chef::Config[:knife].delete(:openstack_password)
31
- Chef::Config[:knife].delete(:openstack_auth_url)
32
- Chef::Config[:knife].delete(:openstack_region)
33
- end
34
-
35
- it "validate openstack mandatory options" do
36
- expect { instance.validate! }.to_not raise_error
37
- end
38
-
39
- it "raise error on openstack_username missing" do
40
- Chef::Config[:knife].delete(:openstack_username)
41
- expect(instance.ui).to receive(:error).with("You did not provide a valid 'Openstack Username' value.")
42
- expect { instance.validate! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError)
43
- end
44
-
45
- it "raise error on openstack_password missing" do
46
- Chef::Config[:knife].delete(:openstack_password)
47
- expect(instance.ui).to receive(:error).with("You did not provide a valid 'Openstack Password' value.")
48
- expect { instance.validate! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError)
49
- end
50
-
51
- it "raise error on openstack_auth_url missing" do
52
- Chef::Config[:knife].delete(:openstack_auth_url)
53
- expect(instance.ui).to receive(:error).with("You did not provide a valid 'Openstack Auth Url' value.")
54
- expect { instance.validate! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError)
55
- end
56
- end
@@ -1,128 +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
-
19
- $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
20
- require "chef/knife/bootstrap"
21
- require "chef/knife/openstack_helpers"
22
- require "fog"
23
- require "chef/knife/winrm_base"
24
- require "chef/knife/bootstrap_windows_winrm"
25
- require "chef/knife/openstack_server_create"
26
- require "chef/knife/openstack_server_delete"
27
- require "chef/knife/bootstrap_windows_ssh"
28
- require "securerandom"
29
- require "knife-openstack/version"
30
- require "test/knife-utils/test_bed"
31
- require "resource_spec_helper"
32
- require "server_command_common_spec_helper"
33
- require "tempfile"
34
- require "spec_context"
35
-
36
- def find_instance_id(instance_name, file)
37
- file.lines.each do |line|
38
- return "#{line}".split(" ")[2].strip if line.include?("#{instance_name}")
39
- end
40
- end
41
-
42
- def is_config_present
43
- unless ENV["RUN_INTEGRATION_TESTS"]
44
- puts("\nPlease set RUN_INTEGRATION_TESTS environment variable to run integration tests")
45
- return false
46
- end
47
-
48
- unset_env_var = []
49
- unset_config_options = []
50
- is_config = true
51
- config_file_exist = File.exist?(File.expand_path("../integration/config/environment.yml", __FILE__))
52
- openstack_config = YAML.load(File.read(File.expand_path("../integration/config/environment.yml", __FILE__))) if config_file_exist
53
- %w{OPENSTACK_USERNAME OPENSTACK_PASSWORD OPENSTACK_AUTH_URL OPENSTACK_TENANT}.each do |os_env_var|
54
- if ENV[os_env_var].nil?
55
- unset_env_var << os_env_var
56
- is_config = false
57
- end
58
- end
59
-
60
- err_msg = "\nPlease set #{unset_env_var.join(', ')} environment"
61
- err_msg = err_msg + (unset_env_var.length > 1 ? " variables " : " variable ") + "for integration tests."
62
- puts err_msg unless unset_env_var.empty?
63
-
64
- %w{OS_SSH_USER OPENSTACK_PRI_KEY OPENSTACK_KEY_PAIR OS_WINDOWS_SSH_USER OS_WINDOWS_SSH_PASSWORD OS_WINRM_USER OS_WINRM_PASSWORD OS_LINUX_IMAGE OS_LINUX_FLAVOR OS_INVALID_FLAVOR OS_INVALID_FLOATING_IP OS_WINDOWS_FLAVOR OS_WINDOWS_IMAGE OS_WINDOWS_SSH_IMAGE OS_NETWORK_IDS OS_AVAILABILITY_ZONE}.each do |os_config_opt|
65
- option_value = ENV[os_config_opt] || (openstack_config[os_config_opt] if openstack_config)
66
- if option_value.nil?
67
- unset_config_options << os_config_opt
68
- is_config = false
69
- end
70
- end
71
-
72
- config_err_msg = "\nPlease set #{unset_config_options.join(', ')} config"
73
- config_err_msg = config_err_msg + (unset_config_options.length > 1 ? " options in ../spec/integration/config/environment.yml or as environment variables" : " option in ../spec/integration/config/environment.yml or as environment variable") + " for integration tests."
74
- puts config_err_msg unless unset_config_options.empty?
75
-
76
- is_config
77
- end
78
-
79
- def get_gem_file_name
80
- "knife-openstack-" + Knife::OpenStack::VERSION + ".gem"
81
- end
82
-
83
- def delete_instance_cmd(stdout)
84
- "knife openstack server delete " + find_instance_id("Instance ID", stdout) +
85
- append_openstack_creds(is_list_cmd = true) + " --yes"
86
- end
87
-
88
- def create_node_name(name)
89
- @name_node = (name == "linux") ? "os-integration-test-linux-#{SecureRandom.hex(4)}" : "os-integration-test-win-#{SecureRandom.hex(4)}"
90
- end
91
-
92
- def init_openstack_test
93
- init_test
94
-
95
- begin
96
- data_to_write = File.read(File.expand_path("../integration/config/incorrect_openstack.pem", __FILE__))
97
- File.open("#{temp_dir}/incorrect_openstack.pem", "w") { |f| f.write(data_to_write) }
98
- rescue
99
- puts "Error while creating file - incorrect_openstack.pem"
100
- end
101
-
102
- config_file_exist = File.exist?(File.expand_path("../integration/config/environment.yml", __FILE__))
103
- openstack_config = YAML.load(File.read(File.expand_path("../integration/config/environment.yml", __FILE__))) if config_file_exist
104
-
105
- %w{OS_SSH_USER OPENSTACK_KEY_PAIR OPENSTACK_PRI_KEY OS_WINDOWS_SSH_USER OS_WINDOWS_SSH_PASSWORD OS_WINRM_USER OS_WINRM_PASSWORD OS_LINUX_IMAGE OS_LINUX_FLAVOR OS_INVALID_FLAVOR OS_INVALID_FLOATING_IP OS_WINDOWS_FLAVOR OS_WINDOWS_IMAGE OS_WINDOWS_SSH_IMAGE OS_NETWORK_IDS OS_AVAILABILITY_ZONE}.each do |os_config_opt|
106
- instance_variable_set("@#{os_config_opt.downcase}", (openstack_config[os_config_opt] if openstack_config) || ENV[os_config_opt])
107
- end
108
- begin
109
- key_file_path = @openstack_pri_key
110
- key_file_exist = File.exist?(File.expand_path(key_file_path, __FILE__))
111
- data_to_write = File.read(File.expand_path(key_file_path, __FILE__)) if key_file_exist
112
- File.open("#{temp_dir}/openstack.pem", "w") { |f| f.write(data_to_write) }
113
- rescue
114
- puts "Error while creating file - openstack.pem"
115
- end
116
- end
117
-
118
- def create_sh_user_data_file
119
- file = Tempfile.new(["test_user_data", ".sh"])
120
- file.write("echo 'sample user data file created' >> #{Dir.tmpdir}/testuserdata.txt")
121
- file.rewind
122
- file
123
- end
124
-
125
- def delete_sh_user_data_file(file)
126
- file.close
127
- file.unlink
128
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Author:: Mukta Aphale (<mukta.aphale@clogeny.com>)
4
- # Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
5
- # Author:: Ameya Varade (<ameya.varade@clogeny.com>)
6
- # Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
7
- # License:: Apache License, Version 2.0
8
- #
9
- # Licensed under the Apache License, Version 2.0 (the "License");
10
- # you may not use this file except in compliance with the License.
11
- # You may obtain a copy of the License at
12
- #
13
- # http://www.apache.org/licenses/LICENSE-2.0
14
- #
15
- # Unless required by applicable law or agreed to in writing, software
16
- # distributed under the License is distributed on an "AS IS" BASIS,
17
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- # See the License for the specific language governing permissions and
19
- # limitations under the License.
20
-
21
- require "spec_helper"
22
- require "chef/knife/openstack_flavor_list"
23
- require "chef/knife/cloud/openstack_service"
24
- require "support/shared_examples_for_command"
25
-
26
- describe Chef::Knife::Cloud::OpenstackFlavorList do
27
- it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackFlavorList.new
28
-
29
- include_context "#validate!", Chef::Knife::Cloud::OpenstackFlavorList.new
30
- end
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
4
- # Copyright:: Copyright (c) 2013-2015 Chef Software, Inc.
5
- # License:: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- require "spec_helper"
20
- require "chef/knife/openstack_floating_ip_allocate"
21
- require "chef/knife/cloud/openstack_service"
22
- require "support/shared_examples_for_command"
23
-
24
- describe Chef::Knife::Cloud::OpenstackFloatingIpAllocate do
25
- it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackFloatingIpAllocate.new
26
- include_context "#validate!", Chef::Knife::Cloud::OpenstackFloatingIpAllocate.new
27
-
28
- before(:each) do
29
- @instance = Chef::Knife::Cloud::OpenstackFloatingIpAllocate.new
30
- allow(@instance.ui).to receive(:error)
31
- end
32
-
33
- describe "create service instance" do
34
- it "return OpenstackService instance" do
35
- expect(@instance.create_service_instance).to be_an_instance_of(Chef::Knife::Cloud::OpenstackService)
36
- end
37
- end
38
-
39
- describe "allocate floating ip" do
40
- it "calls allocate address" do
41
- @instance.service = double
42
- expect(@instance.service).to receive(:allocate_address).and_return(true)
43
- @instance.execute_command
44
- end
45
- end
46
-
47
- describe "when user provides pool option " do
48
- it "allocates floating ip in user specified pool" do
49
- @instance = Chef::Knife::Cloud::OpenstackFloatingIpAllocate.new(["--pool", "test-pool"])
50
- @instance.service = Chef::Knife::Cloud::Service.new
51
- response = { floating_ip: { "id" => "test-id", "instance_id" => "test-instance-id", "floating_ip" => "127.0.0.1", "fixed_ip" => "nil", "pool" => "test-pool" } }
52
- expect(@instance.service).to receive(:allocate_address).and_return(response)
53
- @instance.execute_command
54
- end
55
- end
56
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
4
- # Copyright:: Copyright (c) 2013-2015 Chef Software, Inc.
5
- # License:: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- require "spec_helper"
19
- require "chef/knife/openstack_floating_ip_associate"
20
- require "chef/knife/cloud/openstack_service"
21
- require "support/shared_examples_for_command"
22
- require "ostruct"
23
-
24
- describe Chef::Knife::Cloud::OpenstackFloatingIpAssociate do
25
- before(:each) do
26
- @instance = Chef::Knife::Cloud::OpenstackFloatingIpAssociate.new(["--instance-id", "23849038438240934n3294839248"])
27
- @instance.name_args = ["127.0.0.1"]
28
- end
29
-
30
- describe "associate floating ip" do
31
- it "calls associate address" do
32
- success_message = "Floating IP 127.0.0.1 associated with Instance 23849038438240934n3294839248"
33
- @instance.service = Chef::Knife::Cloud::Service.new
34
- response = OpenStruct.new(status: 202)
35
- expect(@instance.service).to receive(:associate_address).and_return(response)
36
- expect(@instance.ui).to receive(:info).and_return(success_message)
37
- @instance.execute_command
38
- end
39
- end
40
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
4
- # Copyright:: Copyright (c) 2013-2015 Chef Software, Inc.
5
- # License:: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- require "spec_helper"
19
- require "chef/knife/openstack_floating_ip_disassociate"
20
- require "chef/knife/cloud/openstack_service"
21
- require "support/shared_examples_for_command"
22
- require "ostruct"
23
-
24
- describe Chef::Knife::Cloud::OpenstackFloatingIpDisassociate do
25
- before(:each) do
26
- @instance = Chef::Knife::Cloud::OpenstackFloatingIpDisassociate.new(["--instance-id", "23849038438240934n3294839248"])
27
- @instance.name_args = ["127.0.0.1"]
28
- end
29
-
30
- describe "associate floating ip" do
31
- it "calls associate address" do
32
- @instance.service = Chef::Knife::Cloud::Service.new
33
- response = OpenStruct.new(status: 202)
34
- expect(@instance.service).to receive(:disassociate_address).with("23849038438240934n3294839248", "127.0.0.1").and_return(response)
35
- expect(@instance.ui).to receive(:info).and_return("Floating IP 127.0.0.1 disassociated with Instance 23849038438240934n3294839248")
36
- @instance.execute_command
37
- end
38
- end
39
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
4
- # Copyright:: Copyright (c) 2013-2015 Chef Software, Inc.
5
- # License:: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- require "spec_helper"
20
- require "chef/knife/openstack_floating_ip_list"
21
- require "chef/knife/cloud/openstack_service"
22
- require "support/shared_examples_for_command"
23
-
24
- describe Chef::Knife::Cloud::OpenstackFloatingIpList do
25
- it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackFloatingIpList.new
26
- include_context "#validate!", Chef::Knife::Cloud::OpenstackFloatingIpList.new
27
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
4
- # Copyright:: Copyright (c) 2013-2015 Chef Software, Inc.
5
- # License:: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- require "spec_helper"
19
- require "chef/knife/openstack_floating_ip_release"
20
- require "chef/knife/cloud/openstack_service"
21
- require "support/shared_examples_for_command"
22
-
23
- describe Chef::Knife::Cloud::OpenstackFloatingIpRelease do
24
- it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackFloatingIpRelease.new
25
- include_context "#validate!", Chef::Knife::Cloud::OpenstackFloatingIpRelease.new
26
-
27
- before(:each) do
28
- @instance = Chef::Knife::Cloud::OpenstackFloatingIpRelease.new
29
- allow(@instance.ui).to receive(:error)
30
- @instance.name_args = ["23849038438240934n3294839248"]
31
- end
32
-
33
- describe "create service instance" do
34
- it "return OpenstackService instance" do
35
- expect(@instance.create_service_instance).to be_an_instance_of(Chef::Knife::Cloud::OpenstackService)
36
- end
37
- end
38
-
39
- describe "release floating ip" do
40
- it "calls release address" do
41
- address_id = "23849038438240934n3294839248"
42
- @instance.service = double
43
- response = OpenStruct.new(status: 202)
44
- expect(@instance.service).to receive(:release_address).and_return(response)
45
- expect(@instance.ui).to receive(:info).and_return("Floating IP released successfully.")
46
- @instance.execute_command
47
- end
48
- end
49
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Author:: Mukta Aphale (<mukta.aphale@clogeny.com>)
4
- # Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
5
- # Author:: Ameya Varade (<ameya.varade@clogeny.com>)
6
- # Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
7
- # License:: Apache License, Version 2.0
8
- #
9
- # Licensed under the Apache License, Version 2.0 (the "License");
10
- # you may not use this file except in compliance with the License.
11
- # You may obtain a copy of the License at
12
- #
13
- # http://www.apache.org/licenses/LICENSE-2.0
14
- #
15
- # Unless required by applicable law or agreed to in writing, software
16
- # distributed under the License is distributed on an "AS IS" BASIS,
17
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- # See the License for the specific language governing permissions and
19
- # limitations under the License.
20
-
21
- require "spec_helper"
22
- require "chef/knife/openstack_group_list"
23
- require "chef/knife/cloud/openstack_service"
24
- require "support/shared_examples_for_command"
25
-
26
- describe Chef::Knife::Cloud::OpenstackGroupList do
27
- it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackGroupList.new
28
-
29
- include_context "#validate!", Chef::Knife::Cloud::OpenstackGroupList.new
30
-
31
- let (:instance) { Chef::Knife::Cloud::OpenstackGroupList.new }
32
-
33
- context "#list" do
34
- before(:each) do
35
- @security_groups = [TestResource.new("name" => "Unrestricted", "description" => "testdescription", "security_group_rules" => [TestResource.new("from_port" => 636, "group" => {}, "ip_protocol" => "tcp", "to_port" => 636, "parent_group_id" => 14, "ip_range" => { "cidr" => "0.0.0.0/0" }, "id" => 183)])]
36
- instance.config[:format] = "summary"
37
- end
38
-
39
- it "returns group list" do
40
- expect(instance.ui).to receive(:list).with(["Name", "Protocol", "From", "To", "CIDR", "Description", "Unrestricted", "tcp", "636", "636", "0.0.0.0/0", "testdescription"], :uneven_columns_across, 6)
41
- instance.list(@security_groups)
42
- end
43
- end
44
- end