bolt 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bolt might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/bolt/cli.rb +127 -31
- data/lib/bolt/config.rb +39 -6
- data/lib/bolt/execution_result.rb +109 -0
- data/lib/bolt/executor.rb +4 -1
- data/lib/bolt/node.rb +6 -1
- data/lib/bolt/node/orch.rb +20 -2
- data/lib/bolt/node/winrm.rb +22 -10
- data/lib/bolt/node_uri.rb +5 -7
- data/lib/bolt/outputter/human.rb +60 -1
- data/lib/bolt/outputter/json.rb +11 -0
- data/lib/bolt/target.rb +32 -0
- data/lib/bolt/version.rb +1 -1
- data/modules/boltlib/lib/puppet/datatypes/executionresult.rb +30 -0
- data/modules/boltlib/lib/puppet/datatypes/target.rb +12 -0
- data/modules/boltlib/lib/puppet/functions/file_upload.rb +3 -3
- data/modules/boltlib/lib/puppet/functions/run_command.rb +3 -3
- data/modules/boltlib/lib/puppet/functions/run_script.rb +3 -3
- data/modules/boltlib/lib/puppet/functions/run_task.rb +10 -2
- data/vendored/puppet/lib/puppet/application/describe.rb +0 -1
- data/vendored/puppet/lib/puppet/configurer.rb +1 -1
- data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +15 -9
- data/vendored/puppet/lib/puppet/datatypes.rb +213 -0
- data/vendored/puppet/lib/puppet/datatypes/error.rb +19 -0
- data/vendored/puppet/lib/puppet/datatypes/impl/error.rb +42 -0
- data/vendored/puppet/lib/puppet/error.rb +1 -1
- data/vendored/puppet/lib/puppet/face/catalog.rb +1 -1
- data/vendored/puppet/lib/puppet/face/epp.rb +3 -3
- data/vendored/puppet/lib/puppet/face/help.rb +12 -14
- data/vendored/puppet/lib/puppet/face/man.rb +1 -0
- data/vendored/puppet/lib/puppet/face/module/search.rb +1 -1
- data/vendored/puppet/lib/puppet/face/node.rb +1 -0
- data/vendored/puppet/lib/puppet/face/parser.rb +0 -1
- data/vendored/puppet/lib/puppet/face/status.rb +1 -0
- data/vendored/puppet/lib/puppet/feature/base.rb +1 -1
- data/vendored/puppet/lib/puppet/file_bucket/dipper.rb +0 -1
- data/vendored/puppet/lib/puppet/file_system/uniquefile.rb +2 -2
- data/vendored/puppet/lib/puppet/forge/errors.rb +21 -29
- data/vendored/puppet/lib/puppet/functions.rb +64 -84
- data/vendored/puppet/lib/puppet/functions/defined.rb +0 -3
- data/vendored/puppet/lib/puppet/functions/find_file.rb +0 -1
- data/vendored/puppet/lib/puppet/functions/map.rb +0 -1
- data/vendored/puppet/lib/puppet/functions/regsubst.rb +1 -1
- data/vendored/puppet/lib/puppet/graph/simple_graph.rb +6 -10
- data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +37 -25
- data/vendored/puppet/lib/puppet/indirector/file_server.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/indirection.rb +0 -2
- data/vendored/puppet/lib/puppet/indirector/rest.rb +9 -8
- data/vendored/puppet/lib/puppet/info_service/class_information_service.rb +1 -1
- data/vendored/puppet/lib/puppet/interface/option_manager.rb +1 -1
- data/vendored/puppet/lib/puppet/loaders.rb +1 -0
- data/vendored/puppet/lib/puppet/module.rb +6 -2
- data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/vendored/puppet/lib/puppet/module_tool/errors/installer.rb +29 -41
- data/vendored/puppet/lib/puppet/module_tool/errors/shared.rb +63 -138
- data/vendored/puppet/lib/puppet/module_tool/errors/uninstaller.rb +15 -37
- data/vendored/puppet/lib/puppet/module_tool/errors/upgrader.rb +18 -30
- data/vendored/puppet/lib/puppet/module_tool/installed_modules.rb +1 -1
- data/vendored/puppet/lib/puppet/module_tool/metadata.rb +0 -1
- data/vendored/puppet/lib/puppet/network/http/api/indirected_routes.rb +1 -1
- data/vendored/puppet/lib/puppet/network/rights.rb +1 -1
- data/vendored/puppet/lib/puppet/node.rb +1 -1
- data/vendored/puppet/lib/puppet/node/environment.rb +1 -1
- data/vendored/puppet/lib/puppet/parameter/value_collection.rb +4 -17
- data/vendored/puppet/lib/puppet/parser/compiler.rb +1 -0
- data/vendored/puppet/lib/puppet/parser/functions.rb +0 -1
- data/vendored/puppet/lib/puppet/parser/functions/scanf.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/scope.rb +4 -3
- data/vendored/puppet/lib/puppet/parser/script_compiler.rb +1 -0
- data/vendored/puppet/lib/puppet/parser/templatewrapper.rb +3 -2
- data/vendored/puppet/lib/puppet/parser/type_loader.rb +1 -1
- data/vendored/puppet/lib/puppet/pops.rb +1 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/access_operator.rb +3 -2
- data/vendored/puppet/lib/puppet/pops/evaluator/closure.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +6 -5
- data/vendored/puppet/lib/puppet/pops/functions/function.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/loader/loader.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +40 -4
- data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +6 -2
- data/vendored/puppet/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +8 -8
- data/vendored/puppet/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +40 -0
- data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +6 -26
- data/vendored/puppet/lib/puppet/pops/loaders.rb +11 -2
- data/vendored/puppet/lib/puppet/pops/lookup/data_dig_function_provider.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/lookup/lookup_adapter.rb +4 -14
- data/vendored/puppet/lib/puppet/pops/model/model_tree_dumper.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/parser/code_merger.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +1471 -1501
- data/vendored/puppet/lib/puppet/pops/parser/epp_support.rb +0 -2
- data/vendored/puppet/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/parser/interpolation_support.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/parser/lexer2.rb +2 -26
- data/vendored/puppet/lib/puppet/pops/parser/locator.rb +5 -7
- data/vendored/puppet/lib/puppet/pops/parser/parser_support.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/parser/slurp_support.rb +0 -3
- data/vendored/puppet/lib/puppet/pops/pcore.rb +0 -11
- data/vendored/puppet/lib/puppet/pops/serialization/object.rb +3 -4
- data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/time/timespan.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/types/iterable.rb +14 -7
- data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +38 -7
- data/vendored/puppet/lib/puppet/pops/types/p_object_type_extension.rb +21 -22
- data/vendored/puppet/lib/puppet/pops/types/p_sem_ver_range_type.rb +0 -1
- data/vendored/puppet/lib/puppet/pops/types/p_type_set_type.rb +0 -1
- data/vendored/puppet/lib/puppet/pops/types/p_uri_type.rb +0 -1
- data/vendored/puppet/lib/puppet/pops/types/puppet_object.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/types/string_converter.rb +5 -1
- data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +5 -1
- data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +1 -5
- data/vendored/puppet/lib/puppet/pops/types/type_formatter.rb +21 -0
- data/vendored/puppet/lib/puppet/pops/types/types.rb +2 -7
- data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +1 -3
- data/vendored/puppet/lib/puppet/property.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/augeas/augeas.rb +3 -4
- data/vendored/puppet/lib/puppet/provider/exec.rb +0 -2
- data/vendored/puppet/lib/puppet/provider/nameservice.rb +6 -1
- data/vendored/puppet/lib/puppet/provider/nameservice/directoryservice.rb +3 -3
- data/vendored/puppet/lib/puppet/provider/package/appdmg.rb +0 -1
- data/vendored/puppet/lib/puppet/provider/package/apple.rb +0 -1
- data/vendored/puppet/lib/puppet/provider/package/macports.rb +2 -2
- data/vendored/puppet/lib/puppet/provider/package/pkgdmg.rb +0 -1
- data/vendored/puppet/lib/puppet/provider/package/portage.rb +0 -1
- data/vendored/puppet/lib/puppet/provider/package/zypper.rb +2 -2
- data/vendored/puppet/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
- data/vendored/puppet/lib/puppet/provider/service/init.rb +1 -0
- data/vendored/puppet/lib/puppet/provider/service/launchd.rb +3 -3
- data/vendored/puppet/lib/puppet/provider/user/aix.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/user/openbsd.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/user/pw.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +2 -4
- data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/zpool/zpool.rb +1 -1
- data/vendored/puppet/lib/puppet/reference/type.rb +0 -1
- data/vendored/puppet/lib/puppet/resource.rb +1 -2
- data/vendored/puppet/lib/puppet/resource/status.rb +0 -1
- data/vendored/puppet/lib/puppet/resource/type.rb +3 -3
- data/vendored/puppet/lib/puppet/resource/type_collection.rb +1 -1
- data/vendored/puppet/lib/puppet/settings/environment_conf.rb +0 -1
- data/vendored/puppet/lib/puppet/ssl/host.rb +1 -1
- data/vendored/puppet/lib/puppet/syntax_checkers/base64.rb +1 -1
- data/vendored/puppet/lib/puppet/transaction/persistence.rb +1 -1
- data/vendored/puppet/lib/puppet/type.rb +17 -4
- data/vendored/puppet/lib/puppet/type/file.rb +3 -3
- data/vendored/puppet/lib/puppet/type/mount.rb +9 -0
- data/vendored/puppet/lib/puppet/type/schedule.rb +25 -13
- data/vendored/puppet/lib/puppet/type/tidy.rb +2 -2
- data/vendored/puppet/lib/puppet/type/user.rb +1 -1
- data/vendored/puppet/lib/puppet/util.rb +19 -14
- data/vendored/puppet/lib/puppet/util/filetype.rb +2 -2
- data/vendored/puppet/lib/puppet/util/json_lockfile.rb +1 -1
- data/vendored/puppet/lib/puppet/util/log.rb +5 -3
- data/vendored/puppet/lib/puppet/util/log/destinations.rb +0 -1
- data/vendored/puppet/lib/puppet/util/monkey_patches.rb +1 -1
- data/vendored/puppet/lib/puppet/util/network_device/config.rb +2 -2
- data/vendored/puppet/lib/puppet/util/plist.rb +6 -4
- data/vendored/puppet/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
- data/vendored/puppet/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +1 -1
- data/vendored/puppet/lib/puppet/util/storage.rb +2 -2
- data/vendored/puppet/lib/puppet/util/windows/registry.rb +2 -2
- data/vendored/puppet/lib/puppet/util/windows/sid.rb +0 -2
- data/vendored/puppet/lib/puppet/version.rb +1 -1
- data/vendored/puppet/lib/puppet_pal.rb +30 -17
- metadata +28 -7
- data/vendored/puppet/lib/puppet/pops/types/execution_result.rb +0 -137
@@ -442,9 +442,9 @@ class Puppet::Resource::Type
|
|
442
442
|
def convert_from_ast(name)
|
443
443
|
value = name.value
|
444
444
|
if value.is_a?(Puppet::Parser::AST::Regex)
|
445
|
-
|
445
|
+
value.value
|
446
446
|
else
|
447
|
-
|
447
|
+
value
|
448
448
|
end
|
449
449
|
end
|
450
450
|
|
@@ -476,7 +476,7 @@ class Puppet::Resource::Type
|
|
476
476
|
# Note we're doing something somewhat weird here -- we're setting
|
477
477
|
# the class's namespace to its fully qualified name. This means
|
478
478
|
# anything inside that class starts looking in that namespace first.
|
479
|
-
@namespace,
|
479
|
+
@namespace, _ = @type == :hostclass ? [@name, ''] : namesplit(@name)
|
480
480
|
end
|
481
481
|
end
|
482
482
|
|
@@ -22,7 +22,6 @@ class Puppet::Settings::EnvironmentConf
|
|
22
22
|
def self.load_from(path_to_env, global_module_path)
|
23
23
|
path_to_env = File.expand_path(path_to_env)
|
24
24
|
conf_file = File.join(path_to_env, 'environment.conf')
|
25
|
-
config = nil
|
26
25
|
|
27
26
|
begin
|
28
27
|
config = Puppet.settings.parse_file(conf_file)
|
@@ -211,7 +211,7 @@ DOC
|
|
211
211
|
raise Puppet::Error, _("No private key with which to validate certificate with fingerprint: %{fingerprint}") % { fingerprint: certificate.fingerprint } unless key
|
212
212
|
unless certificate.content.check_private_key(key.content)
|
213
213
|
raise Puppet::Error, _(<<ERROR_STRING) % { fingerprint: certificate.fingerprint, cert_name: Puppet[:certname], ssl_dir: Puppet[:ssldir], cert_dir: Puppet[:certdir].gsub('/', '\\') }
|
214
|
-
The certificate retrieved from the master does not match the agent's private key.
|
214
|
+
The certificate retrieved from the master does not match the agent's private key. Did you forget to run as root?
|
215
215
|
Certificate fingerprint: %{fingerprint}
|
216
216
|
To fix this, remove the certificate from both the master and the agent and then start a puppet run, which will automatically regenerate a certificate.
|
217
217
|
On the master:
|
@@ -23,7 +23,7 @@ class Puppet::SyntaxCheckers::Base64 < Puppet::Plugins::SyntaxCheckers::SyntaxCh
|
|
23
23
|
# Do a strict decode64 on text with all whitespace stripped since the non strict version
|
24
24
|
# simply skips all non base64 characters
|
25
25
|
Base64.strict_decode64(cleaned_text)
|
26
|
-
rescue
|
26
|
+
rescue
|
27
27
|
msg = if (cleaned_text.bytes.to_a.size * 8) % 6 != 0
|
28
28
|
_("Base64 syntax checker: Cannot parse invalid Base64 string - padding is not correct")
|
29
29
|
else
|
@@ -52,7 +52,7 @@ class Puppet::Transaction::Persistence
|
|
52
52
|
end
|
53
53
|
|
54
54
|
result = nil
|
55
|
-
Puppet::Util.benchmark(:debug, _("Loaded transaction store file")) do
|
55
|
+
Puppet::Util.benchmark(:debug, _("Loaded transaction store file in %{seconds} seconds")) do
|
56
56
|
begin
|
57
57
|
result = Puppet::Util::Yaml.load_file(filename, false, true)
|
58
58
|
rescue Puppet::Util::Yaml::YamlLoadError => detail
|
@@ -1336,9 +1336,9 @@ class Type
|
|
1336
1336
|
|
1337
1337
|
def properties_to_audit(list)
|
1338
1338
|
if !list.kind_of?(Array) && list.to_sym == :all
|
1339
|
-
|
1339
|
+
all_properties
|
1340
1340
|
else
|
1341
|
-
|
1341
|
+
Array(list).collect { |p| p.to_sym }
|
1342
1342
|
end
|
1343
1343
|
end
|
1344
1344
|
end
|
@@ -1537,12 +1537,25 @@ class Type
|
|
1537
1537
|
:event => self.class.events,
|
1538
1538
|
:callback => method
|
1539
1539
|
}
|
1540
|
-
self.debug { "subscribes to #{related_resource.ref}" }
|
1541
1540
|
else
|
1542
1541
|
# If there's no callback, there's no point in even adding
|
1543
1542
|
# a label.
|
1544
1543
|
subargs = nil
|
1545
|
-
|
1544
|
+
end
|
1545
|
+
|
1546
|
+
## Corrected syntax of debug statement to reflect the way this was called.
|
1547
|
+
# i.e. before, after, subscribe, notify
|
1548
|
+
self.debug do
|
1549
|
+
relation = case self.class.name
|
1550
|
+
when "subscribe"
|
1551
|
+
"subscribes"
|
1552
|
+
when "notify"
|
1553
|
+
"notifies"
|
1554
|
+
else
|
1555
|
+
self.class.name
|
1556
|
+
end
|
1557
|
+
|
1558
|
+
"#{relation} to #{related_resource.ref}"
|
1546
1559
|
end
|
1547
1560
|
|
1548
1561
|
Puppet::Relationship.new(source, target, subargs)
|
@@ -828,11 +828,11 @@ Puppet::Type.newtype(:file) do
|
|
828
828
|
|
829
829
|
@stat = begin
|
830
830
|
Puppet::FileSystem.send(method, self[:path])
|
831
|
-
rescue Errno::ENOENT
|
831
|
+
rescue Errno::ENOENT
|
832
832
|
nil
|
833
|
-
rescue Errno::ENOTDIR
|
833
|
+
rescue Errno::ENOTDIR
|
834
834
|
nil
|
835
|
-
rescue Errno::EACCES
|
835
|
+
rescue Errno::EACCES
|
836
836
|
warning _("Could not stat; permission denied")
|
837
837
|
nil
|
838
838
|
end
|
@@ -16,6 +16,9 @@ module Puppet
|
|
16
16
|
that is, other mount points higher up in the filesystem --- the child
|
17
17
|
mount will autorequire them.
|
18
18
|
|
19
|
+
**Autorequires:** If Puppet is managing a `File` resource for the mount
|
20
|
+
point of a mount resource, the mount will autorequire it.
|
21
|
+
|
19
22
|
**Autobefores:** If Puppet is managing any child file paths of a mount
|
20
23
|
point, the mount resource will autobefore them."
|
21
24
|
|
@@ -300,6 +303,12 @@ module Puppet
|
|
300
303
|
dependencies[0..-2]
|
301
304
|
end
|
302
305
|
|
306
|
+
# Ensure that the mountpoint is created first
|
307
|
+
autorequire(:file) do
|
308
|
+
dependencies = []
|
309
|
+
dependencies.unshift @parameters[:name].value
|
310
|
+
end
|
311
|
+
|
303
312
|
# Autobefore the mount point's child file paths
|
304
313
|
autobefore(:file) do
|
305
314
|
dependencies = []
|
@@ -346,9 +346,9 @@ module Puppet
|
|
346
346
|
newparam(:weekday) do
|
347
347
|
desc <<-EOT
|
348
348
|
The days of the week in which the schedule should be valid.
|
349
|
-
You may specify the full day name
|
350
|
-
abbreviation
|
351
|
-
week where 0 is Sunday, 1 is Monday,
|
349
|
+
You may specify the full day name 'Tuesday', the three character
|
350
|
+
abbreviation 'Tue', or a number (as a string or as an integer) corresponding to the day of the
|
351
|
+
week where 0 is Sunday, 1 is Monday, and so on. Multiple days can be specified
|
352
352
|
as an array. If not specified, the day of the week will not be
|
353
353
|
considered in the schedule.
|
354
354
|
|
@@ -369,13 +369,22 @@ module Puppet
|
|
369
369
|
validate do |values|
|
370
370
|
values = [values] unless values.is_a?(Array)
|
371
371
|
values.each { |value|
|
372
|
-
|
373
|
-
|
372
|
+
if weekday_integer?(value) || weekday_string?(value)
|
373
|
+
value
|
374
|
+
else
|
374
375
|
raise ArgumentError, _("%{value} is not a valid day of the week") % { value: value }
|
375
376
|
end
|
376
377
|
}
|
377
378
|
end
|
378
379
|
|
380
|
+
def weekday_integer?(value)
|
381
|
+
value.is_a?(Integer) && (0..6).include?(value)
|
382
|
+
end
|
383
|
+
|
384
|
+
def weekday_string?(value)
|
385
|
+
value.is_a?(String) && (value =~ /^[0-6]$/ || value =~ /^(Mon|Tues?|Wed(?:nes)?|Thu(?:rs)?|Fri|Sat(?:ur)?|Sun)(day)?$/i)
|
386
|
+
end
|
387
|
+
|
379
388
|
weekdays = {
|
380
389
|
'sun' => 0,
|
381
390
|
'mon' => 1,
|
@@ -390,14 +399,17 @@ module Puppet
|
|
390
399
|
values = [values] unless values.is_a?(Array)
|
391
400
|
ret = {}
|
392
401
|
|
393
|
-
values.each
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
402
|
+
values.each do |value|
|
403
|
+
case value
|
404
|
+
when /^[0-6]$/
|
405
|
+
index = value.to_i
|
406
|
+
when 0..6
|
407
|
+
index = value
|
408
|
+
else
|
409
|
+
index = weekdays[value[0,3].downcase]
|
410
|
+
end
|
411
|
+
ret[index] = true
|
412
|
+
end
|
401
413
|
ret
|
402
414
|
end
|
403
415
|
|
@@ -326,10 +326,10 @@ Puppet::Type.newtype(:tidy) do
|
|
326
326
|
def stat(path)
|
327
327
|
begin
|
328
328
|
Puppet::FileSystem.lstat(path)
|
329
|
-
rescue Errno::ENOENT
|
329
|
+
rescue Errno::ENOENT
|
330
330
|
info _("File does not exist")
|
331
331
|
return nil
|
332
|
-
rescue Errno::EACCES
|
332
|
+
rescue Errno::EACCES
|
333
333
|
#TRANSLATORS "stat" is a program name and should not be translated
|
334
334
|
warning _("Could not stat; permission denied")
|
335
335
|
return nil
|
@@ -767,7 +767,7 @@ module Puppet
|
|
767
767
|
# the name is stored in the 4th capture of the regex
|
768
768
|
name = $4
|
769
769
|
if name.empty?
|
770
|
-
|
770
|
+
$3.delete("\n")
|
771
771
|
# If no comment is specified for this key, generate a unique internal
|
772
772
|
# name. This uses the same rules as
|
773
773
|
# provider/ssh_authorized_key/parsed (PUP-3357)
|
@@ -197,20 +197,27 @@ module Util
|
|
197
197
|
}
|
198
198
|
end
|
199
199
|
|
200
|
+
# execute a block of work and based on the logging level provided, log the provided message with the seconds taken
|
201
|
+
# The message 'msg' should include string ' in %{seconds} seconds' as part of the message and any content should escape
|
202
|
+
# any percent signs '%' so that they are not interpreted as formatting commands
|
203
|
+
# escaped_str = str.gsub(/%/, '%%')
|
204
|
+
#
|
205
|
+
# @param msg [String] the message to be formated to assigned the %{seconds} seconds take to execute,
|
206
|
+
# other percent signs '%' need to be escaped
|
207
|
+
# @param level [Symbol] the logging level for this message
|
208
|
+
# @param object [Object] The object use for logging the message
|
200
209
|
def benchmark(*args)
|
201
210
|
msg = args.pop
|
202
211
|
level = args.pop
|
203
|
-
object =
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
object = args.pop
|
213
|
-
end
|
212
|
+
object = if args.empty?
|
213
|
+
if respond_to?(level)
|
214
|
+
self
|
215
|
+
else
|
216
|
+
Puppet
|
217
|
+
end
|
218
|
+
else
|
219
|
+
args.pop
|
220
|
+
end
|
214
221
|
|
215
222
|
raise Puppet::DevError, "Failed to provide level to :benchmark" unless level
|
216
223
|
|
@@ -223,9 +230,7 @@ module Util
|
|
223
230
|
seconds = Benchmark.realtime {
|
224
231
|
yield
|
225
232
|
}
|
226
|
-
|
227
|
-
# given operation took
|
228
|
-
object.send(level, msg + (_(" in %0.2f seconds") % seconds))
|
233
|
+
object.send(level, msg % { seconds: "%0.2f" % seconds })
|
229
234
|
return seconds
|
230
235
|
else
|
231
236
|
yield
|
@@ -42,7 +42,7 @@ class Puppet::Util::FileType
|
|
42
42
|
else
|
43
43
|
return ""
|
44
44
|
end
|
45
|
-
rescue Puppet::Error
|
45
|
+
rescue Puppet::Error
|
46
46
|
raise
|
47
47
|
rescue => detail
|
48
48
|
message = _("%{klass} could not read %{path}: %{detail}") % { klass: self.class, path: @path, detail: detail }
|
@@ -58,7 +58,7 @@ class Puppet::Util::FileType
|
|
58
58
|
val = real_write(text)
|
59
59
|
@synced = Time.now
|
60
60
|
return val
|
61
|
-
rescue Puppet::Error
|
61
|
+
rescue Puppet::Error
|
62
62
|
raise
|
63
63
|
rescue => detail
|
64
64
|
message = _("%{klass} could not write %{path}: %{detail}") % { klass: self.class, path: @path, detail: detail }
|
@@ -36,7 +36,7 @@ class Puppet::Util::JsonLockfile < Puppet::Util::Lockfile
|
|
36
36
|
file_contents = super
|
37
37
|
return nil if file_contents.nil? or file_contents.empty?
|
38
38
|
JSON.parse(file_contents)
|
39
|
-
rescue JSON::ParserError
|
39
|
+
rescue JSON::ParserError
|
40
40
|
Puppet.warning _("Unable to read lockfile data from %{path}: not in JSON") % { path: @file_path }
|
41
41
|
nil
|
42
42
|
end
|
@@ -124,7 +124,7 @@ class Puppet::Util::Log
|
|
124
124
|
return
|
125
125
|
end
|
126
126
|
|
127
|
-
|
127
|
+
_, type = @desttypes.find do |name, klass|
|
128
128
|
klass.match?(dest)
|
129
129
|
end
|
130
130
|
|
@@ -169,8 +169,10 @@ class Puppet::Util::Log
|
|
169
169
|
return Puppet::Util::CharacterEncoding.convert_to_utf_8(str) if str.valid_encoding?
|
170
170
|
|
171
171
|
# We only select the last 10 callers in the stack to avoid being spammy
|
172
|
-
_("Received a Log attribute with invalid encoding:%{log_message}
|
173
|
-
{ log_message: Puppet::Util::CharacterEncoding.convert_to_utf_8(str.dump)
|
172
|
+
message = _("Received a Log attribute with invalid encoding:%{log_message}") %
|
173
|
+
{ log_message: Puppet::Util::CharacterEncoding.convert_to_utf_8(str.dump)}
|
174
|
+
message += '\n' + _("Backtrace:\n%{backtrace}") % { backtrace: caller[0..10].join("\n") }
|
175
|
+
message
|
174
176
|
end
|
175
177
|
|
176
178
|
public
|
@@ -69,7 +69,7 @@ if Puppet::Util::Platform.windows?
|
|
69
69
|
Puppet::Util::Windows::RootCerts.instance.to_a.uniq { |cert| cert.to_der }.each do |x509|
|
70
70
|
begin
|
71
71
|
add_cert(x509)
|
72
|
-
rescue OpenSSL::X509::StoreError
|
72
|
+
rescue OpenSSL::X509::StoreError
|
73
73
|
warn "Failed to add #{x509.subject.to_s}"
|
74
74
|
end
|
75
75
|
end
|
@@ -67,10 +67,10 @@ class Puppet::Util::NetworkDevice::Config
|
|
67
67
|
count += 1
|
68
68
|
}
|
69
69
|
}
|
70
|
-
rescue Errno::EACCES
|
70
|
+
rescue Errno::EACCES
|
71
71
|
Puppet.err _("Configuration error: Cannot read %{file}; cannot serve") % { file: @file }
|
72
72
|
#raise Puppet::Error, "Cannot read #{@config}"
|
73
|
-
rescue Errno::ENOENT
|
73
|
+
rescue Errno::ENOENT
|
74
74
|
Puppet.err _("Configuration error: '%{file}' does not exit; cannot serve") % { file: @file }
|
75
75
|
end
|
76
76
|
|
@@ -45,7 +45,9 @@ module Puppet::Util::Plist
|
|
45
45
|
{:failonfail => true, :combine => true})
|
46
46
|
return parse_plist(plist)
|
47
47
|
rescue Puppet::ExecutionFailure => detail
|
48
|
-
|
48
|
+
message = _("Cannot read file %{file_path}; Puppet is skipping it.") % { file_path: file_path }
|
49
|
+
message += '\n' + _("Details: %{detail}") % { detail: detail }
|
50
|
+
Puppet.warning(message)
|
49
51
|
end
|
50
52
|
end
|
51
53
|
return nil
|
@@ -122,11 +124,11 @@ module Puppet::Util::Plist
|
|
122
124
|
|
123
125
|
def to_format(format)
|
124
126
|
if format.to_sym == :xml
|
125
|
-
|
127
|
+
CFPropertyList::List::FORMAT_XML
|
126
128
|
elsif format.to_sym == :binary
|
127
|
-
|
129
|
+
CFPropertyList::List::FORMAT_BINARY
|
128
130
|
elsif format.to_sym == :plain
|
129
|
-
|
131
|
+
CFPropertyList::List::FORMAT_PLAIN
|
130
132
|
else
|
131
133
|
raise FormatError.new "Unknown plist format #{format}"
|
132
134
|
end
|
@@ -53,7 +53,7 @@ class Puppet::Util::Storage
|
|
53
53
|
Puppet.warning(_("Checksumfile %{filename} is not a file, ignoring") % { filename: filename })
|
54
54
|
return
|
55
55
|
end
|
56
|
-
Puppet::Util.benchmark(:debug, "Loaded state") do
|
56
|
+
Puppet::Util.benchmark(:debug, "Loaded state in %{seconds} seconds") do
|
57
57
|
begin
|
58
58
|
@@state = Puppet::Util::Yaml.load_file(filename)
|
59
59
|
rescue Puppet::Util::Yaml::YamlLoadError => detail
|
@@ -82,7 +82,7 @@ class Puppet::Util::Storage
|
|
82
82
|
|
83
83
|
Puppet.info _("Creating state file %{file}") % { file: Puppet[:statefile] } unless Puppet::FileSystem.exist?(Puppet[:statefile])
|
84
84
|
|
85
|
-
Puppet::Util.benchmark(:debug, "Stored state") do
|
85
|
+
Puppet::Util.benchmark(:debug, "Stored state in %{seconds} seconds") do
|
86
86
|
Puppet::Util::Yaml.dump(@@state, Puppet[:statefile])
|
87
87
|
end
|
88
88
|
end
|
@@ -44,7 +44,7 @@ module Puppet::Util::Windows
|
|
44
44
|
index = 0
|
45
45
|
subkey = nil
|
46
46
|
|
47
|
-
subkey_max_len,
|
47
|
+
subkey_max_len, _ = reg_query_info_key_max_lengths(key)
|
48
48
|
|
49
49
|
begin
|
50
50
|
subkey, filetime = reg_enum_key(key, index, subkey_max_len)
|
@@ -69,7 +69,7 @@ module Puppet::Util::Windows
|
|
69
69
|
index = 0
|
70
70
|
subkey = nil
|
71
71
|
|
72
|
-
|
72
|
+
_, value_max_len = reg_query_info_key_max_lengths(key)
|
73
73
|
|
74
74
|
begin
|
75
75
|
subkey, type, data = reg_enum_value(key, index, value_max_len)
|