puppet-resource_api 1.8.18 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +80 -47
- data/lib/puppet/resource_api/base_context.rb +11 -7
- data/lib/puppet/resource_api/data_type_handling.rb +15 -19
- data/lib/puppet/resource_api/glue.rb +4 -7
- data/lib/puppet/resource_api/parameter.rb +2 -2
- data/lib/puppet/resource_api/property.rb +9 -14
- data/lib/puppet/resource_api/provider_get_cache.rb +41 -0
- data/lib/puppet/resource_api/puppet_context.rb +1 -0
- data/lib/puppet/resource_api/simple_provider.rb +19 -19
- data/lib/puppet/resource_api/transport/wrapper.rb +5 -3
- data/lib/puppet/resource_api/transport.rb +24 -31
- data/lib/puppet/resource_api/type_definition.rb +39 -46
- data/lib/puppet/resource_api/value_creator.rb +4 -6
- data/lib/puppet/resource_api/version.rb +1 -1
- data/lib/puppet/resource_api.rb +135 -89
- data/lib/puppet/util/network_device/simple/device.rb +2 -0
- metadata +8 -7
data/lib/puppet/resource_api.rb
CHANGED
@@ -5,6 +5,7 @@ require 'puppet/resource_api/data_type_handling'
|
|
5
5
|
require 'puppet/resource_api/glue'
|
6
6
|
require 'puppet/resource_api/parameter'
|
7
7
|
require 'puppet/resource_api/property'
|
8
|
+
require 'puppet/resource_api/provider_get_cache'
|
8
9
|
require 'puppet/resource_api/puppet_context' unless RUBY_PLATFORM == 'java'
|
9
10
|
require 'puppet/resource_api/read_only_parameter'
|
10
11
|
require 'puppet/resource_api/transport'
|
@@ -32,9 +33,7 @@ module Puppet::ResourceApi
|
|
32
33
|
# this has to happen before Puppet::Type.newtype starts autoloading providers
|
33
34
|
# it also needs to be guarded against the namespace already being defined by something
|
34
35
|
# else to avoid ruby warnings
|
35
|
-
unless Puppet::Provider.const_defined?(class_name_from_type_name(definition[:name]), false)
|
36
|
-
Puppet::Provider.const_set(class_name_from_type_name(definition[:name]), Module.new)
|
37
|
-
end
|
36
|
+
Puppet::Provider.const_set(class_name_from_type_name(definition[:name]), Module.new) unless Puppet::Provider.const_defined?(class_name_from_type_name(definition[:name]), false)
|
38
37
|
|
39
38
|
Puppet::Type.newtype(definition[:name].to_sym) do
|
40
39
|
# The :desc value is already cleaned up by the TypeDefinition validation
|
@@ -65,8 +64,15 @@ module Puppet::ResourceApi
|
|
65
64
|
self.class.type_definition
|
66
65
|
end
|
67
66
|
|
68
|
-
if type_definition.feature?('remote_resource')
|
69
|
-
|
67
|
+
apply_to_device if type_definition.feature?('remote_resource')
|
68
|
+
|
69
|
+
define_singleton_method(:rsapi_provider_get_cache) do
|
70
|
+
# This gives a new cache per resource provider on each Puppet run:
|
71
|
+
@rsapi_provider_get_cache ||= Puppet::ResourceApi::ProviderGetCache.new
|
72
|
+
end
|
73
|
+
|
74
|
+
def rsapi_provider_get_cache
|
75
|
+
self.class.rsapi_provider_get_cache
|
70
76
|
end
|
71
77
|
|
72
78
|
def initialize(attributes)
|
@@ -84,27 +90,21 @@ module Puppet::ResourceApi
|
|
84
90
|
# undo puppet's unwrapping of Sensitive values to provide a uniform experience for providers
|
85
91
|
# See https://tickets.puppetlabs.com/browse/PDK-1091 for investigation and background
|
86
92
|
sensitives.each do |name|
|
87
|
-
if attributes.key?(name) && !attributes[name].is_a?(Puppet::Pops::Types::PSensitiveType::Sensitive)
|
88
|
-
attributes[name] = Puppet::Pops::Types::PSensitiveType::Sensitive.new(attributes[name])
|
89
|
-
end
|
93
|
+
attributes[name] = Puppet::Pops::Types::PSensitiveType::Sensitive.new(attributes[name]) if attributes.key?(name) && !attributes[name].is_a?(Puppet::Pops::Types::PSensitiveType::Sensitive)
|
90
94
|
end
|
91
95
|
|
92
96
|
# $stderr.puts "B: #{attributes.inspect}"
|
93
|
-
if type_definition.feature?('canonicalize')
|
94
|
-
attributes = my_provider.canonicalize(context, [attributes])[0]
|
95
|
-
end
|
97
|
+
attributes = my_provider.canonicalize(context, [attributes])[0] if type_definition.feature?('canonicalize')
|
96
98
|
|
97
99
|
# the `Puppet::Resource::Ral.find` method, when `instances` does not return a match, uses a Hash with a `:name` key to create
|
98
100
|
# an "absent" resource. This is often hit by `puppet resource`. This needs to work, even if the namevar is not called `name`.
|
99
101
|
# This bit here relies on the default `title_patterns` (see below) to match the title back to the first (and often only) namevar
|
100
102
|
if type_definition.attributes[:name].nil? && attributes[:title].nil?
|
101
103
|
attributes[:title] = attributes.delete(:name)
|
102
|
-
if attributes[:title].nil? && !type_definition.namevars.empty?
|
103
|
-
attributes[:title] = @title
|
104
|
-
end
|
104
|
+
attributes[:title] = @title if attributes[:title].nil? && !type_definition.namevars.empty?
|
105
105
|
end
|
106
106
|
|
107
|
-
super
|
107
|
+
super
|
108
108
|
end
|
109
109
|
|
110
110
|
def name
|
@@ -129,16 +129,44 @@ module Puppet::ResourceApi
|
|
129
129
|
@rsapi_canonicalized_target_state ||= begin
|
130
130
|
# skip puppet's injected metaparams
|
131
131
|
actual_params = @parameters.select { |k, _v| type_definition.attributes.key? k }
|
132
|
-
target_state =
|
132
|
+
target_state = actual_params.transform_values(&:rs_value)
|
133
133
|
target_state = my_provider.canonicalize(context, [target_state]).first if type_definition.feature?('canonicalize')
|
134
134
|
target_state
|
135
135
|
end
|
136
136
|
@rsapi_canonicalized_target_state
|
137
137
|
end
|
138
138
|
|
139
|
+
# Method is used to custom generate resources which are then applied by Puppet
|
140
|
+
def generate
|
141
|
+
# If feature `custom_generate` has been set then call the generate function within the provider and return the given results
|
142
|
+
return unless type_definition&.feature?('custom_generate')
|
143
|
+
|
144
|
+
should_hash = rsapi_canonicalized_target_state
|
145
|
+
is_hash = rsapi_current_state
|
146
|
+
title = rsapi_title
|
147
|
+
|
148
|
+
# Ensure that a custom `generate` method has been created within the provider
|
149
|
+
raise(Puppet::DevError, 'No generate method found within the types provider') unless my_provider.respond_to?(:generate)
|
150
|
+
|
151
|
+
# Call the providers custom `generate` method
|
152
|
+
my_provider.generate(context, title, is_hash, should_hash)
|
153
|
+
|
154
|
+
# Return array of resources
|
155
|
+
end
|
156
|
+
|
139
157
|
def rsapi_current_state
|
140
|
-
|
141
|
-
|
158
|
+
return @rsapi_current_state if @rsapi_current_state
|
159
|
+
|
160
|
+
# If the current state is not set, then check the cache and, if a value is
|
161
|
+
# found, ensure it passes strict_check before allowing it to be used:
|
162
|
+
cached_value = rsapi_provider_get_cache.get(rsapi_title)
|
163
|
+
strict_check(cached_value) if cached_value
|
164
|
+
@rsapi_current_state = cached_value
|
165
|
+
end
|
166
|
+
|
167
|
+
def rsapi_current_state=(value)
|
168
|
+
rsapi_provider_get_cache.add(rsapi_title, value)
|
169
|
+
@rsapi_current_state = value
|
142
170
|
end
|
143
171
|
|
144
172
|
def to_resource
|
@@ -162,11 +190,11 @@ module Puppet::ResourceApi
|
|
162
190
|
definition[:attributes].each do |name, options|
|
163
191
|
type = Puppet::ResourceApi::DataTypeHandling.parse_puppet_type(
|
164
192
|
:name,
|
165
|
-
options[:type]
|
193
|
+
options[:type]
|
166
194
|
)
|
167
195
|
|
168
196
|
# skip read only vars and the namevar
|
169
|
-
next if [
|
197
|
+
next if %i[read_only namevar].include? options[:behaviour]
|
170
198
|
|
171
199
|
# skip properties if the resource is being deleted
|
172
200
|
next if definition[:attributes][:ensure] &&
|
@@ -193,7 +221,7 @@ module Puppet::ResourceApi
|
|
193
221
|
custom_insync_trigger_options = {
|
194
222
|
type: 'Enum[do_not_specify_in_manifest]',
|
195
223
|
desc: 'A hidden property which enables a type with custom insync to perform an insync check without specifying any insyncable properties',
|
196
|
-
default: 'do_not_specify_in_manifest'
|
224
|
+
default: 'do_not_specify_in_manifest'
|
197
225
|
}
|
198
226
|
|
199
227
|
type_definition.create_attribute_in(self, :rsapi_custom_insync_trigger, :newproperty, Puppet::ResourceApi::Property, custom_insync_trigger_options)
|
@@ -202,16 +230,12 @@ module Puppet::ResourceApi
|
|
202
230
|
definition[:attributes].each do |name, options|
|
203
231
|
# puts "#{name}: #{options.inspect}"
|
204
232
|
|
205
|
-
if options[:behaviour]
|
206
|
-
unless [:read_only, :namevar, :parameter, :init_only].include? options[:behaviour]
|
207
|
-
raise Puppet::ResourceError, "`#{options[:behaviour]}` is not a valid behaviour value"
|
208
|
-
end
|
209
|
-
end
|
233
|
+
raise Puppet::ResourceError, "`#{options[:behaviour]}` is not a valid behaviour value" if options[:behaviour] && !(%i[read_only namevar parameter init_only].include? options[:behaviour])
|
210
234
|
|
211
235
|
# TODO: using newparam everywhere would suppress change reporting
|
212
236
|
# that would allow more fine-grained reporting through context,
|
213
237
|
# but require more invest in hooking up the infrastructure to emulate existing data
|
214
|
-
if [
|
238
|
+
if %i[parameter namevar].include? options[:behaviour]
|
215
239
|
param_or_property = :newparam
|
216
240
|
parent = Puppet::ResourceApi::Parameter
|
217
241
|
elsif options[:behaviour] == :read_only
|
@@ -225,57 +249,77 @@ module Puppet::ResourceApi
|
|
225
249
|
type_definition.create_attribute_in(self, name, param_or_property, parent, options)
|
226
250
|
end
|
227
251
|
|
252
|
+
def self.rsapi_provider_get(names = nil)
|
253
|
+
# If the cache has been marked as having all instances, then just return the
|
254
|
+
# full contents:
|
255
|
+
return rsapi_provider_get_cache.all if rsapi_provider_get_cache.cached_all? && names.nil?
|
256
|
+
|
257
|
+
fetched = if type_definition.feature?('simple_get_filter')
|
258
|
+
my_provider.get(context, names)
|
259
|
+
else
|
260
|
+
my_provider.get(context)
|
261
|
+
end
|
262
|
+
|
263
|
+
fetched.each do |resource_hash|
|
264
|
+
type_definition.check_schema(resource_hash)
|
265
|
+
rsapi_provider_get_cache.add(build_title(type_definition, resource_hash), resource_hash)
|
266
|
+
end
|
267
|
+
|
268
|
+
if names.nil? && !type_definition.feature?('simple_get_filter')
|
269
|
+
# Mark the cache as having all possible instances:
|
270
|
+
rsapi_provider_get_cache.cached_all
|
271
|
+
end
|
272
|
+
|
273
|
+
fetched
|
274
|
+
end
|
275
|
+
|
228
276
|
def self.instances
|
229
277
|
# puts 'instances'
|
230
278
|
# force autoloading of the provider
|
231
279
|
provider(type_definition.name)
|
232
280
|
|
233
|
-
|
234
|
-
my_provider.get(context, [])
|
235
|
-
else
|
236
|
-
my_provider.get(context)
|
237
|
-
end
|
238
|
-
|
239
|
-
initial_fetch.map do |resource_hash|
|
240
|
-
type_definition.check_schema(resource_hash)
|
281
|
+
rsapi_provider_get.map do |resource_hash|
|
241
282
|
# allow a :title from the provider to override the default
|
242
283
|
result = if resource_hash.key? :title
|
243
284
|
new(title: resource_hash[:title])
|
244
285
|
else
|
245
286
|
new(title: build_title(type_definition, resource_hash))
|
246
287
|
end
|
288
|
+
# Cache the state in the generated resource, but unfortunately
|
289
|
+
# this only benefits "puppet resource", not apply runs:
|
247
290
|
result.cache_current_state(resource_hash)
|
248
291
|
result
|
249
292
|
end
|
250
293
|
end
|
251
294
|
|
252
295
|
def refresh_current_state
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
end
|
258
|
-
|
259
|
-
if @rsapi_current_state
|
260
|
-
type_definition.check_schema(@rsapi_current_state)
|
261
|
-
strict_check(@rsapi_current_state)
|
296
|
+
current_state = self.class.rsapi_provider_get([rsapi_title]).find { |h| namevar_match?(h) }
|
297
|
+
|
298
|
+
if current_state
|
299
|
+
strict_check(current_state)
|
262
300
|
else
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
301
|
+
current_state = if rsapi_title.is_a? Hash
|
302
|
+
rsapi_title.dup
|
303
|
+
else
|
304
|
+
{ title: rsapi_title }
|
305
|
+
end
|
306
|
+
current_state[:ensure] = :absent if type_definition.ensurable?
|
269
307
|
end
|
308
|
+
self.rsapi_current_state = current_state
|
270
309
|
end
|
271
310
|
|
272
|
-
# Use this to set the current state from the `instances` method
|
311
|
+
# Use this to set the current state from the `instances` method. "puppet resources"
|
312
|
+
# needs this to minimize provider get() calls, but during a Puppet apply run
|
313
|
+
# the instances() method is only used by resource generation, and resource
|
314
|
+
# generators use and then discard the resources created by `instances``, so this
|
315
|
+
# does not help with that:
|
273
316
|
def cache_current_state(resource_hash)
|
274
|
-
|
275
|
-
strict_check(
|
317
|
+
self.rsapi_current_state = resource_hash
|
318
|
+
strict_check(resource_hash)
|
276
319
|
end
|
277
320
|
|
278
321
|
def retrieve
|
322
|
+
refresh_current_state unless rsapi_current_state
|
279
323
|
Puppet.debug("Current State: #{rsapi_current_state.inspect}")
|
280
324
|
|
281
325
|
result = Puppet::Resource.new(self.class, title, parameters: rsapi_current_state)
|
@@ -299,17 +343,18 @@ module Puppet::ResourceApi
|
|
299
343
|
# puts 'flush'
|
300
344
|
target_state = rsapi_canonicalized_target_state
|
301
345
|
|
302
|
-
retrieve unless
|
346
|
+
retrieve unless rsapi_current_state
|
303
347
|
|
304
|
-
return if
|
348
|
+
return if rsapi_current_state == target_state
|
305
349
|
|
306
350
|
Puppet.debug("Target State: #{target_state.inspect}")
|
307
351
|
|
308
352
|
# enforce init_only attributes
|
309
|
-
if Puppet.settings[:strict] != :off &&
|
353
|
+
if Puppet.settings[:strict] != :off && rsapi_current_state && (rsapi_current_state[:ensure] == 'present' && target_state[:ensure] == 'present')
|
310
354
|
target_state.each do |name, value|
|
311
|
-
next unless type_definition.attributes[name][:behaviour] == :init_only && value !=
|
312
|
-
|
355
|
+
next unless type_definition.attributes[name][:behaviour] == :init_only && value != rsapi_current_state[name]
|
356
|
+
|
357
|
+
message = "Attempting to change `#{name}` init_only attribute value from `#{rsapi_current_state[name]}` to `#{value}`"
|
313
358
|
case Puppet.settings[:strict]
|
314
359
|
when :warning
|
315
360
|
Puppet.warning(message)
|
@@ -320,9 +365,9 @@ module Puppet::ResourceApi
|
|
320
365
|
end
|
321
366
|
|
322
367
|
if type_definition.feature?('supports_noop')
|
323
|
-
my_provider.set(context, { rsapi_title => { is:
|
368
|
+
my_provider.set(context, { rsapi_title => { is: rsapi_current_state, should: target_state } }, noop: noop?)
|
324
369
|
else
|
325
|
-
my_provider.set(context, rsapi_title => { is:
|
370
|
+
my_provider.set(context, rsapi_title => { is: rsapi_current_state, should: target_state }) unless noop?
|
326
371
|
end
|
327
372
|
if context.failed?
|
328
373
|
context.reset_failed
|
@@ -330,16 +375,16 @@ module Puppet::ResourceApi
|
|
330
375
|
end
|
331
376
|
|
332
377
|
# remember that we have successfully reached our desired state
|
333
|
-
|
378
|
+
self.rsapi_current_state = target_state
|
334
379
|
end
|
335
380
|
|
336
381
|
def raise_missing_attrs
|
337
|
-
error_msg = "The following mandatory attributes were not provided:\n *
|
382
|
+
error_msg = "The following mandatory attributes were not provided:\n * #{@missing_attrs.join(", \n * ")}"
|
338
383
|
raise Puppet::ResourceError, error_msg if @missing_attrs.any? && (value(:ensure) != :absent && !value(:ensure).nil?)
|
339
384
|
end
|
340
385
|
|
341
386
|
def raise_missing_params
|
342
|
-
error_msg = "The following mandatory parameters were not provided:\n *
|
387
|
+
error_msg = "The following mandatory parameters were not provided:\n * #{@missing_params.join(", \n * ")}"
|
343
388
|
raise Puppet::ResourceError, error_msg
|
344
389
|
end
|
345
390
|
|
@@ -370,14 +415,14 @@ module Puppet::ResourceApi
|
|
370
415
|
# compare the clone against the current state to see if changes have been made by canonicalize
|
371
416
|
return unless state_clone && (current_state != state_clone)
|
372
417
|
|
373
|
-
|
418
|
+
# :nocov:
|
374
419
|
# codecov fails to register this multiline as covered, even though simplecov does.
|
375
|
-
message =
|
376
|
-
#{type_definition.name}[#{@title}]#get has not provided canonicalized values.
|
377
|
-
Returned values: #{current_state.inspect}
|
378
|
-
Canonicalized values: #{state_clone.inspect}
|
379
|
-
MESSAGE
|
380
|
-
|
420
|
+
message = <<~MESSAGE.strip
|
421
|
+
#{type_definition.name}[#{@title}]#get has not provided canonicalized values.
|
422
|
+
Returned values: #{current_state.inspect}
|
423
|
+
Canonicalized values: #{state_clone.inspect}
|
424
|
+
MESSAGE
|
425
|
+
# :nocov:
|
381
426
|
strict_message(message)
|
382
427
|
end
|
383
428
|
|
@@ -392,6 +437,7 @@ MESSAGE
|
|
392
437
|
self.class.title_patterns.each do |regexp, symbols|
|
393
438
|
captures = regexp.match(current_state[:title])
|
394
439
|
next if captures.nil?
|
440
|
+
|
395
441
|
symbols.zip(captures[1..-1]).each do |symbol_and_lambda, capture|
|
396
442
|
# The Resource API does not support passing procs in title_patterns
|
397
443
|
# so, unlike Puppet::Resource, we do not need to handle that here.
|
@@ -405,15 +451,15 @@ MESSAGE
|
|
405
451
|
|
406
452
|
namevars = type_definition.namevars.reject { |namevar| title_hash[namevar] == rsapi_title[namevar] }
|
407
453
|
|
408
|
-
|
454
|
+
# :nocov:
|
409
455
|
# codecov fails to register this multiline as covered, even though simplecov does.
|
410
|
-
message =
|
411
|
-
#{type_definition.name}[#{@title}]#get has provided a title attribute which does not match all namevars.
|
412
|
-
Namevars which do not match: #{namevars.inspect}
|
413
|
-
Returned parsed title hash: #{title_hash.inspect}
|
414
|
-
Expected hash: #{rsapi_title.inspect}
|
415
|
-
MESSAGE
|
416
|
-
|
456
|
+
message = <<~MESSAGE.strip
|
457
|
+
#{type_definition.name}[#{@title}]#get has provided a title attribute which does not match all namevars.
|
458
|
+
Namevars which do not match: #{namevars.inspect}
|
459
|
+
Returned parsed title hash: #{title_hash.inspect}
|
460
|
+
Expected hash: #{rsapi_title.inspect}
|
461
|
+
MESSAGE
|
462
|
+
# :nocov:
|
417
463
|
strict_message(message)
|
418
464
|
end
|
419
465
|
|
@@ -429,7 +475,7 @@ MESSAGE
|
|
429
475
|
@title_patterns ||= if type_definition.definition.key? :title_patterns
|
430
476
|
parse_title_patterns(type_definition.definition[:title_patterns])
|
431
477
|
else
|
432
|
-
[[
|
478
|
+
[[/(.*)/m, [[type_definition.namevars.first]]]]
|
433
479
|
end
|
434
480
|
end
|
435
481
|
|
@@ -450,14 +496,14 @@ MESSAGE
|
|
450
496
|
end
|
451
497
|
end
|
452
498
|
|
453
|
-
[
|
499
|
+
%i[autorequire autobefore autosubscribe autonotify].each do |auto|
|
454
500
|
next unless definition[auto]
|
455
501
|
|
456
502
|
definition[auto].each do |type, values|
|
457
503
|
Puppet.debug("Registering #{auto} for #{type}: #{values.inspect}")
|
458
504
|
send(auto, type.downcase.to_sym) do
|
459
505
|
resolved = [values].flatten.map do |v|
|
460
|
-
match =
|
506
|
+
match = /\A\$(.*)\Z/.match(v) if v.is_a? String
|
461
507
|
if match.nil?
|
462
508
|
v
|
463
509
|
else
|
@@ -466,13 +512,13 @@ MESSAGE
|
|
466
512
|
end
|
467
513
|
# Flatten to handle any resolved array properties and filter any nil
|
468
514
|
# values resulting from unspecified optional parameters:
|
469
|
-
resolved.flatten.reject
|
515
|
+
resolved.flatten.reject(&:nil?)
|
470
516
|
end
|
471
517
|
end
|
472
518
|
end
|
473
519
|
end
|
474
520
|
end
|
475
|
-
module_function :register_type
|
521
|
+
module_function :register_type
|
476
522
|
|
477
523
|
def load_provider(type_name)
|
478
524
|
class_name = class_name_from_type_name(type_name)
|
@@ -495,20 +541,20 @@ MESSAGE
|
|
495
541
|
end
|
496
542
|
rescue NameError
|
497
543
|
if device_name # line too long # rubocop:disable Style/GuardClause
|
498
|
-
raise Puppet::DevError, "Found neither the device-specific provider class Puppet::Provider::#{class_name}::#{device_class_name} in puppet/provider/#{type_name}/#{device_name}"\
|
499
|
-
|
544
|
+
raise Puppet::DevError, "Found neither the device-specific provider class Puppet::Provider::#{class_name}::#{device_class_name} in puppet/provider/#{type_name}/#{device_name} " \
|
545
|
+
"nor the generic provider class Puppet::Provider::#{class_name}::#{class_name} in puppet/provider/#{type_name}/#{type_name}"
|
500
546
|
else
|
501
547
|
raise Puppet::DevError, "provider class Puppet::Provider::#{class_name}::#{class_name} not found in puppet/provider/#{type_name}/#{type_name}"
|
502
548
|
end
|
503
549
|
end
|
504
|
-
module_function :load_provider
|
550
|
+
module_function :load_provider
|
505
551
|
|
506
552
|
def load_default_provider(class_name, type_name_sym)
|
507
553
|
# loads the "puppet/provider/#{type_name}/#{type_name}" file through puppet
|
508
554
|
Puppet::Type.type(type_name_sym).provider(type_name_sym)
|
509
555
|
Puppet::Provider.const_get(class_name, false).const_get(class_name, false)
|
510
556
|
end
|
511
|
-
module_function :load_default_provider
|
557
|
+
module_function :load_default_provider
|
512
558
|
|
513
559
|
def load_device_provider(class_name, type_name_sym, device_class_name, device_name_sym)
|
514
560
|
# loads the "puppet/provider/#{type_name}/#{device_name}" file through puppet
|
@@ -520,13 +566,13 @@ MESSAGE
|
|
520
566
|
load_default_provider(class_name, type_name_sym)
|
521
567
|
end
|
522
568
|
end
|
523
|
-
module_function :load_device_provider
|
569
|
+
module_function :load_device_provider
|
524
570
|
|
525
571
|
# keeps the existing register API format. e.g. Puppet::ResourceApi.register_type
|
526
572
|
def register_transport(schema)
|
527
573
|
Puppet::ResourceApi::Transport.register(schema)
|
528
574
|
end
|
529
|
-
module_function :register_transport
|
575
|
+
module_function :register_transport
|
530
576
|
|
531
577
|
def self.class_name_from_type_name(type_name)
|
532
578
|
type_name.to_s.split('_').map(&:capitalize).join
|
@@ -7,6 +7,7 @@ require 'hocon/config_syntax'
|
|
7
7
|
module Puppet::Util; end
|
8
8
|
# avoid loading puppet code base
|
9
9
|
class Puppet::Util::NetworkDevice; end
|
10
|
+
|
10
11
|
module Puppet::Util::NetworkDevice::Simple
|
11
12
|
# A basic device class, that reads its configuration from the provided URL.
|
12
13
|
# The URL has to be a local file URL.
|
@@ -26,6 +27,7 @@ module Puppet::Util::NetworkDevice::Simple
|
|
26
27
|
|
27
28
|
def config
|
28
29
|
raise "Trying to load config from '#{@url.path}, but file does not exist." if @url && !File.exist?(@url.path)
|
30
|
+
|
29
31
|
@config ||= Hocon.load(@url.path, syntax: Hocon::ConfigSyntax::HOCON)
|
30
32
|
end
|
31
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-resource_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Schmitt
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hocon
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
|
-
description:
|
27
|
+
description:
|
28
28
|
email:
|
29
29
|
- david.schmitt@puppet.com
|
30
30
|
executables: []
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- lib/puppet/resource_api/io_context.rb
|
55
55
|
- lib/puppet/resource_api/parameter.rb
|
56
56
|
- lib/puppet/resource_api/property.rb
|
57
|
+
- lib/puppet/resource_api/provider_get_cache.rb
|
57
58
|
- lib/puppet/resource_api/puppet_context.rb
|
58
59
|
- lib/puppet/resource_api/read_only_parameter.rb
|
59
60
|
- lib/puppet/resource_api/simple_provider.rb
|
@@ -68,7 +69,7 @@ homepage: https://github.com/puppetlabs/puppet-resource_api
|
|
68
69
|
licenses:
|
69
70
|
- Apache-2.0
|
70
71
|
metadata: {}
|
71
|
-
post_install_message:
|
72
|
+
post_install_message:
|
72
73
|
rdoc_options: []
|
73
74
|
require_paths:
|
74
75
|
- lib
|
@@ -83,8 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
84
|
- !ruby/object:Gem::Version
|
84
85
|
version: '0'
|
85
86
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
87
|
-
signing_key:
|
87
|
+
rubygems_version: 3.1.6
|
88
|
+
signing_key:
|
88
89
|
specification_version: 4
|
89
90
|
summary: This library provides a simple way to write new native resources for puppet.
|
90
91
|
test_files: []
|