puppet 3.1.1 → 3.2.0.rc1
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.
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +32 -19
- data/README_DEVELOPER.md +332 -14
- data/Rakefile +9 -5
- data/ext/build_defaults.yaml +2 -3
- data/ext/debian/changelog.erb +6 -0
- data/ext/debian/control +6 -6
- data/ext/envpuppet +4 -4
- data/ext/project_data.yaml +1 -0
- data/ext/puppet-nm-dispatcher +13 -0
- data/ext/redhat/puppet.spec.erb +17 -0
- data/ext/suse/client.init +1 -1
- data/ext/systemd/puppetagent.service +2 -2
- data/ext/systemd/puppetmaster.service +2 -2
- data/lib/hiera/scope.rb +29 -11
- data/lib/hiera_puppet.rb +1 -3
- data/lib/puppet/agent.rb +3 -3
- data/lib/puppet/application.rb +2 -2
- data/lib/puppet/application/agent.rb +27 -12
- data/lib/puppet/application/apply.rb +11 -1
- data/lib/puppet/application/describe.rb +1 -1
- data/lib/puppet/application/doc.rb +13 -9
- data/lib/puppet/application/filebucket.rb +0 -1
- data/lib/puppet/application/kick.rb +1 -0
- data/lib/puppet/application/master.rb +16 -8
- data/lib/puppet/daemon.rb +19 -64
- data/lib/puppet/defaults.rb +61 -5
- data/lib/puppet/error.rb +15 -4
- data/lib/puppet/external/nagios/grammar.ry +1 -1
- data/lib/puppet/external/nagios/makefile +1 -1
- data/lib/puppet/external/nagios/parser.rb +185 -618
- data/lib/puppet/external/pson/pure/parser.rb +47 -1
- data/lib/puppet/face/certificate.rb +3 -3
- data/lib/puppet/face/module.rb +1 -1
- data/lib/puppet/face/module/changes.rb +3 -1
- data/lib/puppet/face/module/uninstall.rb +1 -1
- data/lib/puppet/face/node/clean.rb +5 -5
- data/lib/puppet/feature/base.rb +3 -1
- data/lib/puppet/feature/libuser.rb +8 -0
- data/lib/puppet/file_serving/fileset.rb +9 -1
- data/lib/puppet/forge.rb +28 -5
- data/lib/puppet/forge/errors.rb +34 -0
- data/lib/puppet/forge/repository.rb +1 -1
- data/lib/puppet/indirector.rb +4 -1
- data/lib/puppet/indirector/catalog/compiler.rb +37 -30
- data/lib/puppet/indirector/facts/inventory_active_record.rb +1 -0
- data/lib/puppet/indirector/indirection.rb +28 -15
- data/lib/puppet/indirector/rest.rb +18 -10
- data/lib/puppet/interface.rb +11 -4
- data/lib/puppet/interface/action.rb +1 -3
- data/lib/puppet/interface/action_builder.rb +0 -3
- data/lib/puppet/interface/action_manager.rb +0 -3
- data/lib/puppet/interface/face_collection.rb +0 -2
- data/lib/puppet/interface/option.rb +0 -2
- data/lib/puppet/interface/option_builder.rb +0 -2
- data/lib/puppet/interface/option_manager.rb +0 -2
- data/lib/puppet/metatype/manager.rb +1 -1
- data/lib/puppet/module_tool.rb +1 -0
- data/lib/puppet/module_tool/applications/application.rb +0 -3
- data/lib/puppet/module_tool/applications/builder.rb +8 -20
- data/lib/puppet/module_tool/applications/checksummer.rb +1 -1
- data/lib/puppet/module_tool/applications/installer.rb +1 -0
- data/lib/puppet/module_tool/applications/unpacker.rb +3 -11
- data/lib/puppet/module_tool/checksums.rb +1 -1
- data/lib/puppet/module_tool/errors/installer.rb +18 -1
- data/lib/puppet/module_tool/modulefile.rb +2 -2
- data/lib/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +1 -1
- data/lib/puppet/module_tool/tar.rb +17 -0
- data/lib/puppet/module_tool/tar/gnu.rb +9 -0
- data/lib/puppet/module_tool/tar/mini.rb +39 -0
- data/lib/puppet/module_tool/tar/solaris.rb +5 -0
- data/lib/puppet/network/http.rb +1 -0
- data/lib/puppet/network/http/connection.rb +9 -23
- data/lib/puppet/network/http/handler.rb +38 -7
- data/lib/puppet/network/http/rack/rest.rb +14 -3
- data/lib/puppet/network/http/webrick.rb +3 -1
- data/lib/puppet/network/http/webrick/rest.rb +11 -2
- data/lib/puppet/node/environment.rb +3 -1
- data/lib/puppet/parameter.rb +32 -29
- data/lib/puppet/parameter/package_options.rb +1 -1
- data/lib/puppet/parameter/path.rb +1 -1
- data/lib/puppet/parameter/value.rb +1 -1
- data/lib/puppet/parameter/value_collection.rb +7 -3
- data/lib/puppet/parser/ast.rb +3 -1
- data/lib/puppet/parser/ast/arithmetic_operator.rb +56 -12
- data/lib/puppet/parser/ast/astarray.rb +1 -1
- data/lib/puppet/parser/ast/block_expression.rb +41 -0
- data/lib/puppet/parser/ast/function.rb +13 -2
- data/lib/puppet/parser/ast/lambda.rb +107 -0
- data/lib/puppet/parser/ast/leaf.rb +1 -2
- data/lib/puppet/parser/ast/method_call.rb +77 -0
- data/lib/puppet/parser/ast/vardef.rb +7 -0
- data/lib/puppet/parser/compiler.rb +27 -16
- data/lib/puppet/parser/e_parser_adapter.rb +120 -0
- data/lib/puppet/parser/files.rb +7 -6
- data/lib/puppet/parser/functions.rb +10 -8
- data/lib/puppet/parser/functions/collect.rb +43 -0
- data/lib/puppet/parser/functions/each.rb +96 -0
- data/lib/puppet/parser/functions/foreach.rb +96 -0
- data/lib/puppet/parser/functions/fqdn_rand.rb +2 -2
- data/lib/puppet/parser/functions/hiera.rb +20 -2
- data/lib/puppet/parser/functions/hiera_array.rb +21 -2
- data/lib/puppet/parser/functions/hiera_hash.rb +23 -2
- data/lib/puppet/parser/functions/hiera_include.rb +33 -2
- data/lib/puppet/parser/functions/inline_template.rb +4 -4
- data/lib/puppet/parser/functions/reduce.rb +74 -0
- data/lib/puppet/parser/functions/reject.rb +46 -0
- data/lib/puppet/parser/functions/select.rb +46 -0
- data/lib/puppet/parser/functions/slice.rb +96 -0
- data/lib/puppet/parser/functions/template.rb +2 -2
- data/lib/puppet/parser/grammar.ra +7 -4
- data/lib/puppet/parser/lexer.rb +10 -0
- data/lib/puppet/parser/methods.rb +69 -0
- data/lib/puppet/parser/parser.rb +855 -808
- data/lib/puppet/parser/parser_factory.rb +62 -0
- data/lib/puppet/parser/parser_support.rb +8 -2
- data/lib/puppet/parser/scope.rb +153 -47
- data/lib/puppet/parser/templatewrapper.rb +28 -21
- data/lib/puppet/parser/type_loader.rb +3 -1
- data/lib/puppet/pops.rb +40 -0
- data/lib/puppet/pops/adaptable.rb +190 -0
- data/lib/puppet/pops/adapters.rb +65 -0
- data/lib/puppet/pops/containment.rb +37 -0
- data/lib/puppet/pops/issues.rb +258 -0
- data/lib/puppet/pops/label_provider.rb +71 -0
- data/lib/puppet/pops/model/ast_transformer.rb +636 -0
- data/lib/puppet/pops/model/ast_tree_dumper.rb +378 -0
- data/lib/puppet/pops/model/factory.rb +804 -0
- data/lib/puppet/pops/model/model.rb +567 -0
- data/lib/puppet/pops/model/model_label_provider.rb +75 -0
- data/lib/puppet/pops/model/model_tree_dumper.rb +352 -0
- data/lib/puppet/pops/model/tree_dumper.rb +59 -0
- data/lib/puppet/pops/parser/egrammar.ra +723 -0
- data/lib/puppet/pops/parser/eparser.rb +2300 -0
- data/lib/puppet/pops/parser/grammar.ra +746 -0
- data/lib/puppet/pops/parser/lexer.rb +842 -0
- data/lib/puppet/pops/parser/makefile +13 -0
- data/lib/puppet/pops/parser/parser_support.rb +203 -0
- data/lib/puppet/pops/patterns.rb +35 -0
- data/lib/puppet/pops/utils.rb +104 -0
- data/lib/puppet/pops/validation.rb +297 -0
- data/lib/puppet/pops/validation/checker3_1.rb +551 -0
- data/lib/puppet/pops/validation/validator_factory_3_1.rb +41 -0
- data/lib/puppet/pops/visitable.rb +6 -0
- data/lib/puppet/pops/visitor.rb +50 -0
- data/lib/puppet/property.rb +37 -28
- data/lib/puppet/property/ensure.rb +2 -2
- data/lib/puppet/property/ordered_list.rb +1 -1
- data/lib/puppet/provider.rb +26 -30
- data/lib/puppet/provider/aixobject.rb +45 -44
- data/lib/puppet/provider/augeas/augeas.rb +0 -1
- data/lib/puppet/provider/confiner.rb +1 -1
- data/lib/puppet/provider/cron/crontab.rb +107 -67
- data/lib/puppet/provider/group/groupadd.rb +59 -3
- data/lib/puppet/provider/interface/cisco.rb +4 -4
- data/lib/puppet/provider/mount/parsed.rb +1 -1
- data/lib/puppet/provider/nameservice.rb +22 -6
- data/lib/puppet/provider/nameservice/pw.rb +1 -1
- data/lib/puppet/provider/package/aix.rb +28 -4
- data/lib/puppet/provider/package/gem.rb +0 -2
- data/lib/puppet/provider/package/macports.rb +1 -1
- data/lib/puppet/provider/package/nim.rb +249 -4
- data/lib/puppet/provider/package/opkg.rb +77 -0
- data/lib/puppet/provider/package/pacman.rb +2 -2
- data/lib/puppet/provider/package/rpm.rb +30 -16
- data/lib/puppet/provider/package/yum.rb +3 -3
- data/lib/puppet/provider/parsedfile.rb +80 -3
- data/lib/puppet/provider/selmodule/semodule.rb +2 -2
- data/lib/puppet/provider/service/debian.rb +0 -4
- data/lib/puppet/provider/service/freebsd.rb +2 -2
- data/lib/puppet/provider/service/gentoo.rb +0 -9
- data/lib/puppet/provider/service/init.rb +27 -2
- data/lib/puppet/provider/service/launchd.rb +1 -1
- data/lib/puppet/provider/service/openwrt.rb +36 -0
- data/lib/puppet/provider/service/redhat.rb +0 -9
- data/lib/puppet/provider/service/src.rb +38 -4
- data/lib/puppet/provider/service/systemd.rb +2 -2
- data/lib/puppet/provider/service/upstart.rb +1 -8
- data/lib/puppet/provider/user/aix.rb +4 -10
- data/lib/puppet/provider/user/pw.rb +6 -10
- data/lib/puppet/provider/user/useradd.rb +129 -31
- data/lib/puppet/provider/vlan/cisco.rb +4 -4
- data/lib/puppet/reference/function.rb +2 -2
- data/lib/puppet/reference/indirection.rb +46 -5
- data/lib/puppet/reference/metaparameter.rb +2 -2
- data/lib/puppet/reports.rb +5 -5
- data/lib/puppet/reports/rrdgraph.rb +4 -4
- data/lib/puppet/reports/tagmail.rb +1 -1
- data/lib/puppet/resource.rb +1 -1
- data/lib/puppet/resource/type.rb +13 -11
- data/lib/puppet/scheduler.rb +16 -0
- data/lib/puppet/scheduler/job.rb +53 -0
- data/lib/puppet/scheduler/scheduler.rb +45 -0
- data/lib/puppet/scheduler/splay_job.rb +32 -0
- data/lib/puppet/scheduler/timer.rb +13 -0
- data/lib/puppet/settings/base_setting.rb +1 -1
- data/lib/puppet/simple_graph.rb +4 -4
- data/lib/puppet/ssl/base.rb +12 -2
- data/lib/puppet/ssl/certificate.rb +4 -1
- data/lib/puppet/ssl/certificate_request.rb +4 -1
- data/lib/puppet/ssl/certificate_revocation_list.rb +4 -1
- data/lib/puppet/ssl/configuration.rb +32 -0
- data/lib/puppet/ssl/host.rb +18 -21
- data/lib/puppet/ssl/key.rb +4 -1
- data/lib/puppet/ssl/validator.rb +116 -0
- data/lib/puppet/transaction.rb +1 -1
- data/lib/puppet/transaction/event.rb +3 -10
- data/lib/puppet/transaction/event_manager.rb +8 -1
- data/lib/puppet/transaction/report.rb +17 -16
- data/lib/puppet/type.rb +77 -69
- data/lib/puppet/type/cron.rb +20 -8
- data/lib/puppet/type/exec.rb +9 -3
- data/lib/puppet/type/file.rb +95 -21
- data/lib/puppet/type/file/content.rb +1 -1
- data/lib/puppet/type/file/mode.rb +7 -1
- data/lib/puppet/type/file/source.rb +2 -2
- data/lib/puppet/type/group.rb +11 -0
- data/lib/puppet/type/scheduled_task.rb +5 -1
- data/lib/puppet/type/service.rb +1 -1
- data/lib/puppet/type/ssh_authorized_key.rb +2 -2
- data/lib/puppet/type/user.rb +24 -6
- data/lib/puppet/util.rb +12 -2
- data/lib/puppet/util/classgen.rb +4 -4
- data/lib/puppet/util/colors.rb +55 -0
- data/lib/puppet/util/command_line/trollop.rb +4 -4
- data/lib/puppet/util/errors.rb +39 -3
- data/lib/puppet/util/fileparsing.rb +5 -0
- data/lib/puppet/util/filetype.rb +11 -9
- data/lib/puppet/util/instrumentation/instrumentable.rb +2 -2
- data/lib/puppet/util/libuser.conf +15 -0
- data/lib/puppet/util/libuser.rb +12 -0
- data/lib/puppet/util/monkey_patches.rb +48 -0
- data/lib/puppet/util/network_device.rb +1 -1
- data/lib/puppet/util/network_device/base.rb +2 -2
- data/lib/puppet/util/network_device/cisco/device.rb +29 -19
- data/lib/puppet/util/network_device/config.rb +5 -2
- data/lib/puppet/util/network_device/ipcalc.rb +1 -1
- data/lib/puppet/util/network_device/transport/ssh.rb +4 -3
- data/lib/puppet/util/network_device/transport/telnet.rb +4 -2
- data/lib/puppet/util/plugins.rb +4 -4
- data/lib/puppet/util/posix.rb +1 -1
- data/lib/puppet/util/profiler.rb +28 -0
- data/lib/puppet/util/profiler/logging.rb +47 -0
- data/lib/puppet/util/profiler/none.rb +8 -0
- data/lib/puppet/util/profiler/object_counts.rb +17 -0
- data/lib/puppet/util/profiler/wall_clock.rb +34 -0
- data/lib/puppet/util/provider_features.rb +1 -1
- data/lib/puppet/util/rdoc/parser.rb +5 -5
- data/lib/puppet/util/ssl.rb +38 -0
- data/lib/puppet/util/subclass_loader.rb +1 -5
- data/lib/puppet/util/windows.rb +1 -0
- data/lib/puppet/util/windows/process.rb +3 -0
- data/lib/puppet/util/windows/root_certs.rb +86 -0
- data/lib/puppet/util/windows/security.rb +1 -0
- data/lib/puppet/version.rb +1 -1
- data/spec/fixtures/integration/provider/cron/crontab/create_normal_entry +19 -0
- data/spec/fixtures/integration/provider/cron/crontab/create_special_entry +18 -0
- data/spec/fixtures/integration/provider/cron/crontab/crontab_user1 +15 -0
- data/spec/fixtures/integration/provider/cron/crontab/crontab_user2 +4 -0
- data/spec/fixtures/integration/provider/cron/crontab/modify_entry +13 -0
- data/spec/fixtures/integration/provider/cron/crontab/moved_cronjob_input1 +15 -0
- data/spec/fixtures/integration/provider/cron/crontab/moved_cronjob_input2 +6 -0
- data/spec/fixtures/integration/provider/cron/crontab/remove_named_resource +12 -0
- data/spec/fixtures/integration/provider/cron/crontab/remove_unnamed_resource +14 -0
- data/spec/fixtures/unit/pops/parser/lexer/aliastest.pp +16 -0
- data/spec/fixtures/unit/pops/parser/lexer/append.pp +11 -0
- data/spec/fixtures/unit/pops/parser/lexer/argumentdefaults.pp +14 -0
- data/spec/fixtures/unit/pops/parser/lexer/arithmetic_expression.pp +8 -0
- data/spec/fixtures/unit/pops/parser/lexer/arraytrailingcomma.pp +3 -0
- data/spec/fixtures/unit/pops/parser/lexer/casestatement.pp +65 -0
- data/spec/fixtures/unit/pops/parser/lexer/classheirarchy.pp +15 -0
- data/spec/fixtures/unit/pops/parser/lexer/classincludes.pp +17 -0
- data/spec/fixtures/unit/pops/parser/lexer/classpathtest.pp +11 -0
- data/spec/fixtures/unit/pops/parser/lexer/collection.pp +10 -0
- data/spec/fixtures/unit/pops/parser/lexer/collection_override.pp +8 -0
- data/spec/fixtures/unit/pops/parser/lexer/collection_within_virtual_definitions.pp +20 -0
- data/spec/fixtures/unit/pops/parser/lexer/componentmetaparams.pp +11 -0
- data/spec/fixtures/unit/pops/parser/lexer/componentrequire.pp +8 -0
- data/spec/fixtures/unit/pops/parser/lexer/deepclassheirarchy.pp +23 -0
- data/spec/fixtures/unit/pops/parser/lexer/defineoverrides.pp +17 -0
- data/spec/fixtures/unit/pops/parser/lexer/emptyclass.pp +9 -0
- data/spec/fixtures/unit/pops/parser/lexer/emptyexec.pp +3 -0
- data/spec/fixtures/unit/pops/parser/lexer/emptyifelse.pp +9 -0
- data/spec/fixtures/unit/pops/parser/lexer/falsevalues.pp +3 -0
- data/spec/fixtures/unit/pops/parser/lexer/filecreate.pp +11 -0
- data/spec/fixtures/unit/pops/parser/lexer/fqdefinition.pp +5 -0
- data/spec/fixtures/unit/pops/parser/lexer/fqparents.pp +11 -0
- data/spec/fixtures/unit/pops/parser/lexer/funccomma.pp +5 -0
- data/spec/fixtures/unit/pops/parser/lexer/hash.pp +33 -0
- data/spec/fixtures/unit/pops/parser/lexer/ifexpression.pp +12 -0
- data/spec/fixtures/unit/pops/parser/lexer/implicititeration.pp +15 -0
- data/spec/fixtures/unit/pops/parser/lexer/multilinecomments.pp +10 -0
- data/spec/fixtures/unit/pops/parser/lexer/multipleclass.pp +9 -0
- data/spec/fixtures/unit/pops/parser/lexer/multipleinstances.pp +7 -0
- data/spec/fixtures/unit/pops/parser/lexer/multisubs.pp +13 -0
- data/spec/fixtures/unit/pops/parser/lexer/namevartest.pp +9 -0
- data/spec/fixtures/unit/pops/parser/lexer/scopetest.pp +13 -0
- data/spec/fixtures/unit/pops/parser/lexer/selectorvalues.pp +49 -0
- data/spec/fixtures/unit/pops/parser/lexer/simpledefaults.pp +5 -0
- data/spec/fixtures/unit/pops/parser/lexer/simpleselector.pp +38 -0
- data/spec/fixtures/unit/pops/parser/lexer/singleary.pp +19 -0
- data/spec/fixtures/unit/pops/parser/lexer/singlequote.pp +11 -0
- data/spec/fixtures/unit/pops/parser/lexer/singleselector.pp +22 -0
- data/spec/fixtures/unit/pops/parser/lexer/subclass_name_duplication.pp +11 -0
- data/spec/fixtures/unit/pops/parser/lexer/tag.pp +9 -0
- data/spec/fixtures/unit/pops/parser/lexer/tagged.pp +35 -0
- data/spec/fixtures/unit/pops/parser/lexer/virtualresources.pp +14 -0
- data/spec/fixtures/unit/provider/cron/crontab/single_line.yaml +4 -4
- data/spec/fixtures/unit/provider/cron/crontab/vixie_header.txt +3 -0
- data/spec/fixtures/unit/provider/cron/parsed/managed +6 -0
- data/spec/fixtures/unit/provider/cron/parsed/simple +9 -0
- data/spec/fixtures/unit/provider/parsedfile/simple.txt +4 -0
- data/spec/fixtures/unit/provider/service/systemd/list_units +18 -0
- data/spec/integration/parser/collector_spec.rb +1 -1
- data/spec/integration/parser/compiler_spec.rb +252 -227
- data/spec/integration/parser/parser_spec.rb +171 -53
- data/spec/integration/parser/scope_spec.rb +1 -1
- data/spec/integration/provider/cron/crontab_spec.rb +187 -0
- data/spec/integration/provider/service/systemd_spec.rb +20 -0
- data/spec/integration/type/file_spec.rb +21 -21
- data/spec/integration/type/package_spec.rb +1 -1
- data/spec/lib/puppet_spec/database.rb +2 -5
- data/spec/spec_helper.rb +6 -1
- data/spec/unit/application/apply_spec.rb +16 -1
- data/spec/unit/application/describe_spec.rb +1 -1
- data/spec/unit/application/doc_spec.rb +55 -32
- data/spec/unit/application/kick_spec.rb +8 -6
- data/spec/unit/application/master_spec.rb +4 -4
- data/spec/unit/daemon_spec.rb +1 -1
- data/spec/unit/forge/errors_spec.rb +40 -0
- data/spec/unit/forge/repository_spec.rb +11 -1
- data/spec/unit/forge_spec.rb +13 -3
- data/spec/unit/hiera/backend/puppet_backend_spec.rb +1 -0
- data/spec/unit/hiera/scope_spec.rb +48 -25
- data/spec/unit/indirector/catalog/active_record_spec.rb +6 -3
- data/spec/unit/indirector/catalog/compiler_spec.rb +3 -28
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +1 -1
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +154 -150
- data/spec/unit/indirector/indirection_spec.rb +5 -0
- data/spec/unit/indirector/resource/active_record_spec.rb +5 -22
- data/spec/unit/indirector_spec.rb +7 -1
- data/spec/unit/interface/action_builder_spec.rb +1 -1
- data/spec/unit/interface/action_manager_spec.rb +0 -2
- data/spec/unit/interface/action_spec.rb +1 -1
- data/spec/unit/interface/documentation_spec.rb +0 -2
- data/spec/unit/interface/face_collection_spec.rb +1 -1
- data/spec/unit/interface/option_builder_spec.rb +1 -1
- data/spec/unit/interface/option_spec.rb +0 -1
- data/spec/unit/module_spec.rb +17 -19
- data/spec/unit/module_tool/application_spec.rb +1 -3
- data/spec/unit/module_tool/applications/builder_spec.rb +38 -0
- data/spec/unit/module_tool/applications/checksummer_spec.rb +134 -0
- data/spec/unit/module_tool/applications/installer_spec.rb +71 -91
- data/spec/unit/module_tool/applications/searcher_spec.rb +1 -3
- data/spec/unit/module_tool/applications/uninstaller_spec.rb +18 -26
- data/spec/unit/module_tool/applications/unpacker_spec.rb +19 -52
- data/spec/unit/module_tool/tar/gnu_spec.rb +19 -0
- data/spec/unit/module_tool/tar/mini_spec.rb +59 -0
- data/spec/unit/module_tool/tar/solaris_spec.rb +19 -0
- data/spec/unit/network/http/connection_spec.rb +17 -2
- data/spec/unit/network/http/handler_spec.rb +195 -167
- data/spec/unit/network/http/rack/rest_spec.rb +26 -4
- data/spec/unit/network/http/webrick/rest_spec.rb +28 -1
- data/spec/unit/network/http/webrick_spec.rb +12 -3
- data/spec/unit/node/environment_spec.rb +421 -404
- data/spec/unit/parser/ast/arithmetic_operator_spec.rb +98 -2
- data/spec/unit/parser/collector_spec.rb +4 -4
- data/spec/unit/parser/compiler_spec.rb +13 -13
- data/spec/unit/parser/eparser_adapter_spec.rb +407 -0
- data/spec/unit/parser/functions/extlookup_spec.rb +20 -17
- data/spec/unit/parser/functions/fqdn_rand_spec.rb +5 -0
- data/spec/unit/parser/functions/hiera_include_spec.rb +0 -2
- data/spec/unit/parser/functions/hiera_spec.rb +0 -2
- data/spec/unit/parser/functions_spec.rb +27 -15
- data/spec/unit/parser/methods/collect_spec.rb +110 -0
- data/spec/unit/parser/methods/each_spec.rb +91 -0
- data/spec/unit/parser/methods/foreach_spec.rb +91 -0
- data/spec/unit/parser/methods/reduce_spec.rb +67 -0
- data/spec/unit/parser/methods/reject_spec.rb +73 -0
- data/spec/unit/parser/methods/select_spec.rb +79 -0
- data/spec/unit/parser/methods/shared.rb +61 -0
- data/spec/unit/parser/methods/slice_spec.rb +97 -0
- data/spec/unit/parser/parser_spec.rb +2 -2
- data/spec/unit/parser/scope_spec.rb +39 -16
- data/spec/unit/parser/templatewrapper_spec.rb +6 -5
- data/spec/unit/parser/type_loader_spec.rb +191 -165
- data/spec/unit/pops/adaptable_spec.rb +143 -0
- data/spec/unit/pops/containment_spec.rb +25 -0
- data/spec/unit/pops/factory_rspec_helper.rb +77 -0
- data/spec/unit/pops/factory_spec.rb +329 -0
- data/spec/unit/pops/issues_spec.rb +26 -0
- data/spec/unit/pops/label_provider_spec.rb +42 -0
- data/spec/unit/pops/model/ast_transformer_spec.rb +65 -0
- data/spec/unit/pops/model/model_spec.rb +37 -0
- data/spec/unit/pops/parser/lexer_spec.rb +884 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +248 -0
- data/spec/unit/pops/parser/parse_calls_spec.rb +93 -0
- data/spec/unit/pops/parser/parse_conditionals_spec.rb +159 -0
- data/spec/unit/pops/parser/parse_containers_spec.rb +175 -0
- data/spec/unit/pops/parser/parse_resource_spec.rb +228 -0
- data/spec/unit/pops/parser/parser_rspec_helper.rb +11 -0
- data/spec/unit/pops/parser/parser_spec.rb +15 -0
- data/spec/unit/pops/parser/rgen_sanitycheck_spec.rb +16 -0
- data/spec/unit/pops/transformer/transform_basic_expressions_spec.rb +243 -0
- data/spec/unit/pops/transformer/transform_calls_spec.rb +80 -0
- data/spec/unit/pops/transformer/transform_conditionals_spec.rb +132 -0
- data/spec/unit/pops/transformer/transform_containers_spec.rb +182 -0
- data/spec/unit/pops/transformer/transform_resource_spec.rb +185 -0
- data/spec/unit/pops/transformer/transformer_rspec_helper.rb +27 -0
- data/spec/unit/pops/visitor_spec.rb +94 -0
- data/spec/unit/property_spec.rb +11 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +3 -0
- data/spec/unit/provider/cron/crontab_spec.rb +97 -7
- data/spec/unit/provider/cron/parsed_spec.rb +325 -0
- data/spec/unit/provider/exec/posix_spec.rb +1 -1
- data/spec/unit/provider/group/groupadd_spec.rb +33 -3
- data/spec/unit/provider/group/pw_spec.rb +5 -5
- data/spec/unit/provider/nameservice_spec.rb +304 -0
- data/spec/unit/provider/package/aix_spec.rb +53 -11
- data/spec/unit/provider/package/aptrpm_spec.rb +6 -0
- data/spec/unit/provider/package/gem_spec.rb +6 -11
- data/spec/unit/provider/package/nim_spec.rb +216 -7
- data/spec/unit/provider/package/opkg_spec.rb +180 -0
- data/spec/unit/provider/package/rpm_spec.rb +149 -3
- data/spec/unit/provider/package/yum_spec.rb +6 -5
- data/spec/unit/provider/parsedfile_spec.rb +122 -28
- data/spec/unit/provider/service/freebsd_spec.rb +18 -0
- data/spec/unit/provider/service/init_spec.rb +108 -87
- data/spec/unit/provider/service/launchd_spec.rb +2 -2
- data/spec/unit/provider/service/openwrt_spec.rb +109 -0
- data/spec/unit/provider/service/src_spec.rb +117 -41
- data/spec/unit/provider/service/systemd_spec.rb +125 -17
- data/spec/unit/provider/service/upstart_spec.rb +1 -1
- data/spec/unit/provider/user/aix_spec.rb +42 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +1 -0
- data/spec/unit/provider/user/pw_spec.rb +24 -12
- data/spec/unit/provider/user/user_role_add_spec.rb +1 -1
- data/spec/unit/provider/user/useradd_spec.rb +179 -15
- data/spec/unit/resource/type_spec.rb +3 -3
- data/spec/unit/scheduler/job_spec.rb +79 -0
- data/spec/unit/scheduler/scheduler_spec.rb +129 -0
- data/spec/unit/scheduler/splay_job_spec.rb +35 -0
- data/spec/unit/ssl/base_spec.rb +3 -9
- data/spec/unit/ssl/certificate_authority_spec.rb +1 -0
- data/spec/unit/ssl/certificate_request_spec.rb +3 -1
- data/spec/unit/ssl/certificate_spec.rb +3 -1
- data/spec/unit/ssl/configuration_spec.rb +74 -0
- data/spec/unit/ssl/host_spec.rb +28 -7
- data/spec/unit/ssl/validator_spec.rb +311 -0
- data/spec/unit/transaction/event_manager_spec.rb +49 -0
- data/spec/unit/transaction/event_spec.rb +20 -5
- data/spec/unit/transaction/report_spec.rb +8 -0
- data/spec/unit/type/cron_spec.rb +9 -0
- data/spec/unit/type/exec_spec.rb +11 -0
- data/spec/unit/type/file/content_spec.rb +20 -20
- data/spec/unit/type/file/mode_spec.rb +6 -0
- data/spec/unit/type/file/source_spec.rb +9 -7
- data/spec/unit/type/file_spec.rb +22 -3
- data/spec/unit/type/service_spec.rb +34 -21
- data/spec/unit/type_spec.rb +46 -1
- data/spec/unit/util/backups_spec.rb +2 -2
- data/spec/unit/util/execution_spec.rb +4 -1
- data/spec/unit/util/filetype_spec.rb +6 -0
- data/spec/unit/util/monkey_patches_spec.rb +18 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +37 -0
- data/spec/unit/util/network_device/config_spec.rb +14 -0
- data/spec/unit/util/network_device_spec.rb +3 -3
- data/spec/unit/util/profiler/logging_spec.rb +81 -0
- data/spec/unit/util/profiler/none_spec.rb +12 -0
- data/spec/unit/util/profiler/object_counts_spec.rb +14 -0
- data/spec/unit/util/profiler/wall_clock_spec.rb +13 -0
- data/spec/unit/util/pson_spec.rb +5 -0
- data/spec/unit/util/ssl_spec.rb +51 -0
- data/spec/unit/util/windows/root_certs_spec.rb +15 -0
- data/spec/unit/util_spec.rb +28 -0
- metadata +2593 -2307
- data/spec/unit/module_tool/applications/application_spec.rb +0 -19
|
@@ -12,6 +12,8 @@ class Puppet::Application::Apply < Puppet::Application
|
|
|
12
12
|
option("--use-nodes")
|
|
13
13
|
option("--detailed-exitcodes")
|
|
14
14
|
|
|
15
|
+
option("--write-catalog-summary")
|
|
16
|
+
|
|
15
17
|
option("--catalog catalog", "-c catalog") do |arg|
|
|
16
18
|
options[:catalog] = arg
|
|
17
19
|
end
|
|
@@ -45,7 +47,7 @@ USAGE
|
|
|
45
47
|
-----
|
|
46
48
|
puppet apply [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]
|
|
47
49
|
[-e|--execute] [--detailed-exitcodes] [-l|--logdest <file>] [--noop]
|
|
48
|
-
[--catalog <catalog>] <file>
|
|
50
|
+
[--catalog <catalog>] [--write-catalog-summary] <file>
|
|
49
51
|
|
|
50
52
|
|
|
51
53
|
DESCRIPTION
|
|
@@ -113,6 +115,9 @@ configuration options can also be generated by running puppet with
|
|
|
113
115
|
Apply a JSON catalog (such as one generated with 'puppet master --compile'). You can
|
|
114
116
|
either specify a JSON file or pipe in JSON from standard input.
|
|
115
117
|
|
|
118
|
+
* --write-catalog-summary
|
|
119
|
+
After compiling the catalog saves the resource list and classes list to the node
|
|
120
|
+
in the state directory named classes.txt and resources.txt
|
|
116
121
|
|
|
117
122
|
EXAMPLE
|
|
118
123
|
-------
|
|
@@ -210,6 +215,11 @@ Copyright (c) 2011 Puppet Labs, LLC Licensed under the Apache 2.0 License
|
|
|
210
215
|
|
|
211
216
|
catalog.retrieval_duration = Time.now - starttime
|
|
212
217
|
|
|
218
|
+
if options[:write_catalog_summary]
|
|
219
|
+
catalog.write_class_file
|
|
220
|
+
catalog.write_resource_file
|
|
221
|
+
end
|
|
222
|
+
|
|
213
223
|
exit_status = apply_catalog(catalog)
|
|
214
224
|
|
|
215
225
|
if not exit_status
|
|
@@ -235,6 +235,8 @@ HELP
|
|
|
235
235
|
else
|
|
236
236
|
setup_reference
|
|
237
237
|
end
|
|
238
|
+
|
|
239
|
+
setup_logging
|
|
238
240
|
end
|
|
239
241
|
|
|
240
242
|
def setup_reference
|
|
@@ -261,16 +263,18 @@ HELP
|
|
|
261
263
|
Puppet.settings.handlearg(option[:opt], option[:arg])
|
|
262
264
|
end
|
|
263
265
|
end
|
|
266
|
+
end
|
|
264
267
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
Puppet::Util::Log.newdestination(:console)
|
|
268
|
+
def setup_logging
|
|
269
|
+
# Handle the logging settings.
|
|
270
|
+
if options[:debug]
|
|
271
|
+
Puppet::Util::Log.level = :debug
|
|
272
|
+
elsif options[:verbose]
|
|
273
|
+
Puppet::Util::Log.level = :info
|
|
274
|
+
else
|
|
275
|
+
Puppet::Util::Log.level = :warning
|
|
274
276
|
end
|
|
277
|
+
|
|
278
|
+
Puppet::Util::Log.newdestination(:console)
|
|
275
279
|
end
|
|
276
280
|
end
|
|
@@ -57,22 +57,26 @@ executable is not used.
|
|
|
57
57
|
|
|
58
58
|
OPTIONS
|
|
59
59
|
-------
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
argument.
|
|
60
|
+
|
|
61
|
+
Note that any Puppet setting that's valid in the configuration file is also a
|
|
62
|
+
valid long argument. For example, 'server' is a valid setting, so you can
|
|
63
|
+
specify '--server <servername>' as an argument. Boolean settings translate into
|
|
64
|
+
'--setting' and '--no-setting' pairs.
|
|
64
65
|
|
|
65
66
|
See the configuration file documentation at
|
|
66
67
|
http://docs.puppetlabs.com/references/stable/configuration.html for the
|
|
67
|
-
full list of acceptable
|
|
68
|
-
|
|
69
|
-
with '--genconfig'.
|
|
68
|
+
full list of acceptable settings. A commented list of all settings can also be
|
|
69
|
+
generated by running puppet master with '--genconfig'.
|
|
70
70
|
|
|
71
71
|
* --daemonize:
|
|
72
72
|
Send the process into the background. This is the default.
|
|
73
|
+
(This is a Puppet setting, and can go in puppet.conf. Note the special 'no-'
|
|
74
|
+
prefix for boolean settings on the command line.)
|
|
73
75
|
|
|
74
76
|
* --no-daemonize:
|
|
75
77
|
Do not send the process into the background.
|
|
78
|
+
(This is a Puppet setting, and can go in puppet.conf. Note the special 'no-'
|
|
79
|
+
prefix for boolean settings on the command line.)
|
|
76
80
|
|
|
77
81
|
* --debug:
|
|
78
82
|
Enable full debugging.
|
|
@@ -85,6 +89,10 @@ with '--genconfig'.
|
|
|
85
89
|
file. Defaults to sending messages to syslog, or the console if
|
|
86
90
|
debugging or verbosity is enabled.
|
|
87
91
|
|
|
92
|
+
* --masterport:
|
|
93
|
+
The port on which to listen for traffic.
|
|
94
|
+
(This is a Puppet setting, and can go in puppet.conf.)
|
|
95
|
+
|
|
88
96
|
* --verbose:
|
|
89
97
|
Enable verbosity.
|
|
90
98
|
|
|
@@ -165,7 +173,7 @@ Copyright (c) 2012 Puppet Labs, LLC Licensed under the Apache 2.0 License
|
|
|
165
173
|
raise "Could not compile catalog for #{options[:node]}"
|
|
166
174
|
end
|
|
167
175
|
|
|
168
|
-
|
|
176
|
+
puts PSON::pretty_generate(catalog.to_resource, :allow_nan => true, :max_nesting => false)
|
|
169
177
|
rescue => detail
|
|
170
178
|
$stderr.puts detail
|
|
171
179
|
exit(30)
|
data/lib/puppet/daemon.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'puppet'
|
|
2
2
|
require 'puppet/util/pidlock'
|
|
3
3
|
require 'puppet/application'
|
|
4
|
+
require 'puppet/scheduler'
|
|
4
5
|
|
|
5
6
|
# A module that handles operations common to all daemons. This is included
|
|
6
7
|
# into the Server and Client base classes.
|
|
@@ -79,7 +80,7 @@ class Puppet::Daemon
|
|
|
79
80
|
return
|
|
80
81
|
end
|
|
81
82
|
|
|
82
|
-
agent.run
|
|
83
|
+
agent.run({:splay => false})
|
|
83
84
|
end
|
|
84
85
|
|
|
85
86
|
# Remove the pid file for our daemon.
|
|
@@ -146,73 +147,27 @@ class Puppet::Daemon
|
|
|
146
147
|
end
|
|
147
148
|
|
|
148
149
|
def run_event_loop
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
agent_run_interval = [Puppet[:runinterval], 0].max
|
|
162
|
-
|
|
163
|
-
# We may not want to reparse; that can be disable. Fun times.
|
|
164
|
-
next_reparse = 0
|
|
165
|
-
reparse_interval = Puppet[:filetimeout]
|
|
166
|
-
|
|
167
|
-
loop do
|
|
168
|
-
now = Time.now.to_i
|
|
169
|
-
|
|
170
|
-
# We set a default wakeup of "one hour from now", which will
|
|
171
|
-
# recheck everything at a minimum every hour. Just in case something in
|
|
172
|
-
# the math messes up or something; it should be inexpensive enough to
|
|
173
|
-
# wake once an hour, then go back to sleep after doing nothing, if
|
|
174
|
-
# someone only wants listen mode.
|
|
175
|
-
next_event = now + 60 * 60
|
|
176
|
-
|
|
177
|
-
# Handle reparsing of configuration files, if desired and required.
|
|
178
|
-
# `reparse` will just check if the action is required, and would be
|
|
179
|
-
# better named `reparse_if_changed` instead.
|
|
180
|
-
if reparse_interval > 0 and now >= next_reparse
|
|
181
|
-
Puppet.settings.reparse_config_files
|
|
182
|
-
|
|
183
|
-
# The time to the next reparse might have changed, so recalculate
|
|
184
|
-
# now. That way we react dynamically to reconfiguration.
|
|
185
|
-
reparse_interval = Puppet[:filetimeout]
|
|
186
|
-
|
|
187
|
-
# Set up the next reparse check based on the new reparse_interval.
|
|
188
|
-
if reparse_interval > 0
|
|
189
|
-
next_reparse = now + reparse_interval
|
|
190
|
-
next_event > next_reparse and next_event = next_reparse
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
# We should also recalculate the agent run interval, and adjust the
|
|
194
|
-
# next time it is scheduled to run, just in case. In the event that
|
|
195
|
-
# we made no change the result will be a zero second adjustment.
|
|
196
|
-
new_run_interval = [Puppet[:runinterval], 0].max
|
|
197
|
-
next_agent_run += agent_run_interval - new_run_interval
|
|
198
|
-
agent_run_interval = new_run_interval
|
|
150
|
+
agent_run = Puppet::Scheduler.create_job(Puppet[:runinterval], Puppet[:splay], Puppet[:splaylimit]) do
|
|
151
|
+
# Splay for the daemon is handled in the scheduler
|
|
152
|
+
agent.run(:splay => false)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
reparse_run = Puppet::Scheduler.create_job(Puppet[:filetimeout]) do
|
|
156
|
+
Puppet.settings.reparse_config_files
|
|
157
|
+
agent_run.run_interval = Puppet[:runinterval]
|
|
158
|
+
if Puppet[:filetimeout] == 0
|
|
159
|
+
reparse_run.disable
|
|
160
|
+
else
|
|
161
|
+
reparse_run.run_interval = Puppet[:filetimeout]
|
|
199
162
|
end
|
|
163
|
+
end
|
|
200
164
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
# behaviour. You should not change that. --daniel 2012-02-21
|
|
204
|
-
if agent and now >= next_agent_run
|
|
205
|
-
agent.run
|
|
165
|
+
reparse_run.disable if Puppet[:filetimeout] == 0
|
|
166
|
+
agent_run.disable unless agent
|
|
206
167
|
|
|
207
|
-
|
|
208
|
-
next_agent_run = now + agent_run_interval
|
|
209
|
-
next_event > next_agent_run and next_event = next_agent_run
|
|
210
|
-
end
|
|
168
|
+
scheduler = Puppet::Scheduler::Scheduler.new([reparse_run, agent_run])
|
|
211
169
|
|
|
212
|
-
|
|
213
|
-
how_long = next_event - now
|
|
214
|
-
how_long > 0 and select([], [], [], how_long)
|
|
215
|
-
end
|
|
170
|
+
scheduler.run_loop
|
|
216
171
|
end
|
|
217
172
|
end
|
|
218
173
|
|
data/lib/puppet/defaults.rb
CHANGED
|
@@ -49,6 +49,11 @@ module Puppet
|
|
|
49
49
|
:type => :boolean,
|
|
50
50
|
:desc => "Whether to print stack traces on some errors",
|
|
51
51
|
},
|
|
52
|
+
:profile => {
|
|
53
|
+
:default => false,
|
|
54
|
+
:type => :boolean,
|
|
55
|
+
:desc => "Whether to enable experimental performance profiling",
|
|
56
|
+
},
|
|
52
57
|
:autoflush => {
|
|
53
58
|
:default => true,
|
|
54
59
|
:type => :boolean,
|
|
@@ -214,7 +219,7 @@ module Puppet
|
|
|
214
219
|
:node_cache_terminus => {
|
|
215
220
|
:type => :terminus,
|
|
216
221
|
:default => nil,
|
|
217
|
-
:desc => "How to store cached nodes.
|
|
222
|
+
:desc => "How to store cached nodes.
|
|
218
223
|
Valid values are (none), 'json', 'yaml' or write only yaml ('write_only_yaml').
|
|
219
224
|
The master application defaults to 'write_only_yaml', all others to none.",
|
|
220
225
|
},
|
|
@@ -225,7 +230,7 @@ module Puppet
|
|
|
225
230
|
},
|
|
226
231
|
:hiera_config => {
|
|
227
232
|
:default => "$confdir/hiera.yaml",
|
|
228
|
-
:desc => "The hiera configuration file",
|
|
233
|
+
:desc => "The hiera configuration file. Puppet only reads this file on startup, so you must restart the puppet master every time you edit it.",
|
|
229
234
|
:type => :file,
|
|
230
235
|
},
|
|
231
236
|
:catalog_terminus => {
|
|
@@ -772,7 +777,9 @@ EOT
|
|
|
772
777
|
},
|
|
773
778
|
:masterport => {
|
|
774
779
|
:default => 8140,
|
|
775
|
-
:desc => "
|
|
780
|
+
:desc => "The port for puppet master traffic. For puppet master,
|
|
781
|
+
this is the port to listen on; for puppet agent, this is the port
|
|
782
|
+
to make requests on. Both applications use this setting to get the port.",
|
|
776
783
|
},
|
|
777
784
|
:node_name => {
|
|
778
785
|
:default => "cert",
|
|
@@ -813,13 +820,26 @@ EOT
|
|
|
813
820
|
:default => "HTTP_X_CLIENT_DN",
|
|
814
821
|
:desc => "The header containing an authenticated client's SSL DN.
|
|
815
822
|
This header must be set by the proxy to the authenticated client's SSL
|
|
816
|
-
DN (e.g., `/CN=puppet.puppetlabs.com`).
|
|
823
|
+
DN (e.g., `/CN=puppet.puppetlabs.com`). Puppet will parse out the Common
|
|
824
|
+
Name (CN) from the Distinguished Name (DN) and use the value of the CN
|
|
825
|
+
field for authorization.
|
|
826
|
+
|
|
827
|
+
Note that the name of the HTTP header gets munged by the web server
|
|
828
|
+
common gateway inteface: an `HTTP_` prefix is added, dashes are converted
|
|
829
|
+
to underscores, and all letters are uppercased. Thus, to use the
|
|
830
|
+
`X-Client-DN` header, this setting should be `HTTP_X_CLIENT_DN`.",
|
|
817
831
|
},
|
|
818
832
|
:ssl_client_verify_header => {
|
|
819
833
|
:default => "HTTP_X_CLIENT_VERIFY",
|
|
820
834
|
:desc => "The header containing the status message of the client
|
|
821
835
|
verification. This header must be set by the proxy to 'SUCCESS' if the
|
|
822
|
-
client successfully authenticated, and anything else otherwise.
|
|
836
|
+
client successfully authenticated, and anything else otherwise.
|
|
837
|
+
|
|
838
|
+
Note that the name of the HTTP header gets munged by the web server
|
|
839
|
+
common gateway inteface: an `HTTP_` prefix is added, dashes are converted
|
|
840
|
+
to underscores, and all letters are uppercased. Thus, to use the
|
|
841
|
+
`X-Client-Verify` header, this setting should be
|
|
842
|
+
`HTTP_X_CLIENT_VERIFY`.",
|
|
823
843
|
},
|
|
824
844
|
# To make sure this directory is created before we try to use it on the server, we need
|
|
825
845
|
# it to be in the server section (#1138).
|
|
@@ -1504,8 +1524,44 @@ between Puppet 2.7.3 and 2.7.14. If you used them during this window, we
|
|
|
1504
1524
|
apologize for the inconvenience --- you can temporarily set this to `true`
|
|
1505
1525
|
in order to upgrade, and can rename your variables at your leisure. Please
|
|
1506
1526
|
revert it to `false` after you have renamed all affected variables.
|
|
1527
|
+
EOT
|
|
1528
|
+
},
|
|
1529
|
+
:parser => {
|
|
1530
|
+
:default => "current",
|
|
1531
|
+
:desc => <<-'EOT'
|
|
1532
|
+
Selects the parser to use for parsing puppet manifests (in puppet DSL language/'.pp' files).
|
|
1533
|
+
Available choices are 'current' (the default), and 'future'.
|
|
1534
|
+
|
|
1535
|
+
The 'curent' parser means that the released version of the parser should be used.
|
|
1536
|
+
|
|
1537
|
+
The 'future' parser is a "time travel to the future" allowing early exposure to new language features.
|
|
1538
|
+
What these fatures are will vary from release to release and they may be invididually configurable.
|
|
1539
|
+
|
|
1540
|
+
Available Since Puppet 3.2.
|
|
1541
|
+
EOT
|
|
1542
|
+
},
|
|
1543
|
+
:max_errors => {
|
|
1544
|
+
:default => 10,
|
|
1545
|
+
:desc => <<-'EOT'
|
|
1546
|
+
Sets the max number of logged/displayed parser validation errors in case multiple errors have been detected.
|
|
1547
|
+
A value of 0 is the same as value 1. The count is per manifest.
|
|
1548
|
+
EOT
|
|
1549
|
+
},
|
|
1550
|
+
:max_warnings => {
|
|
1551
|
+
:default => 10,
|
|
1552
|
+
:desc => <<-'EOT'
|
|
1553
|
+
Sets the max number of logged/displayed parser validation warnings in case multiple errors have been detected.
|
|
1554
|
+
A value of 0 is the same as value 1. The count is per manifest.
|
|
1555
|
+
EOT
|
|
1556
|
+
},
|
|
1557
|
+
:max_deprecations => {
|
|
1558
|
+
:default => 10,
|
|
1559
|
+
:desc => <<-'EOT'
|
|
1560
|
+
Sets the max number of logged/displayed parser validation deprecation warnings in case multiple errors have been detected.
|
|
1561
|
+
A value of 0 is the same as value 1. The count is per manifest.
|
|
1507
1562
|
EOT
|
|
1508
1563
|
}
|
|
1564
|
+
|
|
1509
1565
|
)
|
|
1510
1566
|
define_settings(:puppetdoc,
|
|
1511
1567
|
:document_all => {
|
data/lib/puppet/error.rb
CHANGED
|
@@ -12,18 +12,29 @@ module Puppet
|
|
|
12
12
|
# This module implements logging with a filename and line number. Use this
|
|
13
13
|
# for errors that need to report a location in a non-ruby file that we
|
|
14
14
|
# parse.
|
|
15
|
-
attr_accessor :line, :file
|
|
15
|
+
attr_accessor :line, :file, :pos
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
# May be called with 3 arguments for message, file, line, and exception, or
|
|
18
|
+
# 4 args including the position on the line.
|
|
19
|
+
#
|
|
20
|
+
def initialize(message, file=nil, line=nil, pos=nil, original=nil)
|
|
21
|
+
if pos.kind_of? Exception
|
|
22
|
+
original = pos
|
|
23
|
+
pos = nil
|
|
24
|
+
end
|
|
18
25
|
super(message, original)
|
|
19
26
|
@file = file
|
|
20
27
|
@line = line
|
|
28
|
+
@pos = pos
|
|
21
29
|
end
|
|
22
|
-
|
|
23
30
|
def to_s
|
|
24
31
|
msg = super
|
|
25
|
-
if @file and @line
|
|
32
|
+
if @file and @line and @pos
|
|
33
|
+
"#{msg} at #{@file}:#{@line}:#{@pos}"
|
|
34
|
+
elsif @file and @line
|
|
26
35
|
"#{msg} at #{@file}:#{@line}"
|
|
36
|
+
elsif @line and @pos
|
|
37
|
+
"#{msg} at line #{@line}:#{@pos}"
|
|
27
38
|
elsif @line
|
|
28
39
|
"#{msg} at line #{@line}"
|
|
29
40
|
elsif @file
|
|
@@ -1,581 +1,175 @@
|
|
|
1
1
|
#
|
|
2
2
|
# DO NOT MODIFY!!!!
|
|
3
|
-
# This file is automatically generated by
|
|
4
|
-
# from
|
|
3
|
+
# This file is automatically generated by Racc 1.4.9
|
|
4
|
+
# from Racc grammer file "".
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
# parser.rb: generated by racc (runtime embedded)
|
|
8
|
-
#
|
|
9
|
-
###### racc/parser.rb begin
|
|
10
|
-
unless $LOADED_FEATURES.index 'racc/parser.rb'
|
|
11
|
-
$LOADED_FEATURES.push 'racc/parser.rb'
|
|
12
|
-
|
|
13
|
-
self.class.module_eval <<'..end racc/parser.rb modeval..id5256434e8a', 'racc/parser.rb', 1
|
|
14
|
-
#
|
|
15
|
-
# $Id: parser.rb,v 1.7 2005/11/20 17:31:32 aamine Exp $
|
|
16
|
-
#
|
|
17
|
-
# Copyright (c) 1999-2005 Minero Aoki
|
|
18
|
-
#
|
|
19
|
-
# This program is free software.
|
|
20
|
-
# You can distribute/modify this program under the same terms of ruby.
|
|
21
|
-
#
|
|
22
|
-
# As a special exception, when this code is copied by Racc
|
|
23
|
-
# into a Racc output file, you may use that output file
|
|
24
|
-
# without restriction.
|
|
25
|
-
#
|
|
26
|
-
|
|
27
|
-
NotImplementedError = NotImplementError unless defined?(NotImplementedError)
|
|
28
|
-
|
|
29
|
-
module Racc
|
|
30
|
-
class ParseError < StandardError; end
|
|
31
|
-
end
|
|
32
|
-
ParseError = Racc::ParseError unless defined?(::ParseError)
|
|
33
|
-
|
|
34
|
-
module Racc
|
|
35
|
-
|
|
36
|
-
Racc_No_Extentions = false unless defined?(Racc_No_Extentions)
|
|
37
|
-
|
|
38
|
-
class Parser
|
|
39
|
-
|
|
40
|
-
Racc_Runtime_Version = '1.4.5'
|
|
41
|
-
Racc_Runtime_Revision = '$Revision: 1.7 $'.split[1]
|
|
42
|
-
|
|
43
|
-
Racc_Runtime_Core_Version_R = '1.4.5'
|
|
44
|
-
Racc_Runtime_Core_Revision_R = '$Revision: 1.7 $'.split[1]
|
|
45
|
-
begin
|
|
46
|
-
require 'racc/cparse'
|
|
47
|
-
# Racc_Runtime_Core_Version_C = (defined in extention)
|
|
48
|
-
Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
|
|
49
|
-
raise LoadError, 'old cparse.so' unless new.respond_to?(:_racc_do_parse_c, true)
|
|
50
|
-
raise LoadError, 'selecting ruby version of racc runtime core' if Racc_No_Extentions
|
|
51
|
-
|
|
52
|
-
Racc_Main_Parsing_Routine = :_racc_do_parse_c
|
|
53
|
-
Racc_YY_Parse_Method = :_racc_yyparse_c
|
|
54
|
-
Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C
|
|
55
|
-
Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_C
|
|
56
|
-
Racc_Runtime_Type = 'c'
|
|
57
|
-
rescue LoadError
|
|
58
|
-
Racc_Main_Parsing_Routine = :_racc_do_parse_rb
|
|
59
|
-
Racc_YY_Parse_Method = :_racc_yyparse_rb
|
|
60
|
-
Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
|
|
61
|
-
Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_R
|
|
62
|
-
Racc_Runtime_Type = 'ruby'
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def Parser.racc_runtime_type
|
|
66
|
-
Racc_Runtime_Type
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
private
|
|
70
|
-
|
|
71
|
-
def _racc_setup
|
|
72
|
-
@yydebug = false unless self.class::Racc_debug_parser
|
|
73
|
-
@yydebug ||= false
|
|
74
|
-
if @yydebug
|
|
75
|
-
@racc_debug_out ||= $stderr
|
|
76
|
-
@racc_debug_out ||= $stderr
|
|
77
|
-
end
|
|
78
|
-
arg = self.class::Racc_arg
|
|
79
|
-
arg[13] = true if arg.size < 14
|
|
80
|
-
arg
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def _racc_init_sysvars
|
|
84
|
-
@racc_state = [0]
|
|
85
|
-
@racc_tstack = []
|
|
86
|
-
@racc_vstack = []
|
|
87
|
-
|
|
88
|
-
@racc_t = nil
|
|
89
|
-
@racc_val = nil
|
|
90
|
-
|
|
91
|
-
@racc_read_next = true
|
|
92
|
-
|
|
93
|
-
@racc_user_yyerror = false
|
|
94
|
-
@racc_error_status = 0
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
###
|
|
98
|
-
### do_parse
|
|
99
|
-
###
|
|
100
|
-
|
|
101
|
-
def do_parse
|
|
102
|
-
__send__(Racc_Main_Parsing_Routine, _racc_setup, false)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def next_token
|
|
106
|
-
raise NotImplementedError, "#{self.class}\#next_token is not defined"
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def _racc_do_parse_rb(arg, in_debug)
|
|
110
|
-
action_table, action_check, action_default, action_pointer,
|
|
111
|
-
goto_table, goto_check, goto_default, goto_pointer,
|
|
112
|
-
nt_base, reduce_table, token_table, shift_n,
|
|
113
|
-
reduce_n, use_result, * = arg
|
|
114
|
-
|
|
115
|
-
_racc_init_sysvars
|
|
116
|
-
tok = act = i = nil
|
|
117
|
-
nerr = 0
|
|
118
|
-
|
|
119
|
-
catch(:racc_end_parse) {
|
|
120
|
-
while true
|
|
121
|
-
if i = action_pointer[@racc_state[-1]]
|
|
122
|
-
if @racc_read_next
|
|
123
|
-
if @racc_t != 0 # not EOF
|
|
124
|
-
tok, @racc_val = next_token
|
|
125
|
-
unless tok # EOF
|
|
126
|
-
@racc_t = 0
|
|
127
|
-
else
|
|
128
|
-
@racc_t = (token_table[tok] or 1) # error token
|
|
129
|
-
end
|
|
130
|
-
racc_read_token(@racc_t, tok, @racc_val) if @yydebug
|
|
131
|
-
@racc_read_next = false
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
i += @racc_t
|
|
135
|
-
unless i >= 0 and
|
|
136
|
-
act = action_table[i] and
|
|
137
|
-
action_check[i] == @racc_state[-1]
|
|
138
|
-
act = action_default[@racc_state[-1]]
|
|
139
|
-
end
|
|
140
|
-
else
|
|
141
|
-
act = action_default[@racc_state[-1]]
|
|
142
|
-
end
|
|
143
|
-
while act = _racc_evalact(act, arg)
|
|
144
|
-
;
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
}
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
###
|
|
151
|
-
### yyparse
|
|
152
|
-
###
|
|
153
|
-
|
|
154
|
-
def yyparse(recv, mid)
|
|
155
|
-
__send__(Racc_YY_Parse_Method, recv, mid, _racc_setup, true)
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def _racc_yyparse_rb(recv, mid, arg, c_debug)
|
|
159
|
-
action_table, action_check, action_default, action_pointer,
|
|
160
|
-
goto_table, goto_check, goto_default, goto_pointer,
|
|
161
|
-
nt_base, reduce_table, token_table, shift_n,
|
|
162
|
-
reduce_n, use_result, * = arg
|
|
163
|
-
|
|
164
|
-
_racc_init_sysvars
|
|
165
|
-
tok = nil
|
|
166
|
-
act = nil
|
|
167
|
-
i = nil
|
|
168
|
-
nerr = 0
|
|
169
|
-
|
|
170
|
-
catch(:racc_end_parse) {
|
|
171
|
-
until i = action_pointer[@racc_state[-1]]
|
|
172
|
-
while act = _racc_evalact(action_default[@racc_state[-1]], arg)
|
|
173
|
-
;
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
|
-
recv.__send__(mid) do |tok, val|
|
|
177
|
-
unless tok
|
|
178
|
-
@racc_t = 0
|
|
179
|
-
else
|
|
180
|
-
@racc_t = (token_table[tok] or 1) # error token
|
|
181
|
-
end
|
|
182
|
-
@racc_val = val
|
|
183
|
-
@racc_read_next = false
|
|
184
|
-
|
|
185
|
-
i += @racc_t
|
|
186
|
-
unless i >= 0 and
|
|
187
|
-
act = action_table[i] and
|
|
188
|
-
action_check[i] == @racc_state[-1]
|
|
189
|
-
act = action_default[@racc_state[-1]]
|
|
190
|
-
end
|
|
191
|
-
while act = _racc_evalact(act, arg)
|
|
192
|
-
;
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
while not (i = action_pointer[@racc_state[-1]]) or
|
|
196
|
-
not @racc_read_next or
|
|
197
|
-
@racc_t == 0 # $
|
|
198
|
-
unless i and i += @racc_t and
|
|
199
|
-
i >= 0 and
|
|
200
|
-
act = action_table[i] and
|
|
201
|
-
action_check[i] == @racc_state[-1]
|
|
202
|
-
act = action_default[@racc_state[-1]]
|
|
203
|
-
end
|
|
204
|
-
while act = _racc_evalact(act, arg)
|
|
205
|
-
;
|
|
206
|
-
end
|
|
207
|
-
end
|
|
208
|
-
end
|
|
209
|
-
}
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
###
|
|
213
|
-
### common
|
|
214
|
-
###
|
|
215
|
-
|
|
216
|
-
def _racc_evalact(act, arg)
|
|
217
|
-
action_table, action_check, action_default, action_pointer,
|
|
218
|
-
goto_table, goto_check, goto_default, goto_pointer,
|
|
219
|
-
nt_base, reduce_table, token_table, shift_n,
|
|
220
|
-
reduce_n, use_result, * = arg
|
|
221
|
-
nerr = 0 # tmp
|
|
222
|
-
|
|
223
|
-
if act > 0 and act < shift_n
|
|
224
|
-
#
|
|
225
|
-
# shift
|
|
226
|
-
#
|
|
227
|
-
if @racc_error_status > 0
|
|
228
|
-
@racc_error_status -= 1 unless @racc_t == 1 # error token
|
|
229
|
-
end
|
|
230
|
-
@racc_vstack.push @racc_val
|
|
231
|
-
@racc_state.push act
|
|
232
|
-
@racc_read_next = true
|
|
233
|
-
if @yydebug
|
|
234
|
-
@racc_tstack.push @racc_t
|
|
235
|
-
racc_shift @racc_t, @racc_tstack, @racc_vstack
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
elsif act < 0 and act > -reduce_n
|
|
239
|
-
#
|
|
240
|
-
# reduce
|
|
241
|
-
#
|
|
242
|
-
code = catch(:racc_jump) {
|
|
243
|
-
@racc_state.push _racc_do_reduce(arg, act)
|
|
244
|
-
false
|
|
245
|
-
}
|
|
246
|
-
if code
|
|
247
|
-
case code
|
|
248
|
-
when 1 # yyerror
|
|
249
|
-
@racc_user_yyerror = true # user_yyerror
|
|
250
|
-
return -reduce_n
|
|
251
|
-
when 2 # yyaccept
|
|
252
|
-
return shift_n
|
|
253
|
-
else
|
|
254
|
-
raise '[Racc Bug] unknown jump code'
|
|
255
|
-
end
|
|
256
|
-
end
|
|
257
|
-
|
|
258
|
-
elsif act == shift_n
|
|
259
|
-
#
|
|
260
|
-
# accept
|
|
261
|
-
#
|
|
262
|
-
racc_accept if @yydebug
|
|
263
|
-
throw :racc_end_parse, @racc_vstack[0]
|
|
264
|
-
|
|
265
|
-
elsif act == -reduce_n
|
|
266
|
-
#
|
|
267
|
-
# error
|
|
268
|
-
#
|
|
269
|
-
case @racc_error_status
|
|
270
|
-
when 0
|
|
271
|
-
unless arg[21] # user_yyerror
|
|
272
|
-
nerr += 1
|
|
273
|
-
on_error @racc_t, @racc_val, @racc_vstack
|
|
274
|
-
end
|
|
275
|
-
when 3
|
|
276
|
-
if @racc_t == 0 # is $
|
|
277
|
-
throw :racc_end_parse, nil
|
|
278
|
-
end
|
|
279
|
-
@racc_read_next = true
|
|
280
|
-
end
|
|
281
|
-
@racc_user_yyerror = false
|
|
282
|
-
@racc_error_status = 3
|
|
283
|
-
while true
|
|
284
|
-
if i = action_pointer[@racc_state[-1]]
|
|
285
|
-
i += 1 # error token
|
|
286
|
-
if i >= 0 and
|
|
287
|
-
(act = action_table[i]) and
|
|
288
|
-
action_check[i] == @racc_state[-1]
|
|
289
|
-
break
|
|
290
|
-
end
|
|
291
|
-
end
|
|
292
|
-
throw :racc_end_parse, nil if @racc_state.size <= 1
|
|
293
|
-
@racc_state.pop
|
|
294
|
-
@racc_vstack.pop
|
|
295
|
-
if @yydebug
|
|
296
|
-
@racc_tstack.pop
|
|
297
|
-
racc_e_pop @racc_state, @racc_tstack, @racc_vstack
|
|
298
|
-
end
|
|
299
|
-
end
|
|
300
|
-
return act
|
|
301
|
-
|
|
302
|
-
else
|
|
303
|
-
raise "[Racc Bug] unknown action #{act.inspect}"
|
|
304
|
-
end
|
|
305
|
-
|
|
306
|
-
racc_next_state(@racc_state[-1], @racc_state) if @yydebug
|
|
307
|
-
|
|
308
|
-
nil
|
|
309
|
-
end
|
|
310
|
-
|
|
311
|
-
def _racc_do_reduce(arg, act)
|
|
312
|
-
action_table, action_check, action_default, action_pointer,
|
|
313
|
-
goto_table, goto_check, goto_default, goto_pointer,
|
|
314
|
-
nt_base, reduce_table, token_table, shift_n,
|
|
315
|
-
reduce_n, use_result, * = arg
|
|
316
|
-
state = @racc_state
|
|
317
|
-
vstack = @racc_vstack
|
|
318
|
-
tstack = @racc_tstack
|
|
319
|
-
|
|
320
|
-
i = act * -3
|
|
321
|
-
len = reduce_table[i]
|
|
322
|
-
reduce_to = reduce_table[i+1]
|
|
323
|
-
method_id = reduce_table[i+2]
|
|
324
|
-
void_array = []
|
|
325
|
-
|
|
326
|
-
tmp_t = tstack[-len, len] if @yydebug
|
|
327
|
-
tmp_v = vstack[-len, len]
|
|
328
|
-
tstack[-len, len] = void_array if @yydebug
|
|
329
|
-
vstack[-len, len] = void_array
|
|
330
|
-
state[-len, len] = void_array
|
|
331
|
-
|
|
332
|
-
# tstack must be updated AFTER method call
|
|
333
|
-
if use_result
|
|
334
|
-
vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
|
|
335
|
-
else
|
|
336
|
-
vstack.push __send__(method_id, tmp_v, vstack)
|
|
337
|
-
end
|
|
338
|
-
tstack.push reduce_to
|
|
339
|
-
|
|
340
|
-
racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
|
|
341
|
-
|
|
342
|
-
k1 = reduce_to - nt_base
|
|
343
|
-
if i = goto_pointer[k1]
|
|
344
|
-
i += state[-1]
|
|
345
|
-
if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
|
|
346
|
-
return curstate
|
|
347
|
-
end
|
|
348
|
-
end
|
|
349
|
-
goto_default[k1]
|
|
350
|
-
end
|
|
351
|
-
|
|
352
|
-
def on_error(t, val, vstack)
|
|
353
|
-
raise ParseError, sprintf("\nparse error on value %s (%s)", val.inspect, token_to_str(t) || '?')
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
def yyerror
|
|
357
|
-
throw :racc_jump, 1
|
|
358
|
-
end
|
|
359
|
-
|
|
360
|
-
def yyaccept
|
|
361
|
-
throw :racc_jump, 2
|
|
362
|
-
end
|
|
363
|
-
|
|
364
|
-
def yyerrok
|
|
365
|
-
@racc_error_status = 0
|
|
366
|
-
end
|
|
367
|
-
|
|
368
|
-
#
|
|
369
|
-
# for debugging output
|
|
370
|
-
#
|
|
371
|
-
|
|
372
|
-
def racc_read_token(t, tok, val)
|
|
373
|
-
@racc_debug_out.print 'read '
|
|
374
|
-
@racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
|
|
375
|
-
@racc_debug_out.puts val.inspect
|
|
376
|
-
@racc_debug_out.puts
|
|
377
|
-
end
|
|
378
|
-
|
|
379
|
-
def racc_shift(tok, tstack, vstack)
|
|
380
|
-
@racc_debug_out.puts "shift #{racc_token2str tok}"
|
|
381
|
-
racc_print_stacks tstack, vstack
|
|
382
|
-
@racc_debug_out.puts
|
|
383
|
-
end
|
|
384
|
-
|
|
385
|
-
def racc_reduce(toks, sim, tstack, vstack)
|
|
386
|
-
out = @racc_debug_out
|
|
387
|
-
out.print 'reduce '
|
|
388
|
-
if toks.empty?
|
|
389
|
-
out.print ' <none>'
|
|
390
|
-
else
|
|
391
|
-
toks.each {|t| out.print ' ', racc_token2str(t) }
|
|
392
|
-
end
|
|
393
|
-
out.puts " --> #{racc_token2str(sim)}"
|
|
394
|
-
|
|
395
|
-
racc_print_stacks tstack, vstack
|
|
396
|
-
@racc_debug_out.puts
|
|
397
|
-
end
|
|
398
|
-
|
|
399
|
-
def racc_accept
|
|
400
|
-
@racc_debug_out.puts 'accept'
|
|
401
|
-
@racc_debug_out.puts
|
|
402
|
-
end
|
|
403
|
-
|
|
404
|
-
def racc_e_pop(state, tstack, vstack)
|
|
405
|
-
@racc_debug_out.puts 'error recovering mode: pop token'
|
|
406
|
-
racc_print_states state
|
|
407
|
-
racc_print_stacks tstack, vstack
|
|
408
|
-
@racc_debug_out.puts
|
|
409
|
-
end
|
|
410
|
-
|
|
411
|
-
def racc_next_state(curstate, state)
|
|
412
|
-
@racc_debug_out.puts "goto #{curstate}"
|
|
413
|
-
racc_print_states state
|
|
414
|
-
@racc_debug_out.puts
|
|
415
|
-
end
|
|
416
|
-
|
|
417
|
-
def racc_print_stacks(t, v)
|
|
418
|
-
out = @racc_debug_out
|
|
419
|
-
out.print ' ['
|
|
420
|
-
t.each_index do |i|
|
|
421
|
-
out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
|
|
422
|
-
end
|
|
423
|
-
out.puts ' ]'
|
|
424
|
-
end
|
|
425
|
-
|
|
426
|
-
def racc_print_states(s)
|
|
427
|
-
out = @racc_debug_out
|
|
428
|
-
out.print ' ['
|
|
429
|
-
s.each {|st| out.print ' ', st }
|
|
430
|
-
out.puts ' ]'
|
|
431
|
-
end
|
|
432
|
-
|
|
433
|
-
def racc_token2str(tok)
|
|
434
|
-
self.class::Racc_token_to_s_table[tok] or
|
|
435
|
-
raise "[Racc Bug] can't convert token #{tok} to string"
|
|
436
|
-
end
|
|
437
|
-
|
|
438
|
-
def token_to_str(t)
|
|
439
|
-
self.class::Racc_token_to_s_table[t]
|
|
440
|
-
end
|
|
441
|
-
|
|
442
|
-
end
|
|
443
|
-
|
|
444
|
-
end
|
|
445
|
-
..end racc/parser.rb modeval..id5256434e8a
|
|
446
|
-
end
|
|
447
|
-
###### racc/parser.rb end
|
|
448
|
-
|
|
449
6
|
|
|
7
|
+
require 'racc/parser.rb'
|
|
450
8
|
module Nagios
|
|
451
|
-
|
|
452
9
|
class Parser < Racc::Parser
|
|
453
10
|
|
|
454
|
-
module_eval
|
|
11
|
+
module_eval(<<'...end grammar.ry/module_eval...', 'grammar.ry', 57)
|
|
455
12
|
|
|
456
13
|
class ::Nagios::Parser::SyntaxError < RuntimeError; end
|
|
457
14
|
|
|
458
15
|
def parse(src)
|
|
459
|
-
|
|
16
|
+
@src = src
|
|
460
17
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
18
|
+
# state variables
|
|
19
|
+
@invar = false
|
|
20
|
+
@inobject = false
|
|
21
|
+
@done = false
|
|
465
22
|
|
|
466
|
-
|
|
467
|
-
|
|
23
|
+
@line = 0
|
|
24
|
+
@yydebug = true
|
|
468
25
|
|
|
469
|
-
|
|
26
|
+
do_parse
|
|
470
27
|
end
|
|
471
28
|
|
|
472
29
|
# The lexer. Very simple.
|
|
473
30
|
def token
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
31
|
+
@src.sub!(/\A\n/,'')
|
|
32
|
+
if $&
|
|
33
|
+
@line += 1
|
|
34
|
+
return [ :RETURN, "\n" ]
|
|
478
35
|
end
|
|
479
36
|
|
|
480
|
-
|
|
37
|
+
if @done
|
|
38
|
+
return nil
|
|
39
|
+
end
|
|
481
40
|
yytext = String.new
|
|
482
41
|
|
|
483
42
|
|
|
484
43
|
# remove comments from this line
|
|
485
44
|
@src.sub!(/\A[ \t]*;.*\n/,"\n")
|
|
486
|
-
|
|
45
|
+
if $&
|
|
46
|
+
return [:INLINECOMMENT, ""]
|
|
47
|
+
end
|
|
487
48
|
|
|
488
49
|
@src.sub!(/\A#.*\n/,"\n")
|
|
489
|
-
|
|
50
|
+
if $&
|
|
51
|
+
return [:COMMENT, ""]
|
|
52
|
+
end
|
|
490
53
|
|
|
491
54
|
@src.sub!(/#.*/,'')
|
|
492
55
|
|
|
493
56
|
if @src.length == 0
|
|
494
|
-
|
|
495
|
-
|
|
57
|
+
@done = true
|
|
58
|
+
return [false, '$']
|
|
496
59
|
end
|
|
497
60
|
|
|
498
61
|
if @invar
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
62
|
+
@src.sub!(/\A[ \t]+/,'')
|
|
63
|
+
@src.sub!(/\A([^;\n]+)(\n|;)/,'\2')
|
|
64
|
+
if $1
|
|
65
|
+
yytext += $1
|
|
503
66
|
end
|
|
504
67
|
@invar = false
|
|
505
68
|
return [:VALUE, yytext]
|
|
506
69
|
else
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
70
|
+
@src.sub!(/\A[\t ]*(\S+)([\t ]*|$)/,'')
|
|
71
|
+
if $1
|
|
72
|
+
yytext = $1
|
|
73
|
+
case yytext
|
|
74
|
+
when 'define'
|
|
75
|
+
#puts "got define"
|
|
76
|
+
return [:DEFINE, yytext]
|
|
77
|
+
when '{'
|
|
78
|
+
#puts "got {"
|
|
79
|
+
@inobject = true
|
|
80
|
+
return [:LCURLY, yytext]
|
|
81
|
+
else
|
|
82
|
+
unless @inobject
|
|
83
|
+
#puts "got type: #{yytext}"
|
|
84
|
+
if yytext =~ /\W/
|
|
85
|
+
giveback = yytext.dup
|
|
86
|
+
giveback.sub!(/^\w+/,'')
|
|
87
|
+
#puts "giveback " + giveback
|
|
88
|
+
#puts "yytext " + yytext
|
|
89
|
+
yytext.sub!(/\W.*$/,'')
|
|
90
|
+
#puts "yytext " + yytext
|
|
91
|
+
#puts "all [#{giveback} #{yytext} #{orig}]"
|
|
92
|
+
@src = giveback + @src
|
|
93
|
+
end
|
|
94
|
+
return [:NAME, yytext]
|
|
95
|
+
else
|
|
96
|
+
if yytext == '}'
|
|
97
|
+
#puts "got closure: #{yytext}"
|
|
98
|
+
@inobject = false
|
|
99
|
+
return [:RCURLY, '}']
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
unless @invar
|
|
103
|
+
@invar = true
|
|
104
|
+
return [:PARAM, $1]
|
|
105
|
+
else
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
544
109
|
end
|
|
545
|
-
end
|
|
546
|
-
end
|
|
547
110
|
end
|
|
548
111
|
end
|
|
549
112
|
|
|
550
113
|
def next_token
|
|
551
|
-
|
|
114
|
+
token
|
|
552
115
|
end
|
|
553
116
|
|
|
554
117
|
def yydebug
|
|
555
|
-
|
|
118
|
+
1
|
|
556
119
|
end
|
|
557
120
|
|
|
558
121
|
def yywrap
|
|
559
|
-
|
|
122
|
+
0
|
|
560
123
|
end
|
|
561
124
|
|
|
562
125
|
def on_error(token, value, vstack )
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
126
|
+
msg = ""
|
|
127
|
+
unless value.nil?
|
|
128
|
+
msg = "line #{@line}: syntax error at '#{value}'"
|
|
566
129
|
else
|
|
567
|
-
|
|
130
|
+
msg = "line #{@line}: syntax error at '#{token}'"
|
|
131
|
+
end
|
|
132
|
+
unless @src.size > 0
|
|
133
|
+
msg = "line #{@line}: Unexpected end of file"
|
|
568
134
|
end
|
|
569
|
-
msg = "line #{@line}: Unexpected end of file" unless @src.size > 0
|
|
570
135
|
if token == '$end'.intern
|
|
571
|
-
|
|
136
|
+
puts "okay, this is silly"
|
|
572
137
|
else
|
|
573
|
-
|
|
138
|
+
raise ::Nagios::Parser::SyntaxError, msg
|
|
574
139
|
end
|
|
575
140
|
end
|
|
576
|
-
|
|
141
|
+
...end grammar.ry/module_eval...
|
|
142
|
+
##### State transition tables begin ###
|
|
143
|
+
|
|
144
|
+
racc_action_table = [
|
|
145
|
+
8, 17, 7, 18, 7, 14, 12, 13, 11, 4,
|
|
146
|
+
6, 4, 6, 17, 10, 20, 22, 24, 25 ]
|
|
147
|
+
|
|
148
|
+
racc_action_check = [
|
|
149
|
+
1, 15, 1, 15, 0, 13, 8, 11, 7, 1,
|
|
150
|
+
1, 0, 0, 14, 6, 17, 20, 21, 23 ]
|
|
151
|
+
|
|
152
|
+
racc_action_pointer = [
|
|
153
|
+
2, 0, nil, nil, nil, nil, 5, 5, 6, nil,
|
|
154
|
+
nil, 1, nil, -4, 8, -4, nil, 7, nil, nil,
|
|
155
|
+
5, 8, nil, 9, nil, nil ]
|
|
156
|
+
|
|
157
|
+
racc_action_default = [
|
|
158
|
+
-15, -15, -1, -3, -4, -5, -15, -15, -15, -2,
|
|
159
|
+
-6, -15, 26, -15, -15, -15, -8, -15, -7, -9,
|
|
160
|
+
-13, -15, -14, -10, -11, -12 ]
|
|
161
|
+
|
|
162
|
+
racc_goto_table = [
|
|
163
|
+
16, 19, 2, 9, 1, 15, 21, 23 ]
|
|
577
164
|
|
|
578
|
-
|
|
165
|
+
racc_goto_check = [
|
|
166
|
+
6, 6, 2, 2, 1, 5, 7, 8 ]
|
|
167
|
+
|
|
168
|
+
racc_goto_pointer = [
|
|
169
|
+
nil, 4, 2, nil, nil, -9, -14, -14, -14 ]
|
|
170
|
+
|
|
171
|
+
racc_goto_default = [
|
|
172
|
+
nil, nil, nil, 3, 5, nil, nil, nil, nil ]
|
|
579
173
|
|
|
580
174
|
racc_reduce_table = [
|
|
581
175
|
0, 0, :racc_error,
|
|
@@ -598,35 +192,9 @@ racc_reduce_n = 15
|
|
|
598
192
|
|
|
599
193
|
racc_shift_n = 26
|
|
600
194
|
|
|
601
|
-
racc_action_table = [
|
|
602
|
-
9, 15, 1, 20, 1, 14, 12, 13, 11, 6,
|
|
603
|
-
7, 6, 7, 15, 18, 8, 21, 23, 25 ]
|
|
604
|
-
|
|
605
|
-
racc_action_check = [
|
|
606
|
-
2, 16, 2, 16, 0, 12, 8, 9, 7, 2,
|
|
607
|
-
2, 0, 0, 14, 15, 1, 18, 22, 24 ]
|
|
608
|
-
|
|
609
|
-
racc_action_pointer = [
|
|
610
|
-
2, 12, 0, nil, nil, nil, nil, -1, 0, 7,
|
|
611
|
-
nil, nil, -4, nil, 8, 6, -4, nil, 5, nil,
|
|
612
|
-
nil, nil, 8, nil, 9, nil ]
|
|
613
|
-
|
|
614
|
-
racc_action_default = [
|
|
615
|
-
-15, -15, -15, -1, -3, -5, -4, -15, -15, -15,
|
|
616
|
-
-2, -6, -15, 26, -15, -15, -15, -8, -13, -9,
|
|
617
|
-
-7, -14, -15, -11, -10, -12 ]
|
|
618
|
-
|
|
619
|
-
racc_goto_table = [ 17, 3, 19, 10, 2, 16, 22, 24 ]
|
|
620
|
-
|
|
621
|
-
racc_goto_check = [ 6, 2, 6, 2, 1, 5, 7, 8 ]
|
|
622
|
-
|
|
623
|
-
racc_goto_pointer = [ nil, 4, 1, nil, nil, -9, -14, -12, -15 ]
|
|
624
|
-
|
|
625
|
-
racc_goto_default = [ nil, nil, nil, 4, 5, nil, nil, nil, nil ]
|
|
626
|
-
|
|
627
195
|
racc_token_table = {
|
|
628
196
|
false => 0,
|
|
629
|
-
|
|
197
|
+
:error => 1,
|
|
630
198
|
:DEFINE => 2,
|
|
631
199
|
:NAME => 3,
|
|
632
200
|
:STRING => 4,
|
|
@@ -638,10 +206,10 @@ racc_token_table = {
|
|
|
638
206
|
:COMMENT => 10,
|
|
639
207
|
:INLINECOMMENT => 11 }
|
|
640
208
|
|
|
641
|
-
racc_use_result_var = true
|
|
642
|
-
|
|
643
209
|
racc_nt_base = 12
|
|
644
210
|
|
|
211
|
+
racc_use_result_var = true
|
|
212
|
+
|
|
645
213
|
Racc_arg = [
|
|
646
214
|
racc_action_table,
|
|
647
215
|
racc_action_check,
|
|
@@ -659,103 +227,103 @@ Racc_arg = [
|
|
|
659
227
|
racc_use_result_var ]
|
|
660
228
|
|
|
661
229
|
Racc_token_to_s_table = [
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
230
|
+
"$end",
|
|
231
|
+
"error",
|
|
232
|
+
"DEFINE",
|
|
233
|
+
"NAME",
|
|
234
|
+
"STRING",
|
|
235
|
+
"PARAM",
|
|
236
|
+
"LCURLY",
|
|
237
|
+
"RCURLY",
|
|
238
|
+
"VALUE",
|
|
239
|
+
"RETURN",
|
|
240
|
+
"COMMENT",
|
|
241
|
+
"INLINECOMMENT",
|
|
242
|
+
"$start",
|
|
243
|
+
"decls",
|
|
244
|
+
"decl",
|
|
245
|
+
"object",
|
|
246
|
+
"comment",
|
|
247
|
+
"vars",
|
|
248
|
+
"var",
|
|
249
|
+
"icomment",
|
|
250
|
+
"returns" ]
|
|
683
251
|
|
|
684
252
|
Racc_debug_parser = false
|
|
685
253
|
|
|
686
|
-
#####
|
|
254
|
+
##### State transition tables end #####
|
|
687
255
|
|
|
688
256
|
# reduce 0 omitted
|
|
689
257
|
|
|
690
|
-
module_eval
|
|
691
|
-
def _reduce_1(
|
|
692
|
-
return val[0] if val[0]
|
|
693
|
-
|
|
694
|
-
end
|
|
258
|
+
module_eval(<<'.,.,', 'grammar.ry', 6)
|
|
259
|
+
def _reduce_1(val, _values, result)
|
|
260
|
+
return val[0] if val[0]
|
|
261
|
+
result
|
|
262
|
+
end
|
|
695
263
|
.,.,
|
|
696
264
|
|
|
697
|
-
module_eval
|
|
698
|
-
def _reduce_2(
|
|
265
|
+
module_eval(<<'.,.,', 'grammar.ry', 8)
|
|
266
|
+
def _reduce_2(val, _values, result)
|
|
699
267
|
if val[1].nil?
|
|
700
268
|
result = val[0]
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
269
|
+
else
|
|
270
|
+
if val[0].nil?
|
|
271
|
+
result = val[1]
|
|
272
|
+
else
|
|
273
|
+
result = [ val[0], val[1] ].flatten
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
result
|
|
709
277
|
end
|
|
710
278
|
.,.,
|
|
711
279
|
|
|
712
|
-
module_eval
|
|
713
|
-
def _reduce_3(
|
|
714
|
-
result = [val[0]]
|
|
715
|
-
|
|
716
|
-
end
|
|
280
|
+
module_eval(<<'.,.,', 'grammar.ry', 20)
|
|
281
|
+
def _reduce_3(val, _values, result)
|
|
282
|
+
result = [val[0]]
|
|
283
|
+
result
|
|
284
|
+
end
|
|
717
285
|
.,.,
|
|
718
286
|
|
|
719
|
-
module_eval
|
|
720
|
-
def _reduce_4(
|
|
721
|
-
result = nil
|
|
722
|
-
|
|
723
|
-
end
|
|
287
|
+
module_eval(<<'.,.,', 'grammar.ry', 21)
|
|
288
|
+
def _reduce_4(val, _values, result)
|
|
289
|
+
result = nil
|
|
290
|
+
result
|
|
291
|
+
end
|
|
724
292
|
.,.,
|
|
725
293
|
|
|
726
294
|
# reduce 5 omitted
|
|
727
295
|
|
|
728
|
-
module_eval
|
|
729
|
-
def _reduce_6(
|
|
730
|
-
result = nil
|
|
731
|
-
|
|
732
|
-
end
|
|
296
|
+
module_eval(<<'.,.,', 'grammar.ry', 25)
|
|
297
|
+
def _reduce_6(val, _values, result)
|
|
298
|
+
result = nil
|
|
299
|
+
result
|
|
300
|
+
end
|
|
733
301
|
.,.,
|
|
734
302
|
|
|
735
|
-
module_eval
|
|
736
|
-
def _reduce_7(
|
|
303
|
+
module_eval(<<'.,.,', 'grammar.ry', 29)
|
|
304
|
+
def _reduce_7(val, _values, result)
|
|
737
305
|
result = Nagios::Base.create(val[1],val[4])
|
|
738
|
-
|
|
306
|
+
result
|
|
739
307
|
end
|
|
740
308
|
.,.,
|
|
741
309
|
|
|
742
310
|
# reduce 8 omitted
|
|
743
311
|
|
|
744
|
-
module_eval
|
|
745
|
-
def _reduce_9(
|
|
312
|
+
module_eval(<<'.,.,', 'grammar.ry', 35)
|
|
313
|
+
def _reduce_9(val, _values, result)
|
|
746
314
|
val[1].each {|p,v|
|
|
747
315
|
val[0][p] = v
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
316
|
+
}
|
|
317
|
+
result = val[0]
|
|
318
|
+
result
|
|
751
319
|
end
|
|
752
320
|
.,.,
|
|
753
321
|
|
|
754
|
-
module_eval
|
|
755
|
-
def _reduce_10(
|
|
756
|
-
result = {val[0] => val[1]}
|
|
757
|
-
|
|
758
|
-
end
|
|
322
|
+
module_eval(<<'.,.,', 'grammar.ry', 42)
|
|
323
|
+
def _reduce_10(val, _values, result)
|
|
324
|
+
result = {val[0] => val[1]}
|
|
325
|
+
result
|
|
326
|
+
end
|
|
759
327
|
.,.,
|
|
760
328
|
|
|
761
329
|
# reduce 11 omitted
|
|
@@ -766,10 +334,9 @@ end
|
|
|
766
334
|
|
|
767
335
|
# reduce 14 omitted
|
|
768
336
|
|
|
769
|
-
def _reduce_none(
|
|
770
|
-
|
|
337
|
+
def _reduce_none(val, _values, result)
|
|
338
|
+
val[0]
|
|
771
339
|
end
|
|
772
340
|
|
|
773
|
-
end
|
|
774
|
-
|
|
775
|
-
end
|
|
341
|
+
end # class Parser
|
|
342
|
+
end # module Nagios
|