puppet 3.1.1 → 3.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- 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
data/lib/puppet/util/colors.rb
CHANGED
@@ -83,6 +83,61 @@ module Puppet::Util::Colors
|
|
83
83
|
# We're on windows, need win32console for color to work
|
84
84
|
begin
|
85
85
|
require 'win32console'
|
86
|
+
require 'windows/wide_string'
|
87
|
+
|
88
|
+
# The win32console gem uses ANSI functions for writing to the console
|
89
|
+
# which doesn't work for unicode strings, e.g. module tool. Ruby 1.9
|
90
|
+
# does the same thing, but doesn't account for ANSI escape sequences
|
91
|
+
class WideConsole < Win32::Console
|
92
|
+
WriteConsole = Win32API.new( "kernel32", "WriteConsoleW", ['l', 'p', 'l', 'p', 'p'], 'l' )
|
93
|
+
WriteConsoleOutputCharacter = Win32API.new( "kernel32", "WriteConsoleOutputCharacterW", ['l', 'p', 'l', 'l', 'p'], 'l' )
|
94
|
+
|
95
|
+
def initialize(t = nil)
|
96
|
+
super(t)
|
97
|
+
end
|
98
|
+
|
99
|
+
def WriteChar(str, col, row)
|
100
|
+
dwWriteCoord = (row << 16) + col
|
101
|
+
lpNumberOfCharsWritten = ' ' * 4
|
102
|
+
utf16, nChars = string_encode(str)
|
103
|
+
WriteConsoleOutputCharacter.call(@handle, utf16, nChars, dwWriteCoord, lpNumberOfCharsWritten)
|
104
|
+
lpNumberOfCharsWritten.unpack('L')
|
105
|
+
end
|
106
|
+
|
107
|
+
def Write(str)
|
108
|
+
written = 0.chr * 4
|
109
|
+
reserved = 0.chr * 4
|
110
|
+
utf16, nChars = string_encode(str)
|
111
|
+
WriteConsole.call(@handle, utf16, nChars, written, reserved)
|
112
|
+
end
|
113
|
+
|
114
|
+
if String.method_defined?("encode")
|
115
|
+
def string_encode(str)
|
116
|
+
wstr = str.encode('UTF-16LE')
|
117
|
+
[wstr, wstr.length]
|
118
|
+
end
|
119
|
+
else
|
120
|
+
require 'iconv'
|
121
|
+
def string_encode(str)
|
122
|
+
wstr = Iconv.conv('UTF-16LE', 'UTF-8', str)
|
123
|
+
[wstr, wstr.length/2]
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# Override the win32console's IO class so we can supply
|
129
|
+
# our own Console class
|
130
|
+
class WideIO < Win32::Console::ANSI::IO
|
131
|
+
def initialize(fd_std = :stdout)
|
132
|
+
super(fd_std)
|
133
|
+
|
134
|
+
handle = FD_STD_MAP[fd_std][1]
|
135
|
+
@Out = WideConsole.new(handle)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
$stdout = WideIO.new(:stdout)
|
140
|
+
$stderr = WideIO.new(:stderr)
|
86
141
|
rescue LoadError
|
87
142
|
def console_has_color?
|
88
143
|
false
|
@@ -22,7 +22,7 @@ VERSION = "1.16.2"
|
|
22
22
|
## Thrown by Parser in the event of a commandline error. Not needed if
|
23
23
|
## you're using the Trollop::options entry.
|
24
24
|
class CommandlineError < StandardError; end
|
25
|
-
|
25
|
+
|
26
26
|
## Thrown by Parser if the user passes in '-h' or '--help'. Handled
|
27
27
|
## automatically by Trollop#options.
|
28
28
|
class HelpNeeded < StandardError; end
|
@@ -273,7 +273,7 @@ class Parser
|
|
273
273
|
syms.each { |sym| raise ArgumentError, "unknown option '#{sym}'" unless @specs[sym] }
|
274
274
|
@constraints << [:depends, syms]
|
275
275
|
end
|
276
|
-
|
276
|
+
|
277
277
|
## Marks two (or more!) options as conflicting.
|
278
278
|
def conflicts *syms
|
279
279
|
syms.each { |sym| raise ArgumentError, "unknown option '#{sym}'" unless @specs[sym] }
|
@@ -465,7 +465,7 @@ class Parser
|
|
465
465
|
# call this unless the cursor's at the beginning of a line.
|
466
466
|
|
467
467
|
left = {}
|
468
|
-
@specs.each do |name, spec|
|
468
|
+
@specs.each do |name, spec|
|
469
469
|
left[name] = "--#{spec[:long]}" +
|
470
470
|
(spec[:short] && spec[:short] != :none ? ", -#{spec[:short]}" : "") +
|
471
471
|
case spec[:type]
|
@@ -686,7 +686,7 @@ private
|
|
686
686
|
start = 0
|
687
687
|
ret = []
|
688
688
|
until start > str.length
|
689
|
-
nextt =
|
689
|
+
nextt =
|
690
690
|
if start + width >= str.length
|
691
691
|
str.length
|
692
692
|
else
|
data/lib/puppet/util/errors.rb
CHANGED
@@ -1,11 +1,24 @@
|
|
1
|
-
# Some helper methods for throwing errors.
|
1
|
+
# Some helper methods for throwing and populating errors.
|
2
|
+
#
|
3
|
+
# @api public
|
2
4
|
module Puppet::Util::Errors
|
3
|
-
# Throw a
|
5
|
+
# Throw a Puppet::DevError with the specified message. Used for unknown or
|
6
|
+
# internal application failures.
|
7
|
+
#
|
8
|
+
# @param msg [String] message used in raised error
|
9
|
+
# @raise [Puppet::DevError] always raised with the supplied message
|
4
10
|
def devfail(msg)
|
5
11
|
self.fail(Puppet::DevError, msg)
|
6
12
|
end
|
7
13
|
|
8
|
-
# Add line and file info if available
|
14
|
+
# Add line and file info to the supplied exception if info is available from
|
15
|
+
# this object, is appropriately populated and the supplied exception supports
|
16
|
+
# it. When other is supplied, the backtrace will be copied to the error
|
17
|
+
# object.
|
18
|
+
#
|
19
|
+
# @param error [Exception] exception that is populated with info
|
20
|
+
# @param other [Exception] original exception, source of backtrace info
|
21
|
+
# @return [Exception] error parameter
|
9
22
|
def adderrorcontext(error, other = nil)
|
10
23
|
error.line ||= self.line if error.respond_to?(:line=) and self.respond_to?(:line) and self.line
|
11
24
|
error.file ||= self.file if error.respond_to?(:file=) and self.respond_to?(:file) and self.file
|
@@ -15,6 +28,10 @@ module Puppet::Util::Errors
|
|
15
28
|
error
|
16
29
|
end
|
17
30
|
|
31
|
+
# Return a human-readable string of this object's file and line attributes,
|
32
|
+
# if set.
|
33
|
+
#
|
34
|
+
# @return [String] description of file and line
|
18
35
|
def error_context
|
19
36
|
if file and line
|
20
37
|
" at #{file}:#{line}"
|
@@ -29,6 +46,15 @@ module Puppet::Util::Errors
|
|
29
46
|
|
30
47
|
# Wrap a call in such a way that we always throw the right exception and keep
|
31
48
|
# as much context as possible.
|
49
|
+
#
|
50
|
+
# @param options [Hash<Symbol,Object>] options used to create error
|
51
|
+
# @option options [Class] :type error type to raise, defaults to
|
52
|
+
# Puppet::DevError
|
53
|
+
# @option options [String] :message message to use in error, default mentions
|
54
|
+
# the name of this class
|
55
|
+
# @raise [Puppet::Error] re-raised with extra context if the block raises it
|
56
|
+
# @raise [Error] of type options[:type], when the block raises other
|
57
|
+
# exceptions
|
32
58
|
def exceptwrap(options = {})
|
33
59
|
options[:type] ||= Puppet::DevError
|
34
60
|
begin
|
@@ -48,6 +74,16 @@ module Puppet::Util::Errors
|
|
48
74
|
end
|
49
75
|
|
50
76
|
# Throw an error, defaulting to a Puppet::Error.
|
77
|
+
#
|
78
|
+
# @overload fail(message, ..)
|
79
|
+
# Throw a Puppet::Error with a message concatenated from the given
|
80
|
+
# arguments.
|
81
|
+
# @param [String] message error message(s)
|
82
|
+
# @overload fail(error_klass, message, ..)
|
83
|
+
# Throw an exception of type error_klass with a message concatenated from
|
84
|
+
# the given arguments.
|
85
|
+
# @param [Class] type of error
|
86
|
+
# @param [String] message error message(s)
|
51
87
|
def fail(*args)
|
52
88
|
if args[0].is_a?(Class)
|
53
89
|
type = args.shift
|
@@ -141,6 +141,11 @@ module Puppet::Util::FileParsing
|
|
141
141
|
end
|
142
142
|
|
143
143
|
# Try to match a record.
|
144
|
+
#
|
145
|
+
# @param [String] line The line to be parsed
|
146
|
+
# @param [Puppet::Util::FileType] record The filetype to use for parsing
|
147
|
+
#
|
148
|
+
# @return [Hash<Symbol, Object>] The parsed elements of the line
|
144
149
|
def handle_record_line(line, record)
|
145
150
|
ret = nil
|
146
151
|
if record.respond_to?(:process)
|
data/lib/puppet/util/filetype.rb
CHANGED
@@ -8,6 +8,8 @@ require 'fileutils'
|
|
8
8
|
class Puppet::Util::FileType
|
9
9
|
attr_accessor :loaded, :path, :synced
|
10
10
|
|
11
|
+
class FileReadError < Puppet::Error; end
|
12
|
+
|
11
13
|
include Puppet::Util::SELinux
|
12
14
|
|
13
15
|
class << self
|
@@ -166,7 +168,7 @@ class Puppet::Util::FileType
|
|
166
168
|
begin
|
167
169
|
@uid = Puppet::Util.uid(user)
|
168
170
|
rescue Puppet::Error => detail
|
169
|
-
raise
|
171
|
+
raise FileReadError, "Could not retrieve user #{user}: #{detail}", detail.backtrace
|
170
172
|
end
|
171
173
|
|
172
174
|
# XXX We have to have the user name, not the uid, because some
|
@@ -221,9 +223,9 @@ class Puppet::Util::FileType
|
|
221
223
|
when /can't open your crontab/
|
222
224
|
return ""
|
223
225
|
when /you are not authorized to use cron/
|
224
|
-
raise
|
226
|
+
raise FileReadError, "User #{@path} not authorized to use cron", detail.backtrace
|
225
227
|
else
|
226
|
-
raise
|
228
|
+
raise FileReadError, "Could not read crontab for #{@path}: #{detail}", detail.backtrace
|
227
229
|
end
|
228
230
|
end
|
229
231
|
|
@@ -231,7 +233,7 @@ class Puppet::Util::FileType
|
|
231
233
|
def remove
|
232
234
|
Puppet::Util::Execution.execute(%w{crontab -r}, cronargs)
|
233
235
|
rescue => detail
|
234
|
-
raise
|
236
|
+
raise FileReadError, "Could not remove crontab for #{@path}: #{detail}", detail.backtrace
|
235
237
|
end
|
236
238
|
|
237
239
|
# Overwrite a specific @path's cron tab; must be passed the @path name
|
@@ -245,7 +247,7 @@ class Puppet::Util::FileType
|
|
245
247
|
File.chown(Puppet::Util.uid(@path), nil, output_file.path)
|
246
248
|
Puppet::Util::Execution.execute(["crontab", output_file.path], cronargs)
|
247
249
|
rescue => detail
|
248
|
-
raise
|
250
|
+
raise FileReadError, "Could not write crontab for #{@path}: #{detail}", detail.backtrace
|
249
251
|
ensure
|
250
252
|
output_file.close
|
251
253
|
output_file.unlink
|
@@ -263,9 +265,9 @@ class Puppet::Util::FileType
|
|
263
265
|
when /Cannot open a file in the .* directory/
|
264
266
|
return ""
|
265
267
|
when /You are not authorized to use the cron command/
|
266
|
-
raise
|
268
|
+
raise FileReadError, "User #{@path} not authorized to use cron", detail.backtrace
|
267
269
|
else
|
268
|
-
raise
|
270
|
+
raise FileReadError, "Could not read crontab for #{@path}: #{detail}", detail.backtrace
|
269
271
|
end
|
270
272
|
end
|
271
273
|
|
@@ -273,7 +275,7 @@ class Puppet::Util::FileType
|
|
273
275
|
def remove
|
274
276
|
Puppet::Util::Execution.execute(%w{crontab -r}, cronargs)
|
275
277
|
rescue => detail
|
276
|
-
raise
|
278
|
+
raise FileReadError, "Could not remove crontab for #{@path}: #{detail}", detail.backtrace
|
277
279
|
end
|
278
280
|
|
279
281
|
# Overwrite a specific @path's cron tab; must be passed the @path name
|
@@ -288,7 +290,7 @@ class Puppet::Util::FileType
|
|
288
290
|
File.chown(Puppet::Util.uid(@path), nil, output_file.path)
|
289
291
|
Puppet::Util::Execution.execute(["crontab", output_file.path], cronargs)
|
290
292
|
rescue => detail
|
291
|
-
raise
|
293
|
+
raise FileReadError, "Could not write crontab for #{@path}: #{detail}", detail.backtrace
|
292
294
|
ensure
|
293
295
|
output_file.close
|
294
296
|
output_file.unlink
|
@@ -83,11 +83,11 @@ module Puppet::Util::Instrumentation::Instrumentable
|
|
83
83
|
# this can either be a static symbol/string or a block. If it's a block
|
84
84
|
# this one will be evaluated on every call of the instrumented method and
|
85
85
|
# should return a string or a symbol
|
86
|
-
#
|
86
|
+
#
|
87
87
|
# data::
|
88
88
|
# this can be a hash or a block. If it's a block this one will be evaluated
|
89
89
|
# on every call of the instrumented method and should return a hash.
|
90
|
-
#
|
90
|
+
#
|
91
91
|
#Example:
|
92
92
|
#
|
93
93
|
# class MyClass
|
@@ -0,0 +1,15 @@
|
|
1
|
+
[import]
|
2
|
+
login_defs = /etc/login.defs
|
3
|
+
default_useradd = /etc/default/useradd
|
4
|
+
|
5
|
+
[defaults]
|
6
|
+
crypt_style = md5
|
7
|
+
modules = files shadow
|
8
|
+
create_modules = files shadow
|
9
|
+
|
10
|
+
[userdefaults]
|
11
|
+
LU_USERNAME = %n
|
12
|
+
LU_GIDNUMBER = %u
|
13
|
+
|
14
|
+
[groupdefaults]
|
15
|
+
LU_GROUPNAME = %n
|
@@ -126,6 +126,25 @@ class Array
|
|
126
126
|
|
127
127
|
slice(n, length - n) or []
|
128
128
|
end unless method_defined? :drop
|
129
|
+
|
130
|
+
# Array does not have a to_hash method and Hash uses this instead of checking with "respond_to?" if an
|
131
|
+
# array can convert itself or not. (This is a bad thing in Hash). When Array is extended with a method_missing,
|
132
|
+
# (like when using the RGen package 0.6.1 where meta methods are available on arrays), this trips up the
|
133
|
+
# Hash implementation.
|
134
|
+
# This patch simply does what the regular to_hash does, and it is accompanied by a respond_to? method that
|
135
|
+
# returns false for :to_hash.
|
136
|
+
# This is really ugly, and should be removed when the implementation in lib/rgen/array_extension.rb is
|
137
|
+
# fixed to handle to_hash correctly.
|
138
|
+
def to_hash
|
139
|
+
raise NoMethodError.new
|
140
|
+
end
|
141
|
+
|
142
|
+
# @see #to_hash
|
143
|
+
def respond_to? m, include_private=false
|
144
|
+
return false if m == :to_hash
|
145
|
+
super
|
146
|
+
end
|
147
|
+
|
129
148
|
end
|
130
149
|
|
131
150
|
|
@@ -394,3 +413,32 @@ class OpenSSL::SSL::SSLContext
|
|
394
413
|
set_params(params)
|
395
414
|
end
|
396
415
|
end
|
416
|
+
|
417
|
+
require 'puppet/util/platform'
|
418
|
+
if Puppet::Util::Platform.windows?
|
419
|
+
require 'puppet/util/windows'
|
420
|
+
require 'openssl'
|
421
|
+
|
422
|
+
class OpenSSL::X509::Store
|
423
|
+
alias __original_set_default_paths set_default_paths
|
424
|
+
def set_default_paths
|
425
|
+
# This can be removed once openssl integrates with windows
|
426
|
+
# cert store, see http://rt.openssl.org/Ticket/Display.html?id=2158
|
427
|
+
Puppet::Util::Windows::RootCerts.instance.each do |x509|
|
428
|
+
add_cert(x509)
|
429
|
+
end
|
430
|
+
|
431
|
+
__original_set_default_paths
|
432
|
+
end
|
433
|
+
end
|
434
|
+
end
|
435
|
+
|
436
|
+
# Old puppet clients may make large GET requests, lets be reasonably tolerant
|
437
|
+
# in our default WEBrick server.
|
438
|
+
require 'webrick'
|
439
|
+
if defined?(WEBrick::HTTPRequest::MAX_URI_LENGTH) and WEBrick::HTTPRequest::MAX_URI_LENGTH < 8192
|
440
|
+
# Silence ruby warning: already initialized constant MAX_URI_LENGTH
|
441
|
+
v, $VERBOSE = $VERBOSE, nil
|
442
|
+
WEBrick::HTTPRequest.const_set("MAX_URI_LENGTH", 8192)
|
443
|
+
$VERBOSE = v
|
444
|
+
end
|
@@ -5,7 +5,7 @@ class Puppet::Util::NetworkDevice
|
|
5
5
|
|
6
6
|
def self.init(device)
|
7
7
|
require "puppet/util/network_device/#{device.provider}/device"
|
8
|
-
@current = Puppet::Util::NetworkDevice.const_get(device.provider.capitalize).const_get(:Device).new(device.url)
|
8
|
+
@current = Puppet::Util::NetworkDevice.const_get(device.provider.capitalize).const_get(:Device).new(device.url, device.options)
|
9
9
|
rescue => detail
|
10
10
|
raise "Can't load #{device.provider} for #{device.name}: #{detail}"
|
11
11
|
end
|
@@ -7,7 +7,7 @@ class Puppet::Util::NetworkDevice::Base
|
|
7
7
|
|
8
8
|
attr_accessor :url, :transport
|
9
9
|
|
10
|
-
def initialize(url)
|
10
|
+
def initialize(url, options = {})
|
11
11
|
@url = URI.parse(url)
|
12
12
|
|
13
13
|
@autoloader = Puppet::Util::Autoload.new(
|
@@ -17,7 +17,7 @@ class Puppet::Util::NetworkDevice::Base
|
|
17
17
|
)
|
18
18
|
|
19
19
|
if @autoloader.load(@url.scheme)
|
20
|
-
@transport = Puppet::Util::NetworkDevice::Transport.const_get(@url.scheme.capitalize).new
|
20
|
+
@transport = Puppet::Util::NetworkDevice::Transport.const_get(@url.scheme.capitalize).new(options[:debug])
|
21
21
|
@transport.host = @url.host
|
22
22
|
@transport.port = @url.port || case @url.scheme ; when "ssh" ; 22 ; when "telnet" ; 23 ; end
|
23
23
|
@transport.user = @url.user
|
@@ -13,26 +13,36 @@ class Puppet::Util::NetworkDevice::Cisco::Device < Puppet::Util::NetworkDevice::
|
|
13
13
|
attr_accessor :enable_password
|
14
14
|
|
15
15
|
def initialize(url, options = {})
|
16
|
-
super(url)
|
16
|
+
super(url, options)
|
17
17
|
@enable_password = options[:enable_password] || parse_enable(@url.query)
|
18
18
|
transport.default_prompt = /[#>]\s?\z/n
|
19
19
|
end
|
20
20
|
|
21
21
|
def parse_enable(query)
|
22
|
-
|
22
|
+
if query
|
23
|
+
params = CGI.parse(query)
|
24
|
+
params['enable'].first unless params['enable'].empty?
|
25
|
+
end
|
23
26
|
end
|
24
27
|
|
25
|
-
def
|
26
|
-
Puppet.debug("command #{cmd}")
|
28
|
+
def connect
|
27
29
|
transport.connect
|
28
30
|
login
|
29
31
|
transport.command("terminal length 0") do |out|
|
30
32
|
enable if out =~ />\s?\z/n
|
31
33
|
end
|
32
34
|
find_capabilities
|
35
|
+
end
|
36
|
+
|
37
|
+
def disconnect
|
38
|
+
transport.close
|
39
|
+
end
|
40
|
+
|
41
|
+
def command(cmd = nil)
|
42
|
+
connect
|
33
43
|
out = execute(cmd) if cmd
|
34
44
|
yield self if block_given?
|
35
|
-
|
45
|
+
disconnect
|
36
46
|
out
|
37
47
|
end
|
38
48
|
|
@@ -61,14 +71,14 @@ class Puppet::Util::NetworkDevice::Cisco::Device < Puppet::Util::NetworkDevice::
|
|
61
71
|
end
|
62
72
|
|
63
73
|
def find_capabilities
|
64
|
-
out =
|
74
|
+
out = execute("sh vlan brief")
|
65
75
|
lines = out.split("\n")
|
66
76
|
lines.shift; lines.pop
|
67
77
|
|
68
78
|
@support_vlan_brief = ! (lines.first =~ /^%/)
|
69
79
|
end
|
70
80
|
|
71
|
-
IF={
|
81
|
+
IF = {
|
72
82
|
:FastEthernet => %w{FastEthernet FastEth Fast FE Fa F},
|
73
83
|
:GigabitEthernet => %w{GigabitEthernet GigEthernet GigEth GE Gi G},
|
74
84
|
:TenGigabitEthernet => %w{TenGigabitEthernet TE Te},
|
@@ -116,7 +126,7 @@ class Puppet::Util::NetworkDevice::Cisco::Device < Puppet::Util::NetworkDevice::
|
|
116
126
|
|
117
127
|
def parse_interface(name)
|
118
128
|
resource = {}
|
119
|
-
out =
|
129
|
+
out = execute("sh interface #{name}")
|
120
130
|
lines = out.split("\n")
|
121
131
|
lines.shift; lines.pop
|
122
132
|
lines.each do |l|
|
@@ -144,7 +154,7 @@ class Puppet::Util::NetworkDevice::Cisco::Device < Puppet::Util::NetworkDevice::
|
|
144
154
|
|
145
155
|
def parse_interface_config(name)
|
146
156
|
resource = Hash.new { |hash, key| hash[key] = Array.new ; }
|
147
|
-
out =
|
157
|
+
out = execute("sh running-config interface #{name} | begin interface")
|
148
158
|
lines = out.split("\n")
|
149
159
|
lines.shift; lines.pop
|
150
160
|
lines.each do |l|
|
@@ -166,7 +176,7 @@ class Puppet::Util::NetworkDevice::Cisco::Device < Puppet::Util::NetworkDevice::
|
|
166
176
|
|
167
177
|
def parse_vlans
|
168
178
|
vlans = {}
|
169
|
-
out =
|
179
|
+
out = execute(support_vlan_brief? ? "sh vlan brief" : "sh vlan-switch brief")
|
170
180
|
lines = out.split("\n")
|
171
181
|
lines.shift; lines.shift; lines.shift; lines.pop
|
172
182
|
vlan = nil
|
@@ -193,27 +203,27 @@ class Puppet::Util::NetworkDevice::Cisco::Device < Puppet::Util::NetworkDevice::
|
|
193
203
|
def update_vlan(id, is = {}, should = {})
|
194
204
|
if should[:ensure] == :absent
|
195
205
|
Puppet.info "Removing #{id} from device vlan"
|
196
|
-
|
197
|
-
|
198
|
-
|
206
|
+
execute("conf t")
|
207
|
+
execute("no vlan #{id}")
|
208
|
+
execute("exit")
|
199
209
|
return
|
200
210
|
end
|
201
211
|
|
202
212
|
# We're creating or updating an entry
|
203
|
-
|
204
|
-
|
213
|
+
execute("conf t")
|
214
|
+
execute("vlan #{id}")
|
205
215
|
[is.keys, should.keys].flatten.uniq.each do |property|
|
206
216
|
Puppet.debug("trying property: #{property}: #{should[property]}")
|
207
217
|
next if property != :description
|
208
|
-
|
218
|
+
execute("name #{should[property]}")
|
209
219
|
end
|
210
|
-
|
211
|
-
|
220
|
+
execute("exit")
|
221
|
+
execute("exit")
|
212
222
|
end
|
213
223
|
|
214
224
|
def parse_trunking(interface)
|
215
225
|
trunking = {}
|
216
|
-
out =
|
226
|
+
out = execute("sh interface #{interface} switchport")
|
217
227
|
lines = out.split("\n")
|
218
228
|
lines.shift; lines.pop
|
219
229
|
lines.each do |l|
|