knife-openstack 1.3.2 → 2.0.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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +21 -0
  3. data/.gitignore +5 -0
  4. data/.travis.yml +9 -7
  5. data/CHANGELOG.md +174 -92
  6. data/Gemfile +15 -3
  7. data/README.md +96 -68
  8. data/Rakefile +19 -6
  9. data/knife-openstack.gemspec +17 -15
  10. data/lib/chef/knife/cloud/openstack_server_create_options.rb +36 -35
  11. data/lib/chef/knife/cloud/openstack_service.rb +7 -6
  12. data/lib/chef/knife/cloud/openstack_service_options.rb +18 -17
  13. data/lib/chef/knife/openstack_flavor_list.rb +11 -10
  14. data/lib/chef/knife/openstack_floating_ip_allocate.rb +13 -12
  15. data/lib/chef/knife/openstack_floating_ip_associate.rb +9 -8
  16. data/lib/chef/knife/openstack_floating_ip_disassociate.rb +9 -8
  17. data/lib/chef/knife/openstack_floating_ip_list.rb +10 -9
  18. data/lib/chef/knife/openstack_floating_ip_release.rb +7 -6
  19. data/lib/chef/knife/openstack_group_list.rb +13 -12
  20. data/lib/chef/knife/openstack_helpers.rb +8 -7
  21. data/lib/chef/knife/openstack_image_list.rb +14 -13
  22. data/lib/chef/knife/openstack_network_list.rb +10 -9
  23. data/lib/chef/knife/openstack_server_create.rb +57 -56
  24. data/lib/chef/knife/openstack_server_delete.rb +7 -6
  25. data/lib/chef/knife/openstack_server_list.rb +16 -15
  26. data/lib/chef/knife/openstack_server_show.rb +17 -16
  27. data/lib/chef/knife/openstack_volume_list.rb +10 -9
  28. data/lib/knife-openstack/version.rb +3 -2
  29. data/spec/functional/flavor_list_func_spec.rb +13 -12
  30. data/spec/functional/floating_ip_list_func_spec.rb +14 -13
  31. data/spec/functional/group_list_func_spec.rb +29 -28
  32. data/spec/functional/image_list_func_spec.rb +15 -14
  33. data/spec/functional/network_list_func_spec.rb +13 -12
  34. data/spec/functional/server_create_func_spec.rb +29 -28
  35. data/spec/functional/server_delete_func_spec.rb +18 -17
  36. data/spec/functional/server_list_func_spec.rb +43 -42
  37. data/spec/functional/server_show_func_spec.rb +7 -6
  38. data/spec/functional/volume_list_func_spec.rb +12 -11
  39. data/spec/integration/cleanup.rb +6 -5
  40. data/spec/integration/openstack_spec.rb +287 -286
  41. data/spec/spec_context.rb +10 -9
  42. data/spec/spec_helper.rb +38 -37
  43. data/spec/unit/openstack_flavor_list_spec.rb +6 -5
  44. data/spec/unit/openstack_floating_ip_allocate_spec.rb +14 -13
  45. data/spec/unit/openstack_floating_ip_associate_spec.rb +11 -10
  46. data/spec/unit/openstack_floating_ip_disassociate_spec.rb +12 -11
  47. data/spec/unit/openstack_floating_ip_list_spec.rb +6 -5
  48. data/spec/unit/openstack_floating_ip_release_spec.rb +13 -12
  49. data/spec/unit/openstack_group_list_spec.rb +11 -10
  50. data/spec/unit/openstack_image_list_spec.rb +6 -5
  51. data/spec/unit/openstack_network_list_spec.rb +8 -7
  52. data/spec/unit/openstack_server_create_spec.rb +131 -130
  53. data/spec/unit/openstack_server_delete_spec.rb +8 -7
  54. data/spec/unit/openstack_server_list_spec.rb +6 -5
  55. data/spec/unit/openstack_server_show_spec.rb +10 -9
  56. data/spec/unit/openstack_service_spec.rb +26 -25
  57. data/spec/unit/openstack_volume_list_spec.rb +6 -5
  58. metadata +9 -105
@@ -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 '#validate!' do |instance|
19
+ shared_context "#validate!" do |instance|
19
20
  before(:each) do
20
- Chef::Config[:knife][:openstack_username] = 'testuser'
21
- Chef::Config[:knife][:openstack_password] = 'testpassword'
22
- Chef::Config[:knife][:openstack_auth_url] = 'tsturl'
23
- Chef::Config[:knife][:openstack_region] = 'test-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 'validate openstack mandatory options' do
35
+ it "validate openstack mandatory options" do
35
36
  expect { instance.validate! }.to_not raise_error
36
37
  end
37
38
 
38
- it 'raise error on openstack_username missing' do
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 'raise error on openstack_password missing' do
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 'raise error on openstack_auth_url missing' do
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)
@@ -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('../../lib', __FILE__)
19
- require 'chef/knife/bootstrap'
20
- require 'chef/knife/openstack_helpers'
21
- require 'fog'
22
- require 'chef/knife/winrm_base'
23
- require 'chef/knife/bootstrap_windows_winrm'
24
- require 'chef/knife/openstack_server_create'
25
- require 'chef/knife/openstack_server_delete'
26
- require 'chef/knife/bootstrap_windows_ssh'
27
- require 'securerandom'
28
- require 'knife-openstack/version'
29
- require 'test/knife-utils/test_bed'
30
- require 'resource_spec_helper'
31
- require 'server_command_common_spec_helper'
32
- require 'tempfile'
33
- require 'spec_context'
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(' ')[2].strip if line.include?("#{instance_name}")
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['RUN_INTEGRATION_TESTS']
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('../integration/config/environment.yml', __FILE__))
51
- openstack_config = YAML.load(File.read(File.expand_path('../integration/config/environment.yml', __FILE__))) if config_file_exist
52
- %w(OPENSTACK_USERNAME OPENSTACK_PASSWORD OPENSTACK_AUTH_URL OPENSTACK_TENANT).each do |os_env_var|
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 ? ' variables ' : ' variable ') + 'for integration tests.'
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(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
+ %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 ? ' 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
+ 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
- 'knife-openstack-' + Knife::OpenStack::VERSION + '.gem'
80
+ "knife-openstack-" + Knife::OpenStack::VERSION + ".gem"
80
81
  end
81
82
 
82
83
  def delete_instance_cmd(stdout)
83
- 'knife openstack server delete ' + find_instance_id('Instance ID', stdout) +
84
- append_openstack_creds(is_list_cmd = true) + ' --yes'
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 == 'linux') ? "os-integration-test-linux-#{SecureRandom.hex(4)}" : "os-integration-test-win-#{SecureRandom.hex(4)}"
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('../integration/config/incorrect_openstack.pem', __FILE__))
96
- File.open("#{temp_dir}/incorrect_openstack.pem", 'w') { |f| f.write(data_to_write) }
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 'Error while creating file - incorrect_openstack.pem'
99
+ puts "Error while creating file - incorrect_openstack.pem"
99
100
  end
100
101
 
101
- config_file_exist = File.exist?(File.expand_path('../integration/config/environment.yml', __FILE__))
102
- openstack_config = YAML.load(File.read(File.expand_path('../integration/config/environment.yml', __FILE__))) if config_file_exist
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(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
+ %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", 'w') { |f| f.write(data_to_write) }
112
+ File.open("#{temp_dir}/openstack.pem", "w") { |f| f.write(data_to_write) }
112
113
  rescue
113
- puts 'Error while creating file - openstack.pem'
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(['test_user_data', '.sh'])
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 'spec_helper'
21
- require 'chef/knife/openstack_flavor_list'
22
- require 'chef/knife/cloud/openstack_service'
23
- require 'support/shared_examples_for_command'
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 '#validate!', Chef::Knife::Cloud::OpenstackFlavorList.new
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 'spec_helper'
19
- require 'chef/knife/openstack_floating_ip_allocate'
20
- require 'chef/knife/cloud/openstack_service'
21
- require 'support/shared_examples_for_command'
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 '#validate!', Chef::Knife::Cloud::OpenstackFloatingIpAllocate.new
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 'create service instance' do
33
- it 'return OpenstackService instance' do
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 'allocate floating ip' do
39
- it 'calls allocate address' do
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 'when user provides pool option ' do
47
- it 'allocates floating ip in user specified pool' do
48
- @instance = Chef::Knife::Cloud::OpenstackFloatingIpAllocate.new(['--pool', 'test-pool'])
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: { 'id' => 'test-id', 'instance_id' => 'test-instance-id', 'floating_ip' => '127.0.0.1', 'fixed_ip' => 'nil', 'pool' => 'test-pool' } }
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 'spec_helper'
18
- require 'chef/knife/openstack_floating_ip_associate'
19
- require 'chef/knife/cloud/openstack_service'
20
- require 'support/shared_examples_for_command'
21
- require 'ostruct'
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(['--instance-id', '23849038438240934n3294839248'])
26
- @instance.name_args = ['127.0.0.1']
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 'associate floating ip' do
30
- it 'calls associate address' do
31
- success_message = 'Floating IP 127.0.0.1 associated with Instance 23849038438240934n3294839248'
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 'spec_helper'
18
- require 'chef/knife/openstack_floating_ip_disassociate'
19
- require 'chef/knife/cloud/openstack_service'
20
- require 'support/shared_examples_for_command'
21
- require 'ostruct'
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(['--instance-id', '23849038438240934n3294839248'])
26
- @instance.name_args = ['127.0.0.1']
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 'associate floating ip' do
30
- it 'calls associate address' do
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('23849038438240934n3294839248', '127.0.0.1').and_return(response)
34
- expect(@instance.ui).to receive(:info).and_return('Floating IP 127.0.0.1 disassociated with Instance 23849038438240934n3294839248')
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 'spec_helper'
19
- require 'chef/knife/openstack_floating_ip_list'
20
- require 'chef/knife/cloud/openstack_service'
21
- require 'support/shared_examples_for_command'
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 '#validate!', Chef::Knife::Cloud::OpenstackFloatingIpList.new
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 'spec_helper'
18
- require 'chef/knife/openstack_floating_ip_release'
19
- require 'chef/knife/cloud/openstack_service'
20
- require 'support/shared_examples_for_command'
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 '#validate!', Chef::Knife::Cloud::OpenstackFloatingIpRelease.new
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 = ['23849038438240934n3294839248']
30
+ @instance.name_args = ["23849038438240934n3294839248"]
30
31
  end
31
32
 
32
- describe 'create service instance' do
33
- it 'return OpenstackService instance' do
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 'release floating ip' do
39
- it 'calls release address' do
40
- address_id = '23849038438240934n3294839248'
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('Floating IP released successfully.')
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 'spec_helper'
21
- require 'chef/knife/openstack_group_list'
22
- require 'chef/knife/cloud/openstack_service'
23
- require 'support/shared_examples_for_command'
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 '#validate!', Chef::Knife::Cloud::OpenstackGroupList.new
29
+ include_context "#validate!", Chef::Knife::Cloud::OpenstackGroupList.new
29
30
 
30
31
  let (:instance) { Chef::Knife::Cloud::OpenstackGroupList.new }
31
32
 
32
- context '#list' do
33
+ context "#list" do
33
34
  before(:each) do
34
- @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)])]
35
- instance.config[:format] = 'summary'
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 'returns group list' do
39
- 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)
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