knife-vcenter 2.0.0 → 2.0.1
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 +5 -5
- data/{LICENSE.txt → LICENSE} +0 -0
- data/lib/base.rb +8 -3
- data/lib/chef/knife/cloud/vcenter_service.rb +117 -81
- data/lib/chef/knife/cloud/vcenter_service_helpers.rb +15 -3
- data/lib/chef/knife/cloud/vcenter_service_options.rb +18 -17
- data/lib/chef/knife/vcenter_cluster_list.rb +19 -13
- data/lib/chef/knife/vcenter_datacenter_list.rb +19 -13
- data/lib/chef/knife/vcenter_host_list.rb +28 -19
- data/lib/chef/knife/vcenter_vm_clone.rb +39 -28
- data/lib/chef/knife/vcenter_vm_create.rb +26 -21
- data/lib/chef/knife/vcenter_vm_delete.rb +15 -10
- data/lib/chef/knife/vcenter_vm_list.rb +31 -21
- data/lib/chef/knife/vcenter_vm_show.rb +12 -13
- data/lib/knife-vcenter/version.rb +4 -2
- data/lib/lookup_service_helper.rb +421 -427
- data/lib/sso.rb +213 -218
- data/lib/support/clone_vm.rb +4 -4
- data/spec/spec_helper.rb +2 -2
- data/spec/unit/vcenter_vm_list_spec.rb +21 -22
- metadata +6 -58
- data/.github/ISSUE_TEMPLATE.md +0 -22
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -14
- data/.gitignore +0 -21
- data/.rubocop.yml +0 -18
- data/.travis.yml +0 -16
- data/CHANGELOG.md +0 -34
- data/Gemfile +0 -3
- data/README.md +0 -219
- data/Rakefile +0 -20
- data/knife-vcenter.gemspec +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bb5fd4c5ff94dae14a1fa45b1624ead2f0c89b04c130cd82fe59085b84e76b1c
|
4
|
+
data.tar.gz: 9c18082a34dfc47c62f67b8d7aa073a869ec4ee83c19fe0e141dab6e51552768
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff27319d80c4ca3c0fc374c43f9deabfc7516a213ac2b7f6adb7b04a268a185044eb99a4324a36511a36ba8cc2bffc48c54dbd356b014d8b80fb0c67966d6a86
|
7
|
+
data.tar.gz: a5f2845785c5bf531a6a8119f4cda2a512f77d37ad490192c07d3b1907f78487f287ac9f06dc1b0db85b570cd0d00c8dfcbaf6c6a765041bd6ec7d6fe094bc4b
|
data/{LICENSE.txt → LICENSE}
RENAMED
File without changes
|
data/lib/base.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
3
|
# Author:: Chef Partner Engineering (<partnereng@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2017 Chef Software, Inc.
|
4
|
+
# Copyright:: Copyright (c) 2017-2018 Chef Software, Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -17,18 +17,23 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require
|
20
|
+
require "logger"
|
21
21
|
|
22
|
+
# Base module for vcenter knife commands
|
22
23
|
module Base
|
23
24
|
attr_accessor :log
|
24
25
|
|
26
|
+
# Creates the @log variable
|
27
|
+
#
|
25
28
|
def self.log
|
26
29
|
@log ||= init_logger
|
27
30
|
end
|
28
31
|
|
32
|
+
# Set the logger level by default
|
33
|
+
#
|
29
34
|
def self.init_logger
|
30
35
|
log = Logger.new(STDOUT)
|
31
|
-
log.progname =
|
36
|
+
log.progname = "Knife VCenter"
|
32
37
|
log.level = Logger::INFO
|
33
38
|
log
|
34
39
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
3
|
# Author:: Chef Partner Engineering (<partnereng@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2017 Chef Software, Inc.
|
4
|
+
# Copyright:: Copyright (c) 2017-2018 Chef Software, Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -17,64 +17,67 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
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
|
34
|
-
require
|
35
|
-
require
|
36
|
-
require
|
20
|
+
require "chef/knife/cloud/exceptions"
|
21
|
+
require "chef/knife/cloud/service"
|
22
|
+
require "chef/knife/cloud/helpers"
|
23
|
+
require "chef/knife/cloud/vcenter_service_helpers"
|
24
|
+
require "net/http"
|
25
|
+
require "uri"
|
26
|
+
require "json"
|
27
|
+
require "ostruct"
|
28
|
+
require "lookup_service_helper"
|
29
|
+
require "vapi"
|
30
|
+
require "com/vmware/cis"
|
31
|
+
require "com/vmware/vcenter"
|
32
|
+
require "com/vmware/vcenter/vm"
|
33
|
+
require "sso"
|
34
|
+
require "base"
|
35
|
+
require "set"
|
36
|
+
require "support/clone_vm"
|
37
37
|
|
38
38
|
class Chef
|
39
|
+
# The main knife class
|
39
40
|
class Knife
|
41
|
+
# The main cloud class from knife-cloud
|
40
42
|
class Cloud
|
43
|
+
# Extends the Service method, this is the bulk of the integration
|
41
44
|
class VcenterService < Service
|
42
45
|
include VcenterServiceHelpers
|
43
46
|
|
44
47
|
attr_reader :vapi_config, :session_svc, :session_id
|
45
48
|
attr_reader :connection_options, :ipaddress
|
46
49
|
|
47
|
-
def initialize(options={})
|
50
|
+
def initialize(options = {})
|
48
51
|
super(options)
|
49
52
|
|
50
53
|
# Using the information supplied, configure the connection to vCentre
|
51
54
|
lookup_service_helper = LookupServiceHelper.new(options[:host])
|
52
55
|
|
53
|
-
vapi_urls = lookup_service_helper.find_vapi_urls
|
56
|
+
vapi_urls = lookup_service_helper.find_vapi_urls
|
54
57
|
vapi_url = vapi_urls.values[0]
|
55
|
-
Base.log.info(format(
|
58
|
+
Base.log.info(format("Vapi URL: %s", vapi_url)) if options[:vcenter_logs]
|
56
59
|
|
57
60
|
# Create the VAPI config object
|
58
61
|
ssl_options = {}
|
59
62
|
ssl_options[:verify] = if options[:verify_ssl]
|
60
63
|
:peer
|
61
64
|
else
|
62
|
-
Base.log.warn(
|
65
|
+
Base.log.warn("SSL Verification is turned OFF") if options[:vcenter_logs]
|
63
66
|
:none
|
64
67
|
end
|
65
68
|
@vapi_config = VAPI::Bindings::VapiConfig.new(vapi_url, ssl_options)
|
66
69
|
|
67
70
|
# get the SSO url
|
68
|
-
sso_url = lookup_service_helper.find_sso_url
|
71
|
+
sso_url = lookup_service_helper.find_sso_url
|
69
72
|
sso = SSO::Connection.new(sso_url).login(options[:username], options[:password])
|
70
|
-
token = sso.request_bearer_token
|
73
|
+
token = sso.request_bearer_token
|
71
74
|
vapi_config.set_security_context(
|
72
75
|
VAPI::Security.create_saml_bearer_security_context(token.to_s)
|
73
76
|
)
|
74
77
|
|
75
78
|
# Login and get the session information
|
76
79
|
@session_svc = Com::Vmware::Cis::Session.new(vapi_config)
|
77
|
-
@session_id = session_svc.create
|
80
|
+
@session_id = session_svc.create
|
78
81
|
vapi_config.set_security_context(
|
79
82
|
VAPI::Security.create_session_security_context(session_id)
|
80
83
|
)
|
@@ -88,8 +91,10 @@ class Chef
|
|
88
91
|
}
|
89
92
|
end
|
90
93
|
|
91
|
-
|
92
|
-
|
94
|
+
# Creates the server
|
95
|
+
#
|
96
|
+
# @param [Object] options to override anything you need to do
|
97
|
+
def create_server(options = {})
|
93
98
|
# Create the vm object
|
94
99
|
vmobj = Com::Vmware::Vcenter::VM.new(vapi_config)
|
95
100
|
|
@@ -99,21 +104,23 @@ class Chef
|
|
99
104
|
|
100
105
|
datacenter_exists?(options[:datacenter])
|
101
106
|
|
102
|
-
# Some of ht eoptions need to be the ID of the component in
|
107
|
+
# Some of ht eoptions need to be the ID of the component in VMware
|
103
108
|
# Update these using the REST API so that they can be passed to the support library
|
104
109
|
options[:targethost] = get_host(options[:targethost])
|
105
110
|
|
106
111
|
options[:resource_pool] = get_resource_pool(options[:resource_pool])
|
107
112
|
|
108
113
|
# Configure the folder option as a has with the name an the id
|
109
|
-
options[:folder]
|
110
|
-
|
111
|
-
|
112
|
-
|
114
|
+
unless options[:folder].nil?
|
115
|
+
options[:folder] = {
|
116
|
+
name: options[:folder],
|
117
|
+
id: get_folder(options[:folder]),
|
118
|
+
}
|
119
|
+
end
|
113
120
|
|
114
121
|
# Clone the machine using the support library
|
115
122
|
clone_obj = Support::CloneVm.new(connection_options, options)
|
116
|
-
@ipaddress = clone_obj.clone
|
123
|
+
@ipaddress = clone_obj.clone
|
117
124
|
|
118
125
|
# return an object from the restapi
|
119
126
|
return get_server(options[:name])
|
@@ -121,16 +128,16 @@ class Chef
|
|
121
128
|
when "create"
|
122
129
|
|
123
130
|
# Create the placement object
|
124
|
-
placementspec = Com::Vmware::Vcenter::VM::PlacementSpec.new
|
131
|
+
placementspec = Com::Vmware::Vcenter::VM::PlacementSpec.new
|
125
132
|
placementspec.folder = get_folder(options[:folder])
|
126
133
|
placementspec.host = get_host(options[:targethost])
|
127
134
|
placementspec.datastore = get_datastore(options[:datastore])
|
128
135
|
placementspec.resource_pool = get_resourcepool(options[:resource_pool])
|
129
136
|
|
130
137
|
# Create the CreateSpec object
|
131
|
-
createspec = Com::Vmware::Vcenter::VM::CreateSpec.new
|
138
|
+
createspec = Com::Vmware::Vcenter::VM::CreateSpec.new
|
132
139
|
|
133
|
-
createspec.name = options[:name]
|
140
|
+
createspec.name = options[:name]
|
134
141
|
puts "seting the OS"
|
135
142
|
createspec.guest_OS = Com::Vmware::Vcenter::Vm::GuestOS::UBUNTU_64
|
136
143
|
puts "setting the placement"
|
@@ -139,41 +146,53 @@ class Chef
|
|
139
146
|
# Create the new machine
|
140
147
|
begin
|
141
148
|
vm = vmobj.create(createspec)
|
142
|
-
rescue => e
|
149
|
+
rescue StandardError => e
|
143
150
|
puts e.message
|
144
151
|
end
|
145
152
|
end
|
146
153
|
end
|
147
154
|
|
155
|
+
# Get a list of vms from the API
|
156
|
+
#
|
148
157
|
def list_servers
|
149
|
-
|
150
|
-
Com::Vmware::Vcenter::VM.new(vapi_config).list()
|
158
|
+
Com::Vmware::Vcenter::VM.new(vapi_config).list
|
151
159
|
end
|
152
160
|
|
161
|
+
# Return a list of the hosts in the vCenter
|
162
|
+
#
|
153
163
|
def list_hosts
|
154
|
-
|
155
|
-
Com::Vmware::Vcenter::Host.new(vapi_config).list()
|
164
|
+
Com::Vmware::Vcenter::Host.new(vapi_config).list
|
156
165
|
end
|
157
166
|
|
167
|
+
# Return a list of the datacenters in the vCenter
|
168
|
+
#
|
158
169
|
def list_datacenters
|
159
|
-
Com::Vmware::Vcenter::Datacenter.new(vapi_config).list
|
170
|
+
Com::Vmware::Vcenter::Datacenter.new(vapi_config).list
|
160
171
|
end
|
161
172
|
|
173
|
+
# Return a list of the clusters in the vCenter
|
174
|
+
#
|
162
175
|
def list_clusters
|
163
|
-
Com::Vmware::Vcenter::Cluster.new(vapi_config).list
|
176
|
+
Com::Vmware::Vcenter::Cluster.new(vapi_config).list
|
164
177
|
end
|
165
178
|
|
179
|
+
# Checks to see if the datacenter exists in the vCenter
|
180
|
+
#
|
181
|
+
# @param [String] name is the name of the datacenter
|
166
182
|
def datacenter_exists?(name)
|
167
183
|
filter = Com::Vmware::Vcenter::Datacenter::FilterSpec.new(names: Set.new([name]))
|
168
184
|
dc_obj = Com::Vmware::Vcenter::Datacenter.new(vapi_config)
|
169
185
|
dc = dc_obj.list(filter)
|
170
|
-
|
171
|
-
raise format(
|
186
|
+
|
187
|
+
raise format("Unable to find data center: %s", name) if dc.empty?
|
172
188
|
end
|
173
189
|
|
190
|
+
# Gets the folder
|
191
|
+
#
|
192
|
+
# @param [String] name is the folder of the datacenter
|
174
193
|
def get_folder(name)
|
175
194
|
# Create a filter to ensure that only the named folder is returned
|
176
|
-
filter = Com::Vmware::Vcenter::Folder::FilterSpec.new(
|
195
|
+
filter = Com::Vmware::Vcenter::Folder::FilterSpec.new(names: Set.new([name]))
|
177
196
|
# filter.names = name
|
178
197
|
folder_obj = Com::Vmware::Vcenter::Folder.new(vapi_config)
|
179
198
|
folder = folder_obj.list(filter)
|
@@ -181,32 +200,41 @@ class Chef
|
|
181
200
|
folder[0].folder
|
182
201
|
end
|
183
202
|
|
203
|
+
# Gets the host
|
204
|
+
#
|
205
|
+
# @param [String] name is the host of the datacenter
|
184
206
|
def get_host(name)
|
185
207
|
host_obj = Com::Vmware::Vcenter::Host.new(vapi_config)
|
186
208
|
|
187
209
|
if name.nil?
|
188
210
|
host = host_obj.list
|
189
211
|
else
|
190
|
-
filter = Com::Vmware::Vcenter::Host::FilterSpec.new(
|
212
|
+
filter = Com::Vmware::Vcenter::Host::FilterSpec.new(names: Set.new([name]))
|
191
213
|
host = host_obj.list(filter)
|
192
214
|
end
|
193
215
|
|
194
216
|
host[0].host
|
195
217
|
end
|
196
218
|
|
219
|
+
# Gets the datastore
|
220
|
+
#
|
221
|
+
# @param [String] name is the datastore of the datacenter
|
197
222
|
def get_datastore(name)
|
198
223
|
datastore_obj = Com::Vmware::Vcenter::Datastore.new(vapi_config)
|
199
224
|
|
200
225
|
if name.nil?
|
201
226
|
datastore = datastore_obj.list
|
202
227
|
else
|
203
|
-
filter = Com::Vmware::Vcenter::Datastore::FilterSpec.new(
|
228
|
+
filter = Com::Vmware::Vcenter::Datastore::FilterSpec.new(names: Set.new([name]))
|
204
229
|
datastore = datastore_obj.list(filter)
|
205
230
|
end
|
206
231
|
|
207
232
|
datastore[0].datastore
|
208
233
|
end
|
209
234
|
|
235
|
+
# Gets the resource_pool
|
236
|
+
#
|
237
|
+
# @param [String] name is the resource_pool of the datacenter
|
210
238
|
def get_resource_pool(name)
|
211
239
|
# Create a resource pool object
|
212
240
|
rp_obj = Com::Vmware::Vcenter::ResourcePool.new(vapi_config)
|
@@ -219,71 +247,79 @@ class Chef
|
|
219
247
|
# create a filter to find the named resource pool
|
220
248
|
filter = Com::Vmware::Vcenter::ResourcePool::FilterSpec.new(names: Set.new([name]))
|
221
249
|
resource_pool = rp_obj.list(filter)
|
222
|
-
raise format(
|
250
|
+
raise format("Unable to find Resource Pool: %s", name) if resource_pool.nil?
|
223
251
|
end
|
224
252
|
|
225
253
|
resource_pool[0].resource_pool
|
226
254
|
end
|
227
255
|
|
256
|
+
# Gets the server
|
257
|
+
#
|
258
|
+
# @param [String] name is the server of the datacenter
|
228
259
|
def get_server(name)
|
229
|
-
filter = Com::Vmware::Vcenter::VM::FilterSpec.new(
|
260
|
+
filter = Com::Vmware::Vcenter::VM::FilterSpec.new(names: Set.new([name]))
|
230
261
|
vm_obj = Com::Vmware::Vcenter::VM.new(vapi_config)
|
231
262
|
vm_obj.list(filter)[0]
|
232
263
|
end
|
233
264
|
|
265
|
+
# Deletes the VM
|
266
|
+
#
|
267
|
+
# @param [String] name is the server to delete
|
234
268
|
def delete_vm(name)
|
235
269
|
vm = get_server(name)
|
236
270
|
server_summary(vm)
|
237
|
-
ui.msg(
|
271
|
+
ui.msg("")
|
238
272
|
|
239
|
-
ui.confirm(
|
273
|
+
ui.confirm("Do you really want to be delete this virtual machine")
|
240
274
|
|
241
275
|
vm_obj = Com::Vmware::Vcenter::VM.new(vapi_config)
|
242
276
|
|
243
277
|
# check the power state of the machine, if it is powered on turn it off
|
244
278
|
if vm.power_state.value == "POWERED_ON"
|
245
279
|
power = Com::Vmware::Vcenter::Vm::Power.new(vapi_config)
|
246
|
-
ui.msg(
|
280
|
+
ui.msg("Shutting down machine")
|
247
281
|
power.stop(vm.vm)
|
248
282
|
end
|
249
283
|
|
250
284
|
vm_obj.delete(vm.vm)
|
251
285
|
end
|
252
286
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
287
|
+
# Gets some server information
|
288
|
+
#
|
289
|
+
# @param [Object] server is the server object
|
290
|
+
def server_summary(server, _coloumns_with_inf = nil)
|
291
|
+
msg_pair("ID", server.vm)
|
292
|
+
msg_pair("Name", server.name)
|
293
|
+
msg_pair("Power State", server.power_state)
|
257
294
|
end
|
258
295
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
296
|
+
# def bootstrap_common_params(bootstrap)
|
297
|
+
# bootstrap.config[:run_list] = config[:run_list]
|
298
|
+
# bootstrap.config[:environment] = get_config(:environment)
|
299
|
+
# bootstrap.config[:first_boot_attributes] = get_config(:first_boot_attributes)
|
300
|
+
# bootstrap.config[:chef_node_name] = get_config(:chef_node_name)
|
301
|
+
# bootstrap.config[:node_ssl_verify_mode] = get_config(:node_ssl_verify_mode)
|
302
|
+
# bootstrap
|
303
|
+
# end
|
304
|
+
#
|
305
|
+
# def bootstrap_for_node
|
306
|
+
# Chef::Knife::Bootstrap.load_deps
|
307
|
+
# bootstrap = Chef::Knife::Bootstrap.new
|
308
|
+
# bootstrap.name_args = [config[:fqdn]]
|
309
|
+
# bootstrap.config[:ssh_user] = get_config(:ssh_user)
|
310
|
+
# bootstrap.config[:ssh_password] = get_config(:ssh_password)
|
311
|
+
# bootstrap.config[:ssh_port] = get_config(:ssh_port)
|
312
|
+
# bootstrap.config[:identity_file] = get_config(:identity_file)
|
313
|
+
# bootstrap.config[:use_sudo] = true unless get_config(:ssh_user) == 'root'
|
314
|
+
# bootstrap.config[:use_sudo_password] = true unless get_config(:ssh_user) == 'root'
|
315
|
+
# bootstrap.config[:log_level] = get_config(:log_level)
|
316
|
+
# bootstrap_common_params(bootstrap)
|
317
|
+
# end
|
268
318
|
|
269
|
-
def bootstrap_for_node
|
270
|
-
Chef::Knife::Bootstrap.load_deps
|
271
|
-
bootstrap = Chef::Knife::Bootstrap.new
|
272
|
-
bootstrap.name_args = [config[:fqdn]]
|
273
|
-
bootstrap.config[:ssh_user] = get_config(:ssh_user)
|
274
|
-
bootstrap.config[:ssh_password] = get_config(:ssh_password)
|
275
|
-
bootstrap.config[:ssh_port] = get_config(:ssh_port)
|
276
|
-
bootstrap.config[:identity_file] = get_config(:identity_file)
|
277
|
-
bootstrap.config[:use_sudo] = true unless get_config(:ssh_user) == 'root'
|
278
|
-
bootstrap.config[:use_sudo_password] = true unless get_config(:ssh_user) == 'root'
|
279
|
-
bootstrap.config[:log_level] = get_config(:log_level)
|
280
|
-
bootstrap_common_params(bootstrap)
|
281
|
-
end
|
282
|
-
=end
|
283
319
|
private
|
284
320
|
|
285
321
|
def cleanup
|
286
|
-
session_svc.delete
|
322
|
+
session_svc.delete unless session_id.nil?
|
287
323
|
end
|
288
324
|
end
|
289
325
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
3
|
# Author:: Chef Partner Engineering (<partnereng@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2017 Chef Software, Inc.
|
4
|
+
# Copyright:: Copyright (c) 2017-2018 Chef Software, Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -17,14 +17,19 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require
|
20
|
+
require "chef/knife/cloud/helpers"
|
21
21
|
|
22
22
|
class Chef
|
23
|
+
# The main knife class
|
23
24
|
class Knife
|
25
|
+
# The main cloud class from knife-cloud
|
24
26
|
class Cloud
|
27
|
+
# Module that creates the helpers for this gem
|
25
28
|
module VcenterServiceHelpers
|
26
29
|
include Chef::Knife::Cloud::Helpers
|
27
30
|
|
31
|
+
# Creates the object for vCenterService
|
32
|
+
#
|
28
33
|
def create_service_instance
|
29
34
|
Chef::Knife::Cloud::VcenterService.new(username: locate_config_value(:vcenter_username),
|
30
35
|
password: locate_config_value(:vcenter_password),
|
@@ -32,20 +37,27 @@ class Chef
|
|
32
37
|
verify_ssl: verify_ssl?)
|
33
38
|
end
|
34
39
|
|
40
|
+
# Do we have valid SSL?
|
41
|
+
#
|
35
42
|
def verify_ssl?
|
36
43
|
!locate_config_value(:vcenter_disable_ssl_verify)
|
37
44
|
end
|
38
45
|
|
46
|
+
# Validate the options and fail out if something isn't there
|
47
|
+
#
|
39
48
|
def validate!
|
40
49
|
check_for_missing_config_values!(:vcenter_username, :vcenter_password, :vcenter_host)
|
41
50
|
end
|
42
51
|
|
43
52
|
# rubocop:disable Style/GuardClause
|
53
|
+
# Checks for any missing values
|
54
|
+
#
|
55
|
+
# @param [Object] keys makes sure that the values are all not nil
|
44
56
|
def check_for_missing_config_values!(*keys)
|
45
57
|
missing = keys.select { |x| locate_config_value(x).nil? }
|
46
58
|
|
47
59
|
unless missing.empty?
|
48
|
-
ui.error(format("The following required parameters are missing: %s", missing.join(
|
60
|
+
ui.error(format("The following required parameters are missing: %s", missing.join(", ")))
|
49
61
|
exit(1)
|
50
62
|
end
|
51
63
|
end
|