knife-openstack 3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 893c5909a78491c4fc25e39572e7360a9a7a15cb977e901032598ecb2461c179
4
- data.tar.gz: f4e8d63647fc7ffb3a090ead708749f3195850ba079519f8a54d4b1d0ca0afd5
3
+ metadata.gz: fea575415f8293a82e3549df15fe0904421689eb1501ecde02f6c763e5d11567
4
+ data.tar.gz: df4336564c9df6eb7dc4360169dd6d843614222e1092085ed54183abea88513e
5
5
  SHA512:
6
- metadata.gz: e4dfe6c74483e8ebc2c16cb358c8ce0149e03a1733aa4fa82d53a340b552b4c3f87d7a940db1b9a1126a4e451ed0b12bc32b8a211b10fdc05d386a48f43eeef9
7
- data.tar.gz: 39714c903a74e9ae4032cefe23ad8284d587fab9273b750797f238a288fd1155734e23f03285b3a1b53f690ac8739b672a912660849fee067f732dc99efc1f59
6
+ metadata.gz: f69a9955f12b7ebfee46e574b9929ac71a248b151c2a64ada9b50b3d59b124118e188b6ce7cd828505e254d10d14ea6c3cc089ea7d02d163c59abd1f7e0d9912
7
+ data.tar.gz: 8731570f7c7cc4e7a15a53c8f9ff1e733c3e79db7957fbd53b6e7345751b9268cce77ee98e6bb6b4e9130b5c30a89aac0661bbb01b64117d396b65ee770c7190
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2018 Chef Software, Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -45,8 +45,7 @@ class Chef
45
45
 
46
46
  option :openstack_scheduler_hints,
47
47
  long: "--scheduler-hints HINTS",
48
- description: "A scheduler group hint to OpenStack",
49
- proc: proc { |i| Chef::Config[:knife][:openstack_scheduler_hints] = i }
48
+ description: "A scheduler group hint to OpenStack"
50
49
 
51
50
  option :openstack_security_groups,
52
51
  short: "-G X,Y,Z",
@@ -58,8 +57,7 @@ class Chef
58
57
  option :openstack_ssh_key_id,
59
58
  short: "-S KEY",
60
59
  long: "--openstack-ssh-key-id KEY",
61
- description: "The OpenStack SSH keypair id",
62
- proc: proc { |key| Chef::Config[:knife][:openstack_ssh_key_id] = key }
60
+ description: "The OpenStack SSH keypair id"
63
61
 
64
62
  option :user_data,
65
63
  long: "--user-data USER_DATA",
@@ -85,24 +83,24 @@ class Chef
85
83
  option :availability_zone,
86
84
  short: "-Z ZONE_NAME",
87
85
  long: "--availability-zone ZONE_NAME",
88
- description: "The availability zone for this server",
89
- proc: proc { |z| Chef::Config[:knife][:availability_zone] = z }
86
+ description: "The availability zone for this server"
90
87
 
91
88
  option :metadata,
92
89
  short: "-M X=1",
93
90
  long: "--metadata X=1",
94
91
  description: "Metadata information for this server (may pass multiple times)",
95
- proc: proc { |data| Chef::Config[:knife][:metadata] ||= {}; Chef::Config[:knife][:metadata].merge!(data.split("=")[0] => data.split("=")[1]) }
92
+ proc: proc { |data, accumulator|
93
+ accumulator ||= {}
94
+ accumulator.merge!(data.split("=")[0] => data.split("=")[1])
95
+ }
96
96
 
97
97
  option :secret_file,
98
98
  long: "--secret-file SECRET_FILE",
99
- description: "A file containing the secret key to use to encrypt data bag item values",
100
- proc: proc { |sf| Chef::Config[:knife][:secret_file] = sf }
99
+ description: "A file containing the secret key to use to encrypt data bag item values"
101
100
 
102
101
  option :secret,
103
102
  long: "--secret ",
104
- description: "The secret key to use to encrypt data bag item values",
105
- proc: proc { |s| Chef::Config[:knife][:secret] = s }
103
+ description: "The secret key to use to encrypt data bag item values"
106
104
  end
107
105
  end
108
106
  end
@@ -2,7 +2,7 @@
2
2
  # Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
3
3
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
4
4
  # Author:: Lance Albertson(<lance@osuosl.org>)
5
- # Copyright:: Copyright 2013-2020 Chef Software, Inc.
5
+ # Copyright:: Copyright (c) Chef Software Inc.
6
6
  # License:: Apache License, Version 2.0
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,20 +25,22 @@ class Chef
25
25
  class Knife
26
26
  class Cloud
27
27
  class OpenstackService < FogService
28
- def initialize(options = {})
29
- Chef::Log.debug("openstack_username #{Chef::Config[:knife][:openstack_username]}")
30
- Chef::Log.debug("openstack_auth_url #{Chef::Config[:knife][:openstack_auth_url]}")
31
- Chef::Log.debug("openstack_tenant #{Chef::Config[:knife][:openstack_tenant]}")
32
- Chef::Log.debug("openstack_endpoint_type #{Chef::Config[:knife][:openstack_endpoint_type] || "publicURL"}")
33
- Chef::Log.debug("openstack_insecure #{Chef::Config[:knife][:openstack_insecure]}")
34
- Chef::Log.debug("openstack_region #{Chef::Config[:knife][:openstack_region]}")
28
+ def initialize(config:, **kwargs)
29
+ super(config: config, **kwargs)
35
30
 
36
- 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
37
39
  end
38
40
 
39
41
  # add alternate user defined api_endpoint value.
40
42
  def add_api_endpoint
41
- @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?
42
44
  end
43
45
 
44
46
  def get_server(search_term)
@@ -60,11 +62,10 @@ class Chef
60
62
  end
61
63
 
62
64
  def get_auth_params
63
- load_fog_gem
64
65
  params = {
65
66
  provider: "OpenStack",
66
67
  connection_options: {
67
- ssl_verify_peer: !Chef::Config[:knife][:openstack_insecure],
68
+ ssl_verify_peer: !config[:openstack_insecure],
68
69
  },
69
70
  }
70
71
 
@@ -75,9 +76,9 @@ class Chef
75
76
  ).each do |k|
76
77
  next unless k.to_s.start_with?("openstack")
77
78
 
78
- params[k] = Chef::Config[:knife][k]
79
+ params[k] = config[k]
79
80
  end
80
- 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]
81
82
 
82
83
  params
83
84
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2018 Chef Software, Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,37 +27,31 @@ class Chef
27
27
  option :openstack_username,
28
28
  short: "-A USERNAME",
29
29
  long: "--openstack-username KEY",
30
- description: "Your OpenStack Username",
31
- proc: proc { |key| Chef::Config[:knife][:openstack_username] = key }
30
+ description: "Your OpenStack Username"
32
31
 
33
32
  option :openstack_password,
34
33
  short: "-K SECRET",
35
34
  long: "--openstack-password SECRET",
36
- description: "Your OpenStack Password",
37
- proc: proc { |key| Chef::Config[:knife][:openstack_password] = key }
35
+ description: "Your OpenStack Password"
38
36
 
39
37
  option :openstack_tenant,
40
38
  short: "-T NAME",
41
39
  long: "--openstack-tenant NAME",
42
- description: "Your OpenStack Tenant NAME",
43
- proc: proc { |key| Chef::Config[:knife][:openstack_tenant] = key }
40
+ description: "Your OpenStack Tenant NAME"
44
41
 
45
42
  option :openstack_auth_url,
46
43
  long: "--openstack-api-endpoint ENDPOINT",
47
- description: "Your OpenStack API endpoint",
48
- proc: proc { |endpoint| Chef::Config[:knife][:openstack_auth_url] = endpoint }
44
+ description: "Your OpenStack API endpoint"
49
45
 
50
46
  option :openstack_endpoint_type,
51
47
  long: "--openstack-endpoint-type ENDPOINT_TYPE",
52
- description: "OpenStack endpoint type to use (publicURL, internalURL, adminURL)",
53
- proc: proc { |type| Chef::Config[:knife][:openstack_endpoint_type] = type }
48
+ description: "OpenStack endpoint type to use (publicURL, internalURL, adminURL)"
54
49
 
55
50
  option :openstack_insecure,
56
51
  long: "--insecure",
57
52
  description: "Ignore SSL certificate on the Auth URL",
58
53
  boolean: true,
59
- default: false,
60
- proc: proc { |key| Chef::Config[:knife][:openstack_insecure] = key }
54
+ default: false
61
55
  end
62
56
  end
63
57
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
3
- # Copyright:: Copyright 2015-2020 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -32,11 +32,10 @@ class Chef
32
32
  option :pool,
33
33
  short: "-p POOL",
34
34
  long: "--pool POOL",
35
- description: "Floating IP pool to allocate from.",
36
- proc: proc { |key| Chef::Config[:knife][:pool] = key }
35
+ description: "Floating IP pool to allocate from."
37
36
 
38
37
  def execute_command
39
- @resource = @service.allocate_address(locate_config_value(:pool))
38
+ @resource = @service.allocate_address(config[:pool])
40
39
  end
41
40
 
42
41
  def after_exec_command
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
3
- # Copyright:: Copyright 2015-2020 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,7 +33,6 @@ class Chef
33
33
  option :instance_id,
34
34
  long: "--instance-id ID",
35
35
  description: "Instance id to associate it with.",
36
- proc: proc { |key| Chef::Config[:knife][:instance_id] = key },
37
36
  required: true
38
37
 
39
38
  def execute_command
@@ -44,9 +43,9 @@ class Chef
44
43
  exit 1
45
44
  end
46
45
 
47
- response = @service.associate_address(locate_config_value(:instance_id), floating_ip)
46
+ response = @service.associate_address(config[:instance_id], floating_ip)
48
47
  if response && response.status == 202
49
- ui.info "Floating IP #{floating_ip} associated with Instance #{locate_config_value(:instance_id)}"
48
+ ui.info "Floating IP #{floating_ip} associated with Instance #{config[:instance_id]}"
50
49
  end
51
50
  end
52
51
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
3
- # Copyright:: Copyright 2015-2020 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,7 +33,6 @@ class Chef
33
33
  option :instance_id,
34
34
  long: "--instance-id ID",
35
35
  description: "Instance id to disassociate with.",
36
- proc: proc { |key| Chef::Config[:knife][:instance_id] = key },
37
36
  required: true
38
37
 
39
38
  def execute_command
@@ -44,9 +43,9 @@ class Chef
44
43
  exit 1
45
44
  end
46
45
 
47
- response = @service.disassociate_address(locate_config_value(:instance_id), floating_ip)
46
+ response = @service.disassociate_address(config[:instance_id], floating_ip)
48
47
  if response && response.status == 202
49
- ui.info "Floating IP #{floating_ip} disassociated with Instance #{locate_config_value(:instance_id)}"
48
+ ui.info "Floating IP #{floating_ip} disassociated with Instance #{config[:instance_id]}"
50
49
  end
51
50
  end
52
51
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2018 Chef Software, Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,7 +34,7 @@ class Chef
34
34
  end
35
35
 
36
36
  def create_service_instance
37
- OpenstackService.new
37
+ OpenstackService.new(config: config)
38
38
  end
39
39
 
40
40
  def validate!
@@ -3,7 +3,7 @@
3
3
  # Author:: Matt Ray (<matt@chef.io>)
4
4
  # Author:: Chirag Jog (<chirag@clogeny.com>)
5
5
  # Author:: Lance Albertson (<lance@osuosl.org>)
6
- # Copyright:: Copyright 2011-2020 Chef Software, Inc.
6
+ # Copyright:: Copyright (c) Chef Software Inc.
7
7
  # License:: Apache License, Version 2.0
8
8
  #
9
9
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -43,19 +43,19 @@ class Chef
43
43
  server_def: {
44
44
  # servers require a name, knife-cloud generates the chef_node_name
45
45
  :name => config[:chef_node_name],
46
- :image_ref => service.get_image(locate_config_value(:image)).id,
47
- :flavor_ref => service.get_flavor(locate_config_value(:flavor)).id,
48
- :security_groups => locate_config_value(:openstack_security_groups),
49
- :availability_zone => locate_config_value(:availability_zone),
50
- "os:scheduler_hints" => locate_config_value(:openstack_scheduler_hints),
51
- :metadata => locate_config_value(:metadata),
52
- :key_name => locate_config_value(:openstack_ssh_key_id),
46
+ :image_ref => service.get_image(config[:image]).id,
47
+ :flavor_ref => service.get_flavor(config[:flavor]).id,
48
+ :security_groups => config[:openstack_security_groups],
49
+ :availability_zone => config[:availability_zone],
50
+ "os:scheduler_hints" => config[:openstack_scheduler_hints],
51
+ :metadata => config[:metadata],
52
+ :key_name => config[:openstack_ssh_key_id],
53
53
  },
54
- server_create_timeout: locate_config_value(:server_create_timeout),
54
+ server_create_timeout: config[:server_create_timeout],
55
55
  }
56
- unless locate_config_value(:openstack_volumes).nil?
56
+ unless config[:openstack_volumes].nil?
57
57
  counter = 99
58
- @create_options[:server_def][:block_device_mapping] = locate_config_value(:openstack_volumes).map do |vol|
58
+ @create_options[:server_def][:block_device_mapping] = config[:openstack_volumes].map do |vol|
59
59
  counter += 1
60
60
  {
61
61
  volume_id: vol,
@@ -66,8 +66,8 @@ class Chef
66
66
  end
67
67
  end
68
68
 
69
- @create_options[:server_def][:user_data] = locate_config_value(:user_data) if locate_config_value(:user_data)
70
- @create_options[:server_def][:nics] = locate_config_value(:network_ids).map { |nic| nic_id = { "net_id" => nic } } if locate_config_value(:network_ids)
69
+ @create_options[:server_def][:user_data] = config[:user_data] if config[:user_data]
70
+ @create_options[:server_def][:nics] = config[:network_ids].map { |nic| nic_id = { "net_id" => nic } } if config[:network_ids]
71
71
 
72
72
  Chef::Log.debug("Create server params - server_def = #{@create_options[:server_def]}")
73
73
  # set columns_with_info map
@@ -94,7 +94,7 @@ class Chef
94
94
  msg_pair("Public IP Address", primary_public_ip_address(server.addresses)) if primary_public_ip_address(server.addresses)
95
95
  msg_pair("Private IP Address", primary_private_ip_address(server.addresses)) if primary_private_ip_address(server.addresses)
96
96
 
97
- floating_address = locate_config_value(:openstack_floating_ip)
97
+ floating_address = config[:openstack_floating_ip]
98
98
  bind_ip = primary_network_ip_address(server.addresses, server.addresses.keys[0])
99
99
  Chef::Log.debug("Floating IP Address requested #{floating_address}")
100
100
  unless floating_address == "-1" # no floating IP requested
@@ -140,7 +140,7 @@ class Chef
140
140
  super
141
141
 
142
142
  # Use SSH password either specified from command line or from openstack server instance
143
- config[:ssh_password] = locate_config_value(:ssh_password) || server.password unless config[:openstack_ssh_key_id]
143
+ config[:ssh_password] = config[:ssh_password] || server.password unless config[:openstack_ssh_key_id]
144
144
 
145
145
  # The bootstrap network is always initialised to 'public' when a network name isn't specified. Therefore,
146
146
  # only set the bootstrap network to 'private' if still initialised to public and nothing was specified for
@@ -172,33 +172,33 @@ class Chef
172
172
 
173
173
  def validate_params!
174
174
  # set param vm_name to a random value if the name is not set by the user (plugin)
175
- config[:chef_node_name] = get_node_name(locate_config_value(:chef_node_name), locate_config_value(:chef_node_name_prefix))
175
+ config[:chef_node_name] = get_node_name(config[:chef_node_name], config[:chef_node_name_prefix])
176
176
 
177
177
  errors = []
178
178
 
179
- if locate_config_value(:connection_protocol) == "winrm"
180
- if locate_config_value(:connection_password).nil?
179
+ if config[:connection_protocol] == "winrm"
180
+ if config[:connection_password].nil?
181
181
  errors << "You must provide Connection Password."
182
182
  end
183
- elsif locate_config_value(:connection_protocol) != "ssh"
183
+ elsif config[:connection_protocol] != "ssh"
184
184
  errors << "You must provide a valid bootstrap protocol. options [ssh/winrm]. For linux type images, options [ssh]"
185
185
  end
186
186
 
187
- errors << "You must provide --image-os-type option [windows/linux]" unless %w{windows linux}.include?(locate_config_value(:image_os_type))
187
+ errors << "You must provide --image-os-type option [windows/linux]" unless %w{windows linux}.include?(config[:image_os_type])
188
188
  error_message = ""
189
189
  raise CloudExceptions::ValidationError, error_message if errors.each { |e| ui.error(e); error_message = "#{error_message} #{e}." }.any?
190
190
  end
191
191
 
192
192
  def is_image_valid?
193
- service.get_image(locate_config_value(:image)).nil? ? false : true
193
+ service.get_image(config[:image]).nil? ? false : true
194
194
  end
195
195
 
196
196
  def is_flavor_valid?
197
- service.get_flavor(locate_config_value(:flavor)).nil? ? false : true
197
+ service.get_flavor(config[:flavor]).nil? ? false : true
198
198
  end
199
199
 
200
200
  def is_floating_ip_valid?
201
- address = locate_config_value(:openstack_floating_ip)
201
+ address = config[:openstack_floating_ip]
202
202
 
203
203
  return true if address == "-1" # no floating IP requested
204
204
 
@@ -1,7 +1,7 @@
1
1
  #
2
2
  module Knife
3
3
  module OpenStack
4
- VERSION = "3.0.1".freeze
4
+ VERSION = "4.0.0".freeze
5
5
  MAJOR, MINOR, TINY = VERSION.split(".")
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-openstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JJ Asghar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-09 00:00:00.000000000 Z
11
+ date: 2020-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-openstack
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '15'
33
+ version: '15.11'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '15'
40
+ version: '15.11'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: knife-cloud
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '4.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '4.0'
55
55
  description: A Chef Infra knife plugin for OpenStack clouds.
56
56
  email:
57
57
  - jj@chef.io