knife-openstack 3.0.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/knife/cloud/openstack_server_create_options.rb +10 -12
- data/lib/chef/knife/cloud/openstack_service.rb +15 -14
- data/lib/chef/knife/cloud/openstack_service_options.rb +7 -13
- data/lib/chef/knife/openstack_floating_ip_allocate.rb +3 -4
- data/lib/chef/knife/openstack_floating_ip_associate.rb +3 -4
- data/lib/chef/knife/openstack_floating_ip_disassociate.rb +3 -4
- data/lib/chef/knife/openstack_helpers.rb +2 -2
- data/lib/chef/knife/openstack_server_create.rb +23 -23
- data/lib/knife-openstack/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fea575415f8293a82e3549df15fe0904421689eb1501ecde02f6c763e5d11567
|
4
|
+
data.tar.gz: df4336564c9df6eb7dc4360169dd6d843614222e1092085ed54183abea88513e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f69a9955f12b7ebfee46e574b9929ac71a248b151c2a64ada9b50b3d59b124118e188b6ce7cd828505e254d10d14ea6c3cc089ea7d02d163c59abd1f7e0d9912
|
7
|
+
data.tar.gz: 8731570f7c7cc4e7a15a53c8f9ff1e733c3e79db7957fbd53b6e7345751b9268cce77ee98e6bb6b4e9130b5c30a89aac0661bbb01b64117d396b65ee770c7190
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright
|
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|
|
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
|
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(
|
29
|
-
|
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
|
-
|
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:
|
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: !
|
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] =
|
79
|
+
params[k] = config[k]
|
79
80
|
end
|
80
|
-
params[: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
|
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
|
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(
|
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
|
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(
|
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 #{
|
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
|
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(
|
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 #{
|
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
|
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
|
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(
|
47
|
-
:flavor_ref => service.get_flavor(
|
48
|
-
:security_groups =>
|
49
|
-
:availability_zone =>
|
50
|
-
"os:scheduler_hints" =>
|
51
|
-
:metadata =>
|
52
|
-
:key_name =>
|
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:
|
54
|
+
server_create_timeout: config[:server_create_timeout],
|
55
55
|
}
|
56
|
-
unless
|
56
|
+
unless config[:openstack_volumes].nil?
|
57
57
|
counter = 99
|
58
|
-
@create_options[:server_def][:block_device_mapping] =
|
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] =
|
70
|
-
@create_options[:server_def][:nics] =
|
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 =
|
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] =
|
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(
|
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
|
180
|
-
if
|
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
|
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?(
|
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(
|
193
|
+
service.get_image(config[:image]).nil? ? false : true
|
194
194
|
end
|
195
195
|
|
196
196
|
def is_flavor_valid?
|
197
|
-
service.get_flavor(
|
197
|
+
service.get_flavor(config[:flavor]).nil? ? false : true
|
198
198
|
end
|
199
199
|
|
200
200
|
def is_floating_ip_valid?
|
201
|
-
address =
|
201
|
+
address = config[:openstack_floating_ip]
|
202
202
|
|
203
203
|
return true if address == "-1" # no floating IP requested
|
204
204
|
|
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:
|
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-
|
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: '
|
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: '
|
54
|
+
version: '4.0'
|
55
55
|
description: A Chef Infra knife plugin for OpenStack clouds.
|
56
56
|
email:
|
57
57
|
- jj@chef.io
|