puppet-parse 0.0.1 → 0.0.2
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/.travis.yml +0 -5
- data/README.md +1 -3
- data/lib/puppet-parse/version.rb +1 -1
- data/lib/puppet-parse.rb +2 -2
- data/lib/vendor/puppet/agent/locker.rb +46 -0
- data/lib/vendor/puppet/agent.rb +99 -0
- data/lib/vendor/puppet/application/agent.rb +489 -0
- data/lib/vendor/puppet/application/apply.rb +266 -0
- data/lib/vendor/puppet/application/ca.rb +5 -0
- data/lib/vendor/puppet/application/catalog.rb +4 -0
- data/lib/vendor/puppet/application/cert.rb +240 -0
- data/lib/vendor/puppet/application/certificate.rb +13 -0
- data/lib/vendor/puppet/application/certificate_request.rb +4 -0
- data/lib/vendor/puppet/application/certificate_revocation_list.rb +4 -0
- data/lib/vendor/puppet/application/config.rb +4 -0
- data/lib/vendor/puppet/application/describe.rb +256 -0
- data/lib/vendor/puppet/application/device.rb +242 -0
- data/lib/vendor/puppet/application/doc.rb +275 -0
- data/lib/vendor/puppet/application/face_base.rb +264 -0
- data/lib/vendor/puppet/application/facts.rb +4 -0
- data/lib/vendor/puppet/application/file.rb +4 -0
- data/lib/vendor/puppet/application/filebucket.rb +191 -0
- data/lib/vendor/puppet/application/help.rb +4 -0
- data/lib/vendor/puppet/application/indirection_base.rb +4 -0
- data/lib/vendor/puppet/application/inspect.rb +191 -0
- data/lib/vendor/puppet/application/instrumentation_data.rb +4 -0
- data/lib/vendor/puppet/application/instrumentation_listener.rb +4 -0
- data/lib/vendor/puppet/application/instrumentation_probe.rb +4 -0
- data/lib/vendor/puppet/application/key.rb +4 -0
- data/lib/vendor/puppet/application/kick.rb +351 -0
- data/lib/vendor/puppet/application/man.rb +4 -0
- data/lib/vendor/puppet/application/master.rb +263 -0
- data/lib/vendor/puppet/application/module.rb +11 -0
- data/lib/vendor/puppet/application/node.rb +4 -0
- data/lib/vendor/puppet/application/parser.rb +5 -0
- data/lib/vendor/puppet/application/plugin.rb +3 -0
- data/lib/vendor/puppet/application/queue.rb +161 -0
- data/lib/vendor/puppet/application/report.rb +4 -0
- data/lib/vendor/puppet/application/resource.rb +237 -0
- data/lib/vendor/puppet/application/resource_type.rb +4 -0
- data/lib/vendor/puppet/application/secret_agent.rb +6 -0
- data/lib/vendor/puppet/application/status.rb +4 -0
- data/lib/vendor/puppet/application.rb +421 -0
- data/lib/vendor/puppet/configurer/downloader.rb +86 -0
- data/lib/vendor/puppet/configurer/fact_handler.rb +56 -0
- data/lib/vendor/puppet/configurer/plugin_handler.rb +37 -0
- data/lib/vendor/puppet/configurer.rb +249 -0
- data/lib/vendor/puppet/daemon.rb +200 -0
- data/lib/vendor/puppet/defaults.rb +970 -0
- data/lib/vendor/puppet/dsl/resource_api.rb +120 -0
- data/lib/vendor/puppet/dsl/resource_type_api.rb +34 -0
- data/lib/vendor/puppet/dsl.rb +7 -0
- data/lib/vendor/puppet/error.rb +43 -0
- data/lib/vendor/puppet/external/base64.rb +19 -0
- data/lib/vendor/puppet/external/dot.rb +326 -0
- data/lib/vendor/puppet/external/lock.rb +63 -0
- data/lib/vendor/puppet/external/nagios/base.rb +472 -0
- data/lib/vendor/puppet/external/nagios/grammar.ry +185 -0
- data/lib/vendor/puppet/external/nagios/makefile +9 -0
- data/lib/vendor/puppet/external/nagios/parser.rb +775 -0
- data/lib/vendor/puppet/external/nagios.rb +48 -0
- data/lib/vendor/puppet/external/pson/common.rb +370 -0
- data/lib/vendor/puppet/external/pson/pure/generator.rb +401 -0
- data/lib/vendor/puppet/external/pson/pure/parser.rb +264 -0
- data/lib/vendor/puppet/external/pson/pure.rb +77 -0
- data/lib/vendor/puppet/external/pson/version.rb +8 -0
- data/lib/vendor/puppet/face/ca.rb +242 -0
- data/lib/vendor/puppet/face/catalog/select.rb +49 -0
- data/lib/vendor/puppet/face/catalog.rb +131 -0
- data/lib/vendor/puppet/face/certificate.rb +148 -0
- data/lib/vendor/puppet/face/certificate_request.rb +53 -0
- data/lib/vendor/puppet/face/certificate_revocation_list.rb +58 -0
- data/lib/vendor/puppet/face/config.rb +45 -0
- data/lib/vendor/puppet/face/facts.rb +81 -0
- data/lib/vendor/puppet/face/file/download.rb +54 -0
- data/lib/vendor/puppet/face/file/store.rb +21 -0
- data/lib/vendor/puppet/face/file.rb +47 -0
- data/lib/vendor/puppet/face/help/action.erb +53 -0
- data/lib/vendor/puppet/face/help/face.erb +79 -0
- data/lib/vendor/puppet/face/help/global.erb +19 -0
- data/lib/vendor/puppet/face/help/man.erb +136 -0
- data/lib/vendor/puppet/face/help.rb +131 -0
- data/lib/vendor/puppet/face/instrumentation_data.rb +28 -0
- data/lib/vendor/puppet/face/instrumentation_listener.rb +96 -0
- data/lib/vendor/puppet/face/instrumentation_probe.rb +77 -0
- data/lib/vendor/puppet/face/key.rb +15 -0
- data/lib/vendor/puppet/face/man.rb +93 -0
- data/lib/vendor/puppet/face/module/build.rb +37 -0
- data/lib/vendor/puppet/face/module/changes.rb +38 -0
- data/lib/vendor/puppet/face/module/generate.rb +42 -0
- data/lib/vendor/puppet/face/module/install.rb +174 -0
- data/lib/vendor/puppet/face/module/list.rb +285 -0
- data/lib/vendor/puppet/face/module/search.rb +88 -0
- data/lib/vendor/puppet/face/module/uninstall.rb +86 -0
- data/lib/vendor/puppet/face/module/upgrade.rb +84 -0
- data/lib/vendor/puppet/face/module.rb +17 -0
- data/lib/vendor/puppet/face/node/clean.rb +156 -0
- data/lib/vendor/puppet/face/node.rb +43 -0
- data/lib/vendor/puppet/face/parser.rb +51 -0
- data/lib/vendor/puppet/face/plugin.rb +55 -0
- data/lib/vendor/puppet/face/report.rb +56 -0
- data/lib/vendor/puppet/face/resource.rb +53 -0
- data/lib/vendor/puppet/face/resource_type.rb +81 -0
- data/lib/vendor/puppet/face/secret_agent.rb +54 -0
- data/lib/vendor/puppet/face/status.rb +53 -0
- data/lib/vendor/puppet/face.rb +12 -0
- data/lib/vendor/puppet/feature/base.rb +67 -0
- data/lib/vendor/puppet/feature/eventlog.rb +6 -0
- data/lib/vendor/puppet/feature/pson.rb +6 -0
- data/lib/vendor/puppet/feature/rack.rb +24 -0
- data/lib/vendor/puppet/feature/rails.rb +30 -0
- data/lib/vendor/puppet/feature/rubygems.rb +3 -0
- data/lib/vendor/puppet/feature/selinux.rb +3 -0
- data/lib/vendor/puppet/feature/ssh.rb +4 -0
- data/lib/vendor/puppet/feature/stomp.rb +6 -0
- data/lib/vendor/puppet/feature/zlib.rb +6 -0
- data/lib/vendor/puppet/file_bucket/dipper.rb +107 -0
- data/lib/vendor/puppet/file_bucket/file.rb +55 -0
- data/lib/vendor/puppet/file_bucket.rb +4 -0
- data/lib/vendor/puppet/file_collection/lookup.rb +10 -0
- data/lib/vendor/puppet/file_collection.rb +19 -0
- data/lib/vendor/puppet/file_serving/base.rb +88 -0
- data/lib/vendor/puppet/file_serving/configuration/parser.rb +115 -0
- data/lib/vendor/puppet/file_serving/configuration.rb +122 -0
- data/lib/vendor/puppet/file_serving/content.rb +45 -0
- data/lib/vendor/puppet/file_serving/fileset.rb +173 -0
- data/lib/vendor/puppet/file_serving/metadata.rb +155 -0
- data/lib/vendor/puppet/file_serving/mount/file.rb +121 -0
- data/lib/vendor/puppet/file_serving/mount/modules.rb +24 -0
- data/lib/vendor/puppet/file_serving/mount/plugins.rb +26 -0
- data/lib/vendor/puppet/file_serving/mount.rb +39 -0
- data/lib/vendor/puppet/file_serving/terminus_helper.rb +21 -0
- data/lib/vendor/puppet/file_serving/terminus_selector.rb +28 -0
- data/lib/vendor/puppet/file_serving.rb +3 -0
- data/lib/vendor/puppet/forge/cache.rb +55 -0
- data/lib/vendor/puppet/forge/repository.rb +102 -0
- data/lib/vendor/puppet/forge.rb +98 -0
- data/lib/vendor/puppet/indirector/active_record.rb +28 -0
- data/lib/vendor/puppet/indirector/catalog/active_record.rb +41 -0
- data/lib/vendor/puppet/indirector/catalog/compiler.rb +153 -0
- data/lib/vendor/puppet/indirector/catalog/queue.rb +5 -0
- data/lib/vendor/puppet/indirector/catalog/rest.rb +6 -0
- data/lib/vendor/puppet/indirector/catalog/static_compiler.rb +136 -0
- data/lib/vendor/puppet/indirector/catalog/store_configs.rb +5 -0
- data/lib/vendor/puppet/indirector/catalog/yaml.rb +22 -0
- data/lib/vendor/puppet/indirector/certificate/ca.rb +9 -0
- data/lib/vendor/puppet/indirector/certificate/disabled_ca.rb +22 -0
- data/lib/vendor/puppet/indirector/certificate/file.rb +9 -0
- data/lib/vendor/puppet/indirector/certificate/rest.rb +15 -0
- data/lib/vendor/puppet/indirector/certificate_request/ca.rb +22 -0
- data/lib/vendor/puppet/indirector/certificate_request/disabled_ca.rb +22 -0
- data/lib/vendor/puppet/indirector/certificate_request/file.rb +8 -0
- data/lib/vendor/puppet/indirector/certificate_request/rest.rb +9 -0
- data/lib/vendor/puppet/indirector/certificate_revocation_list/ca.rb +8 -0
- data/lib/vendor/puppet/indirector/certificate_revocation_list/disabled_ca.rb +22 -0
- data/lib/vendor/puppet/indirector/certificate_revocation_list/file.rb +8 -0
- data/lib/vendor/puppet/indirector/certificate_revocation_list/rest.rb +9 -0
- data/lib/vendor/puppet/indirector/certificate_status/file.rb +82 -0
- data/lib/vendor/puppet/indirector/certificate_status/rest.rb +10 -0
- data/lib/vendor/puppet/indirector/certificate_status.rb +4 -0
- data/lib/vendor/puppet/indirector/code.rb +6 -0
- data/lib/vendor/puppet/indirector/couch.rb +78 -0
- data/lib/vendor/puppet/indirector/direct_file_server.rb +19 -0
- data/lib/vendor/puppet/indirector/envelope.rb +11 -0
- data/lib/vendor/puppet/indirector/exec.rb +48 -0
- data/lib/vendor/puppet/indirector/face.rb +137 -0
- data/lib/vendor/puppet/indirector/facts/active_record.rb +36 -0
- data/lib/vendor/puppet/indirector/facts/couch.rb +31 -0
- data/lib/vendor/puppet/indirector/facts/facter.rb +96 -0
- data/lib/vendor/puppet/indirector/facts/inventory_active_record.rb +100 -0
- data/lib/vendor/puppet/indirector/facts/inventory_service.rb +20 -0
- data/lib/vendor/puppet/indirector/facts/memory.rb +9 -0
- data/lib/vendor/puppet/indirector/facts/network_device.rb +25 -0
- data/lib/vendor/puppet/indirector/facts/rest.rb +8 -0
- data/lib/vendor/puppet/indirector/facts/store_configs.rb +5 -0
- data/lib/vendor/puppet/indirector/facts/yaml.rb +82 -0
- data/lib/vendor/puppet/indirector/file_bucket_file/file.rb +136 -0
- data/lib/vendor/puppet/indirector/file_bucket_file/rest.rb +8 -0
- data/lib/vendor/puppet/indirector/file_bucket_file/selector.rb +49 -0
- data/lib/vendor/puppet/indirector/file_content/file.rb +7 -0
- data/lib/vendor/puppet/indirector/file_content/file_server.rb +7 -0
- data/lib/vendor/puppet/indirector/file_content/rest.rb +7 -0
- data/lib/vendor/puppet/indirector/file_content/selector.rb +30 -0
- data/lib/vendor/puppet/indirector/file_content.rb +5 -0
- data/lib/vendor/puppet/indirector/file_metadata/file.rb +22 -0
- data/lib/vendor/puppet/indirector/file_metadata/file_server.rb +7 -0
- data/lib/vendor/puppet/indirector/file_metadata/rest.rb +7 -0
- data/lib/vendor/puppet/indirector/file_metadata/selector.rb +30 -0
- data/lib/vendor/puppet/indirector/file_metadata.rb +5 -0
- data/lib/vendor/puppet/indirector/file_server.rb +65 -0
- data/lib/vendor/puppet/indirector/indirection.rb +323 -0
- data/lib/vendor/puppet/indirector/instrumentation_data/local.rb +19 -0
- data/lib/vendor/puppet/indirector/instrumentation_data/rest.rb +5 -0
- data/lib/vendor/puppet/indirector/instrumentation_data.rb +3 -0
- data/lib/vendor/puppet/indirector/instrumentation_listener/local.rb +23 -0
- data/lib/vendor/puppet/indirector/instrumentation_listener/rest.rb +5 -0
- data/lib/vendor/puppet/indirector/instrumentation_listener.rb +3 -0
- data/lib/vendor/puppet/indirector/instrumentation_probe/local.rb +24 -0
- data/lib/vendor/puppet/indirector/instrumentation_probe/rest.rb +5 -0
- data/lib/vendor/puppet/indirector/instrumentation_probe.rb +3 -0
- data/lib/vendor/puppet/indirector/inventory/yaml.rb +81 -0
- data/lib/vendor/puppet/indirector/key/ca.rb +12 -0
- data/lib/vendor/puppet/indirector/key/disabled_ca.rb +22 -0
- data/lib/vendor/puppet/indirector/key/file.rb +42 -0
- data/lib/vendor/puppet/indirector/ldap.rb +78 -0
- data/lib/vendor/puppet/indirector/memory.rb +21 -0
- data/lib/vendor/puppet/indirector/node/active_record.rb +13 -0
- data/lib/vendor/puppet/indirector/node/exec.rb +60 -0
- data/lib/vendor/puppet/indirector/node/ldap.rb +256 -0
- data/lib/vendor/puppet/indirector/node/memory.rb +10 -0
- data/lib/vendor/puppet/indirector/node/plain.rb +19 -0
- data/lib/vendor/puppet/indirector/node/rest.rb +7 -0
- data/lib/vendor/puppet/indirector/node/store_configs.rb +5 -0
- data/lib/vendor/puppet/indirector/node/yaml.rb +7 -0
- data/lib/vendor/puppet/indirector/plain.rb +9 -0
- data/lib/vendor/puppet/indirector/queue.rb +81 -0
- data/lib/vendor/puppet/indirector/report/processor.rb +61 -0
- data/lib/vendor/puppet/indirector/report/rest.rb +7 -0
- data/lib/vendor/puppet/indirector/report/yaml.rb +11 -0
- data/lib/vendor/puppet/indirector/request.rb +204 -0
- data/lib/vendor/puppet/indirector/resource/active_record.rb +93 -0
- data/lib/vendor/puppet/indirector/resource/ral.rb +53 -0
- data/lib/vendor/puppet/indirector/resource/rest.rb +5 -0
- data/lib/vendor/puppet/indirector/resource/store_configs.rb +3 -0
- data/lib/vendor/puppet/indirector/resource_type/parser.rb +43 -0
- data/lib/vendor/puppet/indirector/resource_type/rest.rb +7 -0
- data/lib/vendor/puppet/indirector/resource_type.rb +5 -0
- data/lib/vendor/puppet/indirector/rest.rb +166 -0
- data/lib/vendor/puppet/indirector/run/local.rb +8 -0
- data/lib/vendor/puppet/indirector/run/rest.rb +6 -0
- data/lib/vendor/puppet/indirector/ssl_file.rb +178 -0
- data/lib/vendor/puppet/indirector/status/local.rb +7 -0
- data/lib/vendor/puppet/indirector/status/rest.rb +5 -0
- data/lib/vendor/puppet/indirector/status.rb +3 -0
- data/lib/vendor/puppet/indirector/store_configs.rb +30 -0
- data/lib/vendor/puppet/indirector/terminus.rb +145 -0
- data/lib/vendor/puppet/indirector/yaml.rb +75 -0
- data/lib/vendor/puppet/indirector.rb +57 -0
- data/lib/vendor/puppet/interface/action.rb +322 -0
- data/lib/vendor/puppet/interface/action_builder.rb +74 -0
- data/lib/vendor/puppet/interface/action_manager.rb +74 -0
- data/lib/vendor/puppet/interface/documentation.rb +230 -0
- data/lib/vendor/puppet/interface/face_collection.rb +128 -0
- data/lib/vendor/puppet/interface/option.rb +127 -0
- data/lib/vendor/puppet/interface/option_builder.rb +67 -0
- data/lib/vendor/puppet/interface/option_manager.rb +68 -0
- data/lib/vendor/puppet/interface.rb +161 -0
- data/lib/vendor/puppet/metatype/manager.rb +141 -0
- data/lib/vendor/puppet/module.rb +314 -0
- data/lib/vendor/puppet/module_tool/applications/application.rb +82 -0
- data/lib/vendor/puppet/module_tool/applications/builder.rb +91 -0
- data/lib/vendor/puppet/module_tool/applications/checksummer.rb +56 -0
- data/lib/vendor/puppet/module_tool/applications/generator.rb +141 -0
- data/lib/vendor/puppet/module_tool/applications/installer.rb +183 -0
- data/lib/vendor/puppet/module_tool/applications/searcher.rb +15 -0
- data/lib/vendor/puppet/module_tool/applications/uninstaller.rb +107 -0
- data/lib/vendor/puppet/module_tool/applications/unpacker.rb +67 -0
- data/lib/vendor/puppet/module_tool/applications/upgrader.rb +109 -0
- data/lib/vendor/puppet/module_tool/applications.rb +15 -0
- data/lib/vendor/puppet/module_tool/checksums.rb +52 -0
- data/lib/vendor/puppet/module_tool/contents_description.rb +82 -0
- data/lib/vendor/puppet/module_tool/dependency.rb +24 -0
- data/lib/vendor/puppet/module_tool/errors/base.rb +15 -0
- data/lib/vendor/puppet/module_tool/errors/installer.rb +90 -0
- data/lib/vendor/puppet/module_tool/errors/shared.rb +115 -0
- data/lib/vendor/puppet/module_tool/errors/uninstaller.rb +45 -0
- data/lib/vendor/puppet/module_tool/errors/upgrader.rb +72 -0
- data/lib/vendor/puppet/module_tool/errors.rb +9 -0
- data/lib/vendor/puppet/module_tool/metadata.rb +141 -0
- data/lib/vendor/puppet/module_tool/modulefile.rb +75 -0
- data/lib/vendor/puppet/module_tool/shared_behaviors.rb +161 -0
- data/lib/vendor/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +11 -0
- data/lib/vendor/puppet/module_tool/skeleton/templates/generator/README.erb +16 -0
- data/lib/vendor/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +41 -0
- data/lib/vendor/puppet/module_tool/skeleton/templates/generator/spec/spec_helper.rb +17 -0
- data/lib/vendor/puppet/module_tool/skeleton/templates/generator/tests/init.pp.erb +11 -0
- data/lib/vendor/puppet/module_tool/skeleton.rb +34 -0
- data/lib/vendor/puppet/module_tool.rb +99 -0
- data/lib/vendor/puppet/network/authconfig.rb +174 -0
- data/lib/vendor/puppet/network/authorization.rb +76 -0
- data/lib/vendor/puppet/network/authstore.rb +267 -0
- data/lib/vendor/puppet/network/client_request.rb +29 -0
- data/lib/vendor/puppet/network/format.rb +111 -0
- data/lib/vendor/puppet/network/format_handler.rb +181 -0
- data/lib/vendor/puppet/network/formats.rb +171 -0
- data/lib/vendor/puppet/network/handler/ca.rb +61 -0
- data/lib/vendor/puppet/network/handler/filebucket.rb +53 -0
- data/lib/vendor/puppet/network/handler/fileserver.rb +732 -0
- data/lib/vendor/puppet/network/handler/master.rb +87 -0
- data/lib/vendor/puppet/network/handler/report.rb +82 -0
- data/lib/vendor/puppet/network/handler/runner.rb +33 -0
- data/lib/vendor/puppet/network/handler/status.rb +18 -0
- data/lib/vendor/puppet/network/handler.rb +50 -0
- data/lib/vendor/puppet/network/http/api/v1.rb +83 -0
- data/lib/vendor/puppet/network/http/api.rb +4 -0
- data/lib/vendor/puppet/network/http/compression.rb +114 -0
- data/lib/vendor/puppet/network/http/handler.rb +247 -0
- data/lib/vendor/puppet/network/http/mongrel/rest.rb +99 -0
- data/lib/vendor/puppet/network/http/mongrel.rb +55 -0
- data/lib/vendor/puppet/network/http/rack/httphandler.rb +16 -0
- data/lib/vendor/puppet/network/http/rack/rest.rb +100 -0
- data/lib/vendor/puppet/network/http/rack/xmlrpc.rb +65 -0
- data/lib/vendor/puppet/network/http/rack.rb +65 -0
- data/lib/vendor/puppet/network/http/webrick/rest.rb +81 -0
- data/lib/vendor/puppet/network/http/webrick.rb +141 -0
- data/lib/vendor/puppet/network/http.rb +15 -0
- data/lib/vendor/puppet/network/http_pool.rb +57 -0
- data/lib/vendor/puppet/network/http_server/mongrel.rb +129 -0
- data/lib/vendor/puppet/network/http_server.rb +3 -0
- data/lib/vendor/puppet/network/rest_authconfig.rb +102 -0
- data/lib/vendor/puppet/network/rest_authorization.rb +23 -0
- data/lib/vendor/puppet/network/rest_controller.rb +2 -0
- data/lib/vendor/puppet/network/rights.rb +275 -0
- data/lib/vendor/puppet/network/server.rb +164 -0
- data/lib/vendor/puppet/network/xmlrpc/processor.rb +86 -0
- data/lib/vendor/puppet/network/xmlrpc/server.rb +19 -0
- data/lib/vendor/puppet/network/xmlrpc/webrick_servlet.rb +114 -0
- data/lib/vendor/puppet/network.rb +3 -0
- data/lib/vendor/puppet/node/environment.rb +216 -0
- data/lib/vendor/puppet/node/facts.rb +99 -0
- data/lib/vendor/puppet/node/inventory.rb +7 -0
- data/lib/vendor/puppet/node.rb +120 -0
- data/lib/vendor/puppet/parameter/path.rb +34 -0
- data/lib/vendor/puppet/parameter/value.rb +69 -0
- data/lib/vendor/puppet/parameter/value_collection.rb +143 -0
- data/lib/vendor/puppet/parameter.rb +316 -0
- data/lib/vendor/puppet/parser/ast/arithmetic_operator.rb +39 -0
- data/lib/vendor/puppet/parser/ast/astarray.rb +50 -0
- data/lib/vendor/puppet/parser/ast/asthash.rb +37 -0
- data/lib/vendor/puppet/parser/ast/boolean_operator.rb +46 -0
- data/lib/vendor/puppet/parser/ast/branch.rb +37 -0
- data/lib/vendor/puppet/parser/ast/caseopt.rb +52 -0
- data/lib/vendor/puppet/parser/ast/casestatement.rb +44 -0
- data/lib/vendor/puppet/parser/ast/collection.rb +49 -0
- data/lib/vendor/puppet/parser/ast/collexpr.rb +57 -0
- data/lib/vendor/puppet/parser/ast/comparison_operator.rb +38 -0
- data/lib/vendor/puppet/parser/ast/definition.rb +17 -0
- data/lib/vendor/puppet/parser/ast/else.rb +22 -0
- data/lib/vendor/puppet/parser/ast/function.rb +50 -0
- data/lib/vendor/puppet/parser/ast/hostclass.rb +29 -0
- data/lib/vendor/puppet/parser/ast/ifstatement.rb +34 -0
- data/lib/vendor/puppet/parser/ast/in_operator.rb +24 -0
- data/lib/vendor/puppet/parser/ast/leaf.rb +221 -0
- data/lib/vendor/puppet/parser/ast/match_operator.rb +28 -0
- data/lib/vendor/puppet/parser/ast/minus.rb +23 -0
- data/lib/vendor/puppet/parser/ast/node.rb +20 -0
- data/lib/vendor/puppet/parser/ast/nop.rb +11 -0
- data/lib/vendor/puppet/parser/ast/not.rb +19 -0
- data/lib/vendor/puppet/parser/ast/relationship.rb +47 -0
- data/lib/vendor/puppet/parser/ast/resource.rb +74 -0
- data/lib/vendor/puppet/parser/ast/resource_defaults.rb +24 -0
- data/lib/vendor/puppet/parser/ast/resource_instance.rb +9 -0
- data/lib/vendor/puppet/parser/ast/resource_override.rb +67 -0
- data/lib/vendor/puppet/parser/ast/resource_reference.rb +28 -0
- data/lib/vendor/puppet/parser/ast/resourceparam.rb +29 -0
- data/lib/vendor/puppet/parser/ast/selector.rb +44 -0
- data/lib/vendor/puppet/parser/ast/tag.rb +24 -0
- data/lib/vendor/puppet/parser/ast/top_level_construct.rb +4 -0
- data/lib/vendor/puppet/parser/ast/vardef.rb +33 -0
- data/lib/vendor/puppet/parser/ast.rb +139 -0
- data/lib/vendor/puppet/parser/collector.rb +176 -0
- data/lib/vendor/puppet/parser/compiler.rb +476 -0
- data/lib/vendor/puppet/parser/files.rb +88 -0
- data/lib/vendor/puppet/parser/functions/create_resources.rb +75 -0
- data/lib/vendor/puppet/parser/functions/defined.rb +49 -0
- data/lib/vendor/puppet/parser/functions/extlookup.rb +152 -0
- data/lib/vendor/puppet/parser/functions/fail.rb +4 -0
- data/lib/vendor/puppet/parser/functions/file.rb +23 -0
- data/lib/vendor/puppet/parser/functions/fqdn_rand.rb +13 -0
- data/lib/vendor/puppet/parser/functions/generate.rb +37 -0
- data/lib/vendor/puppet/parser/functions/include.rb +24 -0
- data/lib/vendor/puppet/parser/functions/inline_template.rb +21 -0
- data/lib/vendor/puppet/parser/functions/md5.rb +5 -0
- data/lib/vendor/puppet/parser/functions/realize.rb +14 -0
- data/lib/vendor/puppet/parser/functions/regsubst.rb +119 -0
- data/lib/vendor/puppet/parser/functions/require.rb +57 -0
- data/lib/vendor/puppet/parser/functions/search.rb +7 -0
- data/lib/vendor/puppet/parser/functions/sha1.rb +5 -0
- data/lib/vendor/puppet/parser/functions/shellquote.rb +61 -0
- data/lib/vendor/puppet/parser/functions/split.rb +29 -0
- data/lib/vendor/puppet/parser/functions/sprintf.rb +39 -0
- data/lib/vendor/puppet/parser/functions/tag.rb +6 -0
- data/lib/vendor/puppet/parser/functions/tagged.rb +18 -0
- data/lib/vendor/puppet/parser/functions/template.rb +23 -0
- data/lib/vendor/puppet/parser/functions/versioncmp.rb +37 -0
- data/lib/vendor/puppet/parser/functions.rb +165 -0
- data/lib/vendor/puppet/parser/grammar.ra +771 -0
- data/lib/vendor/puppet/parser/lexer.rb +617 -0
- data/lib/vendor/puppet/parser/makefile +8 -0
- data/lib/vendor/puppet/parser/parser.rb +2421 -0
- data/lib/vendor/puppet/parser/parser_support.rb +211 -0
- data/lib/vendor/puppet/parser/relationship.rb +62 -0
- data/lib/vendor/puppet/parser/resource/param.rb +25 -0
- data/lib/vendor/puppet/parser/resource.rb +341 -0
- data/lib/vendor/puppet/parser/scope.rb +497 -0
- data/lib/vendor/puppet/parser/templatewrapper.rb +115 -0
- data/lib/vendor/puppet/parser/type_loader.rb +172 -0
- data/lib/vendor/puppet/parser/yaml_trimmer.rb +9 -0
- data/lib/vendor/puppet/parser.rb +4 -0
- data/lib/vendor/puppet/property/ensure.rb +92 -0
- data/lib/vendor/puppet/property/keyvalue.rb +86 -0
- data/lib/vendor/puppet/property/list.rb +75 -0
- data/lib/vendor/puppet/property/ordered_list.rb +22 -0
- data/lib/vendor/puppet/property.rb +373 -0
- data/lib/vendor/puppet/provider/aixobject.rb +393 -0
- data/lib/vendor/puppet/provider/augeas/augeas.rb +418 -0
- data/lib/vendor/puppet/provider/cisco.rb +9 -0
- data/lib/vendor/puppet/provider/computer/computer.rb +20 -0
- data/lib/vendor/puppet/provider/confine/exists.rb +19 -0
- data/lib/vendor/puppet/provider/confine/false.rb +19 -0
- data/lib/vendor/puppet/provider/confine/feature.rb +17 -0
- data/lib/vendor/puppet/provider/confine/true.rb +20 -0
- data/lib/vendor/puppet/provider/confine/variable.rb +59 -0
- data/lib/vendor/puppet/provider/confine.rb +80 -0
- data/lib/vendor/puppet/provider/confine_collection.rb +50 -0
- data/lib/vendor/puppet/provider/confiner.rb +16 -0
- data/lib/vendor/puppet/provider/cron/crontab.rb +200 -0
- data/lib/vendor/puppet/provider/exec/posix.rb +39 -0
- data/lib/vendor/puppet/provider/exec/shell.rb +25 -0
- data/lib/vendor/puppet/provider/exec/windows.rb +56 -0
- data/lib/vendor/puppet/provider/exec.rb +84 -0
- data/lib/vendor/puppet/provider/file/posix.rb +135 -0
- data/lib/vendor/puppet/provider/file/windows.rb +88 -0
- data/lib/vendor/puppet/provider/group/aix.rb +141 -0
- data/lib/vendor/puppet/provider/group/directoryservice.rb +12 -0
- data/lib/vendor/puppet/provider/group/groupadd.rb +29 -0
- data/lib/vendor/puppet/provider/group/ldap.rb +45 -0
- data/lib/vendor/puppet/provider/group/pw.rb +48 -0
- data/lib/vendor/puppet/provider/group/windows_adsi.rb +54 -0
- data/lib/vendor/puppet/provider/host/parsed.rb +44 -0
- data/lib/vendor/puppet/provider/interface/base.rb +0 -0
- data/lib/vendor/puppet/provider/interface/cisco.rb +27 -0
- data/lib/vendor/puppet/provider/ldap.rb +137 -0
- data/lib/vendor/puppet/provider/macauthorization/macauthorization.rb +313 -0
- data/lib/vendor/puppet/provider/mailalias/aliases.rb +44 -0
- data/lib/vendor/puppet/provider/maillist/mailman.rb +108 -0
- data/lib/vendor/puppet/provider/mcx/mcxcontent.rb +166 -0
- data/lib/vendor/puppet/provider/mount/parsed.rb +124 -0
- data/lib/vendor/puppet/provider/mount.rb +46 -0
- data/lib/vendor/puppet/provider/naginator.rb +63 -0
- data/lib/vendor/puppet/provider/nameservice/directoryservice.rb +652 -0
- data/lib/vendor/puppet/provider/nameservice/objectadd.rb +33 -0
- data/lib/vendor/puppet/provider/nameservice/pw.rb +21 -0
- data/lib/vendor/puppet/provider/nameservice.rb +276 -0
- data/lib/vendor/puppet/provider/network_device.rb +68 -0
- data/lib/vendor/puppet/provider/package/aix.rb +128 -0
- data/lib/vendor/puppet/provider/package/appdmg.rb +109 -0
- data/lib/vendor/puppet/provider/package/apple.rb +47 -0
- data/lib/vendor/puppet/provider/package/apt.rb +111 -0
- data/lib/vendor/puppet/provider/package/aptitude.rb +29 -0
- data/lib/vendor/puppet/provider/package/aptrpm.rb +83 -0
- data/lib/vendor/puppet/provider/package/blastwave.rb +111 -0
- data/lib/vendor/puppet/provider/package/dpkg.rb +155 -0
- data/lib/vendor/puppet/provider/package/fink.rb +81 -0
- data/lib/vendor/puppet/provider/package/freebsd.rb +49 -0
- data/lib/vendor/puppet/provider/package/gem.rb +127 -0
- data/lib/vendor/puppet/provider/package/hpux.rb +44 -0
- data/lib/vendor/puppet/provider/package/macports.rb +105 -0
- data/lib/vendor/puppet/provider/package/msi.rb +141 -0
- data/lib/vendor/puppet/provider/package/nim.rb +35 -0
- data/lib/vendor/puppet/provider/package/openbsd.rb +112 -0
- data/lib/vendor/puppet/provider/package/pacman.rb +94 -0
- data/lib/vendor/puppet/provider/package/pip.rb +111 -0
- data/lib/vendor/puppet/provider/package/pkg.rb +112 -0
- data/lib/vendor/puppet/provider/package/pkgdmg.rb +123 -0
- data/lib/vendor/puppet/provider/package/pkgutil.rb +174 -0
- data/lib/vendor/puppet/provider/package/portage.rb +124 -0
- data/lib/vendor/puppet/provider/package/ports.rb +94 -0
- data/lib/vendor/puppet/provider/package/portupgrade.rb +241 -0
- data/lib/vendor/puppet/provider/package/rpm.rb +132 -0
- data/lib/vendor/puppet/provider/package/rug.rb +52 -0
- data/lib/vendor/puppet/provider/package/sun.rb +154 -0
- data/lib/vendor/puppet/provider/package/sunfreeware.rb +9 -0
- data/lib/vendor/puppet/provider/package/up2date.rb +41 -0
- data/lib/vendor/puppet/provider/package/urpmi.rb +59 -0
- data/lib/vendor/puppet/provider/package/yum.rb +106 -0
- data/lib/vendor/puppet/provider/package/yumhelper.py +129 -0
- data/lib/vendor/puppet/provider/package/zypper.rb +84 -0
- data/lib/vendor/puppet/provider/package.rb +28 -0
- data/lib/vendor/puppet/provider/parsedfile.rb +374 -0
- data/lib/vendor/puppet/provider/port/parsed.rb +173 -0
- data/lib/vendor/puppet/provider/scheduled_task/win32_taskscheduler.rb +565 -0
- data/lib/vendor/puppet/provider/selboolean/getsetsebool.rb +47 -0
- data/lib/vendor/puppet/provider/selmodule/semodule.rb +134 -0
- data/lib/vendor/puppet/provider/service/base.rb +105 -0
- data/lib/vendor/puppet/provider/service/bsd.rb +49 -0
- data/lib/vendor/puppet/provider/service/daemontools.rb +194 -0
- data/lib/vendor/puppet/provider/service/debian.rb +68 -0
- data/lib/vendor/puppet/provider/service/freebsd.rb +139 -0
- data/lib/vendor/puppet/provider/service/gentoo.rb +54 -0
- data/lib/vendor/puppet/provider/service/init.rb +140 -0
- data/lib/vendor/puppet/provider/service/launchd.rb +303 -0
- data/lib/vendor/puppet/provider/service/openrc.rb +69 -0
- data/lib/vendor/puppet/provider/service/redhat.rb +76 -0
- data/lib/vendor/puppet/provider/service/runit.rb +103 -0
- data/lib/vendor/puppet/provider/service/service.rb +43 -0
- data/lib/vendor/puppet/provider/service/smf.rb +104 -0
- data/lib/vendor/puppet/provider/service/src.rb +86 -0
- data/lib/vendor/puppet/provider/service/systemd.rb +64 -0
- data/lib/vendor/puppet/provider/service/upstart.rb +347 -0
- data/lib/vendor/puppet/provider/service/windows.rb +106 -0
- data/lib/vendor/puppet/provider/ssh_authorized_key/parsed.rb +88 -0
- data/lib/vendor/puppet/provider/sshkey/parsed.rb +37 -0
- data/lib/vendor/puppet/provider/user/aix.rb +357 -0
- data/lib/vendor/puppet/provider/user/directoryservice.rb +86 -0
- data/lib/vendor/puppet/provider/user/hpux.rb +31 -0
- data/lib/vendor/puppet/provider/user/ldap.rb +129 -0
- data/lib/vendor/puppet/provider/user/pw.rb +101 -0
- data/lib/vendor/puppet/provider/user/user_role_add.rb +207 -0
- data/lib/vendor/puppet/provider/user/useradd.rb +127 -0
- data/lib/vendor/puppet/provider/user/windows_adsi.rb +99 -0
- data/lib/vendor/puppet/provider/vlan/cisco.rb +28 -0
- data/lib/vendor/puppet/provider/zfs/solaris.rb +45 -0
- data/lib/vendor/puppet/provider/zone/solaris.rb +260 -0
- data/lib/vendor/puppet/provider/zpool/solaris.rb +116 -0
- data/lib/vendor/puppet/provider.rb +290 -0
- data/lib/vendor/puppet/rails/benchmark.rb +63 -0
- data/lib/vendor/puppet/rails/database/001_add_created_at_to_all_tables.rb +13 -0
- data/lib/vendor/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb +13 -0
- data/lib/vendor/puppet/rails/database/003_add_environment_to_host.rb +9 -0
- data/lib/vendor/puppet/rails/database/004_add_inventory_service_tables.rb +36 -0
- data/lib/vendor/puppet/rails/database/schema.rb +131 -0
- data/lib/vendor/puppet/rails/fact_name.rb +6 -0
- data/lib/vendor/puppet/rails/fact_value.rb +8 -0
- data/lib/vendor/puppet/rails/host.rb +258 -0
- data/lib/vendor/puppet/rails/inventory_fact.rb +5 -0
- data/lib/vendor/puppet/rails/inventory_node.rb +43 -0
- data/lib/vendor/puppet/rails/param_name.rb +25 -0
- data/lib/vendor/puppet/rails/param_value.rb +74 -0
- data/lib/vendor/puppet/rails/puppet_tag.rb +10 -0
- data/lib/vendor/puppet/rails/resource.rb +231 -0
- data/lib/vendor/puppet/rails/resource_tag.rb +26 -0
- data/lib/vendor/puppet/rails/source_file.rb +8 -0
- data/lib/vendor/puppet/rails.rb +132 -0
- data/lib/vendor/puppet/rb_tree_map.rb +388 -0
- data/lib/vendor/puppet/reference/configuration.rb +69 -0
- data/lib/vendor/puppet/reference/function.rb +17 -0
- data/lib/vendor/puppet/reference/indirection.rb +32 -0
- data/lib/vendor/puppet/reference/metaparameter.rb +43 -0
- data/lib/vendor/puppet/reference/network.rb +39 -0
- data/lib/vendor/puppet/reference/providers.rb +119 -0
- data/lib/vendor/puppet/reference/report.rb +23 -0
- data/lib/vendor/puppet/reference/type.rb +116 -0
- data/lib/vendor/puppet/relationship.rb +95 -0
- data/lib/vendor/puppet/reports/http.rb +25 -0
- data/lib/vendor/puppet/reports/log.rb +14 -0
- data/lib/vendor/puppet/reports/rrdgraph.rb +128 -0
- data/lib/vendor/puppet/reports/store.rb +74 -0
- data/lib/vendor/puppet/reports/tagmail.rb +179 -0
- data/lib/vendor/puppet/reports.rb +49 -0
- data/lib/vendor/puppet/resource/catalog.rb +661 -0
- data/lib/vendor/puppet/resource/status.rb +79 -0
- data/lib/vendor/puppet/resource/type.rb +344 -0
- data/lib/vendor/puppet/resource/type_collection.rb +215 -0
- data/lib/vendor/puppet/resource/type_collection_helper.rb +7 -0
- data/lib/vendor/puppet/resource.rb +467 -0
- data/lib/vendor/puppet/run.rb +77 -0
- data/lib/vendor/puppet/simple_graph.rb +550 -0
- data/lib/vendor/puppet/ssl/base.rb +86 -0
- data/lib/vendor/puppet/ssl/certificate.rb +40 -0
- data/lib/vendor/puppet/ssl/certificate_authority/interface.rb +182 -0
- data/lib/vendor/puppet/ssl/certificate_authority.rb +374 -0
- data/lib/vendor/puppet/ssl/certificate_factory.rb +166 -0
- data/lib/vendor/puppet/ssl/certificate_request.rb +149 -0
- data/lib/vendor/puppet/ssl/certificate_revocation_list.rb +84 -0
- data/lib/vendor/puppet/ssl/host.rb +365 -0
- data/lib/vendor/puppet/ssl/inventory.rb +54 -0
- data/lib/vendor/puppet/ssl/key.rb +56 -0
- data/lib/vendor/puppet/ssl.rb +8 -0
- data/lib/vendor/puppet/status.rb +28 -0
- data/lib/vendor/puppet/test/test_helper.rb +141 -0
- data/lib/vendor/puppet/transaction/event.rb +66 -0
- data/lib/vendor/puppet/transaction/event_manager.rb +115 -0
- data/lib/vendor/puppet/transaction/report.rb +200 -0
- data/lib/vendor/puppet/transaction/resource_harness.rb +178 -0
- data/lib/vendor/puppet/transaction.rb +493 -0
- data/lib/vendor/puppet/transportable.rb +248 -0
- data/lib/vendor/puppet/type/augeas.rb +218 -0
- data/lib/vendor/puppet/type/component.rb +85 -0
- data/lib/vendor/puppet/type/computer.rb +66 -0
- data/lib/vendor/puppet/type/cron.rb +421 -0
- data/lib/vendor/puppet/type/exec.rb +520 -0
- data/lib/vendor/puppet/type/file/checksum.rb +33 -0
- data/lib/vendor/puppet/type/file/content.rb +230 -0
- data/lib/vendor/puppet/type/file/ctime.rb +18 -0
- data/lib/vendor/puppet/type/file/ensure.rb +172 -0
- data/lib/vendor/puppet/type/file/group.rb +41 -0
- data/lib/vendor/puppet/type/file/mode.rb +148 -0
- data/lib/vendor/puppet/type/file/mtime.rb +17 -0
- data/lib/vendor/puppet/type/file/owner.rb +44 -0
- data/lib/vendor/puppet/type/file/selcontext.rb +123 -0
- data/lib/vendor/puppet/type/file/source.rb +195 -0
- data/lib/vendor/puppet/type/file/target.rb +87 -0
- data/lib/vendor/puppet/type/file/type.rb +19 -0
- data/lib/vendor/puppet/type/file.rb +829 -0
- data/lib/vendor/puppet/type/filebucket.rb +114 -0
- data/lib/vendor/puppet/type/group.rb +149 -0
- data/lib/vendor/puppet/type/host.rb +87 -0
- data/lib/vendor/puppet/type/interface.rb +112 -0
- data/lib/vendor/puppet/type/k5login.rb +88 -0
- data/lib/vendor/puppet/type/macauthorization.rb +167 -0
- data/lib/vendor/puppet/type/mailalias.rb +48 -0
- data/lib/vendor/puppet/type/maillist.rb +62 -0
- data/lib/vendor/puppet/type/mcx.rb +99 -0
- data/lib/vendor/puppet/type/mount.rb +241 -0
- data/lib/vendor/puppet/type/nagios_command.rb +3 -0
- data/lib/vendor/puppet/type/nagios_contact.rb +3 -0
- data/lib/vendor/puppet/type/nagios_contactgroup.rb +3 -0
- data/lib/vendor/puppet/type/nagios_host.rb +3 -0
- data/lib/vendor/puppet/type/nagios_hostdependency.rb +3 -0
- data/lib/vendor/puppet/type/nagios_hostescalation.rb +3 -0
- data/lib/vendor/puppet/type/nagios_hostextinfo.rb +3 -0
- data/lib/vendor/puppet/type/nagios_hostgroup.rb +3 -0
- data/lib/vendor/puppet/type/nagios_service.rb +3 -0
- data/lib/vendor/puppet/type/nagios_servicedependency.rb +3 -0
- data/lib/vendor/puppet/type/nagios_serviceescalation.rb +3 -0
- data/lib/vendor/puppet/type/nagios_serviceextinfo.rb +3 -0
- data/lib/vendor/puppet/type/nagios_servicegroup.rb +3 -0
- data/lib/vendor/puppet/type/nagios_timeperiod.rb +3 -0
- data/lib/vendor/puppet/type/notify.rb +44 -0
- data/lib/vendor/puppet/type/package.rb +357 -0
- data/lib/vendor/puppet/type/port.rb +119 -0
- data/lib/vendor/puppet/type/resources.rb +131 -0
- data/lib/vendor/puppet/type/router.rb +17 -0
- data/lib/vendor/puppet/type/schedule.rb +360 -0
- data/lib/vendor/puppet/type/scheduled_task.rb +166 -0
- data/lib/vendor/puppet/type/selboolean.rb +26 -0
- data/lib/vendor/puppet/type/selmodule.rb +59 -0
- data/lib/vendor/puppet/type/service.rb +221 -0
- data/lib/vendor/puppet/type/ssh_authorized_key.rb +112 -0
- data/lib/vendor/puppet/type/sshkey.rb +72 -0
- data/lib/vendor/puppet/type/stage.rb +19 -0
- data/lib/vendor/puppet/type/tidy.rb +333 -0
- data/lib/vendor/puppet/type/user.rb +524 -0
- data/lib/vendor/puppet/type/vlan.rb +26 -0
- data/lib/vendor/puppet/type/whit.rb +34 -0
- data/lib/vendor/puppet/type/yumrepo.rb +361 -0
- data/lib/vendor/puppet/type/zfs.rb +146 -0
- data/lib/vendor/puppet/type/zone.rb +492 -0
- data/lib/vendor/puppet/type/zpool.rb +91 -0
- data/lib/vendor/puppet/type.rb +1979 -0
- data/lib/vendor/puppet/util/adsi.rb +296 -0
- data/lib/vendor/puppet/util/autoload/file_cache.rb +92 -0
- data/lib/vendor/puppet/util/autoload.rb +158 -0
- data/lib/vendor/puppet/util/backups.rb +87 -0
- data/lib/vendor/puppet/util/cacher.rb +80 -0
- data/lib/vendor/puppet/util/checksums.rb +143 -0
- data/lib/vendor/puppet/util/classgen.rb +209 -0
- data/lib/vendor/puppet/util/colors.rb +128 -0
- data/lib/vendor/puppet/util/command_line.rb +185 -0
- data/lib/vendor/puppet/util/constant_inflector.rb +15 -0
- data/lib/vendor/puppet/util/diff.rb +77 -0
- data/lib/vendor/puppet/util/docs.rb +123 -0
- data/lib/vendor/puppet/util/errors.rb +63 -0
- data/lib/vendor/puppet/util/execution.rb +20 -0
- data/lib/vendor/puppet/util/execution_stub.rb +26 -0
- data/lib/vendor/puppet/util/feature.rb +83 -0
- data/lib/vendor/puppet/util/file_locking.rb +47 -0
- data/lib/vendor/puppet/util/fileparsing.rb +373 -0
- data/lib/vendor/puppet/util/filetype.rb +296 -0
- data/lib/vendor/puppet/util/graph.rb +27 -0
- data/lib/vendor/puppet/util/inifile.rb +203 -0
- data/lib/vendor/puppet/util/inline_docs.rb +26 -0
- data/lib/vendor/puppet/util/instance_loader.rb +81 -0
- data/lib/vendor/puppet/util/instrumentation/data.rb +34 -0
- data/lib/vendor/puppet/util/instrumentation/indirection_probe.rb +29 -0
- data/lib/vendor/puppet/util/instrumentation/instrumentable.rb +143 -0
- data/lib/vendor/puppet/util/instrumentation/listener.rb +60 -0
- data/lib/vendor/puppet/util/instrumentation/listeners/log.rb +29 -0
- data/lib/vendor/puppet/util/instrumentation/listeners/performance.rb +30 -0
- data/lib/vendor/puppet/util/instrumentation.rb +171 -0
- data/lib/vendor/puppet/util/ldap/connection.rb +74 -0
- data/lib/vendor/puppet/util/ldap/generator.rb +42 -0
- data/lib/vendor/puppet/util/ldap/manager.rb +279 -0
- data/lib/vendor/puppet/util/ldap.rb +2 -0
- data/lib/vendor/puppet/util/loadedfile.rb +61 -0
- data/lib/vendor/puppet/util/log/destination.rb +49 -0
- data/lib/vendor/puppet/util/log/destinations.rb +268 -0
- data/lib/vendor/puppet/util/log.rb +275 -0
- data/lib/vendor/puppet/util/log_paths.rb +22 -0
- data/lib/vendor/puppet/util/logging.rb +51 -0
- data/lib/vendor/puppet/util/metaid.rb +21 -0
- data/lib/vendor/puppet/util/methodhelper.rb +32 -0
- data/lib/vendor/puppet/util/metric.rb +186 -0
- data/lib/vendor/puppet/util/monkey_patches.rb +243 -0
- data/lib/vendor/puppet/util/nagios_maker.rb +60 -0
- data/lib/vendor/puppet/util/network_device/base.rb +27 -0
- data/lib/vendor/puppet/util/network_device/cisco/device.rb +257 -0
- data/lib/vendor/puppet/util/network_device/cisco/facts.rb +72 -0
- data/lib/vendor/puppet/util/network_device/cisco/interface.rb +82 -0
- data/lib/vendor/puppet/util/network_device/cisco.rb +4 -0
- data/lib/vendor/puppet/util/network_device/config.rb +92 -0
- data/lib/vendor/puppet/util/network_device/ipcalc.rb +68 -0
- data/lib/vendor/puppet/util/network_device/transport/base.rb +26 -0
- data/lib/vendor/puppet/util/network_device/transport/ssh.rb +121 -0
- data/lib/vendor/puppet/util/network_device/transport/telnet.rb +42 -0
- data/lib/vendor/puppet/util/network_device/transport.rb +3 -0
- data/lib/vendor/puppet/util/network_device.rb +17 -0
- data/lib/vendor/puppet/util/package.rb +31 -0
- data/lib/vendor/puppet/util/pidlock.rb +117 -0
- data/lib/vendor/puppet/util/platform.rb +22 -0
- data/lib/vendor/puppet/util/plugins.rb +82 -0
- data/lib/vendor/puppet/util/posix.rb +137 -0
- data/lib/vendor/puppet/util/provider_features.rb +168 -0
- data/lib/vendor/puppet/util/pson.rb +13 -0
- data/lib/vendor/puppet/util/queue/stomp.rb +60 -0
- data/lib/vendor/puppet/util/queue.rb +96 -0
- data/lib/vendor/puppet/util/rails/cache_accumulator.rb +65 -0
- data/lib/vendor/puppet/util/rails/collection_merger.rb +17 -0
- data/lib/vendor/puppet/util/rails/reference_serializer.rb +32 -0
- data/lib/vendor/puppet/util/rdoc.rb +87 -0
- data/lib/vendor/puppet/util/reference.rb +124 -0
- data/lib/vendor/puppet/util/resource_template.rb +61 -0
- data/lib/vendor/puppet/util/retryaction.rb +48 -0
- data/lib/vendor/puppet/util/run_mode.rb +82 -0
- data/lib/vendor/puppet/util/selinux.rb +211 -0
- data/lib/vendor/puppet/util/settings/boolean_setting.rb +30 -0
- data/lib/vendor/puppet/util/settings/file_setting.rb +135 -0
- data/lib/vendor/puppet/util/settings/setting.rb +94 -0
- data/lib/vendor/puppet/util/settings.rb +926 -0
- data/lib/vendor/puppet/util/storage.rb +96 -0
- data/lib/vendor/puppet/util/subclass_loader.rb +82 -0
- data/lib/vendor/puppet/util/suidmanager.rb +173 -0
- data/lib/vendor/puppet/util/symbolic_file_mode.rb +140 -0
- data/lib/vendor/puppet/util/tagging.rb +78 -0
- data/lib/vendor/puppet/util/terminal.rb +16 -0
- data/lib/vendor/puppet/util/user_attr.rb +21 -0
- data/lib/vendor/puppet/util/warnings.rb +29 -0
- data/lib/vendor/puppet/util/windows/error.rb +16 -0
- data/lib/vendor/puppet/util/windows/file.rb +27 -0
- data/lib/vendor/puppet/util/windows/process.rb +33 -0
- data/lib/vendor/puppet/util/windows/security.rb +622 -0
- data/lib/vendor/puppet/util/windows/sid.rb +96 -0
- data/lib/vendor/puppet/util/windows/user.rb +106 -0
- data/lib/vendor/puppet/util/windows.rb +8 -0
- data/lib/vendor/puppet/util/zaml.rb +407 -0
- data/lib/vendor/puppet/util.rb +646 -0
- data/lib/vendor/puppet/version.rb +18 -0
- data/lib/vendor/puppet.rb +125 -0
- data/lib/vendor/semver.rb +124 -0
- data/puppet-parse.gemspec +2 -8
- metadata +812 -94
|
@@ -0,0 +1,1979 @@
|
|
|
1
|
+
require 'puppet'
|
|
2
|
+
require 'puppet/util/log'
|
|
3
|
+
require 'puppet/util/metric'
|
|
4
|
+
require 'puppet/property'
|
|
5
|
+
require 'puppet/parameter'
|
|
6
|
+
require 'puppet/util'
|
|
7
|
+
require 'puppet/util/autoload'
|
|
8
|
+
require 'puppet/metatype/manager'
|
|
9
|
+
require 'puppet/util/errors'
|
|
10
|
+
require 'puppet/util/log_paths'
|
|
11
|
+
require 'puppet/util/logging'
|
|
12
|
+
require 'puppet/util/tagging'
|
|
13
|
+
|
|
14
|
+
# see the bottom of the file for the rest of the inclusions
|
|
15
|
+
|
|
16
|
+
module Puppet
|
|
17
|
+
class Type
|
|
18
|
+
include Puppet::Util
|
|
19
|
+
include Puppet::Util::Errors
|
|
20
|
+
include Puppet::Util::LogPaths
|
|
21
|
+
include Puppet::Util::Logging
|
|
22
|
+
include Puppet::Util::Tagging
|
|
23
|
+
|
|
24
|
+
###############################
|
|
25
|
+
# Comparing type instances.
|
|
26
|
+
include Comparable
|
|
27
|
+
def <=>(other)
|
|
28
|
+
# We only order against other types, not arbitrary objects.
|
|
29
|
+
return nil unless other.is_a? Puppet::Type
|
|
30
|
+
# Our natural order is based on the reference name we use when comparing
|
|
31
|
+
# against other type instances.
|
|
32
|
+
self.ref <=> other.ref
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
###############################
|
|
36
|
+
# Code related to resource type attributes.
|
|
37
|
+
class << self
|
|
38
|
+
include Puppet::Util::ClassGen
|
|
39
|
+
include Puppet::Util::Warnings
|
|
40
|
+
attr_reader :properties
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.states
|
|
44
|
+
warnonce "The states method is deprecated; use properties"
|
|
45
|
+
properties
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# All parameters, in the appropriate order. The key_attributes come first, then
|
|
49
|
+
# the provider, then the properties, and finally the params and metaparams
|
|
50
|
+
# in the order they were specified in the files.
|
|
51
|
+
def self.allattrs
|
|
52
|
+
key_attributes | (parameters & [:provider]) | properties.collect { |property| property.name } | parameters | metaparams
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Retrieve an attribute alias, if there is one.
|
|
56
|
+
def self.attr_alias(param)
|
|
57
|
+
# Intern again, because this might be called by someone who doesn't
|
|
58
|
+
# understand the calling convention and all.
|
|
59
|
+
@attr_aliases[param.intern]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Create an alias to an existing attribute. This will cause the aliased
|
|
63
|
+
# attribute to be valid when setting and retrieving values on the instance.
|
|
64
|
+
def self.set_attr_alias(hash)
|
|
65
|
+
hash.each do |new, old|
|
|
66
|
+
@attr_aliases[new.intern] = old.intern
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Find the class associated with any given attribute.
|
|
71
|
+
def self.attrclass(name)
|
|
72
|
+
@attrclasses ||= {}
|
|
73
|
+
|
|
74
|
+
# We cache the value, since this method gets called such a huge number
|
|
75
|
+
# of times (as in, hundreds of thousands in a given run).
|
|
76
|
+
unless @attrclasses.include?(name)
|
|
77
|
+
@attrclasses[name] = case self.attrtype(name)
|
|
78
|
+
when :property; @validproperties[name]
|
|
79
|
+
when :meta; @@metaparamhash[name]
|
|
80
|
+
when :param; @paramhash[name]
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
@attrclasses[name]
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# What type of parameter are we dealing with? Cache the results, because
|
|
87
|
+
# this method gets called so many times.
|
|
88
|
+
def self.attrtype(attr)
|
|
89
|
+
@attrtypes ||= {}
|
|
90
|
+
unless @attrtypes.include?(attr)
|
|
91
|
+
@attrtypes[attr] = case
|
|
92
|
+
when @validproperties.include?(attr); :property
|
|
93
|
+
when @paramhash.include?(attr); :param
|
|
94
|
+
when @@metaparamhash.include?(attr); :meta
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
@attrtypes[attr]
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def self.eachmetaparam
|
|
102
|
+
@@metaparams.each { |p| yield p.name }
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Create the 'ensure' class. This is a separate method so other types
|
|
106
|
+
# can easily call it and create their own 'ensure' values.
|
|
107
|
+
def self.ensurable(&block)
|
|
108
|
+
if block_given?
|
|
109
|
+
self.newproperty(:ensure, :parent => Puppet::Property::Ensure, &block)
|
|
110
|
+
else
|
|
111
|
+
self.newproperty(:ensure, :parent => Puppet::Property::Ensure) do
|
|
112
|
+
self.defaultvalues
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Should we add the 'ensure' property to this class?
|
|
118
|
+
def self.ensurable?
|
|
119
|
+
# If the class has all three of these methods defined, then it's
|
|
120
|
+
# ensurable.
|
|
121
|
+
[:exists?, :create, :destroy].all? { |method|
|
|
122
|
+
self.public_method_defined?(method)
|
|
123
|
+
}
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# These `apply_to` methods are horrible. They should really be implemented
|
|
127
|
+
# as part of the usual system of constraints that apply to a type and
|
|
128
|
+
# provider pair, but were implemented as a separate shadow system.
|
|
129
|
+
#
|
|
130
|
+
# We should rip them out in favour of a real constraint pattern around the
|
|
131
|
+
# target device - whatever that looks like - and not have this additional
|
|
132
|
+
# magic here. --daniel 2012-03-08
|
|
133
|
+
def self.apply_to_device
|
|
134
|
+
@apply_to = :device
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def self.apply_to_host
|
|
138
|
+
@apply_to = :host
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def self.apply_to_all
|
|
142
|
+
@apply_to = :both
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def self.apply_to
|
|
146
|
+
@apply_to ||= :host
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def self.can_apply_to(target)
|
|
150
|
+
[ target == :device ? :device : :host, :both ].include?(apply_to)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Deal with any options passed into parameters.
|
|
154
|
+
def self.handle_param_options(name, options)
|
|
155
|
+
# If it's a boolean parameter, create a method to test the value easily
|
|
156
|
+
if options[:boolean]
|
|
157
|
+
define_method(name.to_s + "?") do
|
|
158
|
+
val = self[name]
|
|
159
|
+
if val == :true or val == true
|
|
160
|
+
return true
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Is the parameter in question a meta-parameter?
|
|
167
|
+
def self.metaparam?(param)
|
|
168
|
+
@@metaparamhash.include?(param.intern)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Find the metaparameter class associated with a given metaparameter name.
|
|
172
|
+
# Must accept a `nil` name, and return nil.
|
|
173
|
+
def self.metaparamclass(name)
|
|
174
|
+
return nil if name.nil?
|
|
175
|
+
@@metaparamhash[name.intern]
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def self.metaparams
|
|
179
|
+
@@metaparams.collect { |param| param.name }
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def self.metaparamdoc(metaparam)
|
|
183
|
+
@@metaparamhash[metaparam].doc
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# Create a new metaparam. Requires a block and a name, stores it in the
|
|
187
|
+
# @parameters array, and does some basic checking on it.
|
|
188
|
+
def self.newmetaparam(name, options = {}, &block)
|
|
189
|
+
@@metaparams ||= []
|
|
190
|
+
@@metaparamhash ||= {}
|
|
191
|
+
name = name.intern
|
|
192
|
+
|
|
193
|
+
param = genclass(
|
|
194
|
+
name,
|
|
195
|
+
:parent => options[:parent] || Puppet::Parameter,
|
|
196
|
+
:prefix => "MetaParam",
|
|
197
|
+
:hash => @@metaparamhash,
|
|
198
|
+
:array => @@metaparams,
|
|
199
|
+
:attributes => options[:attributes],
|
|
200
|
+
&block
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
# Grr.
|
|
204
|
+
param.required_features = options[:required_features] if options[:required_features]
|
|
205
|
+
|
|
206
|
+
handle_param_options(name, options)
|
|
207
|
+
|
|
208
|
+
param.metaparam = true
|
|
209
|
+
|
|
210
|
+
param
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def self.key_attribute_parameters
|
|
214
|
+
@key_attribute_parameters ||= (
|
|
215
|
+
params = @parameters.find_all { |param|
|
|
216
|
+
param.isnamevar? or param.name == :name
|
|
217
|
+
}
|
|
218
|
+
)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def self.key_attributes
|
|
222
|
+
# This is a cache miss around 0.05 percent of the time. --daniel 2012-07-17
|
|
223
|
+
@key_attributes_cache ||= key_attribute_parameters.collect { |p| p.name }
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def self.title_patterns
|
|
227
|
+
case key_attributes.length
|
|
228
|
+
when 0; []
|
|
229
|
+
when 1;
|
|
230
|
+
[ [ /(.*)/m, [ [key_attributes.first] ] ] ]
|
|
231
|
+
else
|
|
232
|
+
raise Puppet::DevError,"you must specify title patterns when there are two or more key attributes"
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def uniqueness_key
|
|
237
|
+
self.class.key_attributes.sort_by { |attribute_name| attribute_name.to_s }.map{ |attribute_name| self[attribute_name] }
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# Create a new parameter. Requires a block and a name, stores it in the
|
|
241
|
+
# @parameters array, and does some basic checking on it.
|
|
242
|
+
def self.newparam(name, options = {}, &block)
|
|
243
|
+
options[:attributes] ||= {}
|
|
244
|
+
|
|
245
|
+
param = genclass(
|
|
246
|
+
name,
|
|
247
|
+
:parent => options[:parent] || Puppet::Parameter,
|
|
248
|
+
:attributes => options[:attributes],
|
|
249
|
+
:block => block,
|
|
250
|
+
:prefix => "Parameter",
|
|
251
|
+
:array => @parameters,
|
|
252
|
+
:hash => @paramhash
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
handle_param_options(name, options)
|
|
256
|
+
|
|
257
|
+
# Grr.
|
|
258
|
+
param.required_features = options[:required_features] if options[:required_features]
|
|
259
|
+
|
|
260
|
+
param.isnamevar if options[:namevar]
|
|
261
|
+
|
|
262
|
+
param
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
def self.newstate(name, options = {}, &block)
|
|
266
|
+
Puppet.warning "newstate() has been deprecrated; use newproperty(#{name})"
|
|
267
|
+
newproperty(name, options, &block)
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# Create a new property. The first parameter must be the name of the property;
|
|
271
|
+
# this is how users will refer to the property when creating new instances.
|
|
272
|
+
# The second parameter is a hash of options; the options are:
|
|
273
|
+
# * <tt>:parent</tt>: The parent class for the property. Defaults to Puppet::Property.
|
|
274
|
+
# * <tt>:retrieve</tt>: The method to call on the provider or @parent object (if
|
|
275
|
+
# the provider is not set) to retrieve the current value.
|
|
276
|
+
def self.newproperty(name, options = {}, &block)
|
|
277
|
+
name = name.intern
|
|
278
|
+
|
|
279
|
+
# This is here for types that might still have the old method of defining
|
|
280
|
+
# a parent class.
|
|
281
|
+
unless options.is_a? Hash
|
|
282
|
+
raise Puppet::DevError,
|
|
283
|
+
"Options must be a hash, not #{options.inspect}"
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
raise Puppet::DevError, "Class #{self.name} already has a property named #{name}" if @validproperties.include?(name)
|
|
287
|
+
|
|
288
|
+
if parent = options[:parent]
|
|
289
|
+
options.delete(:parent)
|
|
290
|
+
else
|
|
291
|
+
parent = Puppet::Property
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# We have to create our own, new block here because we want to define
|
|
295
|
+
# an initial :retrieve method, if told to, and then eval the passed
|
|
296
|
+
# block if available.
|
|
297
|
+
prop = genclass(name, :parent => parent, :hash => @validproperties, :attributes => options) do
|
|
298
|
+
# If they've passed a retrieve method, then override the retrieve
|
|
299
|
+
# method on the class.
|
|
300
|
+
if options[:retrieve]
|
|
301
|
+
define_method(:retrieve) do
|
|
302
|
+
provider.send(options[:retrieve])
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
class_eval(&block) if block
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
# If it's the 'ensure' property, always put it first.
|
|
310
|
+
if name == :ensure
|
|
311
|
+
@properties.unshift prop
|
|
312
|
+
else
|
|
313
|
+
@properties << prop
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
prop
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
def self.paramdoc(param)
|
|
320
|
+
@paramhash[param].doc
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# Return the parameter names
|
|
324
|
+
def self.parameters
|
|
325
|
+
return [] unless defined?(@parameters)
|
|
326
|
+
@parameters.collect { |klass| klass.name }
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
# Find the parameter class associated with a given parameter name.
|
|
330
|
+
def self.paramclass(name)
|
|
331
|
+
@paramhash[name]
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
# Return the property class associated with a name
|
|
335
|
+
def self.propertybyname(name)
|
|
336
|
+
@validproperties[name]
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
def self.validattr?(name)
|
|
340
|
+
name = name.intern
|
|
341
|
+
return true if name == :name
|
|
342
|
+
@validattrs ||= {}
|
|
343
|
+
|
|
344
|
+
unless @validattrs.include?(name)
|
|
345
|
+
@validattrs[name] = !!(self.validproperty?(name) or self.validparameter?(name) or self.metaparam?(name))
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
@validattrs[name]
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
# does the name reflect a valid property?
|
|
352
|
+
def self.validproperty?(name)
|
|
353
|
+
name = name.intern
|
|
354
|
+
@validproperties.include?(name) && @validproperties[name]
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
# Return the list of validproperties
|
|
358
|
+
def self.validproperties
|
|
359
|
+
return {} unless defined?(@parameters)
|
|
360
|
+
|
|
361
|
+
@validproperties.keys
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
# does the name reflect a valid parameter?
|
|
365
|
+
def self.validparameter?(name)
|
|
366
|
+
raise Puppet::DevError, "Class #{self} has not defined parameters" unless defined?(@parameters)
|
|
367
|
+
!!(@paramhash.include?(name) or @@metaparamhash.include?(name))
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
# This is a forward-compatibility method - it's the validity interface we'll use in Puppet::Resource.
|
|
371
|
+
def self.valid_parameter?(name)
|
|
372
|
+
validattr?(name)
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
# Return either the attribute alias or the attribute.
|
|
376
|
+
def attr_alias(name)
|
|
377
|
+
name = name.intern
|
|
378
|
+
if synonym = self.class.attr_alias(name)
|
|
379
|
+
return synonym
|
|
380
|
+
else
|
|
381
|
+
return name
|
|
382
|
+
end
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
# Are we deleting this resource?
|
|
386
|
+
def deleting?
|
|
387
|
+
obj = @parameters[:ensure] and obj.should == :absent
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
# Create a new property if it is valid but doesn't exist
|
|
391
|
+
# Returns: true if a new parameter was added, false otherwise
|
|
392
|
+
def add_property_parameter(prop_name)
|
|
393
|
+
if self.class.validproperty?(prop_name) && !@parameters[prop_name]
|
|
394
|
+
self.newattr(prop_name)
|
|
395
|
+
return true
|
|
396
|
+
end
|
|
397
|
+
false
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
#
|
|
401
|
+
# The name_var is the key_attribute in the case that there is only one.
|
|
402
|
+
#
|
|
403
|
+
def name_var
|
|
404
|
+
key_attributes = self.class.key_attributes
|
|
405
|
+
(key_attributes.length == 1) && key_attributes.first
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
# abstract accessing parameters and properties, and normalize
|
|
409
|
+
# access to always be symbols, not strings
|
|
410
|
+
# This returns a value, not an object. It returns the 'is'
|
|
411
|
+
# value, but you can also specifically return 'is' and 'should'
|
|
412
|
+
# values using 'object.is(:property)' or 'object.should(:property)'.
|
|
413
|
+
def [](name)
|
|
414
|
+
name = attr_alias(name)
|
|
415
|
+
|
|
416
|
+
fail("Invalid parameter #{name}(#{name.inspect})") unless self.class.validattr?(name)
|
|
417
|
+
|
|
418
|
+
if name == :name && nv = name_var
|
|
419
|
+
name = nv
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
if obj = @parameters[name]
|
|
423
|
+
# Note that if this is a property, then the value is the "should" value,
|
|
424
|
+
# not the current value.
|
|
425
|
+
obj.value
|
|
426
|
+
else
|
|
427
|
+
return nil
|
|
428
|
+
end
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
# Abstract setting parameters and properties, and normalize
|
|
432
|
+
# access to always be symbols, not strings. This sets the 'should'
|
|
433
|
+
# value on properties, and otherwise just sets the appropriate parameter.
|
|
434
|
+
def []=(name,value)
|
|
435
|
+
name = attr_alias(name)
|
|
436
|
+
|
|
437
|
+
fail("Invalid parameter #{name}") unless self.class.validattr?(name)
|
|
438
|
+
|
|
439
|
+
if name == :name && nv = name_var
|
|
440
|
+
name = nv
|
|
441
|
+
end
|
|
442
|
+
raise Puppet::Error.new("Got nil value for #{name}") if value.nil?
|
|
443
|
+
|
|
444
|
+
property = self.newattr(name)
|
|
445
|
+
|
|
446
|
+
if property
|
|
447
|
+
begin
|
|
448
|
+
# make sure the parameter doesn't have any errors
|
|
449
|
+
property.value = value
|
|
450
|
+
rescue => detail
|
|
451
|
+
error = Puppet::Error.new("Parameter #{name} failed on #{ref}: #{detail}")
|
|
452
|
+
error.set_backtrace(detail.backtrace)
|
|
453
|
+
raise error
|
|
454
|
+
end
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
nil
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
# remove a property from the object; useful in testing or in cleanup
|
|
461
|
+
# when an error has been encountered
|
|
462
|
+
def delete(attr)
|
|
463
|
+
attr = attr.intern
|
|
464
|
+
if @parameters.has_key?(attr)
|
|
465
|
+
@parameters.delete(attr)
|
|
466
|
+
else
|
|
467
|
+
raise Puppet::DevError.new("Undefined attribute '#{attr}' in #{self}")
|
|
468
|
+
end
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
# iterate across the existing properties
|
|
472
|
+
def eachproperty
|
|
473
|
+
# properties is a private method
|
|
474
|
+
properties.each { |property|
|
|
475
|
+
yield property
|
|
476
|
+
}
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
# Create a transaction event. Called by Transaction or by
|
|
480
|
+
# a property.
|
|
481
|
+
def event(options = {})
|
|
482
|
+
Puppet::Transaction::Event.new({:resource => self, :file => file, :line => line, :tags => tags}.merge(options))
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
# retrieve the 'should' value for a specified property
|
|
486
|
+
def should(name)
|
|
487
|
+
name = attr_alias(name)
|
|
488
|
+
(prop = @parameters[name] and prop.is_a?(Puppet::Property)) ? prop.should : nil
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
# Create the actual attribute instance. Requires either the attribute
|
|
492
|
+
# name or class as the first argument, then an optional hash of
|
|
493
|
+
# attributes to set during initialization.
|
|
494
|
+
def newattr(name)
|
|
495
|
+
if name.is_a?(Class)
|
|
496
|
+
klass = name
|
|
497
|
+
name = klass.name
|
|
498
|
+
end
|
|
499
|
+
|
|
500
|
+
unless klass = self.class.attrclass(name)
|
|
501
|
+
raise Puppet::Error, "Resource type #{self.class.name} does not support parameter #{name}"
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
if provider and ! provider.class.supports_parameter?(klass)
|
|
505
|
+
missing = klass.required_features.find_all { |f| ! provider.class.feature?(f) }
|
|
506
|
+
debug "Provider %s does not support features %s; not managing attribute %s" % [provider.class.name, missing.join(", "), name]
|
|
507
|
+
return nil
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
return @parameters[name] if @parameters.include?(name)
|
|
511
|
+
|
|
512
|
+
@parameters[name] = klass.new(:resource => self)
|
|
513
|
+
end
|
|
514
|
+
|
|
515
|
+
# return the value of a parameter
|
|
516
|
+
def parameter(name)
|
|
517
|
+
@parameters[name.to_sym]
|
|
518
|
+
end
|
|
519
|
+
|
|
520
|
+
def parameters
|
|
521
|
+
@parameters.dup
|
|
522
|
+
end
|
|
523
|
+
|
|
524
|
+
# Is the named property defined?
|
|
525
|
+
def propertydefined?(name)
|
|
526
|
+
name = name.intern unless name.is_a? Symbol
|
|
527
|
+
@parameters.include?(name)
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
# Return an actual property instance by name; to return the value, use 'resource[param]'
|
|
531
|
+
# LAK:NOTE(20081028) Since the 'parameter' method is now a superset of this method,
|
|
532
|
+
# this one should probably go away at some point.
|
|
533
|
+
def property(name)
|
|
534
|
+
(obj = @parameters[name.intern] and obj.is_a?(Puppet::Property)) ? obj : nil
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
# For any parameters or properties that have defaults and have not yet been
|
|
538
|
+
# set, set them now. This method can be handed a list of attributes,
|
|
539
|
+
# and if so it will only set defaults for those attributes.
|
|
540
|
+
def set_default(attr)
|
|
541
|
+
return unless klass = self.class.attrclass(attr)
|
|
542
|
+
return unless klass.method_defined?(:default)
|
|
543
|
+
return if @parameters.include?(klass.name)
|
|
544
|
+
|
|
545
|
+
return unless parameter = newattr(klass.name)
|
|
546
|
+
|
|
547
|
+
if value = parameter.default and ! value.nil?
|
|
548
|
+
parameter.value = value
|
|
549
|
+
else
|
|
550
|
+
@parameters.delete(parameter.name)
|
|
551
|
+
end
|
|
552
|
+
end
|
|
553
|
+
|
|
554
|
+
# Convert our object to a hash. This just includes properties.
|
|
555
|
+
def to_hash
|
|
556
|
+
rethash = {}
|
|
557
|
+
|
|
558
|
+
@parameters.each do |name, obj|
|
|
559
|
+
rethash[name] = obj.value
|
|
560
|
+
end
|
|
561
|
+
|
|
562
|
+
rethash
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
def type
|
|
566
|
+
self.class.name
|
|
567
|
+
end
|
|
568
|
+
|
|
569
|
+
# Return a specific value for an attribute.
|
|
570
|
+
def value(name)
|
|
571
|
+
name = attr_alias(name)
|
|
572
|
+
|
|
573
|
+
(obj = @parameters[name] and obj.respond_to?(:value)) ? obj.value : nil
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
def version
|
|
577
|
+
return 0 unless catalog
|
|
578
|
+
catalog.version
|
|
579
|
+
end
|
|
580
|
+
|
|
581
|
+
# Return all of the property objects, in the order specified in the
|
|
582
|
+
# class.
|
|
583
|
+
def properties
|
|
584
|
+
self.class.properties.collect { |prop| @parameters[prop.name] }.compact
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
# Is this type's name isomorphic with the object? That is, if the
|
|
588
|
+
# name conflicts, does it necessarily mean that the objects conflict?
|
|
589
|
+
# Defaults to true.
|
|
590
|
+
def self.isomorphic?
|
|
591
|
+
if defined?(@isomorphic)
|
|
592
|
+
return @isomorphic
|
|
593
|
+
else
|
|
594
|
+
return true
|
|
595
|
+
end
|
|
596
|
+
end
|
|
597
|
+
|
|
598
|
+
def isomorphic?
|
|
599
|
+
self.class.isomorphic?
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
# is the instance a managed instance? A 'yes' here means that
|
|
603
|
+
# the instance was created from the language, vs. being created
|
|
604
|
+
# in order resolve other questions, such as finding a package
|
|
605
|
+
# in a list
|
|
606
|
+
def managed?
|
|
607
|
+
# Once an object is managed, it always stays managed; but an object
|
|
608
|
+
# that is listed as unmanaged might become managed later in the process,
|
|
609
|
+
# so we have to check that every time
|
|
610
|
+
if @managed
|
|
611
|
+
return @managed
|
|
612
|
+
else
|
|
613
|
+
@managed = false
|
|
614
|
+
properties.each { |property|
|
|
615
|
+
s = property.should
|
|
616
|
+
if s and ! property.class.unmanaged
|
|
617
|
+
@managed = true
|
|
618
|
+
break
|
|
619
|
+
end
|
|
620
|
+
}
|
|
621
|
+
return @managed
|
|
622
|
+
end
|
|
623
|
+
end
|
|
624
|
+
|
|
625
|
+
###############################
|
|
626
|
+
# Code related to the container behaviour.
|
|
627
|
+
|
|
628
|
+
def depthfirst?
|
|
629
|
+
false
|
|
630
|
+
end
|
|
631
|
+
|
|
632
|
+
# Remove an object. The argument determines whether the object's
|
|
633
|
+
# subscriptions get eliminated, too.
|
|
634
|
+
def remove(rmdeps = true)
|
|
635
|
+
# This is hackish (mmm, cut and paste), but it works for now, and it's
|
|
636
|
+
# better than warnings.
|
|
637
|
+
@parameters.each do |name, obj|
|
|
638
|
+
obj.remove
|
|
639
|
+
end
|
|
640
|
+
@parameters.clear
|
|
641
|
+
|
|
642
|
+
@parent = nil
|
|
643
|
+
|
|
644
|
+
# Remove the reference to the provider.
|
|
645
|
+
if self.provider
|
|
646
|
+
@provider.clear
|
|
647
|
+
@provider = nil
|
|
648
|
+
end
|
|
649
|
+
end
|
|
650
|
+
|
|
651
|
+
###############################
|
|
652
|
+
# Code related to evaluating the resources.
|
|
653
|
+
|
|
654
|
+
def ancestors
|
|
655
|
+
[]
|
|
656
|
+
end
|
|
657
|
+
|
|
658
|
+
# Flush the provider, if it supports it. This is called by the
|
|
659
|
+
# transaction.
|
|
660
|
+
def flush
|
|
661
|
+
self.provider.flush if self.provider and self.provider.respond_to?(:flush)
|
|
662
|
+
end
|
|
663
|
+
|
|
664
|
+
# if all contained objects are in sync, then we're in sync
|
|
665
|
+
# FIXME I don't think this is used on the type instances any more,
|
|
666
|
+
# it's really only used for testing
|
|
667
|
+
def insync?(is)
|
|
668
|
+
insync = true
|
|
669
|
+
|
|
670
|
+
if property = @parameters[:ensure]
|
|
671
|
+
unless is.include? property
|
|
672
|
+
raise Puppet::DevError,
|
|
673
|
+
"The is value is not in the is array for '#{property.name}'"
|
|
674
|
+
end
|
|
675
|
+
ensureis = is[property]
|
|
676
|
+
if property.safe_insync?(ensureis) and property.should == :absent
|
|
677
|
+
return true
|
|
678
|
+
end
|
|
679
|
+
end
|
|
680
|
+
|
|
681
|
+
properties.each { |property|
|
|
682
|
+
unless is.include? property
|
|
683
|
+
raise Puppet::DevError,
|
|
684
|
+
"The is value is not in the is array for '#{property.name}'"
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
propis = is[property]
|
|
688
|
+
unless property.safe_insync?(propis)
|
|
689
|
+
property.debug("Not in sync: #{propis.inspect} vs #{property.should.inspect}")
|
|
690
|
+
insync = false
|
|
691
|
+
#else
|
|
692
|
+
# property.debug("In sync")
|
|
693
|
+
end
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
#self.debug("#{self} sync status is #{insync}")
|
|
697
|
+
insync
|
|
698
|
+
end
|
|
699
|
+
|
|
700
|
+
# retrieve the current value of all contained properties
|
|
701
|
+
def retrieve
|
|
702
|
+
fail "Provider #{provider.class.name} is not functional on this host" if self.provider.is_a?(Puppet::Provider) and ! provider.class.suitable?
|
|
703
|
+
|
|
704
|
+
result = Puppet::Resource.new(type, title)
|
|
705
|
+
|
|
706
|
+
# Provide the name, so we know we'll always refer to a real thing
|
|
707
|
+
result[:name] = self[:name] unless self[:name] == title
|
|
708
|
+
|
|
709
|
+
if ensure_prop = property(:ensure) or (self.class.validattr?(:ensure) and ensure_prop = newattr(:ensure))
|
|
710
|
+
result[:ensure] = ensure_state = ensure_prop.retrieve
|
|
711
|
+
else
|
|
712
|
+
ensure_state = nil
|
|
713
|
+
end
|
|
714
|
+
|
|
715
|
+
properties.each do |property|
|
|
716
|
+
next if property.name == :ensure
|
|
717
|
+
if ensure_state == :absent
|
|
718
|
+
result[property] = :absent
|
|
719
|
+
else
|
|
720
|
+
result[property] = property.retrieve
|
|
721
|
+
end
|
|
722
|
+
end
|
|
723
|
+
|
|
724
|
+
result
|
|
725
|
+
end
|
|
726
|
+
|
|
727
|
+
def retrieve_resource
|
|
728
|
+
resource = retrieve
|
|
729
|
+
resource = Resource.new(type, title, :parameters => resource) if resource.is_a? Hash
|
|
730
|
+
resource
|
|
731
|
+
end
|
|
732
|
+
|
|
733
|
+
# Get a hash of the current properties. Returns a hash with
|
|
734
|
+
# the actual property instance as the key and the current value
|
|
735
|
+
# as the, um, value.
|
|
736
|
+
def currentpropvalues
|
|
737
|
+
# It's important to use the 'properties' method here, as it follows the order
|
|
738
|
+
# in which they're defined in the class. It also guarantees that 'ensure'
|
|
739
|
+
# is the first property, which is important for skipping 'retrieve' on
|
|
740
|
+
# all the properties if the resource is absent.
|
|
741
|
+
ensure_state = false
|
|
742
|
+
return properties.inject({}) do | prophash, property|
|
|
743
|
+
if property.name == :ensure
|
|
744
|
+
ensure_state = property.retrieve
|
|
745
|
+
prophash[property] = ensure_state
|
|
746
|
+
else
|
|
747
|
+
if ensure_state == :absent
|
|
748
|
+
prophash[property] = :absent
|
|
749
|
+
else
|
|
750
|
+
prophash[property] = property.retrieve
|
|
751
|
+
end
|
|
752
|
+
end
|
|
753
|
+
prophash
|
|
754
|
+
end
|
|
755
|
+
end
|
|
756
|
+
|
|
757
|
+
# Are we running in noop mode?
|
|
758
|
+
def noop?
|
|
759
|
+
# If we're not a host_config, we're almost certainly part of
|
|
760
|
+
# Settings, and we want to ignore 'noop'
|
|
761
|
+
return false if catalog and ! catalog.host_config?
|
|
762
|
+
|
|
763
|
+
if defined?(@noop)
|
|
764
|
+
@noop
|
|
765
|
+
else
|
|
766
|
+
Puppet[:noop]
|
|
767
|
+
end
|
|
768
|
+
end
|
|
769
|
+
|
|
770
|
+
def noop
|
|
771
|
+
noop?
|
|
772
|
+
end
|
|
773
|
+
|
|
774
|
+
###############################
|
|
775
|
+
# Code related to managing resource instances.
|
|
776
|
+
require 'puppet/transportable'
|
|
777
|
+
|
|
778
|
+
# retrieve a named instance of the current type
|
|
779
|
+
def self.[](name)
|
|
780
|
+
raise "Global resource access is deprecated"
|
|
781
|
+
@objects[name] || @aliases[name]
|
|
782
|
+
end
|
|
783
|
+
|
|
784
|
+
# add an instance by name to the class list of instances
|
|
785
|
+
def self.[]=(name,object)
|
|
786
|
+
raise "Global resource storage is deprecated"
|
|
787
|
+
newobj = nil
|
|
788
|
+
if object.is_a?(Puppet::Type)
|
|
789
|
+
newobj = object
|
|
790
|
+
else
|
|
791
|
+
raise Puppet::DevError, "must pass a Puppet::Type object"
|
|
792
|
+
end
|
|
793
|
+
|
|
794
|
+
if exobj = @objects[name] and self.isomorphic?
|
|
795
|
+
msg = "Object '#{newobj.class.name}[#{name}]' already exists"
|
|
796
|
+
|
|
797
|
+
msg += ("in file #{object.file} at line #{object.line}") if exobj.file and exobj.line
|
|
798
|
+
msg += ("and cannot be redefined in file #{object.file} at line #{object.line}") if object.file and object.line
|
|
799
|
+
error = Puppet::Error.new(msg)
|
|
800
|
+
raise error
|
|
801
|
+
else
|
|
802
|
+
#Puppet.info("adding %s of type %s to class list" %
|
|
803
|
+
# [name,object.class])
|
|
804
|
+
@objects[name] = newobj
|
|
805
|
+
end
|
|
806
|
+
end
|
|
807
|
+
|
|
808
|
+
# Create an alias. We keep these in a separate hash so that we don't encounter
|
|
809
|
+
# the objects multiple times when iterating over them.
|
|
810
|
+
def self.alias(name, obj)
|
|
811
|
+
raise "Global resource aliasing is deprecated"
|
|
812
|
+
if @objects.include?(name)
|
|
813
|
+
unless @objects[name] == obj
|
|
814
|
+
raise Puppet::Error.new(
|
|
815
|
+
"Cannot create alias #{name}: object already exists"
|
|
816
|
+
)
|
|
817
|
+
end
|
|
818
|
+
end
|
|
819
|
+
|
|
820
|
+
if @aliases.include?(name)
|
|
821
|
+
unless @aliases[name] == obj
|
|
822
|
+
raise Puppet::Error.new(
|
|
823
|
+
"Object #{@aliases[name].name} already has alias #{name}"
|
|
824
|
+
)
|
|
825
|
+
end
|
|
826
|
+
end
|
|
827
|
+
|
|
828
|
+
@aliases[name] = obj
|
|
829
|
+
end
|
|
830
|
+
|
|
831
|
+
# remove all of the instances of a single type
|
|
832
|
+
def self.clear
|
|
833
|
+
raise "Global resource removal is deprecated"
|
|
834
|
+
if defined?(@objects)
|
|
835
|
+
@objects.each do |name, obj|
|
|
836
|
+
obj.remove(true)
|
|
837
|
+
end
|
|
838
|
+
@objects.clear
|
|
839
|
+
end
|
|
840
|
+
@aliases.clear if defined?(@aliases)
|
|
841
|
+
end
|
|
842
|
+
|
|
843
|
+
# Force users to call this, so that we can merge objects if
|
|
844
|
+
# necessary.
|
|
845
|
+
def self.create(args)
|
|
846
|
+
# LAK:DEP Deprecation notice added 12/17/2008
|
|
847
|
+
Puppet.warning "Puppet::Type.create is deprecated; use Puppet::Type.new"
|
|
848
|
+
new(args)
|
|
849
|
+
end
|
|
850
|
+
|
|
851
|
+
# remove a specified object
|
|
852
|
+
def self.delete(resource)
|
|
853
|
+
raise "Global resource removal is deprecated"
|
|
854
|
+
return unless defined?(@objects)
|
|
855
|
+
@objects.delete(resource.title) if @objects.include?(resource.title)
|
|
856
|
+
@aliases.delete(resource.title) if @aliases.include?(resource.title)
|
|
857
|
+
if @aliases.has_value?(resource)
|
|
858
|
+
names = []
|
|
859
|
+
@aliases.each do |name, otherres|
|
|
860
|
+
if otherres == resource
|
|
861
|
+
names << name
|
|
862
|
+
end
|
|
863
|
+
end
|
|
864
|
+
names.each { |name| @aliases.delete(name) }
|
|
865
|
+
end
|
|
866
|
+
end
|
|
867
|
+
|
|
868
|
+
# iterate across each of the type's instances
|
|
869
|
+
def self.each
|
|
870
|
+
raise "Global resource iteration is deprecated"
|
|
871
|
+
return unless defined?(@objects)
|
|
872
|
+
@objects.each { |name,instance|
|
|
873
|
+
yield instance
|
|
874
|
+
}
|
|
875
|
+
end
|
|
876
|
+
|
|
877
|
+
# does the type have an object with the given name?
|
|
878
|
+
def self.has_key?(name)
|
|
879
|
+
raise "Global resource access is deprecated"
|
|
880
|
+
@objects.has_key?(name)
|
|
881
|
+
end
|
|
882
|
+
|
|
883
|
+
# Retrieve all known instances. Either requires providers or must be overridden.
|
|
884
|
+
def self.instances
|
|
885
|
+
raise Puppet::DevError, "#{self.name} has no providers and has not overridden 'instances'" if provider_hash.empty?
|
|
886
|
+
|
|
887
|
+
# Put the default provider first, then the rest of the suitable providers.
|
|
888
|
+
provider_instances = {}
|
|
889
|
+
providers_by_source.collect do |provider|
|
|
890
|
+
all_properties = self.properties.find_all do |property|
|
|
891
|
+
provider.supports_parameter?(property)
|
|
892
|
+
end.collect do |property|
|
|
893
|
+
property.name
|
|
894
|
+
end
|
|
895
|
+
|
|
896
|
+
provider.instances.collect do |instance|
|
|
897
|
+
# We always want to use the "first" provider instance we find, unless the resource
|
|
898
|
+
# is already managed and has a different provider set
|
|
899
|
+
if other = provider_instances[instance.name]
|
|
900
|
+
Puppet.warning "%s %s found in both %s and %s; skipping the %s version" %
|
|
901
|
+
[self.name.to_s.capitalize, instance.name, other.class.name, instance.class.name, instance.class.name]
|
|
902
|
+
next
|
|
903
|
+
end
|
|
904
|
+
provider_instances[instance.name] = instance
|
|
905
|
+
|
|
906
|
+
result = new(:name => instance.name, :provider => instance)
|
|
907
|
+
properties.each { |name| result.newattr(name) }
|
|
908
|
+
result
|
|
909
|
+
end
|
|
910
|
+
end.flatten.compact
|
|
911
|
+
end
|
|
912
|
+
|
|
913
|
+
# Return a list of one suitable provider per source, with the default provider first.
|
|
914
|
+
def self.providers_by_source
|
|
915
|
+
# Put the default provider first (can be nil), then the rest of the suitable providers.
|
|
916
|
+
sources = []
|
|
917
|
+
[defaultprovider, suitableprovider].flatten.uniq.collect do |provider|
|
|
918
|
+
next if provider.nil?
|
|
919
|
+
next if sources.include?(provider.source)
|
|
920
|
+
|
|
921
|
+
sources << provider.source
|
|
922
|
+
provider
|
|
923
|
+
end.compact
|
|
924
|
+
end
|
|
925
|
+
|
|
926
|
+
# Convert a simple hash into a Resource instance.
|
|
927
|
+
def self.hash2resource(hash)
|
|
928
|
+
hash = hash.inject({}) { |result, ary| result[ary[0].to_sym] = ary[1]; result }
|
|
929
|
+
|
|
930
|
+
title = hash.delete(:title)
|
|
931
|
+
title ||= hash[:name]
|
|
932
|
+
title ||= hash[key_attributes.first] if key_attributes.length == 1
|
|
933
|
+
|
|
934
|
+
raise Puppet::Error, "Title or name must be provided" unless title
|
|
935
|
+
|
|
936
|
+
# Now create our resource.
|
|
937
|
+
resource = Puppet::Resource.new(self.name, title)
|
|
938
|
+
[:catalog].each do |attribute|
|
|
939
|
+
if value = hash[attribute]
|
|
940
|
+
hash.delete(attribute)
|
|
941
|
+
resource.send(attribute.to_s + "=", value)
|
|
942
|
+
end
|
|
943
|
+
end
|
|
944
|
+
|
|
945
|
+
hash.each do |param, value|
|
|
946
|
+
resource[param] = value
|
|
947
|
+
end
|
|
948
|
+
resource
|
|
949
|
+
end
|
|
950
|
+
|
|
951
|
+
# Create the path for logging and such.
|
|
952
|
+
def pathbuilder
|
|
953
|
+
if p = parent
|
|
954
|
+
[p.pathbuilder, self.ref].flatten
|
|
955
|
+
else
|
|
956
|
+
[self.ref]
|
|
957
|
+
end
|
|
958
|
+
end
|
|
959
|
+
|
|
960
|
+
###############################
|
|
961
|
+
# Add all of the meta parameters.
|
|
962
|
+
newmetaparam(:noop) do
|
|
963
|
+
desc "Boolean flag indicating whether work should actually
|
|
964
|
+
be done."
|
|
965
|
+
|
|
966
|
+
newvalues(:true, :false)
|
|
967
|
+
munge do |value|
|
|
968
|
+
case value
|
|
969
|
+
when true, :true, "true"; @resource.noop = true
|
|
970
|
+
when false, :false, "false"; @resource.noop = false
|
|
971
|
+
end
|
|
972
|
+
end
|
|
973
|
+
end
|
|
974
|
+
|
|
975
|
+
newmetaparam(:schedule) do
|
|
976
|
+
desc "On what schedule the object should be managed. You must create a
|
|
977
|
+
schedule object, and then reference the name of that object to use
|
|
978
|
+
that for your schedule:
|
|
979
|
+
|
|
980
|
+
schedule { 'daily':
|
|
981
|
+
period => daily,
|
|
982
|
+
range => \"2-4\"
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
exec { \"/usr/bin/apt-get update\":
|
|
986
|
+
schedule => 'daily'
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
The creation of the schedule object does not need to appear in the
|
|
990
|
+
configuration before objects that use it."
|
|
991
|
+
end
|
|
992
|
+
|
|
993
|
+
newmetaparam(:audit) do
|
|
994
|
+
desc "Marks a subset of this resource's unmanaged attributes for auditing. Accepts an
|
|
995
|
+
attribute name, an array of attribute names, or `all`.
|
|
996
|
+
|
|
997
|
+
Auditing a resource attribute has two effects: First, whenever a catalog
|
|
998
|
+
is applied with puppet apply or puppet agent, Puppet will check whether
|
|
999
|
+
that attribute of the resource has been modified, comparing its current
|
|
1000
|
+
value to the previous run; any change will be logged alongside any actions
|
|
1001
|
+
performed by Puppet while applying the catalog.
|
|
1002
|
+
|
|
1003
|
+
Secondly, marking a resource attribute for auditing will include that
|
|
1004
|
+
attribute in inspection reports generated by puppet inspect; see the
|
|
1005
|
+
puppet inspect documentation for more details.
|
|
1006
|
+
|
|
1007
|
+
Managed attributes for a resource can also be audited, but note that
|
|
1008
|
+
changes made by Puppet will be logged as additional modifications. (I.e.
|
|
1009
|
+
if a user manually edits a file whose contents are audited and managed,
|
|
1010
|
+
puppet agent's next two runs will both log an audit notice: the first run
|
|
1011
|
+
will log the user's edit and then revert the file to the desired state,
|
|
1012
|
+
and the second run will log the edit made by Puppet.)"
|
|
1013
|
+
|
|
1014
|
+
validate do |list|
|
|
1015
|
+
list = Array(list).collect {|p| p.to_sym}
|
|
1016
|
+
unless list == [:all]
|
|
1017
|
+
list.each do |param|
|
|
1018
|
+
next if @resource.class.validattr?(param)
|
|
1019
|
+
fail "Cannot audit #{param}: not a valid attribute for #{resource}"
|
|
1020
|
+
end
|
|
1021
|
+
end
|
|
1022
|
+
end
|
|
1023
|
+
|
|
1024
|
+
munge do |args|
|
|
1025
|
+
properties_to_audit(args).each do |param|
|
|
1026
|
+
next unless resource.class.validproperty?(param)
|
|
1027
|
+
resource.newattr(param)
|
|
1028
|
+
end
|
|
1029
|
+
end
|
|
1030
|
+
|
|
1031
|
+
def all_properties
|
|
1032
|
+
resource.class.properties.find_all do |property|
|
|
1033
|
+
resource.provider.nil? or resource.provider.class.supports_parameter?(property)
|
|
1034
|
+
end.collect do |property|
|
|
1035
|
+
property.name
|
|
1036
|
+
end
|
|
1037
|
+
end
|
|
1038
|
+
|
|
1039
|
+
def properties_to_audit(list)
|
|
1040
|
+
if !list.kind_of?(Array) && list.to_sym == :all
|
|
1041
|
+
list = all_properties
|
|
1042
|
+
else
|
|
1043
|
+
list = Array(list).collect { |p| p.to_sym }
|
|
1044
|
+
end
|
|
1045
|
+
end
|
|
1046
|
+
end
|
|
1047
|
+
|
|
1048
|
+
newmetaparam(:check) do
|
|
1049
|
+
desc "Audit specified attributes of resources over time, and report if any have changed.
|
|
1050
|
+
This parameter has been deprecated in favor of 'audit'."
|
|
1051
|
+
|
|
1052
|
+
munge do |args|
|
|
1053
|
+
resource.warning "'check' attribute is deprecated; use 'audit' instead"
|
|
1054
|
+
resource[:audit] = args
|
|
1055
|
+
end
|
|
1056
|
+
end
|
|
1057
|
+
|
|
1058
|
+
newmetaparam(:loglevel) do
|
|
1059
|
+
desc "Sets the level that information will be logged.
|
|
1060
|
+
The log levels have the biggest impact when logs are sent to
|
|
1061
|
+
syslog (which is currently the default)."
|
|
1062
|
+
defaultto :notice
|
|
1063
|
+
|
|
1064
|
+
newvalues(*Puppet::Util::Log.levels)
|
|
1065
|
+
newvalues(:verbose)
|
|
1066
|
+
|
|
1067
|
+
munge do |loglevel|
|
|
1068
|
+
val = super(loglevel)
|
|
1069
|
+
if val == :verbose
|
|
1070
|
+
val = :info
|
|
1071
|
+
end
|
|
1072
|
+
val
|
|
1073
|
+
end
|
|
1074
|
+
end
|
|
1075
|
+
|
|
1076
|
+
newmetaparam(:alias) do
|
|
1077
|
+
desc "Creates an alias for the object. Puppet uses this internally when you
|
|
1078
|
+
provide a symbolic title:
|
|
1079
|
+
|
|
1080
|
+
file { 'sshdconfig':
|
|
1081
|
+
path => $operatingsystem ? {
|
|
1082
|
+
solaris => \"/usr/local/etc/ssh/sshd_config\",
|
|
1083
|
+
default => \"/etc/ssh/sshd_config\"
|
|
1084
|
+
},
|
|
1085
|
+
source => \"...\"
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
service { 'sshd':
|
|
1089
|
+
subscribe => File['sshdconfig']
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
When you use this feature, the parser sets `sshdconfig` as the title,
|
|
1093
|
+
and the library sets that as an alias for the file so the dependency
|
|
1094
|
+
lookup in `Service['sshd']` works. You can use this metaparameter yourself,
|
|
1095
|
+
but note that only the library can use these aliases; for instance,
|
|
1096
|
+
the following code will not work:
|
|
1097
|
+
|
|
1098
|
+
file { \"/etc/ssh/sshd_config\":
|
|
1099
|
+
owner => root,
|
|
1100
|
+
group => root,
|
|
1101
|
+
alias => 'sshdconfig'
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
file { 'sshdconfig':
|
|
1105
|
+
mode => 644
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
There's no way here for the Puppet parser to know that these two stanzas
|
|
1109
|
+
should be affecting the same file.
|
|
1110
|
+
|
|
1111
|
+
See the [Language Guide](http://docs.puppetlabs.com/guides/language_guide.html) for more information.
|
|
1112
|
+
|
|
1113
|
+
"
|
|
1114
|
+
|
|
1115
|
+
munge do |aliases|
|
|
1116
|
+
aliases = [aliases] unless aliases.is_a?(Array)
|
|
1117
|
+
|
|
1118
|
+
raise(ArgumentError, "Cannot add aliases without a catalog") unless @resource.catalog
|
|
1119
|
+
|
|
1120
|
+
aliases.each do |other|
|
|
1121
|
+
if obj = @resource.catalog.resource(@resource.class.name, other)
|
|
1122
|
+
unless obj.object_id == @resource.object_id
|
|
1123
|
+
self.fail("#{@resource.title} can not create alias #{other}: object already exists")
|
|
1124
|
+
end
|
|
1125
|
+
next
|
|
1126
|
+
end
|
|
1127
|
+
|
|
1128
|
+
# Newschool, add it to the catalog.
|
|
1129
|
+
@resource.catalog.alias(@resource, other)
|
|
1130
|
+
end
|
|
1131
|
+
end
|
|
1132
|
+
end
|
|
1133
|
+
|
|
1134
|
+
newmetaparam(:tag) do
|
|
1135
|
+
desc "Add the specified tags to the associated resource. While all resources
|
|
1136
|
+
are automatically tagged with as much information as possible
|
|
1137
|
+
(e.g., each class and definition containing the resource), it can
|
|
1138
|
+
be useful to add your own tags to a given resource.
|
|
1139
|
+
|
|
1140
|
+
Multiple tags can be specified as an array:
|
|
1141
|
+
|
|
1142
|
+
file {'/etc/hosts':
|
|
1143
|
+
ensure => file,
|
|
1144
|
+
source => 'puppet:///modules/site/hosts',
|
|
1145
|
+
mode => 0644,
|
|
1146
|
+
tag => ['bootstrap', 'minimumrun', 'mediumrun'],
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
Tags are useful for things like applying a subset of a host's configuration
|
|
1150
|
+
with [the `tags` setting](/references/latest/configuration.html#tags):
|
|
1151
|
+
|
|
1152
|
+
puppet agent --test --tags bootstrap
|
|
1153
|
+
|
|
1154
|
+
This way, you can easily isolate the portion of the configuration you're
|
|
1155
|
+
trying to test."
|
|
1156
|
+
|
|
1157
|
+
munge do |tags|
|
|
1158
|
+
tags = [tags] unless tags.is_a? Array
|
|
1159
|
+
|
|
1160
|
+
tags.each do |tag|
|
|
1161
|
+
@resource.tag(tag)
|
|
1162
|
+
end
|
|
1163
|
+
end
|
|
1164
|
+
end
|
|
1165
|
+
|
|
1166
|
+
class RelationshipMetaparam < Puppet::Parameter
|
|
1167
|
+
class << self
|
|
1168
|
+
attr_accessor :direction, :events, :callback, :subclasses
|
|
1169
|
+
end
|
|
1170
|
+
|
|
1171
|
+
@subclasses = []
|
|
1172
|
+
|
|
1173
|
+
def self.inherited(sub)
|
|
1174
|
+
@subclasses << sub
|
|
1175
|
+
end
|
|
1176
|
+
|
|
1177
|
+
def munge(references)
|
|
1178
|
+
references = [references] unless references.is_a?(Array)
|
|
1179
|
+
references.collect do |ref|
|
|
1180
|
+
if ref.is_a?(Puppet::Resource)
|
|
1181
|
+
ref
|
|
1182
|
+
else
|
|
1183
|
+
Puppet::Resource.new(ref)
|
|
1184
|
+
end
|
|
1185
|
+
end
|
|
1186
|
+
end
|
|
1187
|
+
|
|
1188
|
+
def validate_relationship
|
|
1189
|
+
@value.each do |ref|
|
|
1190
|
+
unless @resource.catalog.resource(ref.to_s)
|
|
1191
|
+
description = self.class.direction == :in ? "dependency" : "dependent"
|
|
1192
|
+
fail "Could not find #{description} #{ref} for #{resource.ref}"
|
|
1193
|
+
end
|
|
1194
|
+
end
|
|
1195
|
+
end
|
|
1196
|
+
|
|
1197
|
+
# Create edges from each of our relationships. :in
|
|
1198
|
+
# relationships are specified by the event-receivers, and :out
|
|
1199
|
+
# relationships are specified by the event generator. This
|
|
1200
|
+
# way 'source' and 'target' are consistent terms in both edges
|
|
1201
|
+
# and events -- that is, an event targets edges whose source matches
|
|
1202
|
+
# the event's source. The direction of the relationship determines
|
|
1203
|
+
# which resource is applied first and which resource is considered
|
|
1204
|
+
# to be the event generator.
|
|
1205
|
+
def to_edges
|
|
1206
|
+
@value.collect do |reference|
|
|
1207
|
+
reference.catalog = resource.catalog
|
|
1208
|
+
|
|
1209
|
+
# Either of the two retrieval attempts could have returned
|
|
1210
|
+
# nil.
|
|
1211
|
+
unless related_resource = reference.resolve
|
|
1212
|
+
self.fail "Could not retrieve dependency '#{reference}' of #{@resource.ref}"
|
|
1213
|
+
end
|
|
1214
|
+
|
|
1215
|
+
# Are we requiring them, or vice versa? See the method docs
|
|
1216
|
+
# for futher info on this.
|
|
1217
|
+
if self.class.direction == :in
|
|
1218
|
+
source = related_resource
|
|
1219
|
+
target = @resource
|
|
1220
|
+
else
|
|
1221
|
+
source = @resource
|
|
1222
|
+
target = related_resource
|
|
1223
|
+
end
|
|
1224
|
+
|
|
1225
|
+
if method = self.class.callback
|
|
1226
|
+
subargs = {
|
|
1227
|
+
:event => self.class.events,
|
|
1228
|
+
:callback => method
|
|
1229
|
+
}
|
|
1230
|
+
self.debug("subscribes to #{related_resource.ref}")
|
|
1231
|
+
else
|
|
1232
|
+
# If there's no callback, there's no point in even adding
|
|
1233
|
+
# a label.
|
|
1234
|
+
subargs = nil
|
|
1235
|
+
self.debug("requires #{related_resource.ref}")
|
|
1236
|
+
end
|
|
1237
|
+
|
|
1238
|
+
rel = Puppet::Relationship.new(source, target, subargs)
|
|
1239
|
+
end
|
|
1240
|
+
end
|
|
1241
|
+
end
|
|
1242
|
+
|
|
1243
|
+
def self.relationship_params
|
|
1244
|
+
RelationshipMetaparam.subclasses
|
|
1245
|
+
end
|
|
1246
|
+
|
|
1247
|
+
|
|
1248
|
+
# Note that the order in which the relationships params is defined
|
|
1249
|
+
# matters. The labelled params (notify and subcribe) must be later,
|
|
1250
|
+
# so that if both params are used, those ones win. It's a hackish
|
|
1251
|
+
# solution, but it works.
|
|
1252
|
+
|
|
1253
|
+
newmetaparam(:require, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do
|
|
1254
|
+
desc "References to one or more objects that this object depends on.
|
|
1255
|
+
This is used purely for guaranteeing that changes to required objects
|
|
1256
|
+
happen before the dependent object. For instance:
|
|
1257
|
+
|
|
1258
|
+
# Create the destination directory before you copy things down
|
|
1259
|
+
file { \"/usr/local/scripts\":
|
|
1260
|
+
ensure => directory
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
file { \"/usr/local/scripts/myscript\":
|
|
1264
|
+
source => \"puppet://server/module/myscript\",
|
|
1265
|
+
mode => 755,
|
|
1266
|
+
require => File[\"/usr/local/scripts\"]
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
Multiple dependencies can be specified by providing a comma-separated list
|
|
1270
|
+
of resources, enclosed in square brackets:
|
|
1271
|
+
|
|
1272
|
+
require => [ File[\"/usr/local\"], File[\"/usr/local/scripts\"] ]
|
|
1273
|
+
|
|
1274
|
+
Note that Puppet will autorequire everything that it can, and
|
|
1275
|
+
there are hooks in place so that it's easy for resources to add new
|
|
1276
|
+
ways to autorequire objects, so if you think Puppet could be
|
|
1277
|
+
smarter here, let us know.
|
|
1278
|
+
|
|
1279
|
+
In fact, the above code was redundant --- Puppet will autorequire
|
|
1280
|
+
any parent directories that are being managed; it will
|
|
1281
|
+
automatically realize that the parent directory should be created
|
|
1282
|
+
before the script is pulled down.
|
|
1283
|
+
|
|
1284
|
+
Currently, exec resources will autorequire their CWD (if it is
|
|
1285
|
+
specified) plus any fully qualified paths that appear in the
|
|
1286
|
+
command. For instance, if you had an `exec` command that ran
|
|
1287
|
+
the `myscript` mentioned above, the above code that pulls the
|
|
1288
|
+
file down would be automatically listed as a requirement to the
|
|
1289
|
+
`exec` code, so that you would always be running againts the
|
|
1290
|
+
most recent version.
|
|
1291
|
+
"
|
|
1292
|
+
end
|
|
1293
|
+
|
|
1294
|
+
newmetaparam(:subscribe, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :ALL_EVENTS, :callback => :refresh}) do
|
|
1295
|
+
desc "References to one or more objects that this object depends on. This
|
|
1296
|
+
metaparameter creates a dependency relationship like **require,**
|
|
1297
|
+
and also causes the dependent object to be refreshed when the
|
|
1298
|
+
subscribed object is changed. For instance:
|
|
1299
|
+
|
|
1300
|
+
class nagios {
|
|
1301
|
+
file { 'nagconf':
|
|
1302
|
+
path => \"/etc/nagios/nagios.conf\"
|
|
1303
|
+
source => \"puppet://server/module/nagios.conf\",
|
|
1304
|
+
}
|
|
1305
|
+
service { 'nagios':
|
|
1306
|
+
ensure => running,
|
|
1307
|
+
subscribe => File['nagconf']
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
Currently the `exec`, `mount` and `service` types support
|
|
1312
|
+
refreshing.
|
|
1313
|
+
"
|
|
1314
|
+
end
|
|
1315
|
+
|
|
1316
|
+
newmetaparam(:before, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do
|
|
1317
|
+
desc %{References to one or more objects that depend on this object. This
|
|
1318
|
+
parameter is the opposite of **require** --- it guarantees that
|
|
1319
|
+
the specified object is applied later than the specifying object:
|
|
1320
|
+
|
|
1321
|
+
file { "/var/nagios/configuration":
|
|
1322
|
+
source => "...",
|
|
1323
|
+
recurse => true,
|
|
1324
|
+
before => Exec["nagios-rebuid"]
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
exec { "nagios-rebuild":
|
|
1328
|
+
command => "/usr/bin/make",
|
|
1329
|
+
cwd => "/var/nagios/configuration"
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
This will make sure all of the files are up to date before the
|
|
1333
|
+
make command is run.}
|
|
1334
|
+
end
|
|
1335
|
+
|
|
1336
|
+
newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do
|
|
1337
|
+
desc %{References to one or more objects that depend on this object. This
|
|
1338
|
+
parameter is the opposite of **subscribe** --- it creates a
|
|
1339
|
+
dependency relationship like **before,** and also causes the
|
|
1340
|
+
dependent object(s) to be refreshed when this object is changed. For
|
|
1341
|
+
instance:
|
|
1342
|
+
|
|
1343
|
+
file { "/etc/sshd_config":
|
|
1344
|
+
source => "....",
|
|
1345
|
+
notify => Service['sshd']
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
service { 'sshd':
|
|
1349
|
+
ensure => running
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
This will restart the sshd service if the sshd config file changes.}
|
|
1353
|
+
end
|
|
1354
|
+
|
|
1355
|
+
newmetaparam(:stage) do
|
|
1356
|
+
desc %{Which run stage a given resource should reside in. This just creates
|
|
1357
|
+
a dependency on or from the named milestone. For instance, saying that
|
|
1358
|
+
this is in the 'bootstrap' stage creates a dependency on the 'bootstrap'
|
|
1359
|
+
milestone.
|
|
1360
|
+
|
|
1361
|
+
By default, all classes get directly added to the
|
|
1362
|
+
'main' stage. You can create new stages as resources:
|
|
1363
|
+
|
|
1364
|
+
stage { ['pre', 'post']: }
|
|
1365
|
+
|
|
1366
|
+
To order stages, use standard relationships:
|
|
1367
|
+
|
|
1368
|
+
stage { 'pre': before => Stage['main'] }
|
|
1369
|
+
|
|
1370
|
+
Or use the new relationship syntax:
|
|
1371
|
+
|
|
1372
|
+
Stage['pre'] -> Stage['main'] -> Stage['post']
|
|
1373
|
+
|
|
1374
|
+
Then use the new class parameters to specify a stage:
|
|
1375
|
+
|
|
1376
|
+
class { 'foo': stage => 'pre' }
|
|
1377
|
+
|
|
1378
|
+
Stages can only be set on classes, not individual resources. This will
|
|
1379
|
+
fail:
|
|
1380
|
+
|
|
1381
|
+
file { '/foo': stage => 'pre', ensure => file }
|
|
1382
|
+
}
|
|
1383
|
+
end
|
|
1384
|
+
|
|
1385
|
+
###############################
|
|
1386
|
+
# All of the provider plumbing for the resource types.
|
|
1387
|
+
require 'puppet/provider'
|
|
1388
|
+
require 'puppet/util/provider_features'
|
|
1389
|
+
|
|
1390
|
+
# Add the feature handling module.
|
|
1391
|
+
extend Puppet::Util::ProviderFeatures
|
|
1392
|
+
|
|
1393
|
+
attr_reader :provider
|
|
1394
|
+
|
|
1395
|
+
# the Type class attribute accessors
|
|
1396
|
+
class << self
|
|
1397
|
+
attr_accessor :providerloader
|
|
1398
|
+
attr_writer :defaultprovider
|
|
1399
|
+
end
|
|
1400
|
+
|
|
1401
|
+
# Find the default provider.
|
|
1402
|
+
def self.defaultprovider
|
|
1403
|
+
return @defaultprovider if @defaultprovider
|
|
1404
|
+
|
|
1405
|
+
suitable = suitableprovider
|
|
1406
|
+
|
|
1407
|
+
# Find which providers are a default for this system.
|
|
1408
|
+
defaults = suitable.find_all { |provider| provider.default? }
|
|
1409
|
+
|
|
1410
|
+
# If we don't have any default we use suitable providers
|
|
1411
|
+
defaults = suitable if defaults.empty?
|
|
1412
|
+
max = defaults.collect { |provider| provider.specificity }.max
|
|
1413
|
+
defaults = defaults.find_all { |provider| provider.specificity == max }
|
|
1414
|
+
|
|
1415
|
+
if defaults.length > 1
|
|
1416
|
+
Puppet.warning(
|
|
1417
|
+
"Found multiple default providers for #{self.name}: #{defaults.collect { |i| i.name.to_s }.join(", ")}; using #{defaults[0].name}"
|
|
1418
|
+
)
|
|
1419
|
+
end
|
|
1420
|
+
|
|
1421
|
+
@defaultprovider = defaults.shift unless defaults.empty?
|
|
1422
|
+
end
|
|
1423
|
+
|
|
1424
|
+
def self.provider_hash_by_type(type)
|
|
1425
|
+
@provider_hashes ||= {}
|
|
1426
|
+
@provider_hashes[type] ||= {}
|
|
1427
|
+
end
|
|
1428
|
+
|
|
1429
|
+
def self.provider_hash
|
|
1430
|
+
Puppet::Type.provider_hash_by_type(self.name)
|
|
1431
|
+
end
|
|
1432
|
+
|
|
1433
|
+
# Retrieve a provider by name.
|
|
1434
|
+
def self.provider(name)
|
|
1435
|
+
name = name.intern
|
|
1436
|
+
|
|
1437
|
+
# If we don't have it yet, try loading it.
|
|
1438
|
+
@providerloader.load(name) unless provider_hash.has_key?(name)
|
|
1439
|
+
provider_hash[name]
|
|
1440
|
+
end
|
|
1441
|
+
|
|
1442
|
+
# Just list all of the providers.
|
|
1443
|
+
def self.providers
|
|
1444
|
+
provider_hash.keys
|
|
1445
|
+
end
|
|
1446
|
+
|
|
1447
|
+
def self.validprovider?(name)
|
|
1448
|
+
name = name.intern
|
|
1449
|
+
|
|
1450
|
+
(provider_hash.has_key?(name) && provider_hash[name].suitable?)
|
|
1451
|
+
end
|
|
1452
|
+
|
|
1453
|
+
# Create a new provider of a type. This method must be called
|
|
1454
|
+
# directly on the type that it's implementing.
|
|
1455
|
+
def self.provide(name, options = {}, &block)
|
|
1456
|
+
name = name.intern
|
|
1457
|
+
|
|
1458
|
+
if unprovide(name)
|
|
1459
|
+
Puppet.debug "Reloading #{name} #{self.name} provider"
|
|
1460
|
+
end
|
|
1461
|
+
|
|
1462
|
+
parent = if pname = options[:parent]
|
|
1463
|
+
options.delete(:parent)
|
|
1464
|
+
if pname.is_a? Class
|
|
1465
|
+
pname
|
|
1466
|
+
else
|
|
1467
|
+
if provider = self.provider(pname)
|
|
1468
|
+
provider
|
|
1469
|
+
else
|
|
1470
|
+
raise Puppet::DevError,
|
|
1471
|
+
"Could not find parent provider #{pname} of #{name}"
|
|
1472
|
+
end
|
|
1473
|
+
end
|
|
1474
|
+
else
|
|
1475
|
+
Puppet::Provider
|
|
1476
|
+
end
|
|
1477
|
+
|
|
1478
|
+
options[:resource_type] ||= self
|
|
1479
|
+
|
|
1480
|
+
self.providify
|
|
1481
|
+
|
|
1482
|
+
provider = genclass(
|
|
1483
|
+
name,
|
|
1484
|
+
:parent => parent,
|
|
1485
|
+
:hash => provider_hash,
|
|
1486
|
+
:prefix => "Provider",
|
|
1487
|
+
:block => block,
|
|
1488
|
+
:include => feature_module,
|
|
1489
|
+
:extend => feature_module,
|
|
1490
|
+
:attributes => options
|
|
1491
|
+
)
|
|
1492
|
+
|
|
1493
|
+
provider
|
|
1494
|
+
end
|
|
1495
|
+
|
|
1496
|
+
# Make sure we have a :provider parameter defined. Only gets called if there
|
|
1497
|
+
# are providers.
|
|
1498
|
+
def self.providify
|
|
1499
|
+
return if @paramhash.has_key? :provider
|
|
1500
|
+
|
|
1501
|
+
newparam(:provider) do
|
|
1502
|
+
# We're using a hacky way to get the name of our type, since there doesn't
|
|
1503
|
+
# seem to be a correct way to introspect this at the time this code is run.
|
|
1504
|
+
# We expect that the class in which this code is executed will be something
|
|
1505
|
+
# like Puppet::Type::Ssh_authorized_key::ParameterProvider.
|
|
1506
|
+
desc <<-EOT
|
|
1507
|
+
The specific backend to use for this `#{self.to_s.split('::')[2].downcase}`
|
|
1508
|
+
resource. You will seldom need to specify this --- Puppet will usually
|
|
1509
|
+
discover the appropriate provider for your platform.
|
|
1510
|
+
EOT
|
|
1511
|
+
|
|
1512
|
+
# This is so we can refer back to the type to get a list of
|
|
1513
|
+
# providers for documentation.
|
|
1514
|
+
class << self
|
|
1515
|
+
attr_accessor :parenttype
|
|
1516
|
+
end
|
|
1517
|
+
|
|
1518
|
+
# We need to add documentation for each provider.
|
|
1519
|
+
def self.doc
|
|
1520
|
+
# Since we're mixing @doc with text from other sources, we must normalize
|
|
1521
|
+
# its indentation with scrub. But we don't need to manually scrub the
|
|
1522
|
+
# provider's doc string, since markdown_definitionlist sanitizes its inputs.
|
|
1523
|
+
scrub(@doc) + "Available providers are:\n\n" + parenttype.providers.sort { |a,b|
|
|
1524
|
+
a.to_s <=> b.to_s
|
|
1525
|
+
}.collect { |i|
|
|
1526
|
+
markdown_definitionlist( i, scrub(parenttype().provider(i).doc) )
|
|
1527
|
+
}.join
|
|
1528
|
+
end
|
|
1529
|
+
|
|
1530
|
+
defaultto {
|
|
1531
|
+
prov = @resource.class.defaultprovider
|
|
1532
|
+
prov.name if prov
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
validate do |provider_class|
|
|
1536
|
+
provider_class = provider_class[0] if provider_class.is_a? Array
|
|
1537
|
+
provider_class = provider_class.class.name if provider_class.is_a?(Puppet::Provider)
|
|
1538
|
+
|
|
1539
|
+
unless provider = @resource.class.provider(provider_class)
|
|
1540
|
+
raise ArgumentError, "Invalid #{@resource.class.name} provider '#{provider_class}'"
|
|
1541
|
+
end
|
|
1542
|
+
end
|
|
1543
|
+
|
|
1544
|
+
munge do |provider|
|
|
1545
|
+
provider = provider[0] if provider.is_a? Array
|
|
1546
|
+
provider = provider.intern if provider.is_a? String
|
|
1547
|
+
@resource.provider = provider
|
|
1548
|
+
|
|
1549
|
+
if provider.is_a?(Puppet::Provider)
|
|
1550
|
+
provider.class.name
|
|
1551
|
+
else
|
|
1552
|
+
provider
|
|
1553
|
+
end
|
|
1554
|
+
end
|
|
1555
|
+
end.parenttype = self
|
|
1556
|
+
end
|
|
1557
|
+
|
|
1558
|
+
def self.unprovide(name)
|
|
1559
|
+
if @defaultprovider and @defaultprovider.name == name
|
|
1560
|
+
@defaultprovider = nil
|
|
1561
|
+
end
|
|
1562
|
+
|
|
1563
|
+
rmclass(name, :hash => provider_hash, :prefix => "Provider")
|
|
1564
|
+
end
|
|
1565
|
+
|
|
1566
|
+
# Return an array of all of the suitable providers.
|
|
1567
|
+
def self.suitableprovider
|
|
1568
|
+
providerloader.loadall if provider_hash.empty?
|
|
1569
|
+
provider_hash.find_all { |name, provider|
|
|
1570
|
+
provider.suitable?
|
|
1571
|
+
}.collect { |name, provider|
|
|
1572
|
+
provider
|
|
1573
|
+
}.reject { |p| p.name == :fake } # For testing
|
|
1574
|
+
end
|
|
1575
|
+
|
|
1576
|
+
def suitable?
|
|
1577
|
+
# If we don't use providers, then we consider it suitable.
|
|
1578
|
+
return true unless self.class.paramclass(:provider)
|
|
1579
|
+
|
|
1580
|
+
# We have a provider and it is suitable.
|
|
1581
|
+
return true if provider && provider.class.suitable?
|
|
1582
|
+
|
|
1583
|
+
# We're using the default provider and there is one.
|
|
1584
|
+
if !provider and self.class.defaultprovider
|
|
1585
|
+
self.provider = self.class.defaultprovider.name
|
|
1586
|
+
return true
|
|
1587
|
+
end
|
|
1588
|
+
|
|
1589
|
+
# We specified an unsuitable provider, or there isn't any suitable
|
|
1590
|
+
# provider.
|
|
1591
|
+
false
|
|
1592
|
+
end
|
|
1593
|
+
|
|
1594
|
+
def provider=(name)
|
|
1595
|
+
if name.is_a?(Puppet::Provider)
|
|
1596
|
+
@provider = name
|
|
1597
|
+
@provider.resource = self
|
|
1598
|
+
elsif klass = self.class.provider(name)
|
|
1599
|
+
@provider = klass.new(self)
|
|
1600
|
+
else
|
|
1601
|
+
raise ArgumentError, "Could not find #{name} provider of #{self.class.name}"
|
|
1602
|
+
end
|
|
1603
|
+
end
|
|
1604
|
+
|
|
1605
|
+
###############################
|
|
1606
|
+
# All of the relationship code.
|
|
1607
|
+
|
|
1608
|
+
# Specify a block for generating a list of objects to autorequire. This
|
|
1609
|
+
# makes it so that you don't have to manually specify things that you clearly
|
|
1610
|
+
# require.
|
|
1611
|
+
def self.autorequire(name, &block)
|
|
1612
|
+
@autorequires ||= {}
|
|
1613
|
+
@autorequires[name] = block
|
|
1614
|
+
end
|
|
1615
|
+
|
|
1616
|
+
# Yield each of those autorequires in turn, yo.
|
|
1617
|
+
def self.eachautorequire
|
|
1618
|
+
@autorequires ||= {}
|
|
1619
|
+
@autorequires.each { |type, block|
|
|
1620
|
+
yield(type, block)
|
|
1621
|
+
}
|
|
1622
|
+
end
|
|
1623
|
+
|
|
1624
|
+
# Figure out of there are any objects we can automatically add as
|
|
1625
|
+
# dependencies.
|
|
1626
|
+
def autorequire(rel_catalog = nil)
|
|
1627
|
+
rel_catalog ||= catalog
|
|
1628
|
+
raise(Puppet::DevError, "You cannot add relationships without a catalog") unless rel_catalog
|
|
1629
|
+
|
|
1630
|
+
reqs = []
|
|
1631
|
+
self.class.eachautorequire { |type, block|
|
|
1632
|
+
# Ignore any types we can't find, although that would be a bit odd.
|
|
1633
|
+
next unless typeobj = Puppet::Type.type(type)
|
|
1634
|
+
|
|
1635
|
+
# Retrieve the list of names from the block.
|
|
1636
|
+
next unless list = self.instance_eval(&block)
|
|
1637
|
+
list = [list] unless list.is_a?(Array)
|
|
1638
|
+
|
|
1639
|
+
# Collect the current prereqs
|
|
1640
|
+
list.each { |dep|
|
|
1641
|
+
# Support them passing objects directly, to save some effort.
|
|
1642
|
+
unless dep.is_a? Puppet::Type
|
|
1643
|
+
# Skip autorequires that we aren't managing
|
|
1644
|
+
unless dep = rel_catalog.resource(type, dep)
|
|
1645
|
+
next
|
|
1646
|
+
end
|
|
1647
|
+
end
|
|
1648
|
+
|
|
1649
|
+
reqs << Puppet::Relationship.new(dep, self)
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
reqs
|
|
1654
|
+
end
|
|
1655
|
+
|
|
1656
|
+
# Build the dependencies associated with an individual object.
|
|
1657
|
+
def builddepends
|
|
1658
|
+
# Handle the requires
|
|
1659
|
+
self.class.relationship_params.collect do |klass|
|
|
1660
|
+
if param = @parameters[klass.name]
|
|
1661
|
+
param.to_edges
|
|
1662
|
+
end
|
|
1663
|
+
end.flatten.reject { |r| r.nil? }
|
|
1664
|
+
end
|
|
1665
|
+
|
|
1666
|
+
# Define the initial list of tags.
|
|
1667
|
+
def tags=(list)
|
|
1668
|
+
tag(self.class.name)
|
|
1669
|
+
tag(*list)
|
|
1670
|
+
end
|
|
1671
|
+
|
|
1672
|
+
# Types (which map to resources in the languages) are entirely composed of
|
|
1673
|
+
# attribute value pairs. Generally, Puppet calls any of these things an
|
|
1674
|
+
# 'attribute', but these attributes always take one of three specific
|
|
1675
|
+
# forms: parameters, metaparams, or properties.
|
|
1676
|
+
|
|
1677
|
+
# In naming methods, I have tried to consistently name the method so
|
|
1678
|
+
# that it is clear whether it operates on all attributes (thus has 'attr' in
|
|
1679
|
+
# the method name, or whether it operates on a specific type of attributes.
|
|
1680
|
+
attr_writer :title
|
|
1681
|
+
attr_writer :noop
|
|
1682
|
+
|
|
1683
|
+
include Enumerable
|
|
1684
|
+
|
|
1685
|
+
# class methods dealing with Type management
|
|
1686
|
+
|
|
1687
|
+
public
|
|
1688
|
+
|
|
1689
|
+
# the Type class attribute accessors
|
|
1690
|
+
class << self
|
|
1691
|
+
attr_reader :name
|
|
1692
|
+
attr_accessor :self_refresh
|
|
1693
|
+
include Enumerable, Puppet::Util::ClassGen
|
|
1694
|
+
include Puppet::MetaType::Manager
|
|
1695
|
+
|
|
1696
|
+
include Puppet::Util
|
|
1697
|
+
include Puppet::Util::Logging
|
|
1698
|
+
end
|
|
1699
|
+
|
|
1700
|
+
# all of the variables that must be initialized for each subclass
|
|
1701
|
+
def self.initvars
|
|
1702
|
+
# all of the instances of this class
|
|
1703
|
+
@objects = Hash.new
|
|
1704
|
+
@aliases = Hash.new
|
|
1705
|
+
|
|
1706
|
+
@defaults = {}
|
|
1707
|
+
|
|
1708
|
+
@parameters ||= []
|
|
1709
|
+
|
|
1710
|
+
@validproperties = {}
|
|
1711
|
+
@properties = []
|
|
1712
|
+
@parameters = []
|
|
1713
|
+
@paramhash = {}
|
|
1714
|
+
|
|
1715
|
+
@attr_aliases = {}
|
|
1716
|
+
|
|
1717
|
+
@paramdoc = Hash.new { |hash,key|
|
|
1718
|
+
key = key.intern if key.is_a?(String)
|
|
1719
|
+
if hash.include?(key)
|
|
1720
|
+
hash[key]
|
|
1721
|
+
else
|
|
1722
|
+
"Param Documentation for #{key} not found"
|
|
1723
|
+
end
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
@doc ||= ""
|
|
1727
|
+
|
|
1728
|
+
end
|
|
1729
|
+
|
|
1730
|
+
def self.to_s
|
|
1731
|
+
if defined?(@name)
|
|
1732
|
+
"Puppet::Type::#{@name.to_s.capitalize}"
|
|
1733
|
+
else
|
|
1734
|
+
super
|
|
1735
|
+
end
|
|
1736
|
+
end
|
|
1737
|
+
|
|
1738
|
+
# Create a block to validate that our object is set up entirely. This will
|
|
1739
|
+
# be run before the object is operated on.
|
|
1740
|
+
def self.validate(&block)
|
|
1741
|
+
define_method(:validate, &block)
|
|
1742
|
+
#@validate = block
|
|
1743
|
+
end
|
|
1744
|
+
|
|
1745
|
+
# Origin information.
|
|
1746
|
+
attr_accessor :file, :line
|
|
1747
|
+
|
|
1748
|
+
# The catalog that this resource is stored in.
|
|
1749
|
+
attr_accessor :catalog
|
|
1750
|
+
|
|
1751
|
+
# is the resource exported
|
|
1752
|
+
attr_accessor :exported
|
|
1753
|
+
|
|
1754
|
+
# is the resource virtual (it should not :-))
|
|
1755
|
+
attr_accessor :virtual
|
|
1756
|
+
|
|
1757
|
+
# create a log at specified level
|
|
1758
|
+
def log(msg)
|
|
1759
|
+
|
|
1760
|
+
Puppet::Util::Log.create(
|
|
1761
|
+
|
|
1762
|
+
:level => @parameters[:loglevel].value,
|
|
1763
|
+
:message => msg,
|
|
1764
|
+
|
|
1765
|
+
:source => self
|
|
1766
|
+
)
|
|
1767
|
+
end
|
|
1768
|
+
|
|
1769
|
+
|
|
1770
|
+
# instance methods related to instance intrinsics
|
|
1771
|
+
# e.g., initialize and name
|
|
1772
|
+
|
|
1773
|
+
public
|
|
1774
|
+
|
|
1775
|
+
attr_reader :original_parameters
|
|
1776
|
+
|
|
1777
|
+
# initialize the type instance
|
|
1778
|
+
def initialize(resource)
|
|
1779
|
+
raise Puppet::DevError, "Got TransObject instead of Resource or hash" if resource.is_a?(Puppet::TransObject)
|
|
1780
|
+
resource = self.class.hash2resource(resource) unless resource.is_a?(Puppet::Resource)
|
|
1781
|
+
|
|
1782
|
+
# The list of parameter/property instances.
|
|
1783
|
+
@parameters = {}
|
|
1784
|
+
|
|
1785
|
+
# Set the title first, so any failures print correctly.
|
|
1786
|
+
if resource.type.to_s.downcase.to_sym == self.class.name
|
|
1787
|
+
self.title = resource.title
|
|
1788
|
+
else
|
|
1789
|
+
# This should only ever happen for components
|
|
1790
|
+
self.title = resource.ref
|
|
1791
|
+
end
|
|
1792
|
+
|
|
1793
|
+
[:file, :line, :catalog, :exported, :virtual].each do |getter|
|
|
1794
|
+
setter = getter.to_s + "="
|
|
1795
|
+
if val = resource.send(getter)
|
|
1796
|
+
self.send(setter, val)
|
|
1797
|
+
end
|
|
1798
|
+
end
|
|
1799
|
+
|
|
1800
|
+
@tags = resource.tags
|
|
1801
|
+
|
|
1802
|
+
@original_parameters = resource.to_hash
|
|
1803
|
+
|
|
1804
|
+
set_name(@original_parameters)
|
|
1805
|
+
|
|
1806
|
+
set_default(:provider)
|
|
1807
|
+
|
|
1808
|
+
set_parameters(@original_parameters)
|
|
1809
|
+
|
|
1810
|
+
self.validate if self.respond_to?(:validate)
|
|
1811
|
+
end
|
|
1812
|
+
|
|
1813
|
+
private
|
|
1814
|
+
|
|
1815
|
+
# Set our resource's name.
|
|
1816
|
+
def set_name(hash)
|
|
1817
|
+
self[name_var] = hash.delete(name_var) if name_var
|
|
1818
|
+
end
|
|
1819
|
+
|
|
1820
|
+
# Set all of the parameters from a hash, in the appropriate order.
|
|
1821
|
+
def set_parameters(hash)
|
|
1822
|
+
# Use the order provided by allattrs, but add in any
|
|
1823
|
+
# extra attributes from the resource so we get failures
|
|
1824
|
+
# on invalid attributes.
|
|
1825
|
+
no_values = []
|
|
1826
|
+
(self.class.allattrs + hash.keys).uniq.each do |attr|
|
|
1827
|
+
begin
|
|
1828
|
+
# Set any defaults immediately. This is mostly done so
|
|
1829
|
+
# that the default provider is available for any other
|
|
1830
|
+
# property validation.
|
|
1831
|
+
if hash.has_key?(attr)
|
|
1832
|
+
self[attr] = hash[attr]
|
|
1833
|
+
else
|
|
1834
|
+
no_values << attr
|
|
1835
|
+
end
|
|
1836
|
+
rescue ArgumentError, Puppet::Error, TypeError
|
|
1837
|
+
raise
|
|
1838
|
+
rescue => detail
|
|
1839
|
+
error = Puppet::DevError.new( "Could not set #{attr} on #{self.class.name}: #{detail}")
|
|
1840
|
+
error.set_backtrace(detail.backtrace)
|
|
1841
|
+
raise error
|
|
1842
|
+
end
|
|
1843
|
+
end
|
|
1844
|
+
no_values.each do |attr|
|
|
1845
|
+
set_default(attr)
|
|
1846
|
+
end
|
|
1847
|
+
end
|
|
1848
|
+
|
|
1849
|
+
public
|
|
1850
|
+
|
|
1851
|
+
# Set up all of our autorequires.
|
|
1852
|
+
def finish
|
|
1853
|
+
# Make sure all of our relationships are valid. Again, must be done
|
|
1854
|
+
# when the entire catalog is instantiated.
|
|
1855
|
+
self.class.relationship_params.collect do |klass|
|
|
1856
|
+
if param = @parameters[klass.name]
|
|
1857
|
+
param.validate_relationship
|
|
1858
|
+
end
|
|
1859
|
+
end.flatten.reject { |r| r.nil? }
|
|
1860
|
+
end
|
|
1861
|
+
|
|
1862
|
+
# For now, leave the 'name' method functioning like it used to. Once 'title'
|
|
1863
|
+
# works everywhere, I'll switch it.
|
|
1864
|
+
def name
|
|
1865
|
+
self[:name]
|
|
1866
|
+
end
|
|
1867
|
+
|
|
1868
|
+
# Look up our parent in the catalog, if we have one.
|
|
1869
|
+
def parent
|
|
1870
|
+
return nil unless catalog
|
|
1871
|
+
|
|
1872
|
+
unless defined?(@parent)
|
|
1873
|
+
if parents = catalog.adjacent(self, :direction => :in)
|
|
1874
|
+
# We should never have more than one parent, so let's just ignore
|
|
1875
|
+
# it if we happen to.
|
|
1876
|
+
@parent = parents.shift
|
|
1877
|
+
else
|
|
1878
|
+
@parent = nil
|
|
1879
|
+
end
|
|
1880
|
+
end
|
|
1881
|
+
@parent
|
|
1882
|
+
end
|
|
1883
|
+
|
|
1884
|
+
# Return the "type[name]" style reference.
|
|
1885
|
+
def ref
|
|
1886
|
+
# memoizing this is worthwhile ~ 3 percent of calls are the "first time
|
|
1887
|
+
# around" in an average run of Puppet. --daniel 2012-07-17
|
|
1888
|
+
@ref ||= "#{self.class.name.to_s.capitalize}[#{self.title}]"
|
|
1889
|
+
end
|
|
1890
|
+
|
|
1891
|
+
def self_refresh?
|
|
1892
|
+
self.class.self_refresh
|
|
1893
|
+
end
|
|
1894
|
+
|
|
1895
|
+
# Mark that we're purging.
|
|
1896
|
+
def purging
|
|
1897
|
+
@purging = true
|
|
1898
|
+
end
|
|
1899
|
+
|
|
1900
|
+
# Is this resource being purged? Used by transactions to forbid
|
|
1901
|
+
# deletion when there are dependencies.
|
|
1902
|
+
def purging?
|
|
1903
|
+
if defined?(@purging)
|
|
1904
|
+
@purging
|
|
1905
|
+
else
|
|
1906
|
+
false
|
|
1907
|
+
end
|
|
1908
|
+
end
|
|
1909
|
+
|
|
1910
|
+
# Retrieve the title of an object. If no title was set separately,
|
|
1911
|
+
# then use the object's name.
|
|
1912
|
+
def title
|
|
1913
|
+
unless @title
|
|
1914
|
+
if self.class.validparameter?(name_var)
|
|
1915
|
+
@title = self[:name]
|
|
1916
|
+
elsif self.class.validproperty?(name_var)
|
|
1917
|
+
@title = self.should(name_var)
|
|
1918
|
+
else
|
|
1919
|
+
self.devfail "Could not find namevar #{name_var} for #{self.class.name}"
|
|
1920
|
+
end
|
|
1921
|
+
end
|
|
1922
|
+
|
|
1923
|
+
@title
|
|
1924
|
+
end
|
|
1925
|
+
|
|
1926
|
+
# convert to a string
|
|
1927
|
+
def to_s
|
|
1928
|
+
self.ref
|
|
1929
|
+
end
|
|
1930
|
+
|
|
1931
|
+
# Convert to a transportable object
|
|
1932
|
+
def to_trans(ret = true)
|
|
1933
|
+
trans = TransObject.new(self.title, self.class.name)
|
|
1934
|
+
|
|
1935
|
+
values = retrieve_resource
|
|
1936
|
+
values.each do |name, value|
|
|
1937
|
+
name = name.name if name.respond_to? :name
|
|
1938
|
+
trans[name] = value
|
|
1939
|
+
end
|
|
1940
|
+
|
|
1941
|
+
@parameters.each do |name, param|
|
|
1942
|
+
# Avoid adding each instance name twice
|
|
1943
|
+
next if param.class.isnamevar? and param.value == self.title
|
|
1944
|
+
|
|
1945
|
+
# We've already got property values
|
|
1946
|
+
next if param.is_a?(Puppet::Property)
|
|
1947
|
+
trans[name] = param.value
|
|
1948
|
+
end
|
|
1949
|
+
|
|
1950
|
+
trans.tags = self.tags
|
|
1951
|
+
|
|
1952
|
+
# FIXME I'm currently ignoring 'parent' and 'path'
|
|
1953
|
+
|
|
1954
|
+
trans
|
|
1955
|
+
end
|
|
1956
|
+
|
|
1957
|
+
def to_resource
|
|
1958
|
+
# this 'type instance' versus 'resource' distinction seems artificial
|
|
1959
|
+
# I'd like to see it collapsed someday ~JW
|
|
1960
|
+
self.to_trans.to_resource
|
|
1961
|
+
end
|
|
1962
|
+
|
|
1963
|
+
def virtual?; !!@virtual; end
|
|
1964
|
+
def exported?; !!@exported; end
|
|
1965
|
+
|
|
1966
|
+
def appliable_to_device?
|
|
1967
|
+
self.class.can_apply_to(:device)
|
|
1968
|
+
end
|
|
1969
|
+
|
|
1970
|
+
def appliable_to_host?
|
|
1971
|
+
self.class.can_apply_to(:host)
|
|
1972
|
+
end
|
|
1973
|
+
end
|
|
1974
|
+
end
|
|
1975
|
+
|
|
1976
|
+
require 'puppet/provider'
|
|
1977
|
+
|
|
1978
|
+
# Always load these types.
|
|
1979
|
+
Puppet::Type.type(:component)
|