knife-openstack 1.3.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +21 -0
- data/.gitignore +5 -0
- data/.travis.yml +9 -7
- data/CHANGELOG.md +174 -92
- data/Gemfile +15 -3
- data/README.md +96 -68
- data/Rakefile +19 -6
- data/knife-openstack.gemspec +17 -15
- data/lib/chef/knife/cloud/openstack_server_create_options.rb +36 -35
- data/lib/chef/knife/cloud/openstack_service.rb +7 -6
- data/lib/chef/knife/cloud/openstack_service_options.rb +18 -17
- data/lib/chef/knife/openstack_flavor_list.rb +11 -10
- data/lib/chef/knife/openstack_floating_ip_allocate.rb +13 -12
- data/lib/chef/knife/openstack_floating_ip_associate.rb +9 -8
- data/lib/chef/knife/openstack_floating_ip_disassociate.rb +9 -8
- data/lib/chef/knife/openstack_floating_ip_list.rb +10 -9
- data/lib/chef/knife/openstack_floating_ip_release.rb +7 -6
- data/lib/chef/knife/openstack_group_list.rb +13 -12
- data/lib/chef/knife/openstack_helpers.rb +8 -7
- data/lib/chef/knife/openstack_image_list.rb +14 -13
- data/lib/chef/knife/openstack_network_list.rb +10 -9
- data/lib/chef/knife/openstack_server_create.rb +57 -56
- data/lib/chef/knife/openstack_server_delete.rb +7 -6
- data/lib/chef/knife/openstack_server_list.rb +16 -15
- data/lib/chef/knife/openstack_server_show.rb +17 -16
- data/lib/chef/knife/openstack_volume_list.rb +10 -9
- data/lib/knife-openstack/version.rb +3 -2
- data/spec/functional/flavor_list_func_spec.rb +13 -12
- data/spec/functional/floating_ip_list_func_spec.rb +14 -13
- data/spec/functional/group_list_func_spec.rb +29 -28
- data/spec/functional/image_list_func_spec.rb +15 -14
- data/spec/functional/network_list_func_spec.rb +13 -12
- data/spec/functional/server_create_func_spec.rb +29 -28
- data/spec/functional/server_delete_func_spec.rb +18 -17
- data/spec/functional/server_list_func_spec.rb +43 -42
- data/spec/functional/server_show_func_spec.rb +7 -6
- data/spec/functional/volume_list_func_spec.rb +12 -11
- data/spec/integration/cleanup.rb +6 -5
- data/spec/integration/openstack_spec.rb +287 -286
- data/spec/spec_context.rb +10 -9
- data/spec/spec_helper.rb +38 -37
- data/spec/unit/openstack_flavor_list_spec.rb +6 -5
- data/spec/unit/openstack_floating_ip_allocate_spec.rb +14 -13
- data/spec/unit/openstack_floating_ip_associate_spec.rb +11 -10
- data/spec/unit/openstack_floating_ip_disassociate_spec.rb +12 -11
- data/spec/unit/openstack_floating_ip_list_spec.rb +6 -5
- data/spec/unit/openstack_floating_ip_release_spec.rb +13 -12
- data/spec/unit/openstack_group_list_spec.rb +11 -10
- data/spec/unit/openstack_image_list_spec.rb +6 -5
- data/spec/unit/openstack_network_list_spec.rb +8 -7
- data/spec/unit/openstack_server_create_spec.rb +131 -130
- data/spec/unit/openstack_server_delete_spec.rb +8 -7
- data/spec/unit/openstack_server_list_spec.rb +6 -5
- data/spec/unit/openstack_server_show_spec.rb +10 -9
- data/spec/unit/openstack_service_spec.rb +26 -25
- data/spec/unit/openstack_volume_list_spec.rb +6 -5
- metadata +9 -105
data/spec/spec_context.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
|
3
4
|
# Copyright:: Copyright (c) 2014 Chef Software, Inc.
|
@@ -15,12 +16,12 @@
|
|
15
16
|
# See the License for the specific language governing permissions and
|
16
17
|
# limitations under the License.
|
17
18
|
|
18
|
-
shared_context
|
19
|
+
shared_context "#validate!" do |instance|
|
19
20
|
before(:each) do
|
20
|
-
Chef::Config[:knife][:openstack_username] =
|
21
|
-
Chef::Config[:knife][:openstack_password] =
|
22
|
-
Chef::Config[:knife][:openstack_auth_url] =
|
23
|
-
Chef::Config[:knife][:openstack_region] =
|
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"
|
24
25
|
allow(instance).to receive(:exit)
|
25
26
|
end
|
26
27
|
|
@@ -31,23 +32,23 @@ shared_context '#validate!' do |instance|
|
|
31
32
|
Chef::Config[:knife].delete(:openstack_region)
|
32
33
|
end
|
33
34
|
|
34
|
-
it
|
35
|
+
it "validate openstack mandatory options" do
|
35
36
|
expect { instance.validate! }.to_not raise_error
|
36
37
|
end
|
37
38
|
|
38
|
-
it
|
39
|
+
it "raise error on openstack_username missing" do
|
39
40
|
Chef::Config[:knife].delete(:openstack_username)
|
40
41
|
expect(instance.ui).to receive(:error).with("You did not provide a valid 'Openstack Username' value.")
|
41
42
|
expect { instance.validate! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError)
|
42
43
|
end
|
43
44
|
|
44
|
-
it
|
45
|
+
it "raise error on openstack_password missing" do
|
45
46
|
Chef::Config[:knife].delete(:openstack_password)
|
46
47
|
expect(instance.ui).to receive(:error).with("You did not provide a valid 'Openstack Password' value.")
|
47
48
|
expect { instance.validate! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError)
|
48
49
|
end
|
49
50
|
|
50
|
-
it
|
51
|
+
it "raise error on openstack_auth_url missing" do
|
51
52
|
Chef::Config[:knife].delete(:openstack_auth_url)
|
52
53
|
expect(instance.ui).to receive(:error).with("You did not provide a valid 'Openstack Auth Url' value.")
|
53
54
|
expect { instance.validate! }.to raise_error(Chef::Knife::Cloud::CloudExceptions::ValidationError)
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
|
2
3
|
# License: Apache License, Version 2.0
|
3
4
|
#
|
@@ -15,31 +16,31 @@
|
|
15
16
|
|
16
17
|
# Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
|
17
18
|
|
18
|
-
$LOAD_PATH.unshift File.expand_path(
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
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"
|
34
35
|
|
35
36
|
def find_instance_id(instance_name, file)
|
36
37
|
file.lines.each do |line|
|
37
|
-
return "#{line}".split(
|
38
|
+
return "#{line}".split(" ")[2].strip if line.include?("#{instance_name}")
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
42
|
def is_config_present
|
42
|
-
unless ENV[
|
43
|
+
unless ENV["RUN_INTEGRATION_TESTS"]
|
43
44
|
puts("\nPlease set RUN_INTEGRATION_TESTS environment variable to run integration tests")
|
44
45
|
return false
|
45
46
|
end
|
@@ -47,9 +48,9 @@ def is_config_present
|
|
47
48
|
unset_env_var = []
|
48
49
|
unset_config_options = []
|
49
50
|
is_config = true
|
50
|
-
config_file_exist = File.exist?(File.expand_path(
|
51
|
-
openstack_config = YAML.load(File.read(File.expand_path(
|
52
|
-
%w
|
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|
|
53
54
|
if ENV[os_env_var].nil?
|
54
55
|
unset_env_var << os_env_var
|
55
56
|
is_config = false
|
@@ -57,10 +58,10 @@ def is_config_present
|
|
57
58
|
end
|
58
59
|
|
59
60
|
err_msg = "\nPlease set #{unset_env_var.join(', ')} environment"
|
60
|
-
err_msg = err_msg + (unset_env_var.length > 1 ?
|
61
|
+
err_msg = err_msg + (unset_env_var.length > 1 ? " variables " : " variable ") + "for integration tests."
|
61
62
|
puts err_msg unless unset_env_var.empty?
|
62
63
|
|
63
|
-
%w
|
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|
|
64
65
|
option_value = ENV[os_config_opt] || (openstack_config[os_config_opt] if openstack_config)
|
65
66
|
if option_value.nil?
|
66
67
|
unset_config_options << os_config_opt
|
@@ -69,53 +70,53 @@ def is_config_present
|
|
69
70
|
end
|
70
71
|
|
71
72
|
config_err_msg = "\nPlease set #{unset_config_options.join(', ')} config"
|
72
|
-
config_err_msg = config_err_msg + (unset_config_options.length > 1 ?
|
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."
|
73
74
|
puts config_err_msg unless unset_config_options.empty?
|
74
75
|
|
75
76
|
is_config
|
76
77
|
end
|
77
78
|
|
78
79
|
def get_gem_file_name
|
79
|
-
|
80
|
+
"knife-openstack-" + Knife::OpenStack::VERSION + ".gem"
|
80
81
|
end
|
81
82
|
|
82
83
|
def delete_instance_cmd(stdout)
|
83
|
-
|
84
|
-
append_openstack_creds(is_list_cmd = true) +
|
84
|
+
"knife openstack server delete " + find_instance_id("Instance ID", stdout) +
|
85
|
+
append_openstack_creds(is_list_cmd = true) + " --yes"
|
85
86
|
end
|
86
87
|
|
87
88
|
def create_node_name(name)
|
88
|
-
@name_node = (name ==
|
89
|
+
@name_node = (name == "linux") ? "os-integration-test-linux-#{SecureRandom.hex(4)}" : "os-integration-test-win-#{SecureRandom.hex(4)}"
|
89
90
|
end
|
90
91
|
|
91
92
|
def init_openstack_test
|
92
93
|
init_test
|
93
94
|
|
94
95
|
begin
|
95
|
-
data_to_write = File.read(File.expand_path(
|
96
|
-
File.open("#{temp_dir}/incorrect_openstack.pem",
|
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) }
|
97
98
|
rescue
|
98
|
-
puts
|
99
|
+
puts "Error while creating file - incorrect_openstack.pem"
|
99
100
|
end
|
100
101
|
|
101
|
-
config_file_exist = File.exist?(File.expand_path(
|
102
|
-
openstack_config = YAML.load(File.read(File.expand_path(
|
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
|
103
104
|
|
104
|
-
%w
|
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|
|
105
106
|
instance_variable_set("@#{os_config_opt.downcase}", (openstack_config[os_config_opt] if openstack_config) || ENV[os_config_opt])
|
106
107
|
end
|
107
108
|
begin
|
108
109
|
key_file_path = @openstack_pri_key
|
109
110
|
key_file_exist = File.exist?(File.expand_path(key_file_path, __FILE__))
|
110
111
|
data_to_write = File.read(File.expand_path(key_file_path, __FILE__)) if key_file_exist
|
111
|
-
File.open("#{temp_dir}/openstack.pem",
|
112
|
+
File.open("#{temp_dir}/openstack.pem", "w") { |f| f.write(data_to_write) }
|
112
113
|
rescue
|
113
|
-
puts
|
114
|
+
puts "Error while creating file - openstack.pem"
|
114
115
|
end
|
115
116
|
end
|
116
117
|
|
117
118
|
def create_sh_user_data_file
|
118
|
-
file = Tempfile.new([
|
119
|
+
file = Tempfile.new(["test_user_data", ".sh"])
|
119
120
|
file.write("echo 'sample user data file created' >> #{Dir.tmpdir}/testuserdata.txt")
|
120
121
|
file.rewind
|
121
122
|
file
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Mukta Aphale (<mukta.aphale@clogeny.com>)
|
3
4
|
# Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
|
@@ -17,13 +18,13 @@
|
|
17
18
|
# See the License for the specific language governing permissions and
|
18
19
|
# limitations under the License.
|
19
20
|
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
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"
|
24
25
|
|
25
26
|
describe Chef::Knife::Cloud::OpenstackFlavorList do
|
26
27
|
it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackFlavorList.new
|
27
28
|
|
28
|
-
include_context
|
29
|
+
include_context "#validate!", Chef::Knife::Cloud::OpenstackFlavorList.new
|
29
30
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
|
3
4
|
# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc.
|
@@ -15,39 +16,39 @@
|
|
15
16
|
# See the License for the specific language governing permissions and
|
16
17
|
# limitations under the License.
|
17
18
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
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"
|
22
23
|
|
23
24
|
describe Chef::Knife::Cloud::OpenstackFloatingIpAllocate do
|
24
25
|
it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackFloatingIpAllocate.new
|
25
|
-
include_context
|
26
|
+
include_context "#validate!", Chef::Knife::Cloud::OpenstackFloatingIpAllocate.new
|
26
27
|
|
27
28
|
before(:each) do
|
28
29
|
@instance = Chef::Knife::Cloud::OpenstackFloatingIpAllocate.new
|
29
30
|
allow(@instance.ui).to receive(:error)
|
30
31
|
end
|
31
32
|
|
32
|
-
describe
|
33
|
-
it
|
33
|
+
describe "create service instance" do
|
34
|
+
it "return OpenstackService instance" do
|
34
35
|
expect(@instance.create_service_instance).to be_an_instance_of(Chef::Knife::Cloud::OpenstackService)
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
|
-
describe
|
39
|
-
it
|
39
|
+
describe "allocate floating ip" do
|
40
|
+
it "calls allocate address" do
|
40
41
|
@instance.service = double
|
41
42
|
expect(@instance.service).to receive(:allocate_address).and_return(true)
|
42
43
|
@instance.execute_command
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
|
-
describe
|
47
|
-
it
|
48
|
-
@instance = Chef::Knife::Cloud::OpenstackFloatingIpAllocate.new([
|
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"])
|
49
50
|
@instance.service = Chef::Knife::Cloud::Service.new
|
50
|
-
response = { floating_ip: {
|
51
|
+
response = { floating_ip: { "id" => "test-id", "instance_id" => "test-instance-id", "floating_ip" => "127.0.0.1", "fixed_ip" => "nil", "pool" => "test-pool" } }
|
51
52
|
expect(@instance.service).to receive(:allocate_address).and_return(response)
|
52
53
|
@instance.execute_command
|
53
54
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
|
3
4
|
# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc.
|
@@ -14,21 +15,21 @@
|
|
14
15
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
16
|
# See the License for the specific language governing permissions and
|
16
17
|
# limitations under the License.
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
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"
|
22
23
|
|
23
24
|
describe Chef::Knife::Cloud::OpenstackFloatingIpAssociate do
|
24
25
|
before(:each) do
|
25
|
-
@instance = Chef::Knife::Cloud::OpenstackFloatingIpAssociate.new([
|
26
|
-
@instance.name_args = [
|
26
|
+
@instance = Chef::Knife::Cloud::OpenstackFloatingIpAssociate.new(["--instance-id", "23849038438240934n3294839248"])
|
27
|
+
@instance.name_args = ["127.0.0.1"]
|
27
28
|
end
|
28
29
|
|
29
|
-
describe
|
30
|
-
it
|
31
|
-
success_message =
|
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"
|
32
33
|
@instance.service = Chef::Knife::Cloud::Service.new
|
33
34
|
response = OpenStruct.new(status: 202)
|
34
35
|
expect(@instance.service).to receive(:associate_address).and_return(response)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
|
3
4
|
# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc.
|
@@ -14,24 +15,24 @@
|
|
14
15
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
16
|
# See the License for the specific language governing permissions and
|
16
17
|
# limitations under the License.
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
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"
|
22
23
|
|
23
24
|
describe Chef::Knife::Cloud::OpenstackFloatingIpDisassociate do
|
24
25
|
before(:each) do
|
25
|
-
@instance = Chef::Knife::Cloud::OpenstackFloatingIpDisassociate.new([
|
26
|
-
@instance.name_args = [
|
26
|
+
@instance = Chef::Knife::Cloud::OpenstackFloatingIpDisassociate.new(["--instance-id", "23849038438240934n3294839248"])
|
27
|
+
@instance.name_args = ["127.0.0.1"]
|
27
28
|
end
|
28
29
|
|
29
|
-
describe
|
30
|
-
it
|
30
|
+
describe "associate floating ip" do
|
31
|
+
it "calls associate address" do
|
31
32
|
@instance.service = Chef::Knife::Cloud::Service.new
|
32
33
|
response = OpenStruct.new(status: 202)
|
33
|
-
expect(@instance.service).to receive(:disassociate_address).with(
|
34
|
-
expect(@instance.ui).to receive(:info).and_return(
|
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")
|
35
36
|
@instance.execute_command
|
36
37
|
end
|
37
38
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
|
3
4
|
# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc.
|
@@ -15,12 +16,12 @@
|
|
15
16
|
# See the License for the specific language governing permissions and
|
16
17
|
# limitations under the License.
|
17
18
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
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"
|
22
23
|
|
23
24
|
describe Chef::Knife::Cloud::OpenstackFloatingIpList do
|
24
25
|
it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackFloatingIpList.new
|
25
|
-
include_context
|
26
|
+
include_context "#validate!", Chef::Knife::Cloud::OpenstackFloatingIpList.new
|
26
27
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
|
3
4
|
# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc.
|
@@ -14,34 +15,34 @@
|
|
14
15
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
16
|
# See the License for the specific language governing permissions and
|
16
17
|
# limitations under the License.
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
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"
|
21
22
|
|
22
23
|
describe Chef::Knife::Cloud::OpenstackFloatingIpRelease do
|
23
24
|
it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackFloatingIpRelease.new
|
24
|
-
include_context
|
25
|
+
include_context "#validate!", Chef::Knife::Cloud::OpenstackFloatingIpRelease.new
|
25
26
|
|
26
27
|
before(:each) do
|
27
28
|
@instance = Chef::Knife::Cloud::OpenstackFloatingIpRelease.new
|
28
29
|
allow(@instance.ui).to receive(:error)
|
29
|
-
@instance.name_args = [
|
30
|
+
@instance.name_args = ["23849038438240934n3294839248"]
|
30
31
|
end
|
31
32
|
|
32
|
-
describe
|
33
|
-
it
|
33
|
+
describe "create service instance" do
|
34
|
+
it "return OpenstackService instance" do
|
34
35
|
expect(@instance.create_service_instance).to be_an_instance_of(Chef::Knife::Cloud::OpenstackService)
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
|
-
describe
|
39
|
-
it
|
40
|
-
address_id =
|
39
|
+
describe "release floating ip" do
|
40
|
+
it "calls release address" do
|
41
|
+
address_id = "23849038438240934n3294839248"
|
41
42
|
@instance.service = double
|
42
43
|
response = OpenStruct.new(status: 202)
|
43
44
|
expect(@instance.service).to receive(:release_address).and_return(response)
|
44
|
-
expect(@instance.ui).to receive(:info).and_return(
|
45
|
+
expect(@instance.ui).to receive(:info).and_return("Floating IP released successfully.")
|
45
46
|
@instance.execute_command
|
46
47
|
end
|
47
48
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Mukta Aphale (<mukta.aphale@clogeny.com>)
|
3
4
|
# Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
|
@@ -17,26 +18,26 @@
|
|
17
18
|
# See the License for the specific language governing permissions and
|
18
19
|
# limitations under the License.
|
19
20
|
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
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"
|
24
25
|
|
25
26
|
describe Chef::Knife::Cloud::OpenstackGroupList do
|
26
27
|
it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackGroupList.new
|
27
28
|
|
28
|
-
include_context
|
29
|
+
include_context "#validate!", Chef::Knife::Cloud::OpenstackGroupList.new
|
29
30
|
|
30
31
|
let (:instance) { Chef::Knife::Cloud::OpenstackGroupList.new }
|
31
32
|
|
32
|
-
context
|
33
|
+
context "#list" do
|
33
34
|
before(:each) do
|
34
|
-
@security_groups = [TestResource.new(
|
35
|
-
instance.config[:format] =
|
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"
|
36
37
|
end
|
37
38
|
|
38
|
-
it
|
39
|
-
expect(instance.ui).to receive(:list).with([
|
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)
|
40
41
|
instance.list(@security_groups)
|
41
42
|
end
|
42
43
|
end
|