knife-openstack 2.0.1 → 4.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 (60) hide show
  1. checksums.yaml +5 -5
  2. data/lib/chef/knife/cloud/openstack_server_create_options.rb +64 -51
  3. data/lib/chef/knife/cloud/openstack_service.rb +33 -17
  4. data/lib/chef/knife/cloud/openstack_service_options.rb +34 -24
  5. data/lib/chef/knife/openstack_flavor_list.rb +18 -4
  6. data/lib/chef/knife/openstack_floating_ip_allocate.rb +22 -9
  7. data/lib/chef/knife/openstack_floating_ip_associate.rb +24 -12
  8. data/lib/chef/knife/openstack_floating_ip_disassociate.rb +25 -12
  9. data/lib/chef/knife/openstack_floating_ip_list.rb +18 -4
  10. data/lib/chef/knife/openstack_floating_ip_release.rb +16 -4
  11. data/lib/chef/knife/openstack_group_list.rb +21 -4
  12. data/lib/chef/knife/openstack_helpers.rb +20 -4
  13. data/lib/chef/knife/openstack_image_list.rb +22 -8
  14. data/lib/chef/knife/openstack_network_list.rb +18 -4
  15. data/lib/chef/knife/openstack_server_create.rb +36 -35
  16. data/lib/chef/knife/openstack_server_delete.rb +17 -5
  17. data/lib/chef/knife/openstack_server_list.rb +5 -6
  18. data/lib/chef/knife/openstack_server_show.rb +4 -5
  19. data/lib/chef/knife/openstack_volume_list.rb +10 -9
  20. data/lib/knife-openstack/version.rb +2 -2
  21. metadata +17 -91
  22. data/.github/ISSUE_TEMPLATE.md +0 -21
  23. data/.gitignore +0 -32
  24. data/.travis.yml +0 -10
  25. data/CHANGELOG.md +0 -335
  26. data/CONTRIBUTING.MD +0 -164
  27. data/Gemfile +0 -21
  28. data/README.md +0 -179
  29. data/Rakefile +0 -27
  30. data/knife-openstack.gemspec +0 -30
  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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: bccced8e7a4e0fb7c2f339e9f4fc82fc2a22447f
4
- data.tar.gz: 1311204c17a6a5d0fd198a1be33df0b5f0bbd8b8
2
+ SHA256:
3
+ metadata.gz: fea575415f8293a82e3549df15fe0904421689eb1501ecde02f6c763e5d11567
4
+ data.tar.gz: df4336564c9df6eb7dc4360169dd6d843614222e1092085ed54183abea88513e
5
5
  SHA512:
6
- metadata.gz: 552efcd4d6ed050e5a479e5ac2e3927dfba6ff60b17379d1e78a20e5b90bd04dda285b0707f04b8870e5f3d47e4fe464c74c09e2885481447c79522ba357cdbb
7
- data.tar.gz: 626bf0dcc77ec5cd389dae99d2d9f6df910f180a086b237007007e791c2f0ed5613e585d3019b9690e0ab90b765635af5c02fa3e0fc66375e0380360448aa678
6
+ metadata.gz: f69a9955f12b7ebfee46e574b9929ac71a248b151c2a64ada9b50b3d59b124118e188b6ce7cd828505e254d10d14ea6c3cc089ea7d02d163c59abd1f7e0d9912
7
+ data.tar.gz: 8731570f7c7cc4e7a15a53c8f9ff1e733c3e79db7957fbd53b6e7345751b9268cce77ee98e6bb6b4e9130b5c30a89aac0661bbb01b64117d396b65ee770c7190
@@ -1,5 +1,20 @@
1
+ #
2
+ # Copyright:: Copyright (c) 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
+ #
1
17
 
2
- # frozen_string_literal: true
3
18
  require "chef/knife/cloud/server/create_options"
4
19
 
5
20
  class Chef
@@ -12,82 +27,80 @@ class Chef
12
27
 
13
28
  # Openstack Server create params.
14
29
  option :private_network,
15
- long: "--openstack-private-network",
16
- description: "Use the private IP for bootstrapping rather than the public IP",
17
- boolean: true,
18
- default: false
30
+ long: "--openstack-private-network",
31
+ description: "Use the private IP for bootstrapping rather than the public IP",
32
+ boolean: true,
33
+ default: false
19
34
 
20
35
  option :openstack_floating_ip,
21
- short: "-a [IP]",
22
- long: "--openstack-floating-ip [IP]",
23
- default: "-1",
24
- description: "Request to associate a floating IP address to the new OpenStack node. Assumes IPs have been allocated to the project. Specific IP is optional."
36
+ short: "-a [IP]",
37
+ long: "--openstack-floating-ip [IP]",
38
+ default: "-1",
39
+ description: "Request to associate a floating IP address to the new OpenStack node. Assumes IPs have been allocated to the project. Specific IP is optional."
25
40
 
26
41
  option :openstack_volumes,
27
- long: "--openstack-volumes VOLUME1,VOLUME2,VOLUME3",
28
- description: "Comma separated list of the UUID(s) of the volume(s) to attach to the server",
29
- proc: proc { |volumes| volumes.split(",") }
42
+ long: "--openstack-volumes VOLUME1,VOLUME2,VOLUME3",
43
+ description: "Comma separated list of the UUID(s) of the volume(s) to attach to the server",
44
+ proc: proc { |volumes| volumes.split(",") }
30
45
 
31
46
  option :openstack_scheduler_hints,
32
- long: "--scheduler-hints HINTS",
33
- description: "A scheduler group hint to OpenStack",
34
- proc: proc { |i| Chef::Config[:knife][:openstack_scheduler_hints] = i }
47
+ long: "--scheduler-hints HINTS",
48
+ description: "A scheduler group hint to OpenStack"
35
49
 
36
50
  option :openstack_security_groups,
37
- short: "-G X,Y,Z",
38
- long: "--openstack-groups X,Y,Z",
39
- description: "The security groups for this server",
40
- default: ["default"],
41
- proc: proc { |groups| groups.split(",") }
51
+ short: "-G X,Y,Z",
52
+ long: "--openstack-groups X,Y,Z",
53
+ description: "The security groups for this server",
54
+ default: ["default"],
55
+ proc: proc { |groups| groups.split(",") }
42
56
 
43
57
  option :openstack_ssh_key_id,
44
- short: "-S KEY",
45
- long: "--openstack-ssh-key-id KEY",
46
- description: "The OpenStack SSH keypair id",
47
- proc: proc { |key| Chef::Config[:knife][:openstack_ssh_key_id] = key }
58
+ short: "-S KEY",
59
+ long: "--openstack-ssh-key-id KEY",
60
+ description: "The OpenStack SSH keypair id"
48
61
 
49
62
  option :user_data,
50
- long: "--user-data USER_DATA",
51
- description: "The file path containing user data information for this server",
52
- proc: proc { |user_data| open(user_data, &:read) }
63
+ long: "--user-data USER_DATA",
64
+ description: "The file path containing user data information for this server",
65
+ proc: proc { |user_data| open(user_data, &:read) }
53
66
 
54
67
  option :bootstrap_network,
55
- long: "--bootstrap-network NAME",
56
- default: "public",
57
- description: "Specify network for bootstrapping. Default is 'public'."
68
+ long: "--bootstrap-network NAME",
69
+ default: "public",
70
+ description: "Specify network for bootstrapping. Default is 'public'."
58
71
 
59
72
  option :network,
60
- long: "--no-network",
61
- boolean: true,
62
- default: true,
63
- description: "Use first available network for bootstrapping if 'public' and 'private' are unavailable."
73
+ long: "--no-network",
74
+ boolean: true,
75
+ default: true,
76
+ description: "Use first available network for bootstrapping if 'public' and 'private' are unavailable."
64
77
 
65
78
  option :network_ids,
66
- long: "--network-ids NETWORK_ID_1,NETWORK_ID_2,NETWORK_ID_3",
67
- description: "Comma separated list of the UUID(s) of the network(s) for the server to attach",
68
- proc: proc { |networks| networks.split(",") }
79
+ long: "--network-ids NETWORK_ID_1,NETWORK_ID_2,NETWORK_ID_3",
80
+ description: "Comma separated list of the UUID(s) of the network(s) for the server to attach",
81
+ proc: proc { |networks| networks.split(",") }
69
82
 
70
83
  option :availability_zone,
71
- short: "-Z ZONE_NAME",
72
- long: "--availability-zone ZONE_NAME",
73
- description: "The availability zone for this server",
74
- proc: proc { |z| Chef::Config[:knife][:availability_zone] = z }
84
+ short: "-Z ZONE_NAME",
85
+ long: "--availability-zone ZONE_NAME",
86
+ description: "The availability zone for this server"
75
87
 
76
88
  option :metadata,
77
- short: "-M X=1",
78
- long: "--metadata X=1",
79
- description: "Metadata information for this server (may pass multiple times)",
80
- proc: proc { |data| Chef::Config[:knife][:metadata] ||= {}; Chef::Config[:knife][:metadata].merge!(data.split("=")[0] => data.split("=")[1]) }
89
+ short: "-M X=1",
90
+ long: "--metadata X=1",
91
+ description: "Metadata information for this server (may pass multiple times)",
92
+ proc: proc { |data, accumulator|
93
+ accumulator ||= {}
94
+ accumulator.merge!(data.split("=")[0] => data.split("=")[1])
95
+ }
81
96
 
82
97
  option :secret_file,
83
- long: "--secret-file SECRET_FILE",
84
- description: "A file containing the secret key to use to encrypt data bag item values",
85
- proc: proc { |sf| Chef::Config[:knife][:secret_file] = sf }
98
+ long: "--secret-file SECRET_FILE",
99
+ description: "A file containing the secret key to use to encrypt data bag item values"
86
100
 
87
101
  option :secret,
88
- long: "--secret ",
89
- description: "The secret key to use to encrypt data bag item values",
90
- proc: proc { |s| Chef::Config[:knife][:secret] = s }
102
+ long: "--secret ",
103
+ description: "The secret key to use to encrypt data bag item values"
91
104
  end
92
105
  end
93
106
  end
@@ -1,30 +1,46 @@
1
- # frozen_string_literal: true
2
1
  #
3
2
  # Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
4
3
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
5
- # Copyright:: Copyright (c) 2013 Chef Software, Inc.
4
+ # Author:: Lance Albertson(<lance@osuosl.org>)
5
+ # Copyright:: Copyright (c) Chef Software Inc.
6
+ # License:: Apache License, Version 2.0
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
6
19
  #
7
20
 
8
21
  require "chef/knife/cloud/fog/service"
22
+ require "fog/openstack"
9
23
 
10
24
  class Chef
11
25
  class Knife
12
26
  class Cloud
13
27
  class OpenstackService < FogService
14
- def initialize(options = {})
15
- Chef::Log.debug("openstack_username #{Chef::Config[:knife][:openstack_username]}")
16
- Chef::Log.debug("openstack_auth_url #{Chef::Config[:knife][:openstack_auth_url]}")
17
- Chef::Log.debug("openstack_tenant #{Chef::Config[:knife][:openstack_tenant]}")
18
- Chef::Log.debug("openstack_endpoint_type #{Chef::Config[:knife][:openstack_endpoint_type] || 'publicURL'}")
19
- Chef::Log.debug("openstack_insecure #{Chef::Config[:knife][:openstack_insecure]}")
20
- Chef::Log.debug("openstack_region #{Chef::Config[:knife][:openstack_region]}")
28
+ def initialize(config:, **kwargs)
29
+ super(config: config, **kwargs)
21
30
 
22
- super(options.merge(auth_params: get_auth_params))
31
+ Chef::Log.debug("openstack_username #{config[:openstack_username]}")
32
+ Chef::Log.debug("openstack_auth_url #{config[:openstack_auth_url]}")
33
+ Chef::Log.debug("openstack_tenant #{config[:openstack_tenant]}")
34
+ Chef::Log.debug("openstack_endpoint_type #{config[:openstack_endpoint_type] || "publicURL"}")
35
+ Chef::Log.debug("openstack_insecure #{config[:openstack_insecure]}")
36
+ Chef::Log.debug("openstack_region #{config[:openstack_region]}")
37
+
38
+ @auth_params = get_auth_params
23
39
  end
24
40
 
25
41
  # add alternate user defined api_endpoint value.
26
42
  def add_api_endpoint
27
- @auth_params.merge!(openstack_auth_url: Chef::Config[:knife][:api_endpoint]) unless Chef::Config[:knife][:api_endpoint].nil?
43
+ @auth_params.merge!(openstack_auth_url: config[:api_endpoint]) unless config[:api_endpoint].nil?
28
44
  end
29
45
 
30
46
  def get_server(search_term)
@@ -46,23 +62,23 @@ class Chef
46
62
  end
47
63
 
48
64
  def get_auth_params
49
- load_fog_gem
50
65
  params = {
51
66
  provider: "OpenStack",
52
67
  connection_options: {
53
- ssl_verify_peer: !Chef::Config[:knife][:openstack_insecure],
68
+ ssl_verify_peer: !config[:openstack_insecure],
54
69
  },
55
70
  }
56
71
 
57
72
  (
58
- Fog::Compute::OpenStack.requirements +
59
- Fog::Compute::OpenStack.recognized -
73
+ Fog::OpenStack::Compute.requirements +
74
+ Fog::OpenStack::Compute.recognized -
60
75
  [:openstack_api_key]
61
76
  ).each do |k|
62
77
  next unless k.to_s.start_with?("openstack")
63
- params[k] = Chef::Config[:knife][k]
78
+
79
+ params[k] = config[k]
64
80
  end
65
- params[:openstack_api_key] = Chef::Config[:knife][:openstack_password] || Chef::Config[:knife][:openstack_api_key]
81
+ params[:openstack_api_key] = config[:openstack_password] || config[:openstack_api_key]
66
82
 
67
83
  params
68
84
  end
@@ -1,4 +1,20 @@
1
- # frozen_string_literal: true
1
+ #
2
+ # Copyright:: Copyright (c) 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
+
2
18
  require "chef/knife/cloud/fog/options"
3
19
  class Chef
4
20
  class Knife
@@ -9,39 +25,33 @@ class Chef
9
25
  include FogOptions
10
26
  # Openstack Connection params.
11
27
  option :openstack_username,
12
- short: "-A USERNAME",
13
- long: "--openstack-username KEY",
14
- description: "Your OpenStack Username",
15
- proc: proc { |key| Chef::Config[:knife][:openstack_username] = key }
28
+ short: "-A USERNAME",
29
+ long: "--openstack-username KEY",
30
+ description: "Your OpenStack Username"
16
31
 
17
32
  option :openstack_password,
18
- short: "-K SECRET",
19
- long: "--openstack-password SECRET",
20
- description: "Your OpenStack Password",
21
- proc: proc { |key| Chef::Config[:knife][:openstack_password] = key }
33
+ short: "-K SECRET",
34
+ long: "--openstack-password SECRET",
35
+ description: "Your OpenStack Password"
22
36
 
23
37
  option :openstack_tenant,
24
- short: "-T NAME",
25
- long: "--openstack-tenant NAME",
26
- description: "Your OpenStack Tenant NAME",
27
- proc: proc { |key| Chef::Config[:knife][:openstack_tenant] = key }
38
+ short: "-T NAME",
39
+ long: "--openstack-tenant NAME",
40
+ description: "Your OpenStack Tenant NAME"
28
41
 
29
42
  option :openstack_auth_url,
30
- long: "--openstack-api-endpoint ENDPOINT",
31
- description: "Your OpenStack API endpoint",
32
- proc: proc { |endpoint| Chef::Config[:knife][:openstack_auth_url] = endpoint }
43
+ long: "--openstack-api-endpoint ENDPOINT",
44
+ description: "Your OpenStack API endpoint"
33
45
 
34
46
  option :openstack_endpoint_type,
35
- long: "--openstack-endpoint-type ENDPOINT_TYPE",
36
- description: "OpenStack endpoint type to use (publicURL, internalURL, adminURL)",
37
- proc: proc { |type| Chef::Config[:knife][:openstack_endpoint_type] = type }
47
+ long: "--openstack-endpoint-type ENDPOINT_TYPE",
48
+ description: "OpenStack endpoint type to use (publicURL, internalURL, adminURL)"
38
49
 
39
50
  option :openstack_insecure,
40
- long: "--insecure",
41
- description: "Ignore SSL certificate on the Auth URL",
42
- boolean: true,
43
- default: false,
44
- proc: proc { |key| Chef::Config[:knife][:openstack_insecure] = key }
51
+ long: "--insecure",
52
+ description: "Ignore SSL certificate on the Auth URL",
53
+ boolean: true,
54
+ default: false
45
55
  end
46
56
  end
47
57
  end
@@ -1,10 +1,24 @@
1
- # frozen_string_literal: true
1
+ #
2
2
  # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
3
- # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
+ # Copyright:: Copyright 2014-2020 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
4
18
 
5
19
  require "chef/knife/cloud/list_resource_command"
6
- require "chef/knife/openstack_helpers"
7
- require "chef/knife/cloud/openstack_service_options"
20
+ require_relative "openstack_helpers"
21
+ require_relative "cloud/openstack_service_options"
8
22
 
9
23
  class Chef
10
24
  class Knife
@@ -1,9 +1,23 @@
1
- # frozen_string_literal: true
1
+ #
2
2
  # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
3
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
4
18
 
5
- require "chef/knife/openstack_helpers"
6
- require "chef/knife/cloud/openstack_service_options"
19
+ require_relative "openstack_helpers"
20
+ require_relative "cloud/openstack_service_options"
7
21
  require "chef/knife/cloud/command"
8
22
 
9
23
  class Chef
@@ -16,13 +30,12 @@ class Chef
16
30
  banner "knife openstack floating_ip allocate (options)"
17
31
 
18
32
  option :pool,
19
- short: "-p POOL",
20
- long: "--pool POOL",
21
- description: "Floating IP pool to allocate from.",
22
- proc: proc { |key| Chef::Config[:knife][:pool] = key }
33
+ short: "-p POOL",
34
+ long: "--pool POOL",
35
+ description: "Floating IP pool to allocate from."
23
36
 
24
37
  def execute_command
25
- @resource = @service.allocate_address(locate_config_value(:pool))
38
+ @resource = @service.allocate_address(config[:pool])
26
39
  end
27
40
 
28
41
  def after_exec_command
@@ -1,10 +1,24 @@
1
- # frozen_string_literal: true
1
+ #
2
2
  # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
3
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
4
18
 
5
- require "chef/knife/openstack_helpers"
6
- require "chef/knife/cloud/openstack_service_options"
7
- require "chef/knife/cloud/openstack_service"
19
+ require_relative "openstack_helpers"
20
+ require_relative "cloud/openstack_service_options"
21
+ require_relative "cloud/openstack_service"
8
22
  require "chef/knife/cloud/command"
9
23
 
10
24
  class Chef
@@ -17,10 +31,9 @@ class Chef
17
31
  banner "knife openstack floating_ip associate IP (options)"
18
32
 
19
33
  option :instance_id,
20
- long: "--instance-id ID",
21
- description: "Instance id to associate it with.",
22
- proc: proc { |key| Chef::Config[:knife][:instance_id] = key },
23
- required: true
34
+ long: "--instance-id ID",
35
+ description: "Instance id to associate it with.",
36
+ required: true
24
37
 
25
38
  def execute_command
26
39
  if @name_args[0]
@@ -30,10 +43,9 @@ class Chef
30
43
  exit 1
31
44
  end
32
45
 
33
- instance_id = locate_config_value(:instance_id)
34
- response = @service.associate_address(instance_id, floating_ip)
46
+ response = @service.associate_address(config[:instance_id], floating_ip)
35
47
  if response && response.status == 202
36
- ui.info "Floating IP #{floating_ip} associated with Instance #{instance_id}"
48
+ ui.info "Floating IP #{floating_ip} associated with Instance #{config[:instance_id]}"
37
49
  end
38
50
  end
39
51
  end