puppet-resource_api 1.9.0 → 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 +64 -44
- 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 +38 -45
- 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 +120 -91
- 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,7 +129,7 @@ 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
|
@@ -140,22 +140,33 @@ module Puppet::ResourceApi
|
|
140
140
|
def generate
|
141
141
|
# If feature `custom_generate` has been set then call the generate function within the provider and return the given results
|
142
142
|
return unless type_definition&.feature?('custom_generate')
|
143
|
+
|
143
144
|
should_hash = rsapi_canonicalized_target_state
|
144
145
|
is_hash = rsapi_current_state
|
145
146
|
title = rsapi_title
|
146
147
|
|
147
148
|
# Ensure that a custom `generate` method has been created within the provider
|
148
149
|
raise(Puppet::DevError, 'No generate method found within the types provider') unless my_provider.respond_to?(:generate)
|
150
|
+
|
149
151
|
# Call the providers custom `generate` method
|
150
|
-
|
152
|
+
my_provider.generate(context, title, is_hash, should_hash)
|
151
153
|
|
152
154
|
# Return array of resources
|
153
|
-
rules_resources
|
154
155
|
end
|
155
156
|
|
156
157
|
def rsapi_current_state
|
157
|
-
|
158
|
-
|
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
|
159
170
|
end
|
160
171
|
|
161
172
|
def to_resource
|
@@ -179,11 +190,11 @@ module Puppet::ResourceApi
|
|
179
190
|
definition[:attributes].each do |name, options|
|
180
191
|
type = Puppet::ResourceApi::DataTypeHandling.parse_puppet_type(
|
181
192
|
:name,
|
182
|
-
options[:type]
|
193
|
+
options[:type]
|
183
194
|
)
|
184
195
|
|
185
196
|
# skip read only vars and the namevar
|
186
|
-
next if [
|
197
|
+
next if %i[read_only namevar].include? options[:behaviour]
|
187
198
|
|
188
199
|
# skip properties if the resource is being deleted
|
189
200
|
next if definition[:attributes][:ensure] &&
|
@@ -210,7 +221,7 @@ module Puppet::ResourceApi
|
|
210
221
|
custom_insync_trigger_options = {
|
211
222
|
type: 'Enum[do_not_specify_in_manifest]',
|
212
223
|
desc: 'A hidden property which enables a type with custom insync to perform an insync check without specifying any insyncable properties',
|
213
|
-
default: 'do_not_specify_in_manifest'
|
224
|
+
default: 'do_not_specify_in_manifest'
|
214
225
|
}
|
215
226
|
|
216
227
|
type_definition.create_attribute_in(self, :rsapi_custom_insync_trigger, :newproperty, Puppet::ResourceApi::Property, custom_insync_trigger_options)
|
@@ -219,16 +230,12 @@ module Puppet::ResourceApi
|
|
219
230
|
definition[:attributes].each do |name, options|
|
220
231
|
# puts "#{name}: #{options.inspect}"
|
221
232
|
|
222
|
-
if options[:behaviour]
|
223
|
-
unless [:read_only, :namevar, :parameter, :init_only].include? options[:behaviour]
|
224
|
-
raise Puppet::ResourceError, "`#{options[:behaviour]}` is not a valid behaviour value"
|
225
|
-
end
|
226
|
-
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])
|
227
234
|
|
228
235
|
# TODO: using newparam everywhere would suppress change reporting
|
229
236
|
# that would allow more fine-grained reporting through context,
|
230
237
|
# but require more invest in hooking up the infrastructure to emulate existing data
|
231
|
-
if [
|
238
|
+
if %i[parameter namevar].include? options[:behaviour]
|
232
239
|
param_or_property = :newparam
|
233
240
|
parent = Puppet::ResourceApi::Parameter
|
234
241
|
elsif options[:behaviour] == :read_only
|
@@ -242,57 +249,77 @@ module Puppet::ResourceApi
|
|
242
249
|
type_definition.create_attribute_in(self, name, param_or_property, parent, options)
|
243
250
|
end
|
244
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
|
+
|
245
276
|
def self.instances
|
246
277
|
# puts 'instances'
|
247
278
|
# force autoloading of the provider
|
248
279
|
provider(type_definition.name)
|
249
280
|
|
250
|
-
|
251
|
-
my_provider.get(context, [])
|
252
|
-
else
|
253
|
-
my_provider.get(context)
|
254
|
-
end
|
255
|
-
|
256
|
-
initial_fetch.map do |resource_hash|
|
257
|
-
type_definition.check_schema(resource_hash)
|
281
|
+
rsapi_provider_get.map do |resource_hash|
|
258
282
|
# allow a :title from the provider to override the default
|
259
283
|
result = if resource_hash.key? :title
|
260
284
|
new(title: resource_hash[:title])
|
261
285
|
else
|
262
286
|
new(title: build_title(type_definition, resource_hash))
|
263
287
|
end
|
288
|
+
# Cache the state in the generated resource, but unfortunately
|
289
|
+
# this only benefits "puppet resource", not apply runs:
|
264
290
|
result.cache_current_state(resource_hash)
|
265
291
|
result
|
266
292
|
end
|
267
293
|
end
|
268
294
|
|
269
295
|
def refresh_current_state
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
end
|
275
|
-
|
276
|
-
if @rsapi_current_state
|
277
|
-
type_definition.check_schema(@rsapi_current_state)
|
278
|
-
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)
|
279
300
|
else
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
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?
|
286
307
|
end
|
308
|
+
self.rsapi_current_state = current_state
|
287
309
|
end
|
288
310
|
|
289
|
-
# 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:
|
290
316
|
def cache_current_state(resource_hash)
|
291
|
-
|
292
|
-
strict_check(
|
317
|
+
self.rsapi_current_state = resource_hash
|
318
|
+
strict_check(resource_hash)
|
293
319
|
end
|
294
320
|
|
295
321
|
def retrieve
|
322
|
+
refresh_current_state unless rsapi_current_state
|
296
323
|
Puppet.debug("Current State: #{rsapi_current_state.inspect}")
|
297
324
|
|
298
325
|
result = Puppet::Resource.new(self.class, title, parameters: rsapi_current_state)
|
@@ -316,17 +343,18 @@ module Puppet::ResourceApi
|
|
316
343
|
# puts 'flush'
|
317
344
|
target_state = rsapi_canonicalized_target_state
|
318
345
|
|
319
|
-
retrieve unless
|
346
|
+
retrieve unless rsapi_current_state
|
320
347
|
|
321
|
-
return if
|
348
|
+
return if rsapi_current_state == target_state
|
322
349
|
|
323
350
|
Puppet.debug("Target State: #{target_state.inspect}")
|
324
351
|
|
325
352
|
# enforce init_only attributes
|
326
|
-
if Puppet.settings[:strict] != :off &&
|
353
|
+
if Puppet.settings[:strict] != :off && rsapi_current_state && (rsapi_current_state[:ensure] == 'present' && target_state[:ensure] == 'present')
|
327
354
|
target_state.each do |name, value|
|
328
|
-
next unless type_definition.attributes[name][:behaviour] == :init_only && value !=
|
329
|
-
|
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}`"
|
330
358
|
case Puppet.settings[:strict]
|
331
359
|
when :warning
|
332
360
|
Puppet.warning(message)
|
@@ -337,9 +365,9 @@ module Puppet::ResourceApi
|
|
337
365
|
end
|
338
366
|
|
339
367
|
if type_definition.feature?('supports_noop')
|
340
|
-
my_provider.set(context, { rsapi_title => { is:
|
368
|
+
my_provider.set(context, { rsapi_title => { is: rsapi_current_state, should: target_state } }, noop: noop?)
|
341
369
|
else
|
342
|
-
my_provider.set(context, rsapi_title => { is:
|
370
|
+
my_provider.set(context, rsapi_title => { is: rsapi_current_state, should: target_state }) unless noop?
|
343
371
|
end
|
344
372
|
if context.failed?
|
345
373
|
context.reset_failed
|
@@ -347,16 +375,16 @@ module Puppet::ResourceApi
|
|
347
375
|
end
|
348
376
|
|
349
377
|
# remember that we have successfully reached our desired state
|
350
|
-
|
378
|
+
self.rsapi_current_state = target_state
|
351
379
|
end
|
352
380
|
|
353
381
|
def raise_missing_attrs
|
354
|
-
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 * ")}"
|
355
383
|
raise Puppet::ResourceError, error_msg if @missing_attrs.any? && (value(:ensure) != :absent && !value(:ensure).nil?)
|
356
384
|
end
|
357
385
|
|
358
386
|
def raise_missing_params
|
359
|
-
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 * ")}"
|
360
388
|
raise Puppet::ResourceError, error_msg
|
361
389
|
end
|
362
390
|
|
@@ -387,14 +415,14 @@ module Puppet::ResourceApi
|
|
387
415
|
# compare the clone against the current state to see if changes have been made by canonicalize
|
388
416
|
return unless state_clone && (current_state != state_clone)
|
389
417
|
|
390
|
-
|
418
|
+
# :nocov:
|
391
419
|
# codecov fails to register this multiline as covered, even though simplecov does.
|
392
|
-
message =
|
393
|
-
#{type_definition.name}[#{@title}]#get has not provided canonicalized values.
|
394
|
-
Returned values: #{current_state.inspect}
|
395
|
-
Canonicalized values: #{state_clone.inspect}
|
396
|
-
MESSAGE
|
397
|
-
|
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:
|
398
426
|
strict_message(message)
|
399
427
|
end
|
400
428
|
|
@@ -409,6 +437,7 @@ MESSAGE
|
|
409
437
|
self.class.title_patterns.each do |regexp, symbols|
|
410
438
|
captures = regexp.match(current_state[:title])
|
411
439
|
next if captures.nil?
|
440
|
+
|
412
441
|
symbols.zip(captures[1..-1]).each do |symbol_and_lambda, capture|
|
413
442
|
# The Resource API does not support passing procs in title_patterns
|
414
443
|
# so, unlike Puppet::Resource, we do not need to handle that here.
|
@@ -422,15 +451,15 @@ MESSAGE
|
|
422
451
|
|
423
452
|
namevars = type_definition.namevars.reject { |namevar| title_hash[namevar] == rsapi_title[namevar] }
|
424
453
|
|
425
|
-
|
454
|
+
# :nocov:
|
426
455
|
# codecov fails to register this multiline as covered, even though simplecov does.
|
427
|
-
message =
|
428
|
-
#{type_definition.name}[#{@title}]#get has provided a title attribute which does not match all namevars.
|
429
|
-
Namevars which do not match: #{namevars.inspect}
|
430
|
-
Returned parsed title hash: #{title_hash.inspect}
|
431
|
-
Expected hash: #{rsapi_title.inspect}
|
432
|
-
MESSAGE
|
433
|
-
|
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:
|
434
463
|
strict_message(message)
|
435
464
|
end
|
436
465
|
|
@@ -446,7 +475,7 @@ MESSAGE
|
|
446
475
|
@title_patterns ||= if type_definition.definition.key? :title_patterns
|
447
476
|
parse_title_patterns(type_definition.definition[:title_patterns])
|
448
477
|
else
|
449
|
-
[[
|
478
|
+
[[/(.*)/m, [[type_definition.namevars.first]]]]
|
450
479
|
end
|
451
480
|
end
|
452
481
|
|
@@ -467,14 +496,14 @@ MESSAGE
|
|
467
496
|
end
|
468
497
|
end
|
469
498
|
|
470
|
-
[
|
499
|
+
%i[autorequire autobefore autosubscribe autonotify].each do |auto|
|
471
500
|
next unless definition[auto]
|
472
501
|
|
473
502
|
definition[auto].each do |type, values|
|
474
503
|
Puppet.debug("Registering #{auto} for #{type}: #{values.inspect}")
|
475
504
|
send(auto, type.downcase.to_sym) do
|
476
505
|
resolved = [values].flatten.map do |v|
|
477
|
-
match =
|
506
|
+
match = /\A\$(.*)\Z/.match(v) if v.is_a? String
|
478
507
|
if match.nil?
|
479
508
|
v
|
480
509
|
else
|
@@ -483,13 +512,13 @@ MESSAGE
|
|
483
512
|
end
|
484
513
|
# Flatten to handle any resolved array properties and filter any nil
|
485
514
|
# values resulting from unspecified optional parameters:
|
486
|
-
resolved.flatten.reject
|
515
|
+
resolved.flatten.reject(&:nil?)
|
487
516
|
end
|
488
517
|
end
|
489
518
|
end
|
490
519
|
end
|
491
520
|
end
|
492
|
-
module_function :register_type
|
521
|
+
module_function :register_type
|
493
522
|
|
494
523
|
def load_provider(type_name)
|
495
524
|
class_name = class_name_from_type_name(type_name)
|
@@ -512,20 +541,20 @@ MESSAGE
|
|
512
541
|
end
|
513
542
|
rescue NameError
|
514
543
|
if device_name # line too long # rubocop:disable Style/GuardClause
|
515
|
-
raise Puppet::DevError, "Found neither the device-specific provider class Puppet::Provider::#{class_name}::#{device_class_name} in puppet/provider/#{type_name}/#{device_name}"\
|
516
|
-
|
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}"
|
517
546
|
else
|
518
547
|
raise Puppet::DevError, "provider class Puppet::Provider::#{class_name}::#{class_name} not found in puppet/provider/#{type_name}/#{type_name}"
|
519
548
|
end
|
520
549
|
end
|
521
|
-
module_function :load_provider
|
550
|
+
module_function :load_provider
|
522
551
|
|
523
552
|
def load_default_provider(class_name, type_name_sym)
|
524
553
|
# loads the "puppet/provider/#{type_name}/#{type_name}" file through puppet
|
525
554
|
Puppet::Type.type(type_name_sym).provider(type_name_sym)
|
526
555
|
Puppet::Provider.const_get(class_name, false).const_get(class_name, false)
|
527
556
|
end
|
528
|
-
module_function :load_default_provider
|
557
|
+
module_function :load_default_provider
|
529
558
|
|
530
559
|
def load_device_provider(class_name, type_name_sym, device_class_name, device_name_sym)
|
531
560
|
# loads the "puppet/provider/#{type_name}/#{device_name}" file through puppet
|
@@ -537,13 +566,13 @@ MESSAGE
|
|
537
566
|
load_default_provider(class_name, type_name_sym)
|
538
567
|
end
|
539
568
|
end
|
540
|
-
module_function :load_device_provider
|
569
|
+
module_function :load_device_provider
|
541
570
|
|
542
571
|
# keeps the existing register API format. e.g. Puppet::ResourceApi.register_type
|
543
572
|
def register_transport(schema)
|
544
573
|
Puppet::ResourceApi::Transport.register(schema)
|
545
574
|
end
|
546
|
-
module_function :register_transport
|
575
|
+
module_function :register_transport
|
547
576
|
|
548
577
|
def self.class_name_from_type_name(type_name)
|
549
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: []
|