puppet 0.24.9 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +18680 -1241
- data/CHANGELOG.old +1705 -0
- data/LICENSE +2 -2
- data/README +1 -1
- data/README.queueing +126 -0
- data/README.rst +4 -4
- data/Rakefile +62 -216
- data/bin/filebucket +6 -117
- data/bin/pi +50 -0
- data/bin/puppet +7 -188
- data/bin/puppetdoc +7 -198
- data/bin/ralsh +4 -191
- data/conf/auth.conf +94 -0
- data/conf/gentoo/init.d/puppetmaster +30 -30
- data/conf/osx/PackageInfo.plist +30 -30
- data/conf/osx/createpackage.sh +23 -18
- data/conf/osx/preflight +8 -0
- data/conf/puppet-queue.conf +10 -0
- data/conf/redhat/client.init +52 -41
- data/conf/redhat/logrotate +1 -0
- data/conf/redhat/puppet.spec +74 -36
- data/conf/redhat/rundir-perms.patch +28 -0
- data/conf/redhat/server.init +48 -43
- data/conf/redhat/server.sysconfig +4 -4
- data/conf/solaris/smf/puppetd.xml +53 -53
- data/conf/solaris/smf/puppetmasterd.xml +53 -53
- data/conf/solaris/smf/svc-puppetd +4 -4
- data/conf/solaris/smf/svc-puppetmasterd +3 -3
- data/conf/suse/client.init +4 -4
- data/conf/suse/puppet.spec +14 -14
- data/conf/suse/server.init +17 -17
- data/examples/etc/init.d/sleeper +8 -8
- data/examples/mac_dscl.pp +2 -2
- data/examples/mac_dscl_revert.pp +1 -1
- data/examples/mcx_dock_default.pp +108 -108
- data/examples/mcx_dock_full.pp +108 -108
- data/examples/mcx_nogroup.pp +108 -108
- data/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb +5 -5
- data/examples/modules/sample-module/manifests/init.pp +2 -2
- data/examples/relationships +1 -1
- data/ext/autotest/config +6 -6
- data/ext/bin/sleeper +12 -12
- data/ext/dbfix.sql +21 -21
- data/ext/emacs/puppet-mode.el +42 -41
- data/ext/extlookup.rb +183 -0
- data/ext/ldap/puppet.schema +2 -1
- data/ext/logcheck/puppet +1 -1
- data/ext/module_puppet +7 -7
- data/ext/nagios/check_puppet.rb +83 -83
- data/ext/nagios/naggen +302 -0
- data/ext/puppet-test +61 -18
- data/ext/puppetlisten/puppetlisten.rb +76 -0
- data/ext/puppetlisten/puppetrun.rb +39 -0
- data/ext/puppetstoredconfigclean.rb +29 -29
- data/ext/rack/README +73 -0
- data/ext/rack/files/apache2.conf +38 -0
- data/ext/rack/files/config.ru +18 -0
- data/ext/rack/manifest.pp +59 -0
- data/ext/vim/syntax/puppet.vim +54 -35
- data/install.rb +37 -26
- data/lib/puppet.rb +15 -227
- data/lib/puppet/agent.rb +134 -0
- data/lib/puppet/agent/locker.rb +42 -0
- data/lib/puppet/agent/runner.rb +65 -0
- data/lib/puppet/application.rb +313 -0
- data/lib/puppet/application/filebucket.rb +87 -0
- data/lib/puppet/application/pi.rb +214 -0
- data/lib/puppet/application/puppet.rb +177 -0
- data/lib/puppet/application/puppetca.rb +71 -0
- data/lib/puppet/application/puppetd.rb +256 -0
- data/lib/puppet/application/puppetdoc.rb +222 -0
- data/lib/puppet/application/puppetmasterd.rb +168 -0
- data/lib/puppet/application/puppetqd.rb +96 -0
- data/lib/puppet/application/puppetrun.rb +219 -0
- data/lib/puppet/application/ralsh.rb +168 -0
- data/lib/puppet/configurer.rb +177 -0
- data/lib/puppet/configurer/downloader.rb +79 -0
- data/lib/puppet/configurer/fact_handler.rb +68 -0
- data/lib/puppet/configurer/plugin_handler.rb +26 -0
- data/lib/puppet/daemon.rb +78 -28
- data/lib/puppet/defaults.rb +239 -166
- data/lib/puppet/dsl.rb +7 -7
- data/lib/puppet/external/dot.rb +271 -271
- data/lib/puppet/external/event-loop/better-definers.rb +298 -298
- data/lib/puppet/external/event-loop/event-loop.rb +274 -274
- data/lib/puppet/external/event-loop/signal-system.rb +163 -163
- data/lib/puppet/external/lock.rb +1 -1
- data/lib/puppet/external/nagios.rb +20 -20
- data/lib/puppet/external/nagios/base.rb +3 -3
- data/lib/puppet/external/nagios/grammar.ry +185 -0
- data/lib/puppet/external/nagios/makefile +9 -0
- data/lib/puppet/external/nagios/parser.rb +1 -1
- data/lib/puppet/feature/json.rb +2 -0
- data/lib/puppet/feature/rack.rb +24 -0
- data/lib/puppet/feature/rails.rb +23 -33
- data/lib/puppet/feature/rubygems.rb +6 -0
- data/lib/puppet/feature/stomp.rb +6 -0
- data/lib/puppet/file_serving/{file_base.rb → base.rb} +10 -9
- data/lib/puppet/file_serving/configuration.rb +61 -61
- data/lib/puppet/file_serving/configuration/parser.rb +24 -29
- data/lib/puppet/file_serving/content.rb +26 -11
- data/lib/puppet/file_serving/fileset.rb +54 -19
- data/lib/puppet/file_serving/indirection_hooks.rb +12 -24
- data/lib/puppet/file_serving/metadata.rb +8 -8
- data/lib/puppet/file_serving/mount.rb +9 -151
- data/lib/puppet/file_serving/mount/file.rb +126 -0
- data/lib/puppet/file_serving/mount/modules.rb +25 -0
- data/lib/puppet/file_serving/mount/plugins.rb +27 -0
- data/lib/puppet/file_serving/terminus_helper.rb +9 -4
- data/lib/puppet/indirector.rb +6 -4
- data/lib/puppet/indirector/active_record.rb +28 -0
- data/lib/puppet/indirector/catalog/active_record.rb +36 -0
- data/lib/puppet/indirector/catalog/compiler.rb +50 -24
- data/lib/puppet/indirector/catalog/queue.rb +5 -0
- data/lib/puppet/indirector/catalog/rest.rb +6 -0
- data/lib/puppet/indirector/catalog/yaml.rb +2 -4
- data/lib/puppet/indirector/certificate/ca.rb +9 -0
- data/lib/puppet/indirector/certificate/file.rb +9 -0
- data/lib/puppet/indirector/certificate/rest.rb +9 -0
- data/lib/puppet/indirector/certificate_request/ca.rb +14 -0
- data/lib/puppet/indirector/certificate_request/file.rb +8 -0
- data/lib/puppet/indirector/certificate_request/rest.rb +9 -0
- data/lib/puppet/indirector/certificate_revocation_list/ca.rb +8 -0
- data/lib/puppet/indirector/certificate_revocation_list/file.rb +8 -0
- data/lib/puppet/indirector/certificate_revocation_list/rest.rb +9 -0
- data/lib/puppet/indirector/direct_file_server.rb +4 -8
- data/lib/puppet/indirector/exec.rb +2 -6
- data/lib/puppet/indirector/facts/active_record.rb +36 -0
- data/lib/puppet/indirector/facts/facter.rb +30 -22
- data/lib/puppet/indirector/facts/rest.rb +6 -0
- data/lib/puppet/indirector/file.rb +1 -0
- data/lib/puppet/indirector/file_content/rest.rb +0 -1
- data/lib/puppet/indirector/file_metadata/file.rb +2 -2
- data/lib/puppet/indirector/file_metadata/rest.rb +0 -1
- data/lib/puppet/indirector/file_server.rb +31 -18
- data/lib/puppet/indirector/indirection.rb +46 -33
- data/lib/puppet/indirector/key/ca.rb +12 -0
- data/lib/puppet/indirector/key/file.rb +42 -0
- data/lib/puppet/indirector/node/active_record.rb +13 -0
- data/lib/puppet/indirector/node/ldap.rb +1 -1
- data/lib/puppet/indirector/queue.rb +83 -0
- data/lib/puppet/indirector/report/processor.rb +1 -1
- data/lib/puppet/indirector/report/rest.rb +7 -0
- data/lib/puppet/indirector/request.rb +158 -15
- data/lib/puppet/indirector/rest.rb +74 -36
- data/lib/puppet/indirector/runner/rest.rb +7 -0
- data/lib/puppet/indirector/ssl_file.rb +174 -0
- data/lib/puppet/indirector/terminus.rb +4 -4
- data/lib/puppet/indirector/yaml.rb +1 -1
- data/lib/puppet/metatype/manager.rb +3 -3
- data/lib/puppet/module.rb +99 -124
- data/lib/puppet/network/authconfig.rb +57 -42
- data/lib/puppet/network/authstore.rb +58 -10
- data/lib/puppet/network/client.rb +0 -2
- data/lib/puppet/network/client/ca.rb +1 -1
- data/lib/puppet/network/client/dipper.rb +7 -2
- data/lib/puppet/network/format.rb +123 -0
- data/lib/puppet/network/format_handler.rb +156 -0
- data/lib/puppet/network/formats.rb +123 -0
- data/lib/puppet/network/handler/filebucket.rb +1 -1
- data/lib/puppet/network/handler/fileserver.rb +43 -35
- data/lib/puppet/network/handler/master.rb +4 -4
- data/lib/puppet/network/handler/report.rb +1 -1
- data/lib/puppet/network/handler/resource.rb +16 -20
- data/lib/puppet/network/handler/runner.rb +9 -42
- data/lib/puppet/network/http.rb +4 -4
- data/lib/puppet/network/http/api.rb +4 -0
- data/lib/puppet/network/http/api/v1.rb +65 -0
- data/lib/puppet/network/http/handler.rb +163 -56
- data/lib/puppet/network/http/mongrel.rb +19 -15
- data/lib/puppet/network/http/mongrel/rest.rb +35 -17
- data/lib/puppet/network/http/rack.rb +62 -0
- data/lib/puppet/network/http/rack/httphandler.rb +34 -0
- data/lib/puppet/network/http/rack/rest.rb +79 -0
- data/lib/puppet/network/http/rack/xmlrpc.rb +65 -0
- data/lib/puppet/network/http/webrick.rb +89 -16
- data/lib/puppet/network/http/webrick/rest.rb +24 -11
- data/lib/puppet/network/http_pool.rb +28 -29
- data/lib/puppet/network/http_server/mongrel.rb +8 -10
- data/lib/puppet/network/http_server/webrick.rb +1 -3
- data/lib/puppet/network/rest_authconfig.rb +89 -0
- data/lib/puppet/network/rest_authorization.rb +25 -0
- data/lib/puppet/network/rights.rb +230 -27
- data/lib/puppet/network/server.rb +133 -31
- data/lib/puppet/network/xmlrpc/client.rb +5 -5
- data/lib/puppet/network/xmlrpc/webrick_servlet.rb +6 -6
- data/lib/puppet/node.rb +28 -21
- data/lib/puppet/node/environment.rb +48 -0
- data/lib/puppet/node/facts.rb +21 -0
- data/lib/puppet/parameter.rb +291 -219
- data/lib/puppet/parser/ast.rb +1 -0
- data/lib/puppet/parser/ast/astarray.rb +5 -1
- data/lib/puppet/parser/ast/boolean_operator.rb +3 -3
- data/lib/puppet/parser/ast/caseopt.rb +10 -0
- data/lib/puppet/parser/ast/casestatement.rb +12 -27
- data/lib/puppet/parser/ast/collection.rb +31 -0
- data/lib/puppet/parser/ast/collexpr.rb +18 -11
- data/lib/puppet/parser/ast/comparison_operator.rb +1 -1
- data/lib/puppet/parser/ast/definition.rb +6 -2
- data/lib/puppet/parser/ast/function.rb +7 -2
- data/lib/puppet/parser/ast/ifstatement.rb +11 -6
- data/lib/puppet/parser/ast/leaf.rb +106 -3
- data/lib/puppet/parser/ast/match_operator.rb +31 -0
- data/lib/puppet/parser/ast/node.rb +10 -6
- data/lib/puppet/parser/ast/resource_defaults.rb +2 -2
- data/lib/puppet/parser/ast/resource_override.rb +1 -1
- data/lib/puppet/parser/ast/resource_reference.rb +11 -3
- data/lib/puppet/parser/ast/selector.rb +14 -32
- data/lib/puppet/parser/ast/vardef.rb +1 -1
- data/lib/puppet/parser/collector.rb +67 -15
- data/lib/puppet/parser/compiler.rb +21 -53
- data/lib/puppet/parser/files.rb +92 -0
- data/lib/puppet/parser/functions.rb +3 -3
- data/lib/puppet/parser/functions/defined.rb +3 -3
- data/lib/puppet/parser/functions/fqdn_rand.rb +3 -3
- data/lib/puppet/parser/functions/inline_template.rb +4 -4
- data/lib/puppet/parser/functions/regsubst.rb +37 -35
- data/lib/puppet/parser/functions/require.rb +34 -0
- data/lib/puppet/parser/functions/shellquote.rb +41 -0
- data/lib/puppet/parser/functions/split.rb +29 -0
- data/lib/puppet/parser/functions/sprintf.rb +6 -6
- data/lib/puppet/parser/functions/template.rb +4 -4
- data/lib/puppet/parser/functions/versioncmp.rb +22 -1
- data/lib/puppet/parser/grammar.ra +812 -0
- data/lib/puppet/parser/interpreter.rb +4 -4
- data/lib/puppet/parser/lexer.rb +44 -15
- data/lib/puppet/parser/loaded_code.rb +115 -0
- data/lib/puppet/parser/makefile +8 -0
- data/lib/puppet/parser/parser.rb +1080 -928
- data/lib/puppet/parser/parser_support.rb +118 -96
- data/lib/puppet/parser/resource.rb +56 -126
- data/lib/puppet/parser/resource/param.rb +2 -76
- data/lib/puppet/parser/resource/reference.rb +15 -8
- data/lib/puppet/parser/scope.rb +68 -35
- data/lib/puppet/parser/templatewrapper.rb +8 -8
- data/lib/puppet/parser/yaml_trimmer.rb +11 -0
- data/lib/puppet/property.rb +69 -124
- data/lib/puppet/property/list.rb +3 -3
- data/lib/puppet/provider.rb +5 -5
- data/lib/puppet/provider/augeas/augeas.rb +119 -118
- data/lib/puppet/provider/computer/computer.rb +3 -3
- data/lib/puppet/provider/confine/variable.rb +1 -1
- data/lib/puppet/provider/cron/crontab.rb +8 -7
- data/lib/puppet/provider/group/directoryservice.rb +2 -2
- data/lib/puppet/provider/group/groupadd.rb +1 -1
- data/lib/puppet/provider/group/ldap.rb +3 -3
- data/lib/puppet/provider/group/pw.rb +1 -1
- data/lib/puppet/provider/host/parsed.rb +3 -3
- data/lib/puppet/provider/ldap.rb +1 -3
- data/lib/puppet/provider/macauthorization/macauthorization.rb +62 -55
- data/lib/puppet/provider/mailalias/aliases.rb +9 -1
- data/lib/puppet/provider/maillist/mailman.rb +8 -4
- data/lib/puppet/provider/mcx/mcxcontent.rb +11 -11
- data/lib/puppet/provider/mount/parsed.rb +2 -2
- data/lib/puppet/provider/nameservice.rb +6 -6
- data/lib/puppet/provider/nameservice/directoryservice.rb +83 -87
- data/lib/puppet/provider/package/appdmg.rb +10 -9
- data/lib/puppet/provider/package/apple.rb +1 -3
- data/lib/puppet/provider/package/apt.rb +5 -5
- data/lib/puppet/provider/package/aptitude.rb +1 -1
- data/lib/puppet/provider/package/aptrpm.rb +1 -1
- data/lib/puppet/provider/package/darwinport.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +2 -2
- data/lib/puppet/provider/package/fink.rb +6 -6
- data/lib/puppet/provider/package/freebsd.rb +1 -1
- data/lib/puppet/provider/package/gem.rb +2 -2
- data/lib/puppet/provider/package/hpux.rb +5 -5
- data/lib/puppet/provider/package/pkgdmg.rb +30 -22
- data/lib/puppet/provider/package/portage.rb +1 -1
- data/lib/puppet/provider/package/ports.rb +1 -1
- data/lib/puppet/provider/package/rpm.rb +5 -5
- data/lib/puppet/provider/package/rug.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +7 -7
- data/lib/puppet/provider/package/up2date.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +2 -2
- data/lib/puppet/provider/package/yumhelper.py +2 -2
- data/lib/puppet/provider/port/parsed.rb +1 -1
- data/lib/puppet/provider/selmodule/semodule.rb +3 -3
- data/lib/puppet/provider/service/base.rb +21 -12
- data/lib/puppet/provider/service/daemontools.rb +86 -49
- data/lib/puppet/provider/service/debian.rb +20 -12
- data/lib/puppet/provider/service/freebsd.rb +5 -5
- data/lib/puppet/provider/service/gentoo.rb +2 -2
- data/lib/puppet/provider/service/init.rb +21 -33
- data/lib/puppet/provider/service/launchd.rb +120 -48
- data/lib/puppet/provider/service/redhat.rb +12 -21
- data/lib/puppet/provider/service/runit.rb +19 -9
- data/lib/puppet/provider/service/smf.rb +49 -34
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +34 -0
- data/lib/puppet/provider/sshkey/parsed.rb +2 -2
- data/lib/puppet/provider/user/directoryservice.rb +12 -29
- data/lib/puppet/provider/user/hpux.rb +3 -3
- data/lib/puppet/provider/user/ldap.rb +2 -2
- data/lib/puppet/provider/zfs/solaris.rb +1 -1
- data/lib/puppet/provider/zone/solaris.rb +4 -4
- data/lib/puppet/provider/zpool/solaris.rb +3 -3
- data/lib/puppet/rails.rb +9 -9
- data/lib/puppet/rails/benchmark.rb +69 -0
- data/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +5 -5
- data/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb +2 -2
- data/lib/puppet/rails/database/003_add_environment_to_host.rb +1 -1
- data/lib/puppet/rails/database/schema.rb +8 -8
- data/lib/puppet/rails/fact_value.rb +1 -1
- data/lib/puppet/rails/host.rb +211 -93
- data/lib/puppet/rails/param_name.rb +5 -1
- data/lib/puppet/rails/param_value.rb +29 -2
- data/lib/puppet/rails/puppet_tag.rb +5 -0
- data/lib/puppet/rails/resource.rb +120 -20
- data/lib/puppet/rails/resource_tag.rb +1 -1
- data/lib/puppet/rails/source_file.rb +1 -1
- data/lib/puppet/reference/configuration.rb +14 -14
- data/lib/puppet/reference/function.rb +1 -1
- data/lib/puppet/reference/metaparameter.rb +48 -0
- data/lib/puppet/reference/providers.rb +6 -6
- data/lib/puppet/reference/type.rb +1 -37
- data/lib/puppet/relationship.rb +57 -30
- data/lib/puppet/reports/rrdgraph.rb +4 -4
- data/lib/puppet/reports/store.rb +3 -3
- data/lib/puppet/reports/tagmail.rb +15 -15
- data/lib/puppet/resource.rb +265 -0
- data/lib/puppet/{node → resource}/catalog.rb +188 -112
- data/lib/puppet/{resource_reference.rb → resource/reference.rb} +46 -24
- data/lib/puppet/simple_graph.rb +165 -27
- data/lib/puppet/ssl.rb +7 -0
- data/lib/puppet/ssl/base.rb +62 -0
- data/lib/puppet/ssl/certificate.rb +34 -0
- data/lib/puppet/ssl/certificate_authority.rb +298 -0
- data/lib/puppet/ssl/certificate_authority/interface.rb +118 -0
- data/lib/puppet/ssl/certificate_factory.rb +145 -0
- data/lib/puppet/ssl/certificate_request.rb +51 -0
- data/lib/puppet/ssl/certificate_revocation_list.rb +86 -0
- data/lib/puppet/ssl/host.rb +271 -0
- data/lib/puppet/ssl/inventory.rb +52 -0
- data/lib/puppet/ssl/key.rb +56 -0
- data/lib/puppet/sslcertificates.rb +6 -6
- data/lib/puppet/sslcertificates/ca.rb +15 -15
- data/lib/puppet/sslcertificates/certificate.rb +4 -4
- data/lib/puppet/sslcertificates/inventory.rb +3 -3
- data/lib/puppet/transaction.rb +113 -139
- data/lib/puppet/transaction/change.rb +6 -6
- data/lib/puppet/transaction/event.rb +1 -1
- data/lib/puppet/transaction/report.rb +7 -1
- data/lib/puppet/transportable.rb +28 -28
- data/lib/puppet/type.rb +263 -688
- data/lib/puppet/type/augeas.rb +3 -2
- data/lib/puppet/type/component.rb +28 -95
- data/lib/puppet/type/computer.rb +10 -10
- data/lib/puppet/type/cron.rb +19 -14
- data/lib/puppet/type/exec.rb +21 -20
- data/lib/puppet/type/file.rb +306 -633
- data/lib/puppet/type/file/checksum.rb +10 -11
- data/lib/puppet/type/file/content.rb +83 -22
- data/lib/puppet/type/file/ensure.rb +15 -9
- data/lib/puppet/type/file/group.rb +7 -1
- data/lib/puppet/type/file/mode.rb +1 -1
- data/lib/puppet/type/file/owner.rb +9 -3
- data/lib/puppet/type/file/selcontext.rb +4 -4
- data/lib/puppet/type/file/source.rb +78 -179
- data/lib/puppet/type/file/target.rb +3 -3
- data/lib/puppet/type/file/type.rb +2 -2
- data/lib/puppet/type/filebucket.rb +33 -54
- data/lib/puppet/type/group.rb +8 -8
- data/lib/puppet/type/host.rb +7 -7
- data/lib/puppet/type/k5login.rb +2 -2
- data/lib/puppet/type/macauthorization.rb +77 -52
- data/lib/puppet/type/mailalias.rb +2 -2
- data/lib/puppet/type/maillist.rb +2 -2
- data/lib/puppet/type/mcx.rb +3 -3
- data/lib/puppet/type/mount.rb +16 -11
- data/lib/puppet/type/notify.rb +4 -4
- data/lib/puppet/type/package.rb +6 -28
- data/lib/puppet/type/port.rb +1 -1
- data/lib/puppet/type/resources.rb +19 -19
- data/lib/puppet/type/schedule.rb +18 -20
- data/lib/puppet/type/selmodule.rb +1 -1
- data/lib/puppet/type/service.rb +11 -7
- data/lib/puppet/type/ssh_authorized_key.rb +26 -9
- data/lib/puppet/type/sshkey.rb +2 -2
- data/lib/puppet/type/tidy.rb +285 -289
- data/lib/puppet/type/user.rb +9 -7
- data/lib/puppet/type/yumrepo.rb +17 -16
- data/lib/puppet/type/zone.rb +8 -7
- data/lib/puppet/util.rb +11 -36
- data/lib/puppet/util/autoload.rb +31 -19
- data/lib/puppet/util/autoload/file_cache.rb +115 -0
- data/lib/puppet/util/backups.rb +86 -0
- data/lib/puppet/util/cacher.rb +135 -0
- data/lib/puppet/util/checksums.rb +11 -1
- data/lib/puppet/util/classgen.rb +1 -1
- data/lib/puppet/util/config_store.rb +2 -2
- data/lib/puppet/util/constant_inflector.rb +1 -1
- data/lib/puppet/util/diff.rb +2 -2
- data/lib/puppet/util/docs.rb +9 -3
- data/lib/puppet/util/execution.rb +1 -1
- data/lib/puppet/util/feature.rb +27 -20
- data/lib/puppet/util/fileparsing.rb +3 -3
- data/lib/puppet/util/filetype.rb +8 -6
- data/lib/puppet/util/graph.rb +5 -5
- data/lib/puppet/util/inifile.rb +5 -5
- data/lib/puppet/util/json.rb +13 -0
- data/lib/puppet/util/ldap/connection.rb +2 -2
- data/lib/puppet/util/log.rb +48 -31
- data/lib/puppet/util/metric.rb +4 -4
- data/lib/puppet/util/monkey_patches.rb +43 -0
- data/lib/puppet/util/nagios_maker.rb +1 -1
- data/lib/puppet/util/package.rb +4 -4
- data/lib/puppet/util/pidlock.rb +59 -59
- data/lib/puppet/util/posix.rb +13 -52
- data/lib/puppet/util/provider_features.rb +3 -3
- data/lib/puppet/util/queue.rb +96 -0
- data/lib/puppet/util/queue/stomp.rb +47 -0
- data/lib/puppet/util/rails/cache_accumulator.rb +65 -0
- data/lib/puppet/util/rails/collection_merger.rb +0 -39
- data/lib/puppet/util/rails/reference_serializer.rb +17 -3
- data/lib/puppet/util/rdoc.rb +1 -0
- data/lib/puppet/util/rdoc/code_objects.rb +5 -1
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +5 -5
- data/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +13 -13
- data/lib/puppet/util/rdoc/parser.rb +28 -32
- data/lib/puppet/util/reference.rb +29 -8
- data/lib/puppet/util/resource_template.rb +1 -1
- data/lib/puppet/util/selinux.rb +12 -6
- data/lib/puppet/util/settings.rb +203 -578
- data/lib/puppet/util/settings/boolean_setting.rb +33 -0
- data/lib/puppet/util/settings/file_setting.rb +119 -0
- data/lib/puppet/util/settings/setting.rb +110 -0
- data/lib/puppet/util/subclass_loader.rb +1 -1
- data/lib/puppet/util/suidmanager.rb +2 -2
- data/lib/puppet/util/tagging.rb +1 -1
- data/lib/puppet/util/warnings.rb +17 -9
- data/man/man8/filebucket.8 +2 -2
- data/man/man8/pi.8 +2 -2
- data/man/man8/puppet.8 +3 -4
- data/man/man8/puppet.conf.8 +63 -63
- data/man/man8/puppetca.8 +2 -2
- data/man/man8/puppetd.8 +2 -2
- data/man/man8/puppetdoc.8 +2 -2
- data/man/man8/puppetmasterd.8 +2 -2
- data/man/man8/puppetrun.8 +2 -2
- data/man/man8/ralsh.8 +3 -3
- data/sbin/puppetca +102 -0
- data/sbin/puppetd +159 -0
- data/sbin/puppetmasterd +66 -0
- data/sbin/puppetqd +53 -0
- data/sbin/puppetrun +130 -0
- data/spec/Rakefile +2 -2
- data/spec/integration/application/puppet.rb +33 -0
- data/spec/integration/bin/puppetmasterd.rb +110 -0
- data/spec/integration/configurer.rb +18 -0
- data/spec/integration/defaults.rb +158 -7
- data/spec/integration/file_serving/content.rb +2 -0
- data/spec/integration/file_serving/fileset.rb +14 -0
- data/spec/integration/file_serving/metadata.rb +2 -0
- data/spec/integration/file_serving/terminus_helper.rb +22 -0
- data/spec/integration/indirector/catalog/compiler.rb +67 -0
- data/spec/integration/indirector/catalog/queue.rb +61 -0
- data/spec/integration/indirector/certificate/rest.rb +69 -0
- data/spec/integration/indirector/certificate_request/rest.rb +89 -0
- data/spec/integration/indirector/certificate_revocation_list/rest.rb +77 -0
- data/spec/integration/indirector/direct_file_server.rb +16 -23
- data/spec/integration/indirector/file_content/file_server.rb +75 -0
- data/spec/integration/indirector/report/rest.rb +95 -0
- data/spec/integration/indirector/rest.rb +207 -147
- data/spec/integration/network/client.rb +19 -0
- data/spec/integration/network/formats.rb +110 -0
- data/spec/integration/network/handler.rb +25 -0
- data/spec/integration/network/server/mongrel.rb +26 -8
- data/spec/integration/network/server/webrick.rb +49 -11
- data/spec/integration/node/environment.rb +58 -0
- data/spec/integration/node/facts.rb +4 -2
- data/spec/integration/parser/compiler.rb +29 -0
- data/spec/integration/parser/functions/require.rb +67 -0
- data/spec/integration/provider/mailalias/aliases.rb +25 -0
- data/spec/integration/{node → resource}/catalog.rb +17 -10
- data/spec/integration/ssl/certificate_authority.rb +135 -0
- data/spec/integration/ssl/certificate_request.rb +59 -0
- data/spec/integration/ssl/certificate_revocation_list.rb +42 -0
- data/spec/integration/ssl/host.rb +90 -0
- data/spec/integration/transaction.rb +66 -0
- data/spec/integration/transaction/report.rb +2 -5
- data/spec/integration/type.rb +22 -0
- data/spec/integration/type/file.rb +458 -0
- data/spec/integration/type/package.rb +1 -1
- data/spec/integration/type/tidy.rb +27 -0
- data/spec/integration/util/autoload.rb +114 -0
- data/spec/integration/util/feature.rb +54 -0
- data/spec/integration/util/file_locking.rb +2 -1
- data/spec/integration/util/settings.rb +27 -0
- data/spec/lib/puppet_spec/files.rb +9 -0
- data/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +1 -0
- data/spec/monkey_patches/alias_should_to_must.rb +1 -0
- data/spec/shared_behaviours/file_server_terminus.rb +14 -11
- data/spec/shared_behaviours/file_serving.rb +13 -17
- data/spec/spec_helper.rb +22 -5
- data/spec/unit/agent.rb +259 -0
- data/spec/unit/agent/locker.rb +100 -0
- data/spec/unit/agent/runner.rb +118 -0
- data/spec/unit/application.rb +420 -0
- data/spec/unit/application/filebucket.rb +220 -0
- data/spec/unit/application/pi.rb +84 -0
- data/spec/unit/application/puppet.rb +404 -0
- data/spec/unit/application/puppetca.rb +142 -0
- data/spec/unit/application/puppetd.rb +502 -0
- data/spec/unit/application/puppetdoc.rb +345 -0
- data/spec/unit/application/puppetmasterd.rb +456 -0
- data/spec/unit/application/puppetqd.rb +186 -0
- data/spec/unit/application/puppetrun.rb +279 -0
- data/spec/unit/application/ralsh.rb +237 -0
- data/spec/unit/configurer.rb +232 -0
- data/spec/unit/configurer/downloader.rb +188 -0
- data/spec/unit/configurer/fact_handler.rb +150 -0
- data/spec/unit/configurer/plugin_handler.rb +112 -0
- data/spec/unit/daemon.rb +287 -0
- data/spec/unit/file_serving/{file_base.rb → base.rb} +39 -31
- data/spec/unit/file_serving/configuration.rb +104 -93
- data/spec/unit/file_serving/configuration/parser.rb +64 -18
- data/spec/unit/file_serving/content.rb +65 -26
- data/spec/unit/file_serving/fileset.rb +116 -14
- data/spec/unit/file_serving/indirection_hooks.rb +34 -95
- data/spec/unit/file_serving/metadata.rb +27 -40
- data/spec/unit/file_serving/mount.rb +7 -118
- data/spec/unit/file_serving/mount/file.rb +188 -0
- data/spec/unit/file_serving/mount/modules.rb +63 -0
- data/spec/unit/file_serving/mount/plugins.rb +61 -0
- data/spec/unit/file_serving/terminus_helper.rb +39 -27
- data/spec/unit/indirector.rb +6 -1
- data/spec/unit/indirector/active_record.rb +76 -0
- data/spec/unit/indirector/catalog/active_record.rb +122 -0
- data/spec/unit/indirector/catalog/compiler.rb +222 -118
- data/spec/unit/indirector/catalog/queue.rb +20 -0
- data/spec/unit/indirector/catalog/rest.rb +11 -0
- data/spec/unit/indirector/catalog/yaml.rb +6 -6
- data/spec/unit/indirector/certificate/ca.rb +28 -0
- data/spec/unit/indirector/certificate/file.rb +28 -0
- data/spec/unit/indirector/certificate/rest.rb +23 -0
- data/spec/unit/indirector/certificate_request/ca.rb +19 -0
- data/spec/unit/indirector/certificate_request/file.rb +19 -0
- data/spec/unit/indirector/certificate_request/rest.rb +23 -0
- data/spec/unit/indirector/certificate_revocation_list/ca.rb +21 -0
- data/spec/unit/indirector/certificate_revocation_list/file.rb +20 -0
- data/spec/unit/indirector/certificate_revocation_list/rest.rb +23 -0
- data/spec/unit/indirector/direct_file_server.rb +3 -8
- data/spec/unit/indirector/exec.rb +6 -1
- data/spec/unit/indirector/facts/active_record.rb +104 -0
- data/spec/unit/indirector/facts/facter.rb +53 -12
- data/spec/unit/indirector/facts/rest.rb +11 -0
- data/spec/unit/indirector/file.rb +8 -1
- data/spec/unit/indirector/file_metadata/file.rb +5 -5
- data/spec/unit/indirector/file_server.rb +181 -98
- data/spec/unit/indirector/indirection.rb +102 -38
- data/spec/unit/indirector/key/ca.rb +28 -0
- data/spec/unit/indirector/key/file.rb +104 -0
- data/spec/unit/indirector/node/active_record.rb +34 -0
- data/spec/unit/indirector/node/ldap.rb +1 -1
- data/spec/unit/indirector/node/rest.rb +2 -2
- data/spec/unit/indirector/queue.rb +123 -0
- data/spec/unit/indirector/report/rest.rb +28 -0
- data/spec/unit/indirector/request.rb +221 -0
- data/spec/unit/indirector/rest.rb +343 -334
- data/spec/unit/indirector/runner/rest.rb +11 -0
- data/spec/unit/indirector/ssl_file.rb +280 -0
- data/spec/unit/module.rb +180 -180
- data/spec/unit/network/authconfig.rb +292 -0
- data/spec/unit/network/authstore.rb +94 -0
- data/spec/unit/network/client.rb +2 -2
- data/spec/unit/network/client/dipper.rb +16 -0
- data/spec/unit/network/format.rb +191 -0
- data/spec/unit/network/format_handler.rb +306 -0
- data/spec/unit/network/formats.rb +249 -0
- data/spec/unit/network/handler/fileserver.rb +2 -5
- data/spec/unit/network/http.rb +3 -3
- data/spec/unit/network/http/api/v1.rb +122 -0
- data/spec/unit/network/http/handler.rb +448 -0
- data/spec/unit/network/http/mongrel.rb +46 -32
- data/spec/unit/network/http/mongrel/rest.rb +174 -319
- data/spec/unit/network/http/rack.rb +102 -0
- data/spec/unit/network/http/rack/rest.rb +199 -0
- data/spec/unit/network/http/rack/xmlrpc.rb +157 -0
- data/spec/unit/network/http/webrick.rb +249 -37
- data/spec/unit/network/http/webrick/rest.rb +113 -279
- data/spec/unit/network/http_pool.rb +86 -110
- data/spec/unit/network/rest_authconfig.rb +146 -0
- data/spec/unit/network/rest_authorization.rb +43 -0
- data/spec/unit/network/rights.rb +519 -0
- data/spec/unit/network/server.rb +475 -257
- data/spec/unit/node.rb +43 -10
- data/spec/unit/node/environment.rb +143 -9
- data/spec/unit/node/facts.rb +77 -24
- data/spec/unit/other/selinux.rb +85 -0
- data/spec/unit/other/transbucket.rb +29 -13
- data/spec/unit/other/transobject.rb +35 -15
- data/spec/unit/parameter.rb +378 -5
- data/spec/unit/parser/ast.rb +1 -1
- data/spec/unit/parser/ast/arithmetic_operator.rb +17 -17
- data/spec/unit/parser/ast/astarray.rb +16 -10
- data/spec/unit/parser/ast/boolean_operator.rb +2 -2
- data/spec/unit/parser/ast/casestatement.rb +143 -0
- data/spec/unit/parser/ast/collection.rb +63 -0
- data/spec/unit/parser/ast/collexpr.rb +31 -8
- data/spec/unit/parser/ast/comparison_operator.rb +9 -9
- data/spec/unit/parser/ast/definition.rb +18 -0
- data/spec/unit/parser/ast/function.rb +6 -0
- data/spec/unit/parser/ast/ifstatement.rb +75 -0
- data/spec/unit/parser/ast/leaf.rb +261 -0
- data/spec/unit/parser/ast/match_operator.rb +50 -0
- data/spec/unit/parser/ast/minus.rb +1 -1
- data/spec/unit/parser/ast/node.rb +20 -0
- data/spec/unit/parser/ast/not.rb +1 -1
- data/spec/unit/parser/ast/resource_override.rb +5 -5
- data/spec/unit/parser/ast/resource_reference.rb +11 -5
- data/spec/unit/parser/ast/selector.rb +156 -0
- data/spec/unit/parser/ast/vardef.rb +11 -11
- data/spec/unit/parser/collector.rb +167 -48
- data/spec/unit/parser/compiler.rb +128 -104
- data/spec/unit/parser/files.rb +190 -0
- data/spec/unit/parser/functions/inline_template.rb +0 -0
- data/spec/unit/parser/functions/regsubst.rb +42 -42
- data/spec/unit/parser/functions/require.rb +36 -0
- data/spec/unit/parser/functions/shellquote.rb +92 -0
- data/spec/unit/parser/functions/split.rb +51 -0
- data/spec/unit/parser/functions/sprintf.rb +11 -11
- data/spec/unit/parser/functions/template.rb +0 -0
- data/spec/unit/parser/functions/versioncmp.rb +2 -2
- data/spec/unit/parser/interpreter.rb +16 -7
- data/spec/unit/parser/lexer.rb +72 -12
- data/spec/unit/parser/loaded_code.rb +198 -0
- data/spec/unit/parser/parser.rb +215 -28
- data/spec/unit/parser/resource.rb +131 -22
- data/spec/unit/parser/scope.rb +207 -12
- data/spec/unit/parser/templatewrapper.rb +8 -3
- data/spec/unit/property.rb +270 -16
- data/spec/unit/property/list.rb +12 -6
- data/spec/unit/provider.rb +31 -0
- data/spec/unit/provider/augeas/augeas.rb +61 -33
- data/spec/unit/provider/macauthorization.rb +29 -29
- data/spec/unit/provider/mcx/mcxcontent.rb +4 -4
- data/spec/unit/provider/mount/parsed.rb +5 -8
- data/spec/unit/provider/naginator.rb +0 -0
- data/spec/unit/provider/package/apt.rb +6 -6
- data/spec/unit/provider/package/pkgdmg.rb +73 -0
- data/spec/unit/provider/selboolean.rb +1 -1
- data/spec/unit/provider/selmodule.rb +2 -2
- data/spec/unit/provider/service/daemontools.rb +40 -15
- data/spec/unit/provider/service/debian.rb +89 -0
- data/spec/unit/provider/service/init.rb +106 -0
- data/spec/unit/provider/service/launchd.rb +71 -13
- data/spec/unit/provider/service/redhat.rb +94 -0
- data/spec/unit/provider/service/runit.rb +14 -2
- data/spec/unit/provider/ssh_authorized_key/parsed.rb +66 -2
- data/spec/unit/provider/user/ldap.rb +1 -1
- data/spec/unit/provider/user/user_role_add.rb +1 -1
- data/spec/unit/provider/zfs/solaris.rb +18 -6
- data/spec/unit/provider/zone/solaris.rb +1 -1
- data/spec/unit/rails.rb +16 -22
- data/spec/unit/rails/host.rb +163 -0
- data/spec/unit/rails/param_value.rb +49 -0
- data/spec/unit/rails/resource.rb +87 -0
- data/spec/unit/relationship.rb +141 -29
- data/spec/unit/resource.rb +504 -0
- data/spec/unit/resource/catalog.rb +1061 -0
- data/spec/unit/resource/reference.rb +111 -0
- data/spec/unit/simple_graph.rb +448 -191
- data/spec/unit/ssl/certificate.rb +124 -0
- data/spec/unit/ssl/certificate_authority.rb +741 -0
- data/spec/unit/ssl/certificate_authority/interface.rb +269 -0
- data/spec/unit/ssl/certificate_factory.rb +107 -0
- data/spec/unit/ssl/certificate_request.rb +193 -0
- data/spec/unit/ssl/certificate_revocation_list.rb +180 -0
- data/spec/unit/ssl/host.rb +704 -0
- data/spec/unit/ssl/inventory.rb +180 -0
- data/spec/unit/ssl/key.rb +198 -0
- data/spec/unit/transaction.rb +65 -2
- data/spec/unit/transaction/change.rb +1 -1
- data/spec/unit/transaction/report.rb +1 -1
- data/spec/unit/type.rb +361 -8
- data/spec/unit/type/augeas.rb +30 -37
- data/spec/unit/type/component.rb +63 -0
- data/spec/unit/type/computer.rb +17 -21
- data/spec/unit/type/exec.rb +27 -2
- data/spec/unit/type/file.rb +704 -83
- data/spec/unit/type/file/content.rb +253 -15
- data/spec/unit/type/file/ensure.rb +65 -2
- data/spec/unit/type/file/group.rb +5 -0
- data/spec/unit/type/file/owner.rb +5 -0
- data/spec/unit/type/file/selinux.rb +12 -16
- data/spec/unit/type/file/source.rb +264 -0
- data/spec/unit/type/filebucket.rb +74 -0
- data/spec/unit/type/group.rb +1 -5
- data/spec/unit/type/macauthorization.rb +59 -26
- data/spec/unit/type/mcx.rb +8 -16
- data/spec/unit/type/mount.rb +8 -16
- data/spec/unit/type/noop_metaparam.rb +0 -2
- data/spec/unit/type/package.rb +13 -23
- data/spec/unit/type/resources.rb +4 -7
- data/spec/unit/type/schedule.rb +1 -7
- data/spec/unit/type/selboolean.rb +4 -6
- data/spec/unit/type/service.rb +23 -33
- data/spec/unit/type/ssh_authorized_key.rb +25 -14
- data/spec/unit/type/tidy.rb +329 -21
- data/spec/unit/type/user.rb +18 -10
- data/spec/unit/type/zfs.rb +6 -6
- data/spec/unit/util/autoload.rb +94 -3
- data/spec/unit/util/autoload/file_cache.rb +183 -0
- data/spec/unit/util/backups.rb +159 -0
- data/spec/unit/util/cache_accumulator.rb +69 -0
- data/spec/unit/util/cacher.rb +185 -0
- data/spec/unit/util/checksums.rb +9 -1
- data/spec/unit/util/feature.rb +72 -0
- data/spec/unit/util/filetype.rb +1 -11
- data/spec/unit/util/json.rb +21 -0
- data/spec/unit/util/log.rb +45 -0
- data/spec/unit/util/package.rb +2 -2
- data/spec/unit/util/queue.rb +88 -0
- data/spec/unit/util/queue/stomp.rb +140 -0
- data/spec/unit/util/reference_serializer.rb +52 -0
- data/spec/unit/util/selinux.rb +5 -3
- data/spec/unit/util/settings.rb +413 -264
- data/spec/unit/util/settings/file_setting.rb +223 -0
- data/spec/unit/util/storage.rb +11 -11
- data/spec/unit/util/warnings.rb +21 -17
- data/test/Rakefile +6 -5
- data/test/certmgr/ca.rb +5 -5
- data/test/certmgr/certmgr.rb +4 -4
- data/test/data/providers/cron/crontab.allthree +2 -2
- data/test/data/providers/cron/crontab.envNcomment +1 -1
- data/test/data/providers/cron/crontab.envNname +1 -1
- data/test/data/providers/cron/crontab.multirecords +1 -1
- data/test/data/providers/cron/crontab_collections.yaml +14 -14
- data/test/data/providers/cron/crontab_multiple_with_env.yaml +6 -6
- data/test/data/providers/cron/crontab_sample_records.yaml +102 -102
- data/test/data/providers/mailalias/aliases/test1 +28 -0
- data/test/data/providers/package/testpackages.yaml +6 -6
- data/test/data/reports/1.yaml +17 -17
- data/test/data/reports/tagmail_passers.conf +2 -2
- data/test/data/snippets/append.pp +5 -5
- data/test/data/snippets/casestatement.pp +9 -2
- data/test/data/snippets/classincludes.pp +1 -1
- data/test/data/snippets/collection_override.pp +8 -0
- data/test/data/snippets/fqparents.pp +2 -2
- data/test/data/snippets/ifexpression.pp +12 -0
- data/test/data/snippets/multilinecomments.pp +5 -1
- data/test/data/snippets/selectorvalues.pp +7 -0
- data/test/data/types/hosts/1 +1 -1
- data/test/data/types/hosts/2 +3 -3
- data/test/data/types/hosts/solaris +2 -2
- data/test/data/types/mount/freebsd.fstab +7 -7
- data/test/data/types/mount/solaris.fstab +10 -10
- data/test/data/types/port/1 +472 -472
- data/test/data/types/port/darwin +4347 -4347
- data/test/language/ast.rb +3 -2
- data/test/language/ast/casestatement.rb +12 -12
- data/test/language/ast/resource.rb +4 -4
- data/test/language/ast/resource_reference.rb +5 -5
- data/test/language/ast/selector.rb +11 -11
- data/test/language/ast/variable.rb +4 -4
- data/test/language/functions.rb +16 -16
- data/test/language/parser.rb +89 -111
- data/test/language/resource.rb +3 -88
- data/test/language/scope.rb +14 -55
- data/test/language/snippets.rb +31 -31
- data/test/lib/puppettest.rb +12 -12
- data/test/lib/puppettest/certificates.rb +2 -2
- data/test/lib/puppettest/exetest.rb +0 -1
- data/test/lib/puppettest/fakes.rb +1 -1
- data/test/lib/puppettest/parsertesting.rb +9 -4
- data/test/lib/puppettest/railstesting.rb +3 -3
- data/test/lib/puppettest/servertest.rb +1 -1
- data/test/lib/puppettest/support/assertions.rb +2 -2
- data/test/lib/puppettest/support/collection.rb +1 -1
- data/test/lib/puppettest/support/resources.rb +7 -7
- data/test/lib/puppettest/support/utils.rb +10 -16
- data/test/lib/puppettest/testcase.rb +2 -1
- data/test/network/authconfig.rb +1 -1
- data/test/network/authorization.rb +1 -1
- data/test/network/authstore.rb +57 -14
- data/test/network/client/ca.rb +1 -0
- data/test/network/client/resource.rb +12 -50
- data/test/network/client_request.rb +1 -1
- data/test/network/handler/bucket.rb +2 -2
- data/test/network/handler/fileserver.rb +17 -21
- data/test/network/handler/master.rb +5 -5
- data/test/network/handler/report.rb +3 -3
- data/test/network/handler/resource.rb +29 -75
- data/test/network/handler/runner.rb +8 -58
- data/test/network/rights.rb +1 -1
- data/test/network/server/mongrel_test.rb +15 -1
- data/test/network/server/webrick.rb +0 -36
- data/test/network/xmlrpc/webrick_servlet.rb +5 -5
- data/test/other/dsl.rb +3 -3
- data/test/other/events.rb +15 -15
- data/test/other/puppet.rb +2 -32
- data/test/other/relationships.rb +21 -148
- data/test/other/report.rb +20 -23
- data/test/other/transactions.rb +110 -298
- data/test/puppet/defaults.rb +1 -1
- data/test/puppet/tc_suidmanager.rb +1 -1
- data/test/rails/railsparameter.rb +4 -4
- data/test/ral/manager/attributes.rb +12 -68
- data/test/ral/manager/instances.rb +3 -19
- data/test/ral/manager/manager.rb +7 -7
- data/test/ral/manager/provider.rb +7 -7
- data/test/ral/manager/type.rb +54 -349
- data/test/ral/providers/cron/crontab.rb +14 -14
- data/test/ral/providers/group.rb +5 -6
- data/test/ral/providers/host/parsed.rb +3 -3
- data/test/ral/providers/mailalias/aliases.rb +4 -4
- data/test/ral/providers/package.rb +3 -3
- data/test/ral/providers/package/aptitude.rb +55 -55
- data/test/ral/providers/package/aptrpm.rb +7 -7
- data/test/ral/providers/parsedfile.rb +10 -14
- data/test/ral/providers/port/parsed.rb +6 -6
- data/test/ral/providers/provider.rb +10 -10
- data/test/ral/providers/service/base.rb +32 -32
- data/test/ral/providers/sshkey/parsed.rb +14 -14
- data/test/ral/providers/user.rb +16 -17
- data/test/ral/providers/user/useradd.rb +19 -22
- data/test/ral/type/cron.rb +21 -28
- data/test/ral/type/exec.rb +57 -60
- data/test/ral/type/file.rb +88 -862
- data/test/ral/type/file/target.rb +21 -70
- data/test/ral/type/fileignoresource.rb +37 -44
- data/test/ral/type/filesources.rb +43 -473
- data/test/ral/type/group.rb +6 -7
- data/test/ral/type/host.rb +14 -30
- data/test/ral/type/mailalias.rb +3 -3
- data/test/ral/type/port.rb +5 -5
- data/test/ral/type/resources.rb +37 -37
- data/test/ral/type/service.rb +3 -3
- data/test/ral/type/sshkey.rb +34 -39
- data/test/ral/type/user.rb +15 -14
- data/test/ral/type/yumrepo.rb +18 -17
- data/test/ral/type/zone.rb +4 -6
- data/test/test +9 -9
- data/test/util/fileparsing.rb +10 -10
- data/test/util/inifile.rb +6 -6
- data/test/util/instance_loader.rb +1 -1
- data/test/util/log.rb +2 -2
- data/test/util/metrics.rb +1 -6
- data/test/util/package.rb +1 -1
- data/test/util/pidlock.rb +116 -116
- data/test/util/settings.rb +40 -429
- data/test/util/storage.rb +5 -5
- data/test/util/subclass_loader.rb +0 -7
- data/test/util/utiltest.rb +10 -29
- metadata +1369 -941
- data/bin/puppetca +0 -363
- data/bin/puppetd +0 -439
- data/bin/puppetmasterd +0 -289
- data/bin/puppetrun +0 -369
- data/conf/redhat/lsb-config.patch +0 -51
- data/conf/redhat/no-chuser-0.15.1.patch +0 -38
- data/conf/redhat/no-lockdir.patch +0 -13
- data/examples/mac_netinfo.pp +0 -5
- data/ext/passenger/README +0 -63
- data/ext/passenger/apache2.conf +0 -29
- data/ext/passenger/config.ru +0 -40
- data/lib/puppet/config_stores/rest.rb +0 -60
- data/lib/puppet/executables/client/certhandler.rb +0 -82
- data/lib/puppet/indirector/file_content/modules.rb +0 -11
- data/lib/puppet/indirector/file_metadata/modules.rb +0 -17
- data/lib/puppet/indirector/module_files.rb +0 -82
- data/lib/puppet/indirector/ssl_rsa.rb +0 -5
- data/lib/puppet/indirector/ssl_rsa/file.rb +0 -33
- data/lib/puppet/network/client/master.rb +0 -524
- data/lib/puppet/network/http_server/rack.rb +0 -148
- data/lib/puppet/pgraph.rb +0 -121
- data/lib/puppet/provider/group/netinfo.rb +0 -15
- data/lib/puppet/provider/host/netinfo.rb +0 -19
- data/lib/puppet/provider/mount/netinfo.rb +0 -37
- data/lib/puppet/provider/nameservice/netinfo.rb +0 -224
- data/lib/puppet/provider/user/netinfo.rb +0 -111
- data/lib/puppet/util/fact_store.rb +0 -59
- data/lib/puppet/util/uri_helper.rb +0 -22
- data/spec/integration/file_serving/configuration.rb +0 -43
- data/spec/integration/indirector/module_files.rb +0 -57
- data/spec/unit/executables/client/certhandler.rb +0 -135
- data/spec/unit/indirector/file_content/modules.rb +0 -18
- data/spec/unit/indirector/file_metadata/modules.rb +0 -42
- data/spec/unit/indirector/module_files.rb +0 -259
- data/spec/unit/indirector/ssl_rsa/file.rb +0 -121
- data/spec/unit/network/client/master.rb +0 -442
- data/spec/unit/node/catalog.rb +0 -865
- data/spec/unit/other/pgraph.rb +0 -210
- data/spec/unit/resource_reference.rb +0 -73
- data/spec/unit/util/uri_helper.rb +0 -41
- data/test/data/snippets/ifexpression.rb +0 -6
- data/test/executables/filebucket.rb +0 -51
- data/test/executables/puppetbin.rb +0 -104
- data/test/executables/puppetca.rb +0 -115
- data/test/executables/puppetd.rb +0 -55
- data/test/executables/puppetmasterd.rb +0 -147
- data/test/network/client/client.rb +0 -195
- data/test/network/client/master.rb +0 -490
- data/test/network/daemon.rb +0 -70
- data/test/network/handler/handler.rb +0 -63
- data/test/other/overrides.rb +0 -107
- data/test/puppet/conffiles.rb +0 -107
- data/test/rails/ast.rb +0 -73
- data/test/rails/configuration.rb +0 -71
- data/test/rails/host.rb +0 -154
- data/test/rails/railsresource.rb +0 -251
- data/test/ral/providers/host/netinfo.rb +0 -56
- data/test/ral/providers/mount/netinfo.rb +0 -79
- data/test/ral/type/basic.rb +0 -85
- data/test/ral/type/filebucket.rb +0 -157
- data/test/ral/type/parameter.rb +0 -174
- data/test/ral/type/property.rb +0 -388
- data/test/ral/type/tidy.rb +0 -291
- data/test/util/autoload.rb +0 -145
- data/test/util/features.rb +0 -95
@@ -5,7 +5,7 @@ require 'puppet/transaction/event'
|
|
5
5
|
# including calling 'sync' on the properties and producing events.
|
6
6
|
class Puppet::Transaction::Change
|
7
7
|
attr_accessor :is, :should, :path, :property, :changed, :proxy
|
8
|
-
|
8
|
+
|
9
9
|
# Switch the goals of the property, thus running the change in reverse.
|
10
10
|
def backward
|
11
11
|
@is, @should = @should, @is
|
@@ -14,7 +14,7 @@ class Puppet::Transaction::Change
|
|
14
14
|
@property.info "Reversing %s" % self
|
15
15
|
return self.go
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def changed?
|
19
19
|
self.changed
|
20
20
|
end
|
@@ -28,7 +28,7 @@ class Puppet::Transaction::Change
|
|
28
28
|
|
29
29
|
name = @property.event(should)
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
Puppet::Transaction::Event.new(name, self.resource)
|
33
33
|
end
|
34
34
|
|
@@ -61,7 +61,7 @@ class Puppet::Transaction::Change
|
|
61
61
|
else
|
62
62
|
events = [events]
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
return events.collect { |name|
|
66
66
|
@report = @property.log(@property.change_to_s(@is, @should))
|
67
67
|
event(name)
|
@@ -71,12 +71,12 @@ class Puppet::Transaction::Change
|
|
71
71
|
def forward
|
72
72
|
return self.go
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
# Is our property noop? This is used for generating special events.
|
76
76
|
def noop?
|
77
77
|
return @property.noop
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
# The resource that generated this change. This is used for handling events,
|
81
81
|
# and the proxy resource is used for generated resources, since we can't
|
82
82
|
# send an event to a resource we don't have a direct relationship. If we
|
@@ -11,7 +11,13 @@ class Puppet::Transaction::Report
|
|
11
11
|
indirects :report, :terminus_class => :processor
|
12
12
|
|
13
13
|
attr_accessor :logs, :metrics, :time, :host
|
14
|
-
|
14
|
+
|
15
|
+
# This is necessary since Marshall doesn't know how to
|
16
|
+
# dump hash with default proc (see below @records)
|
17
|
+
def self.default_format
|
18
|
+
:yaml
|
19
|
+
end
|
20
|
+
|
15
21
|
def <<(msg)
|
16
22
|
@logs << msg
|
17
23
|
return self
|
data/lib/puppet/transportable.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'puppet'
|
2
|
-
require 'puppet/
|
2
|
+
require 'puppet/resource/reference'
|
3
3
|
require 'yaml'
|
4
4
|
|
5
5
|
module Puppet
|
@@ -36,7 +36,7 @@ module Puppet
|
|
36
36
|
|
37
37
|
def ref
|
38
38
|
unless defined? @ref
|
39
|
-
@ref = Puppet::
|
39
|
+
@ref = Puppet::Resource::Reference.new(@type, @name)
|
40
40
|
end
|
41
41
|
@ref.to_s
|
42
42
|
end
|
@@ -66,7 +66,7 @@ module Puppet
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def to_manifest
|
69
|
-
"%s { '%s':\n%s\n}" %
|
69
|
+
"%s { '%s':\n%s\n}" %
|
70
70
|
[self.type.to_s, self.name,
|
71
71
|
@params.collect { |p, v|
|
72
72
|
if v.is_a? Array
|
@@ -78,6 +78,14 @@ module Puppet
|
|
78
78
|
]
|
79
79
|
end
|
80
80
|
|
81
|
+
# Create a normalized resource from our TransObject.
|
82
|
+
def to_resource
|
83
|
+
result = Puppet::Resource.new(type, name, @params.dup)
|
84
|
+
result.tag(*tags)
|
85
|
+
|
86
|
+
result
|
87
|
+
end
|
88
|
+
|
81
89
|
def to_yaml_properties
|
82
90
|
instance_variables.reject { |v| %w{@ref}.include?(v) }
|
83
91
|
end
|
@@ -86,12 +94,8 @@ module Puppet
|
|
86
94
|
ref
|
87
95
|
end
|
88
96
|
|
89
|
-
def
|
90
|
-
|
91
|
-
return typeklass.create(self)
|
92
|
-
else
|
93
|
-
return to_component
|
94
|
-
end
|
97
|
+
def to_ral
|
98
|
+
to_resource.to_ral
|
95
99
|
end
|
96
100
|
end
|
97
101
|
|
@@ -181,7 +185,7 @@ module Puppet
|
|
181
185
|
|
182
186
|
# Create a resource graph from our structure.
|
183
187
|
def to_catalog(clear_on_failure = true)
|
184
|
-
catalog = Puppet::
|
188
|
+
catalog = Puppet::Resource::Catalog.new(Facter.value("hostname"))
|
185
189
|
|
186
190
|
# This should really use the 'delve' method, but this
|
187
191
|
# whole class is going away relatively soon, hopefully,
|
@@ -189,13 +193,13 @@ module Puppet
|
|
189
193
|
delver = proc do |obj|
|
190
194
|
obj.catalog = catalog
|
191
195
|
unless container = catalog.resource(obj.to_ref)
|
192
|
-
container = obj.
|
196
|
+
container = obj.to_ral
|
193
197
|
catalog.add_resource container
|
194
198
|
end
|
195
199
|
obj.each do |child|
|
196
200
|
child.catalog = catalog
|
197
201
|
unless resource = catalog.resource(child.to_ref)
|
198
|
-
resource = child.
|
202
|
+
resource = child.to_ral
|
199
203
|
catalog.add_resource resource
|
200
204
|
end
|
201
205
|
|
@@ -205,7 +209,7 @@ module Puppet
|
|
205
209
|
end
|
206
210
|
end
|
207
211
|
end
|
208
|
-
|
212
|
+
|
209
213
|
begin
|
210
214
|
delver.call(self)
|
211
215
|
catalog.finalize
|
@@ -214,18 +218,18 @@ module Puppet
|
|
214
218
|
catalog.clear if (clear_on_failure)
|
215
219
|
raise
|
216
220
|
end
|
217
|
-
|
221
|
+
|
218
222
|
return catalog
|
219
223
|
end
|
220
224
|
|
221
225
|
def to_ref
|
222
226
|
unless defined? @ref
|
223
227
|
if self.type and self.name
|
224
|
-
@ref = Puppet::
|
228
|
+
@ref = Puppet::Resource::Reference.new(self.type, self.name)
|
225
229
|
elsif self.type and ! self.name # This is old-school node types
|
226
|
-
@ref = Puppet::
|
230
|
+
@ref = Puppet::Resource::Reference.new("node", self.type)
|
227
231
|
elsif ! self.type and self.name
|
228
|
-
@ref = Puppet::
|
232
|
+
@ref = Puppet::Resource::Reference.new("component", self.name)
|
229
233
|
else
|
230
234
|
@ref = nil
|
231
235
|
end
|
@@ -233,18 +237,14 @@ module Puppet
|
|
233
237
|
@ref.to_s if @ref
|
234
238
|
end
|
235
239
|
|
236
|
-
def
|
237
|
-
|
240
|
+
def to_ral
|
241
|
+
to_resource.to_ral
|
242
|
+
end
|
238
243
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
Puppet.debug "Defining %s on %s" % [param, to_ref]
|
244
|
-
trans[param] = value
|
245
|
-
}
|
246
|
-
end
|
247
|
-
return Puppet::Type::Component.create(trans)
|
244
|
+
# Create a normalized resource from our TransObject.
|
245
|
+
def to_resource
|
246
|
+
params = defined?(@parameters) ? @parameters.dup : {}
|
247
|
+
Puppet::Resource.new(type, name, params)
|
248
248
|
end
|
249
249
|
|
250
250
|
def param(param,value)
|
data/lib/puppet/type.rb
CHANGED
@@ -9,8 +9,10 @@ require 'puppet/metatype/manager'
|
|
9
9
|
require 'puppet/util/errors'
|
10
10
|
require 'puppet/util/log_paths'
|
11
11
|
require 'puppet/util/logging'
|
12
|
-
require 'puppet/
|
12
|
+
require 'puppet/resource/reference'
|
13
|
+
require 'puppet/util/cacher'
|
13
14
|
require 'puppet/file_collection/lookup'
|
15
|
+
require 'puppet/util/tagging'
|
14
16
|
|
15
17
|
# see the bottom of the file for the rest of the inclusions
|
16
18
|
|
@@ -20,7 +22,9 @@ class Type
|
|
20
22
|
include Puppet::Util::Errors
|
21
23
|
include Puppet::Util::LogPaths
|
22
24
|
include Puppet::Util::Logging
|
25
|
+
include Puppet::Util::Cacher
|
23
26
|
include Puppet::FileCollection::Lookup
|
27
|
+
include Puppet::Util::Tagging
|
24
28
|
|
25
29
|
###############################
|
26
30
|
# Code related to resource type attributes.
|
@@ -35,12 +39,11 @@ class Type
|
|
35
39
|
properties()
|
36
40
|
end
|
37
41
|
|
38
|
-
# All parameters, in the appropriate order. The namevar comes first,
|
39
|
-
# then the properties,
|
40
|
-
# were specified in the files.
|
42
|
+
# All parameters, in the appropriate order. The namevar comes first, then
|
43
|
+
# the provider, then the properties, and finally the params and metaparams
|
44
|
+
# in the order they were specified in the files.
|
41
45
|
def self.allattrs
|
42
|
-
#
|
43
|
-
# Cache this, since it gets called so many times
|
46
|
+
# Cache this, since it gets called multiple times
|
44
47
|
namevar = self.namevar
|
45
48
|
|
46
49
|
order = [namevar]
|
@@ -52,7 +55,7 @@ class Type
|
|
52
55
|
self.metaparams].flatten.reject { |param|
|
53
56
|
# we don't want our namevar in there multiple times
|
54
57
|
param == namevar
|
55
|
-
|
58
|
+
}
|
56
59
|
|
57
60
|
order.flatten!
|
58
61
|
|
@@ -80,9 +83,9 @@ class Type
|
|
80
83
|
# of times (as in, hundreds of thousands in a given run).
|
81
84
|
unless @attrclasses.include?(name)
|
82
85
|
@attrclasses[name] = case self.attrtype(name)
|
83
|
-
when :property
|
84
|
-
when :meta
|
85
|
-
when :param
|
86
|
+
when :property; @validproperties[name]
|
87
|
+
when :meta; @@metaparamhash[name]
|
88
|
+
when :param; @paramhash[name]
|
86
89
|
end
|
87
90
|
end
|
88
91
|
@attrclasses[name]
|
@@ -94,13 +97,9 @@ class Type
|
|
94
97
|
@attrtypes ||= {}
|
95
98
|
unless @attrtypes.include?(attr)
|
96
99
|
@attrtypes[attr] = case
|
97
|
-
when @validproperties.include?(attr)
|
98
|
-
when @paramhash.include?(attr)
|
99
|
-
when @@metaparamhash.include?(attr)
|
100
|
-
else
|
101
|
-
raise Puppet::DevError,
|
102
|
-
"Invalid attribute '%s' for class '%s'" %
|
103
|
-
[attr, self.name]
|
100
|
+
when @validproperties.include?(attr); :property
|
101
|
+
when @paramhash.include?(attr); :param
|
102
|
+
when @@metaparamhash.include?(attr); :meta
|
104
103
|
end
|
105
104
|
end
|
106
105
|
|
@@ -124,30 +123,6 @@ class Type
|
|
124
123
|
end
|
125
124
|
end
|
126
125
|
|
127
|
-
# A similar function but one that yields the class and type.
|
128
|
-
# This is mainly so that setdefaults doesn't call quite so many functions.
|
129
|
-
def self.eachattr(*ary)
|
130
|
-
if ary.empty?
|
131
|
-
ary = nil
|
132
|
-
end
|
133
|
-
|
134
|
-
# We have to do this in a specific order, so that defaults are
|
135
|
-
# created in that order (e.g., providers should be set up before
|
136
|
-
# anything else).
|
137
|
-
allattrs.each do |name|
|
138
|
-
next unless ary.nil? or ary.include?(name)
|
139
|
-
if obj = @properties.find { |p| p.name == name }
|
140
|
-
yield obj, :property
|
141
|
-
elsif obj = @parameters.find { |p| p.name == name }
|
142
|
-
yield obj, :param
|
143
|
-
elsif obj = @@metaparams.find { |p| p.name == name }
|
144
|
-
yield obj, :meta
|
145
|
-
else
|
146
|
-
raise Puppet::DevError, "Could not find parameter %s" % name
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
126
|
def self.eachmetaparam
|
152
127
|
@@metaparams.each { |p| yield p.name }
|
153
128
|
end
|
@@ -174,7 +149,7 @@ class Type
|
|
174
149
|
|
175
150
|
return ens
|
176
151
|
end
|
177
|
-
|
152
|
+
|
178
153
|
# Deal with any options passed into parameters.
|
179
154
|
def self.handle_param_options(name, options)
|
180
155
|
# If it's a boolean parameter, create a method to test the value easily
|
@@ -186,8 +161,6 @@ class Type
|
|
186
161
|
end
|
187
162
|
end
|
188
163
|
end
|
189
|
-
|
190
|
-
# If this param handles relationships, store that information
|
191
164
|
end
|
192
165
|
|
193
166
|
# Is the parameter in question a meta-parameter?
|
@@ -228,7 +201,7 @@ class Type
|
|
228
201
|
if options[:required_features]
|
229
202
|
param.required_features = options[:required_features]
|
230
203
|
end
|
231
|
-
|
204
|
+
|
232
205
|
handle_param_options(name, options)
|
233
206
|
|
234
207
|
param.metaparam = true
|
@@ -266,7 +239,7 @@ class Type
|
|
266
239
|
:array => @parameters,
|
267
240
|
:hash => @paramhash
|
268
241
|
)
|
269
|
-
|
242
|
+
|
270
243
|
handle_param_options(name, options)
|
271
244
|
|
272
245
|
# Grr.
|
@@ -276,15 +249,6 @@ class Type
|
|
276
249
|
|
277
250
|
param.isnamevar if options[:namevar]
|
278
251
|
|
279
|
-
# These might be enabled later.
|
280
|
-
# define_method(name) do
|
281
|
-
# @parameters[name].value
|
282
|
-
# end
|
283
|
-
#
|
284
|
-
# define_method(name.to_s + "=") do |value|
|
285
|
-
# newparam(param, value)
|
286
|
-
# end
|
287
|
-
|
288
252
|
if param.isnamevar?
|
289
253
|
@namevar = param.name
|
290
254
|
end
|
@@ -314,7 +278,7 @@ class Type
|
|
314
278
|
"Options must be a hash, not %s" % options.inspect
|
315
279
|
end
|
316
280
|
|
317
|
-
if @validproperties.include?(name)
|
281
|
+
if @validproperties.include?(name)
|
318
282
|
raise Puppet::DevError, "Class %s already has a property named %s" %
|
319
283
|
[self.name, name]
|
320
284
|
end
|
@@ -349,14 +313,6 @@ class Type
|
|
349
313
|
@properties << prop
|
350
314
|
end
|
351
315
|
|
352
|
-
# define_method(name) do
|
353
|
-
# @parameters[name].should
|
354
|
-
# end
|
355
|
-
#
|
356
|
-
# define_method(name.to_s + "=") do |value|
|
357
|
-
# newproperty(name, :should => value)
|
358
|
-
# end
|
359
|
-
|
360
316
|
return prop
|
361
317
|
end
|
362
318
|
|
@@ -425,38 +381,6 @@ class Type
|
|
425
381
|
end
|
426
382
|
end
|
427
383
|
|
428
|
-
# fix any namevar => param translations
|
429
|
-
def argclean(oldhash)
|
430
|
-
# This duplication is here because it might be a transobject.
|
431
|
-
hash = oldhash.dup.to_hash
|
432
|
-
|
433
|
-
if hash.include?(:resource)
|
434
|
-
hash.delete(:resource)
|
435
|
-
end
|
436
|
-
namevar = self.class.namevar
|
437
|
-
|
438
|
-
# Do a simple translation for those cases where they've passed :name
|
439
|
-
# but that's not our namevar
|
440
|
-
if hash.include? :name and namevar != :name
|
441
|
-
if hash.include? namevar
|
442
|
-
raise ArgumentError, "Cannot provide both name and %s" % namevar
|
443
|
-
end
|
444
|
-
hash[namevar] = hash[:name]
|
445
|
-
hash.delete(:name)
|
446
|
-
end
|
447
|
-
|
448
|
-
# Make sure we have a name, one way or another
|
449
|
-
unless hash.include? namevar
|
450
|
-
if defined? @title and @title
|
451
|
-
hash[namevar] = @title
|
452
|
-
else
|
453
|
-
raise Puppet::Error, "Was not passed a namevar or title"
|
454
|
-
end
|
455
|
-
end
|
456
|
-
|
457
|
-
return hash
|
458
|
-
end
|
459
|
-
|
460
384
|
# Return either the attribute alias or the attribute.
|
461
385
|
def attr_alias(name)
|
462
386
|
name = symbolize(name)
|
@@ -466,7 +390,7 @@ class Type
|
|
466
390
|
return name
|
467
391
|
end
|
468
392
|
end
|
469
|
-
|
393
|
+
|
470
394
|
# Are we deleting this resource?
|
471
395
|
def deleting?
|
472
396
|
obj = @parameters[:ensure] and obj.should == :absent
|
@@ -481,7 +405,7 @@ class Type
|
|
481
405
|
end
|
482
406
|
return false
|
483
407
|
end
|
484
|
-
|
408
|
+
|
485
409
|
# abstract accessing parameters and properties, and normalize
|
486
410
|
# access to always be symbols, not strings
|
487
411
|
# This returns a value, not an object. It returns the 'is'
|
@@ -491,7 +415,7 @@ class Type
|
|
491
415
|
name = attr_alias(name)
|
492
416
|
|
493
417
|
unless self.class.validattr?(name)
|
494
|
-
|
418
|
+
fail("Invalid parameter %s(%s)" % [name, name.inspect])
|
495
419
|
end
|
496
420
|
|
497
421
|
if name == :name
|
@@ -514,7 +438,7 @@ class Type
|
|
514
438
|
name = attr_alias(name)
|
515
439
|
|
516
440
|
unless self.class.validattr?(name)
|
517
|
-
|
441
|
+
fail("Invalid parameter %s" % [name])
|
518
442
|
end
|
519
443
|
|
520
444
|
if name == :name
|
@@ -553,6 +477,12 @@ class Type
|
|
553
477
|
}
|
554
478
|
end
|
555
479
|
|
480
|
+
# Let the catalog determine whether a given cached value is
|
481
|
+
# still valid or has expired.
|
482
|
+
def expirer
|
483
|
+
catalog
|
484
|
+
end
|
485
|
+
|
556
486
|
# retrieve the 'should' value for a specified property
|
557
487
|
def should(name)
|
558
488
|
name = attr_alias(name)
|
@@ -603,10 +533,7 @@ class Type
|
|
603
533
|
|
604
534
|
# return the value of a parameter
|
605
535
|
def parameter(name)
|
606
|
-
|
607
|
-
name = name.intern
|
608
|
-
end
|
609
|
-
return @parameters[name].value
|
536
|
+
@parameters[name.to_sym]
|
610
537
|
end
|
611
538
|
|
612
539
|
# Is the named property defined?
|
@@ -617,8 +544,9 @@ class Type
|
|
617
544
|
return @parameters.include?(name)
|
618
545
|
end
|
619
546
|
|
620
|
-
#
|
621
|
-
#
|
547
|
+
# Return an actual property instance by name; to return the value, use 'resource[param]'
|
548
|
+
# LAK:NOTE(20081028) Since the 'parameter' method is now a superset of this method,
|
549
|
+
# this one should probably go away at some point.
|
622
550
|
def property(name)
|
623
551
|
if obj = @parameters[symbolize(name)] and obj.is_a?(Puppet::Property)
|
624
552
|
return obj
|
@@ -627,42 +555,27 @@ class Type
|
|
627
555
|
end
|
628
556
|
end
|
629
557
|
|
630
|
-
# def set(name, value)
|
631
|
-
# send(name.to_s + "=", value)
|
632
|
-
# end
|
633
|
-
#
|
634
|
-
# def get(name)
|
635
|
-
# send(name)
|
636
|
-
# end
|
637
|
-
|
638
558
|
# For any parameters or properties that have defaults and have not yet been
|
639
559
|
# set, set them now. This method can be handed a list of attributes,
|
640
560
|
# and if so it will only set defaults for those attributes.
|
641
|
-
def
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
value = obj.default and ! value.nil?
|
654
|
-
if ! value.nil?
|
655
|
-
obj.value = value
|
656
|
-
else
|
657
|
-
@parameters.delete(obj.name)
|
658
|
-
end
|
659
|
-
}
|
561
|
+
def set_default(attr)
|
562
|
+
return unless klass = self.class.attrclass(attr)
|
563
|
+
return unless klass.method_defined?(:default)
|
564
|
+
return if @parameters.include?(klass.name)
|
565
|
+
|
566
|
+
return unless parameter = newattr(klass.name)
|
567
|
+
|
568
|
+
if value = parameter.default and ! value.nil?
|
569
|
+
parameter.value = value
|
570
|
+
else
|
571
|
+
@parameters.delete(parameter.name)
|
572
|
+
end
|
660
573
|
end
|
661
574
|
|
662
575
|
# Convert our object to a hash. This just includes properties.
|
663
576
|
def to_hash
|
664
577
|
rethash = {}
|
665
|
-
|
578
|
+
|
666
579
|
@parameters.each do |name, obj|
|
667
580
|
rethash[name] = obj.value
|
668
581
|
end
|
@@ -681,6 +594,11 @@ class Type
|
|
681
594
|
end
|
682
595
|
end
|
683
596
|
|
597
|
+
def version
|
598
|
+
return 0 unless catalog
|
599
|
+
catalog.version
|
600
|
+
end
|
601
|
+
|
684
602
|
# Meta-parameter methods: These methods deal with the results
|
685
603
|
# of specifying metaparameters
|
686
604
|
|
@@ -706,10 +624,6 @@ class Type
|
|
706
624
|
|
707
625
|
public
|
708
626
|
|
709
|
-
###############################
|
710
|
-
# Code related to the closure-like behaviour of the resource classes.
|
711
|
-
attr_writer :implicit
|
712
|
-
|
713
627
|
# Is this type's name isomorphic with the object? That is, if the
|
714
628
|
# name conflicts, does it necessarily mean that the objects conflict?
|
715
629
|
# Defaults to true.
|
@@ -721,14 +635,6 @@ class Type
|
|
721
635
|
end
|
722
636
|
end
|
723
637
|
|
724
|
-
def implicit?
|
725
|
-
if defined? @implicit and @implicit
|
726
|
-
return true
|
727
|
-
else
|
728
|
-
return false
|
729
|
-
end
|
730
|
-
end
|
731
|
-
|
732
638
|
def isomorphic?
|
733
639
|
self.class.isomorphic?
|
734
640
|
end
|
@@ -758,6 +664,9 @@ class Type
|
|
758
664
|
|
759
665
|
###############################
|
760
666
|
# Code related to the container behaviour.
|
667
|
+
|
668
|
+
# this is a retarded hack method to get around the difference between
|
669
|
+
# component children and file children
|
761
670
|
def self.depthfirst?
|
762
671
|
if defined? @depthfirst
|
763
672
|
return @depthfirst
|
@@ -765,24 +674,11 @@ class Type
|
|
765
674
|
return false
|
766
675
|
end
|
767
676
|
end
|
768
|
-
|
677
|
+
|
769
678
|
def depthfirst?
|
770
679
|
self.class.depthfirst?
|
771
680
|
end
|
772
681
|
|
773
|
-
# Add a hook for testing for recursion.
|
774
|
-
def parentof?(child)
|
775
|
-
if (self == child)
|
776
|
-
debug "parent is equal to child"
|
777
|
-
return true
|
778
|
-
elsif defined? @parent and @parent.parentof?(child)
|
779
|
-
debug "My parent is parent of child"
|
780
|
-
return true
|
781
|
-
else
|
782
|
-
return false
|
783
|
-
end
|
784
|
-
end
|
785
|
-
|
786
682
|
# Remove an object. The argument determines whether the object's
|
787
683
|
# subscriptions get eliminated, too.
|
788
684
|
def remove(rmdeps = true)
|
@@ -792,7 +688,6 @@ class Type
|
|
792
688
|
obj.remove
|
793
689
|
end
|
794
690
|
@parameters.clear
|
795
|
-
self.class.delete(self)
|
796
691
|
|
797
692
|
@parent = nil
|
798
693
|
|
@@ -816,13 +711,6 @@ class Type
|
|
816
711
|
raise Puppet::Error, "Provider %s is not functional on this platform" % provider.class.name
|
817
712
|
end
|
818
713
|
end
|
819
|
-
#Puppet.err "Evaluating %s" % self.path.join(":")
|
820
|
-
unless defined? @evalcount
|
821
|
-
self.err "No evalcount defined on '%s' of type '%s'" %
|
822
|
-
[self.title,self.class]
|
823
|
-
@evalcount = 0
|
824
|
-
end
|
825
|
-
@evalcount += 1
|
826
714
|
|
827
715
|
# this only operates on properties, not properties + children
|
828
716
|
# it's important that we call retrieve() on the type instance,
|
@@ -863,14 +751,14 @@ class Type
|
|
863
751
|
# it's really only used for testing
|
864
752
|
def insync?(is)
|
865
753
|
insync = true
|
866
|
-
|
754
|
+
|
867
755
|
if property = @parameters[:ensure]
|
868
756
|
unless is.include? property
|
869
757
|
raise Puppet::DevError,
|
870
758
|
"The is value is not in the is array for '%s'" %
|
871
759
|
[property.name]
|
872
760
|
end
|
873
|
-
ensureis = is[property]
|
761
|
+
ensureis = is[property]
|
874
762
|
if property.insync?(ensureis) and property.should == :absent
|
875
763
|
return true
|
876
764
|
end
|
@@ -896,12 +784,12 @@ class Type
|
|
896
784
|
#self.debug("%s sync status is %s" % [self,insync])
|
897
785
|
return insync
|
898
786
|
end
|
899
|
-
|
787
|
+
|
900
788
|
# retrieve the current value of all contained properties
|
901
789
|
def retrieve
|
902
790
|
return currentpropvalues
|
903
791
|
end
|
904
|
-
|
792
|
+
|
905
793
|
# Get a hash of the current properties. Returns a hash with
|
906
794
|
# the actual property instance as the key and the current value
|
907
795
|
# as the, um, value.
|
@@ -938,7 +826,7 @@ class Type
|
|
938
826
|
def noop
|
939
827
|
noop?
|
940
828
|
end
|
941
|
-
|
829
|
+
|
942
830
|
# Retrieve the changes associated with all of the properties.
|
943
831
|
def propertychanges(currentvalues)
|
944
832
|
# If we are changing the existence of the object, then none of
|
@@ -979,18 +867,15 @@ class Type
|
|
979
867
|
# Code related to managing resource instances.
|
980
868
|
require 'puppet/transportable'
|
981
869
|
|
982
|
-
# Make 'new' private, so people have to use create instead.
|
983
|
-
class << self
|
984
|
-
private :new
|
985
|
-
end
|
986
|
-
|
987
870
|
# retrieve a named instance of the current type
|
988
871
|
def self.[](name)
|
872
|
+
raise "Global resource access is deprecated"
|
989
873
|
@objects[name] || @aliases[name]
|
990
874
|
end
|
991
875
|
|
992
876
|
# add an instance by name to the class list of instances
|
993
877
|
def self.[]=(name,object)
|
878
|
+
raise "Global resource storage is deprecated"
|
994
879
|
newobj = nil
|
995
880
|
if object.is_a?(Puppet::Type)
|
996
881
|
newobj = object
|
@@ -1022,6 +907,7 @@ class Type
|
|
1022
907
|
# Create an alias. We keep these in a separate hash so that we don't encounter
|
1023
908
|
# the objects multiple times when iterating over them.
|
1024
909
|
def self.alias(name, obj)
|
910
|
+
raise "Global resource aliasing is deprecated"
|
1025
911
|
if @objects.include?(name)
|
1026
912
|
unless @objects[name] == obj
|
1027
913
|
raise Puppet::Error.new(
|
@@ -1045,6 +931,7 @@ class Type
|
|
1045
931
|
|
1046
932
|
# remove all of the instances of a single type
|
1047
933
|
def self.clear
|
934
|
+
raise "Global resource removal is deprecated"
|
1048
935
|
if defined? @objects
|
1049
936
|
@objects.each do |name, obj|
|
1050
937
|
obj.remove(true)
|
@@ -1059,96 +946,14 @@ class Type
|
|
1059
946
|
# Force users to call this, so that we can merge objects if
|
1060
947
|
# necessary.
|
1061
948
|
def self.create(args)
|
1062
|
-
#
|
1063
|
-
|
1064
|
-
|
1065
|
-
hash = args.dup
|
1066
|
-
symbolizehash!(hash)
|
1067
|
-
|
1068
|
-
# If we're the base class, then pass the info on appropriately
|
1069
|
-
if self == Puppet::Type
|
1070
|
-
type = nil
|
1071
|
-
if hash.is_a? Puppet::TransObject
|
1072
|
-
type = hash.type
|
1073
|
-
else
|
1074
|
-
# If we're using the type to determine object type, then delete it
|
1075
|
-
if type = hash[:type]
|
1076
|
-
hash.delete(:type)
|
1077
|
-
end
|
1078
|
-
end
|
1079
|
-
|
1080
|
-
# If they've specified a type and called on the base, then
|
1081
|
-
# delegate to the subclass.
|
1082
|
-
if type
|
1083
|
-
if typeklass = self.type(type)
|
1084
|
-
return typeklass.create(hash)
|
1085
|
-
else
|
1086
|
-
raise Puppet::Error, "Unknown type %s" % type
|
1087
|
-
end
|
1088
|
-
else
|
1089
|
-
raise Puppet::Error, "No type found for %s" % hash.inspect
|
1090
|
-
end
|
1091
|
-
end
|
1092
|
-
|
1093
|
-
# Handle this new object being implicit
|
1094
|
-
implicit = hash[:implicit] || false
|
1095
|
-
if hash.include?(:implicit)
|
1096
|
-
hash.delete(:implicit)
|
1097
|
-
end
|
1098
|
-
|
1099
|
-
name = nil
|
1100
|
-
unless hash.is_a? Puppet::TransObject
|
1101
|
-
hash = self.hash2trans(hash)
|
1102
|
-
end
|
1103
|
-
|
1104
|
-
# XXX This will have to change when transobjects change to using titles
|
1105
|
-
title = hash.name
|
1106
|
-
|
1107
|
-
# if the object already exists
|
1108
|
-
if self.isomorphic? and retobj = self[title]
|
1109
|
-
# if only one of our objects is implicit, then it's easy to see
|
1110
|
-
# who wins -- the non-implicit one.
|
1111
|
-
if retobj.implicit? and ! implicit
|
1112
|
-
Puppet.notice "Removing implicit %s" % retobj.title
|
1113
|
-
# Remove all of the objects, but do not remove their subscriptions.
|
1114
|
-
retobj.remove(false)
|
1115
|
-
|
1116
|
-
# now pass through and create the new object
|
1117
|
-
elsif implicit
|
1118
|
-
Puppet.debug "Ignoring implicit %s[%s]" % [self.name, title]
|
1119
|
-
return nil
|
1120
|
-
else
|
1121
|
-
raise Puppet::Error, "%s is already being managed" % retobj.ref
|
1122
|
-
end
|
1123
|
-
end
|
1124
|
-
|
1125
|
-
# create it anew
|
1126
|
-
# if there's a failure, destroy the object if it got that far, but raise
|
1127
|
-
# the error.
|
1128
|
-
begin
|
1129
|
-
obj = new(hash)
|
1130
|
-
rescue => detail
|
1131
|
-
Puppet.err "Could not create %s: %s" % [title, detail.to_s]
|
1132
|
-
if obj
|
1133
|
-
obj.remove(true)
|
1134
|
-
elsif obj = self[title]
|
1135
|
-
obj.remove(true)
|
1136
|
-
end
|
1137
|
-
raise
|
1138
|
-
end
|
1139
|
-
|
1140
|
-
if implicit
|
1141
|
-
obj.implicit = true
|
1142
|
-
end
|
1143
|
-
|
1144
|
-
# Store the object by title
|
1145
|
-
self[obj.title] = obj
|
1146
|
-
|
1147
|
-
return obj
|
949
|
+
# LAK:DEP Deprecation notice added 12/17/2008
|
950
|
+
Puppet.warning "Puppet::Type.create is deprecated; use Puppet::Type.new"
|
951
|
+
new(args)
|
1148
952
|
end
|
1149
953
|
|
1150
954
|
# remove a specified object
|
1151
955
|
def self.delete(resource)
|
956
|
+
raise "Global resource removal is deprecated"
|
1152
957
|
return unless defined? @objects
|
1153
958
|
if @objects.include?(resource.title)
|
1154
959
|
@objects.delete(resource.title)
|
@@ -1169,6 +974,7 @@ class Type
|
|
1169
974
|
|
1170
975
|
# iterate across each of the type's instances
|
1171
976
|
def self.each
|
977
|
+
raise "Global resource iteration is deprecated"
|
1172
978
|
return unless defined? @objects
|
1173
979
|
@objects.each { |name,instance|
|
1174
980
|
yield instance
|
@@ -1177,58 +983,13 @@ class Type
|
|
1177
983
|
|
1178
984
|
# does the type have an object with the given name?
|
1179
985
|
def self.has_key?(name)
|
986
|
+
raise "Global resource access is deprecated"
|
1180
987
|
return @objects.has_key?(name)
|
1181
988
|
end
|
1182
989
|
|
1183
|
-
# Convert a hash to a TransObject.
|
1184
|
-
def self.hash2trans(hash)
|
1185
|
-
title = nil
|
1186
|
-
if hash.include? :title
|
1187
|
-
title = hash[:title]
|
1188
|
-
hash.delete(:title)
|
1189
|
-
elsif hash.include? self.namevar
|
1190
|
-
title = hash[self.namevar]
|
1191
|
-
hash.delete(self.namevar)
|
1192
|
-
|
1193
|
-
if hash.include? :name
|
1194
|
-
raise ArgumentError, "Cannot provide both name and %s to %s" %
|
1195
|
-
[self.namevar, self.name]
|
1196
|
-
end
|
1197
|
-
elsif hash[:name]
|
1198
|
-
title = hash[:name]
|
1199
|
-
hash.delete :name
|
1200
|
-
end
|
1201
|
-
|
1202
|
-
if catalog = hash[:catalog]
|
1203
|
-
hash.delete(:catalog)
|
1204
|
-
end
|
1205
|
-
|
1206
|
-
raise(Puppet::Error, "You must specify a title for objects of type %s" % self.to_s) unless title
|
1207
|
-
|
1208
|
-
if hash.include? :type
|
1209
|
-
unless self.validattr? :type
|
1210
|
-
hash.delete :type
|
1211
|
-
end
|
1212
|
-
end
|
1213
|
-
|
1214
|
-
# okay, now make a transobject out of hash
|
1215
|
-
begin
|
1216
|
-
trans = Puppet::TransObject.new(title, self.name.to_s)
|
1217
|
-
trans.catalog = catalog if catalog
|
1218
|
-
hash.each { |param, value|
|
1219
|
-
trans[param] = value
|
1220
|
-
}
|
1221
|
-
rescue => detail
|
1222
|
-
raise Puppet::Error, "Could not create %s: %s" %
|
1223
|
-
[name, detail]
|
1224
|
-
end
|
1225
|
-
|
1226
|
-
return trans
|
1227
|
-
end
|
1228
|
-
|
1229
990
|
# Retrieve all known instances. Either requires providers or must be overridden.
|
1230
991
|
def self.instances
|
1231
|
-
|
992
|
+
if provider_hash.empty?
|
1232
993
|
raise Puppet::DevError, "%s has no providers and has not overridden 'instances'" % self.name
|
1233
994
|
end
|
1234
995
|
|
@@ -1236,10 +997,6 @@ class Type
|
|
1236
997
|
provider_instances = {}
|
1237
998
|
providers_by_source.collect do |provider|
|
1238
999
|
provider.instances.collect do |instance|
|
1239
|
-
# First try to get the resource if it already exists
|
1240
|
-
# Skip instances that map to a managed resource with a different provider
|
1241
|
-
next if resource = self[instance.name] and resource.provider.class != instance.class
|
1242
|
-
|
1243
1000
|
# We always want to use the "first" provider instance we find, unless the resource
|
1244
1001
|
# is already managed and has a different provider set
|
1245
1002
|
if other = provider_instances[instance.name]
|
@@ -1249,12 +1006,7 @@ class Type
|
|
1249
1006
|
end
|
1250
1007
|
provider_instances[instance.name] = instance
|
1251
1008
|
|
1252
|
-
|
1253
|
-
resource.provider = instance
|
1254
|
-
resource
|
1255
|
-
else
|
1256
|
-
create(:name => instance.name, :provider => instance, :check => :all)
|
1257
|
-
end
|
1009
|
+
new(:name => instance.name, :provider => instance, :check => :all)
|
1258
1010
|
end
|
1259
1011
|
end.flatten.compact
|
1260
1012
|
end
|
@@ -1271,6 +1023,47 @@ class Type
|
|
1271
1023
|
end.compact
|
1272
1024
|
end
|
1273
1025
|
|
1026
|
+
# Convert a simple hash into a Resource instance. This is a convenience method,
|
1027
|
+
# so people can create RAL resources with a hash and get the same behaviour
|
1028
|
+
# as we get internally when we use Resource instances.
|
1029
|
+
# This should only be used directly from Ruby -- it's not used when going through
|
1030
|
+
# normal Puppet usage.
|
1031
|
+
def self.hash2resource(hash)
|
1032
|
+
hash = hash.inject({}) { |result, ary| result[ary[0].to_sym] = ary[1]; result }
|
1033
|
+
|
1034
|
+
if title = hash[:title]
|
1035
|
+
hash.delete(:title)
|
1036
|
+
else
|
1037
|
+
if self.namevar != :name
|
1038
|
+
if hash.include?(:name) and hash.include?(self.namevar)
|
1039
|
+
raise Puppet::Error, "Cannot provide both name and %s to resources of type %s" % [self.namevar, self.name]
|
1040
|
+
end
|
1041
|
+
if title = hash[self.namevar]
|
1042
|
+
hash.delete(self.namevar)
|
1043
|
+
end
|
1044
|
+
end
|
1045
|
+
|
1046
|
+
unless title ||= hash[:name]
|
1047
|
+
raise Puppet::Error, "You must specify a name or title for resources"
|
1048
|
+
end
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
|
1052
|
+
# Now create our resource.
|
1053
|
+
resource = Puppet::Resource.new(self.name, title)
|
1054
|
+
[:catalog].each do |attribute|
|
1055
|
+
if value = hash[attribute]
|
1056
|
+
hash.delete(attribute)
|
1057
|
+
resource.send(attribute.to_s + "=", value)
|
1058
|
+
end
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
hash.each do |param, value|
|
1062
|
+
resource[param] = value
|
1063
|
+
end
|
1064
|
+
return resource
|
1065
|
+
end
|
1066
|
+
|
1274
1067
|
# Create the path for logging and such.
|
1275
1068
|
def pathbuilder
|
1276
1069
|
if p = parent
|
@@ -1285,12 +1078,12 @@ class Type
|
|
1285
1078
|
newmetaparam(:noop) do
|
1286
1079
|
desc "Boolean flag indicating whether work should actually
|
1287
1080
|
be done."
|
1288
|
-
|
1081
|
+
|
1289
1082
|
newvalues(:true, :false)
|
1290
1083
|
munge do |value|
|
1291
1084
|
case value
|
1292
|
-
when true, :true, "true"
|
1293
|
-
when false, :false, "false"
|
1085
|
+
when true, :true, "true"; @resource.noop = true
|
1086
|
+
when false, :false, "false"; @resource.noop = false
|
1294
1087
|
end
|
1295
1088
|
end
|
1296
1089
|
end
|
@@ -1364,47 +1157,6 @@ class Type
|
|
1364
1157
|
}
|
1365
1158
|
end
|
1366
1159
|
end
|
1367
|
-
|
1368
|
-
# We've got four relationship metaparameters, so this method is used
|
1369
|
-
# to reduce code duplication between them.
|
1370
|
-
def munge_relationship(param, values)
|
1371
|
-
# We need to support values passed in as an array or as a
|
1372
|
-
# resource reference.
|
1373
|
-
result = []
|
1374
|
-
|
1375
|
-
# 'values' could be an array or a reference. If it's an array,
|
1376
|
-
# it could be an array of references or an array of arrays.
|
1377
|
-
if values.is_a?(Puppet::Type)
|
1378
|
-
result << [values.class.name, values.title]
|
1379
|
-
else
|
1380
|
-
unless values.is_a?(Array)
|
1381
|
-
devfail "Relationships must be resource references"
|
1382
|
-
end
|
1383
|
-
if values[0].is_a?(String) or values[0].is_a?(Symbol)
|
1384
|
-
# we're a type/title array reference
|
1385
|
-
values[0] = symbolize(values[0])
|
1386
|
-
result << values
|
1387
|
-
else
|
1388
|
-
# we're an array of stuff
|
1389
|
-
values.each do |value|
|
1390
|
-
if value.is_a?(Puppet::Type)
|
1391
|
-
result << [value.class.name, value.title]
|
1392
|
-
elsif value.is_a?(Array)
|
1393
|
-
value[0] = symbolize(value[0])
|
1394
|
-
result << value
|
1395
|
-
else
|
1396
|
-
devfail "Invalid relationship %s" % value.inspect
|
1397
|
-
end
|
1398
|
-
end
|
1399
|
-
end
|
1400
|
-
end
|
1401
|
-
|
1402
|
-
if existing = self[param]
|
1403
|
-
result = existing + result
|
1404
|
-
end
|
1405
|
-
|
1406
|
-
result
|
1407
|
-
end
|
1408
1160
|
|
1409
1161
|
newmetaparam(:loglevel) do
|
1410
1162
|
desc "Sets the level that information will be logged.
|
@@ -1418,8 +1170,8 @@ class Type
|
|
1418
1170
|
munge do |loglevel|
|
1419
1171
|
val = super(loglevel)
|
1420
1172
|
if val == :verbose
|
1421
|
-
val = :info
|
1422
|
-
end
|
1173
|
+
val = :info
|
1174
|
+
end
|
1423
1175
|
val
|
1424
1176
|
end
|
1425
1177
|
end
|
@@ -1427,7 +1179,7 @@ class Type
|
|
1427
1179
|
newmetaparam(:alias) do
|
1428
1180
|
desc "Creates an alias for the object. Puppet uses this internally when you
|
1429
1181
|
provide a symbolic name::
|
1430
|
-
|
1182
|
+
|
1431
1183
|
file { sshdconfig:
|
1432
1184
|
path => $operatingsystem ? {
|
1433
1185
|
solaris => \"/usr/local/etc/ssh/sshd_config\",
|
@@ -1460,7 +1212,7 @@ class Type
|
|
1460
1212
|
should be affecting the same file.
|
1461
1213
|
|
1462
1214
|
See the `LanguageTutorial language tutorial`:trac: for more information.
|
1463
|
-
|
1215
|
+
|
1464
1216
|
"
|
1465
1217
|
|
1466
1218
|
munge do |aliases|
|
@@ -1478,9 +1230,6 @@ class Type
|
|
1478
1230
|
next
|
1479
1231
|
end
|
1480
1232
|
|
1481
|
-
# LAK:FIXME Old-school, add the alias to the class.
|
1482
|
-
@resource.class.alias(other, @resource)
|
1483
|
-
|
1484
1233
|
# Newschool, add it to the catalog.
|
1485
1234
|
@resource.catalog.alias(@resource, other)
|
1486
1235
|
end
|
@@ -1495,7 +1244,7 @@ class Type
|
|
1495
1244
|
|
1496
1245
|
Tags are currently useful for things like applying a subset of a
|
1497
1246
|
host's configuration::
|
1498
|
-
|
1247
|
+
|
1499
1248
|
puppetd --test --tags mytag
|
1500
1249
|
|
1501
1250
|
This way, when you're testing a configuration you can run just the
|
@@ -1509,32 +1258,38 @@ class Type
|
|
1509
1258
|
end
|
1510
1259
|
end
|
1511
1260
|
end
|
1512
|
-
|
1261
|
+
|
1513
1262
|
class RelationshipMetaparam < Puppet::Parameter
|
1514
1263
|
class << self
|
1515
1264
|
attr_accessor :direction, :events, :callback, :subclasses
|
1516
1265
|
end
|
1517
|
-
|
1266
|
+
|
1518
1267
|
@subclasses = []
|
1519
|
-
|
1268
|
+
|
1520
1269
|
def self.inherited(sub)
|
1521
1270
|
@subclasses << sub
|
1522
1271
|
end
|
1523
|
-
|
1524
|
-
def munge(
|
1525
|
-
|
1272
|
+
|
1273
|
+
def munge(references)
|
1274
|
+
references = [references] unless references.is_a?(Array)
|
1275
|
+
references.collect do |ref|
|
1276
|
+
if ref.is_a?(Puppet::Resource::Reference)
|
1277
|
+
ref
|
1278
|
+
else
|
1279
|
+
Puppet::Resource::Reference.new(ref)
|
1280
|
+
end
|
1281
|
+
end
|
1526
1282
|
end
|
1527
1283
|
|
1528
1284
|
def validate_relationship
|
1529
|
-
@value.each do |
|
1530
|
-
unless @resource.catalog.resource(
|
1285
|
+
@value.each do |ref|
|
1286
|
+
unless @resource.catalog.resource(ref.to_s)
|
1531
1287
|
description = self.class.direction == :in ? "dependency" : "dependent"
|
1532
|
-
fail
|
1533
|
-
[description, value[0].to_s.capitalize, value[1], resource.ref]
|
1288
|
+
fail "Could not find %s %s for %s" % [description, ref.to_s, resource.ref]
|
1534
1289
|
end
|
1535
1290
|
end
|
1536
1291
|
end
|
1537
|
-
|
1292
|
+
|
1538
1293
|
# Create edges from each of our relationships. :in
|
1539
1294
|
# relationships are specified by the event-receivers, and :out
|
1540
1295
|
# relationships are specified by the event generator. This
|
@@ -1544,26 +1299,23 @@ class Type
|
|
1544
1299
|
# which resource is applied first and which resource is considered
|
1545
1300
|
# to be the event generator.
|
1546
1301
|
def to_edges
|
1547
|
-
@value.collect do |
|
1548
|
-
|
1549
|
-
|
1550
|
-
tname, name = value
|
1551
|
-
reference = Puppet::ResourceReference.new(tname, name)
|
1552
|
-
|
1302
|
+
@value.collect do |reference|
|
1303
|
+
reference.catalog = resource.catalog
|
1304
|
+
|
1553
1305
|
# Either of the two retrieval attempts could have returned
|
1554
1306
|
# nil.
|
1555
|
-
unless
|
1307
|
+
unless related_resource = reference.resolve
|
1556
1308
|
self.fail "Could not retrieve dependency '%s' of %s" % [reference, @resource.ref]
|
1557
1309
|
end
|
1558
1310
|
|
1559
1311
|
# Are we requiring them, or vice versa? See the method docs
|
1560
1312
|
# for futher info on this.
|
1561
1313
|
if self.class.direction == :in
|
1562
|
-
source =
|
1314
|
+
source = related_resource
|
1563
1315
|
target = @resource
|
1564
1316
|
else
|
1565
1317
|
source = @resource
|
1566
|
-
target =
|
1318
|
+
target = related_resource
|
1567
1319
|
end
|
1568
1320
|
|
1569
1321
|
if method = self.class.callback
|
@@ -1571,19 +1323,19 @@ class Type
|
|
1571
1323
|
:event => self.class.events,
|
1572
1324
|
:callback => method
|
1573
1325
|
}
|
1574
|
-
self.debug("subscribes to %s" % [
|
1326
|
+
self.debug("subscribes to %s" % [related_resource.ref])
|
1575
1327
|
else
|
1576
1328
|
# If there's no callback, there's no point in even adding
|
1577
1329
|
# a label.
|
1578
1330
|
subargs = nil
|
1579
|
-
self.debug("requires %s" % [
|
1331
|
+
self.debug("requires %s" % [related_resource.ref])
|
1580
1332
|
end
|
1581
|
-
|
1333
|
+
|
1582
1334
|
rel = Puppet::Relationship.new(source, target, subargs)
|
1583
1335
|
end
|
1584
1336
|
end
|
1585
1337
|
end
|
1586
|
-
|
1338
|
+
|
1587
1339
|
def self.relationship_params
|
1588
1340
|
RelationshipMetaparam.subclasses
|
1589
1341
|
end
|
@@ -1598,7 +1350,7 @@ class Type
|
|
1598
1350
|
desc "One or more objects that this object depends on.
|
1599
1351
|
This is used purely for guaranteeing that changes to required objects
|
1600
1352
|
happen before the dependent object. For instance::
|
1601
|
-
|
1353
|
+
|
1602
1354
|
# Create the destination directory before you copy things down
|
1603
1355
|
file { \"/usr/local/scripts\":
|
1604
1356
|
ensure => directory
|
@@ -1624,7 +1376,7 @@ class Type
|
|
1624
1376
|
any parent directories that are being managed; it will
|
1625
1377
|
automatically realize that the parent directory should be created
|
1626
1378
|
before the script is pulled down.
|
1627
|
-
|
1379
|
+
|
1628
1380
|
Currently, exec resources will autorequire their CWD (if it is
|
1629
1381
|
specified) plus any fully qualified paths that appear in the
|
1630
1382
|
command. For instance, if you had an ``exec`` command that ran
|
@@ -1639,7 +1391,7 @@ class Type
|
|
1639
1391
|
desc "One or more objects that this object depends on. Changes in the
|
1640
1392
|
subscribed to objects result in the dependent objects being
|
1641
1393
|
refreshed (e.g., a service will get restarted). For instance::
|
1642
|
-
|
1394
|
+
|
1643
1395
|
class nagios {
|
1644
1396
|
file { \"/etc/nagios/nagios.conf\":
|
1645
1397
|
source => \"puppet://server/module/nagios.conf\",
|
@@ -1650,7 +1402,7 @@ class Type
|
|
1650
1402
|
subscribe => File[nagconf]
|
1651
1403
|
}
|
1652
1404
|
}
|
1653
|
-
|
1405
|
+
|
1654
1406
|
Currently the ``exec``, ``mount`` and ``service`` type support
|
1655
1407
|
refreshing.
|
1656
1408
|
"
|
@@ -1671,11 +1423,11 @@ class Type
|
|
1671
1423
|
command => "/usr/bin/make",
|
1672
1424
|
cwd => "/var/nagios/configuration"
|
1673
1425
|
}
|
1674
|
-
|
1426
|
+
|
1675
1427
|
This will make sure all of the files are up to date before the
|
1676
1428
|
make command is run.}
|
1677
1429
|
end
|
1678
|
-
|
1430
|
+
|
1679
1431
|
newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do
|
1680
1432
|
desc %{This parameter is the opposite of **subscribe** -- it sends events
|
1681
1433
|
to the specified object::
|
@@ -1688,7 +1440,7 @@ class Type
|
|
1688
1440
|
service { sshd:
|
1689
1441
|
ensure => running
|
1690
1442
|
}
|
1691
|
-
|
1443
|
+
|
1692
1444
|
This will restart the sshd service if the sshd config file changes.}
|
1693
1445
|
end
|
1694
1446
|
|
@@ -1718,8 +1470,8 @@ class Type
|
|
1718
1470
|
|
1719
1471
|
# If we don't have any default we use suitable providers
|
1720
1472
|
defaults = suitable if defaults.empty?
|
1721
|
-
max = defaults.collect { |provider| provider.
|
1722
|
-
defaults = defaults.find_all { |provider| provider.
|
1473
|
+
max = defaults.collect { |provider| provider.specificity }.max
|
1474
|
+
defaults = defaults.find_all { |provider| provider.specificity == max }
|
1723
1475
|
|
1724
1476
|
retval = nil
|
1725
1477
|
if defaults.length > 1
|
@@ -1742,45 +1494,13 @@ class Type
|
|
1742
1494
|
return @defaultprovider
|
1743
1495
|
end
|
1744
1496
|
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
namevar = self.namevar
|
1750
|
-
unless hash.include?(namevar) and hash[namevar]
|
1751
|
-
raise Puppet::DevError, "Hash was not passed with namevar"
|
1752
|
-
end
|
1753
|
-
|
1754
|
-
# if the obj already exists with that name...
|
1755
|
-
if obj = self[hash[namevar]]
|
1756
|
-
# We're assuming here that objects with the same name
|
1757
|
-
# are the same object, which *should* be the case, assuming
|
1758
|
-
# we've set up our naming stuff correctly everywhere.
|
1759
|
-
|
1760
|
-
# Mark found objects as present
|
1761
|
-
hash.each { |param, value|
|
1762
|
-
if property = obj.property(param)
|
1763
|
-
elsif val = obj[param]
|
1764
|
-
obj[param] = val
|
1765
|
-
else
|
1766
|
-
# There is a value on disk, but it should go away
|
1767
|
-
obj[param] = :absent
|
1768
|
-
end
|
1769
|
-
}
|
1770
|
-
else
|
1771
|
-
# create a new obj, since no existing one seems to
|
1772
|
-
# match
|
1773
|
-
obj = self.create(namevar => hash[namevar])
|
1774
|
-
|
1775
|
-
# We can't just pass the hash in at object creation time,
|
1776
|
-
# because it sets the should value, not the is value.
|
1777
|
-
hash.delete(namevar)
|
1778
|
-
hash.each { |param, value|
|
1779
|
-
obj[param] = value unless obj.add_property_parameter(param)
|
1780
|
-
}
|
1781
|
-
end
|
1497
|
+
def self.provider_hash_by_type(type)
|
1498
|
+
@provider_hashes ||= {}
|
1499
|
+
@provider_hashes[type] ||= {}
|
1500
|
+
end
|
1782
1501
|
|
1783
|
-
|
1502
|
+
def self.provider_hash
|
1503
|
+
Puppet::Type.provider_hash_by_type(self.name)
|
1784
1504
|
end
|
1785
1505
|
|
1786
1506
|
# Retrieve a provider by name.
|
@@ -1788,21 +1508,21 @@ class Type
|
|
1788
1508
|
name = Puppet::Util.symbolize(name)
|
1789
1509
|
|
1790
1510
|
# If we don't have it yet, try loading it.
|
1791
|
-
unless
|
1511
|
+
unless provider_hash.has_key?(name)
|
1792
1512
|
@providerloader.load(name)
|
1793
1513
|
end
|
1794
|
-
return
|
1514
|
+
return provider_hash[name]
|
1795
1515
|
end
|
1796
1516
|
|
1797
1517
|
# Just list all of the providers.
|
1798
1518
|
def self.providers
|
1799
|
-
|
1519
|
+
provider_hash.keys
|
1800
1520
|
end
|
1801
1521
|
|
1802
1522
|
def self.validprovider?(name)
|
1803
1523
|
name = Puppet::Util.symbolize(name)
|
1804
1524
|
|
1805
|
-
return (
|
1525
|
+
return (provider_hash.has_key?(name) && provider_hash[name].suitable?)
|
1806
1526
|
end
|
1807
1527
|
|
1808
1528
|
# Create a new provider of a type. This method must be called
|
@@ -1810,7 +1530,7 @@ class Type
|
|
1810
1530
|
def self.provide(name, options = {}, &block)
|
1811
1531
|
name = Puppet::Util.symbolize(name)
|
1812
1532
|
|
1813
|
-
if obj =
|
1533
|
+
if obj = provider_hash[name]
|
1814
1534
|
Puppet.debug "Reloading %s %s provider" % [name, self.name]
|
1815
1535
|
unprovide(name)
|
1816
1536
|
end
|
@@ -1838,7 +1558,7 @@ class Type
|
|
1838
1558
|
|
1839
1559
|
provider = genclass(name,
|
1840
1560
|
:parent => parent,
|
1841
|
-
:hash =>
|
1561
|
+
:hash => provider_hash,
|
1842
1562
|
:prefix => "Provider",
|
1843
1563
|
:block => block,
|
1844
1564
|
:include => feature_module,
|
@@ -1906,9 +1626,9 @@ class Type
|
|
1906
1626
|
end
|
1907
1627
|
|
1908
1628
|
def self.unprovide(name)
|
1909
|
-
if
|
1629
|
+
if provider_hash.has_key? name
|
1910
1630
|
rmclass(name,
|
1911
|
-
:hash =>
|
1631
|
+
:hash => provider_hash,
|
1912
1632
|
:prefix => "Provider"
|
1913
1633
|
)
|
1914
1634
|
if @defaultprovider and @defaultprovider.name == name
|
@@ -1919,10 +1639,10 @@ class Type
|
|
1919
1639
|
|
1920
1640
|
# Return an array of all of the suitable providers.
|
1921
1641
|
def self.suitableprovider
|
1922
|
-
if
|
1642
|
+
if provider_hash.empty?
|
1923
1643
|
providerloader.loadall
|
1924
1644
|
end
|
1925
|
-
|
1645
|
+
provider_hash.find_all { |name, provider|
|
1926
1646
|
provider.suitable?
|
1927
1647
|
}.collect { |name, provider|
|
1928
1648
|
provider
|
@@ -1962,11 +1682,14 @@ class Type
|
|
1962
1682
|
|
1963
1683
|
# Figure out of there are any objects we can automatically add as
|
1964
1684
|
# dependencies.
|
1965
|
-
def autorequire
|
1685
|
+
def autorequire(rel_catalog = nil)
|
1686
|
+
rel_catalog ||= catalog
|
1687
|
+
raise(Puppet::DevError, "You cannot add relationships without a catalog") unless rel_catalog
|
1688
|
+
|
1966
1689
|
reqs = []
|
1967
1690
|
self.class.eachautorequire { |type, block|
|
1968
1691
|
# Ignore any types we can't find, although that would be a bit odd.
|
1969
|
-
next unless typeobj = Puppet.type(type)
|
1692
|
+
next unless typeobj = Puppet::Type.type(type)
|
1970
1693
|
|
1971
1694
|
# Retrieve the list of names from the block.
|
1972
1695
|
next unless list = self.instance_eval(&block)
|
@@ -1980,15 +1703,15 @@ class Type
|
|
1980
1703
|
# Support them passing objects directly, to save some effort.
|
1981
1704
|
unless dep.is_a? Puppet::Type
|
1982
1705
|
# Skip autorequires that we aren't managing
|
1983
|
-
unless dep =
|
1706
|
+
unless dep = rel_catalog.resource(type, dep)
|
1984
1707
|
next
|
1985
1708
|
end
|
1986
1709
|
end
|
1987
|
-
|
1710
|
+
|
1988
1711
|
reqs << Puppet::Relationship.new(dep, self)
|
1989
1712
|
}
|
1990
1713
|
}
|
1991
|
-
|
1714
|
+
|
1992
1715
|
return reqs
|
1993
1716
|
end
|
1994
1717
|
|
@@ -2001,61 +1724,6 @@ class Type
|
|
2001
1724
|
end
|
2002
1725
|
end.flatten.reject { |r| r.nil? }
|
2003
1726
|
end
|
2004
|
-
|
2005
|
-
# Does this resource have a relationship with the other? We have to
|
2006
|
-
# check each object for both directions of relationship.
|
2007
|
-
def requires?(other)
|
2008
|
-
them = [other.class.name, other.title]
|
2009
|
-
me = [self.class.name, self.title]
|
2010
|
-
self.class.relationship_params.each do |param|
|
2011
|
-
case param.direction
|
2012
|
-
when :in: return true if v = self[param.name] and v.include?(them)
|
2013
|
-
when :out: return true if v = other[param.name] and v.include?(me)
|
2014
|
-
end
|
2015
|
-
end
|
2016
|
-
return false
|
2017
|
-
end
|
2018
|
-
|
2019
|
-
# we've received an event
|
2020
|
-
# we only support local events right now, so we can pass actual
|
2021
|
-
# objects around, including the transaction object
|
2022
|
-
# the assumption here is that container objects will pass received
|
2023
|
-
# methods on to contained objects
|
2024
|
-
# i.e., we don't trigger our children, our refresh() method calls
|
2025
|
-
# refresh() on our children
|
2026
|
-
def trigger(event, source)
|
2027
|
-
trans = event.transaction
|
2028
|
-
if @callbacks.include?(source)
|
2029
|
-
[:ALL_EVENTS, event.event].each { |eventname|
|
2030
|
-
if method = @callbacks[source][eventname]
|
2031
|
-
if trans.triggered?(self, method) > 0
|
2032
|
-
next
|
2033
|
-
end
|
2034
|
-
if self.respond_to?(method)
|
2035
|
-
self.send(method)
|
2036
|
-
end
|
2037
|
-
|
2038
|
-
trans.triggered(self, method)
|
2039
|
-
end
|
2040
|
-
}
|
2041
|
-
end
|
2042
|
-
end
|
2043
|
-
|
2044
|
-
# Unsubscribe from a given object, possibly with a specific event.
|
2045
|
-
def unsubscribe(object, event = nil)
|
2046
|
-
# First look through our own relationship params
|
2047
|
-
[:require, :subscribe].each do |param|
|
2048
|
-
if values = self[param]
|
2049
|
-
newvals = values.reject { |d|
|
2050
|
-
d == [object.class.name, object.title]
|
2051
|
-
}
|
2052
|
-
if newvals.length != values.length
|
2053
|
-
self.delete(param)
|
2054
|
-
self[param] = newvals
|
2055
|
-
end
|
2056
|
-
end
|
2057
|
-
end
|
2058
|
-
end
|
2059
1727
|
|
2060
1728
|
###############################
|
2061
1729
|
# All of the scheduling code.
|
@@ -2064,9 +1732,14 @@ class Type
|
|
2064
1732
|
# the instantiation phase, so that the schedule can be anywhere in the
|
2065
1733
|
# file.
|
2066
1734
|
def schedule
|
1735
|
+
unless catalog
|
1736
|
+
warning "Cannot schedule without a schedule-containing catalog"
|
1737
|
+
return nil
|
1738
|
+
end
|
1739
|
+
|
2067
1740
|
unless defined? @schedule
|
2068
1741
|
if name = self[:schedule]
|
2069
|
-
if sched =
|
1742
|
+
if sched = catalog.resource(:schedule, name)
|
2070
1743
|
@schedule = sched
|
2071
1744
|
else
|
2072
1745
|
self.fail "Could not find schedule %s" % name
|
@@ -2091,42 +1764,10 @@ class Type
|
|
2091
1764
|
return schedule.match?(self.cached(:checked).to_i)
|
2092
1765
|
end
|
2093
1766
|
|
2094
|
-
###############################
|
2095
|
-
# All of the tagging code.
|
2096
|
-
attr_reader :tags
|
2097
|
-
|
2098
|
-
# Add a new tag.
|
2099
|
-
def tag(tag)
|
2100
|
-
tag = tag.intern if tag.is_a? String
|
2101
|
-
unless @tags.include? tag
|
2102
|
-
@tags << tag
|
2103
|
-
end
|
2104
|
-
end
|
2105
|
-
|
2106
1767
|
# Define the initial list of tags.
|
2107
1768
|
def tags=(list)
|
2108
|
-
|
2109
|
-
|
2110
|
-
@tags = list.collect do |t|
|
2111
|
-
case t
|
2112
|
-
when String: t.intern
|
2113
|
-
when Symbol: t
|
2114
|
-
else
|
2115
|
-
self.warning "Ignoring tag %s of type %s" % [tag.inspect, tag.class]
|
2116
|
-
end
|
2117
|
-
end
|
2118
|
-
|
2119
|
-
@tags << self.class.name unless @tags.include?(self.class.name)
|
2120
|
-
end
|
2121
|
-
|
2122
|
-
# Figure out of any of the specified tags apply to this object. This is an
|
2123
|
-
# OR operation.
|
2124
|
-
def tagged?(tags)
|
2125
|
-
tags = [tags] unless tags.is_a? Array
|
2126
|
-
|
2127
|
-
tags = tags.collect { |t| t.intern }
|
2128
|
-
|
2129
|
-
return tags.find { |tag| @tags.include? tag }
|
1769
|
+
tag(self.class.name)
|
1770
|
+
tag(*list)
|
2130
1771
|
end
|
2131
1772
|
|
2132
1773
|
# Types (which map to resources in the languages) are entirely composed of
|
@@ -2141,7 +1782,7 @@ class Type
|
|
2141
1782
|
attr_writer :noop
|
2142
1783
|
|
2143
1784
|
include Enumerable
|
2144
|
-
|
1785
|
+
|
2145
1786
|
# class methods dealing with Type management
|
2146
1787
|
|
2147
1788
|
public
|
@@ -2163,7 +1804,6 @@ class Type
|
|
2163
1804
|
@objects = Hash.new
|
2164
1805
|
@aliases = Hash.new
|
2165
1806
|
|
2166
|
-
@providers = Hash.new
|
2167
1807
|
@defaults = {}
|
2168
1808
|
|
2169
1809
|
unless defined? @parameters
|
@@ -2211,7 +1851,13 @@ class Type
|
|
2211
1851
|
|
2212
1852
|
# The catalog that this resource is stored in.
|
2213
1853
|
attr_accessor :catalog
|
2214
|
-
|
1854
|
+
|
1855
|
+
# is the resource exported
|
1856
|
+
attr_accessor :exported
|
1857
|
+
|
1858
|
+
# is the resource virtual (it should not :-))
|
1859
|
+
attr_accessor :virtual
|
1860
|
+
|
2215
1861
|
# create a log at specified level
|
2216
1862
|
def log(msg)
|
2217
1863
|
Puppet::Util::Log.create(
|
@@ -2227,147 +1873,84 @@ class Type
|
|
2227
1873
|
|
2228
1874
|
public
|
2229
1875
|
|
2230
|
-
|
2231
|
-
@evalcount = 0
|
2232
|
-
@tags = []
|
2233
|
-
|
2234
|
-
# callbacks are per object and event
|
2235
|
-
@callbacks = Hash.new { |chash, key|
|
2236
|
-
chash[key] = {}
|
2237
|
-
}
|
2238
|
-
|
2239
|
-
# properties and parameters are treated equivalently from the outside:
|
2240
|
-
# as name-value pairs (using [] and []=)
|
2241
|
-
# internally, however, parameters are merely a hash, while properties
|
2242
|
-
# point to Property objects
|
2243
|
-
# further, the lists of valid properties and parameters are defined
|
2244
|
-
# at the class level
|
2245
|
-
unless defined? @parameters
|
2246
|
-
@parameters = {}
|
2247
|
-
end
|
2248
|
-
|
2249
|
-
# keeping stats for the total number of changes, and how many were
|
2250
|
-
# completely sync'ed
|
2251
|
-
# this isn't really sufficient either, because it adds lots of special
|
2252
|
-
# cases such as failed changes
|
2253
|
-
# it also doesn't distinguish between changes from the current transaction
|
2254
|
-
# vs. changes over the process lifetime
|
2255
|
-
@totalchanges = 0
|
2256
|
-
@syncedchanges = 0
|
2257
|
-
@failedchanges = 0
|
2258
|
-
|
2259
|
-
@inited = true
|
2260
|
-
end
|
1876
|
+
attr_reader :original_parameters
|
2261
1877
|
|
2262
1878
|
# initialize the type instance
|
2263
|
-
def initialize(
|
2264
|
-
|
2265
|
-
|
2266
|
-
|
2267
|
-
|
2268
|
-
|
2269
|
-
orighash = hash
|
2270
|
-
|
2271
|
-
# If we got passed a transportable object, we just pull a bunch of info
|
2272
|
-
# directly from it. This is the main object instantiation mechanism.
|
2273
|
-
if hash.is_a?(Puppet::TransObject)
|
2274
|
-
# XXX This will need to change when transobjects change to titles.
|
2275
|
-
self.title = hash.name
|
2276
|
-
|
2277
|
-
#self[:name] = hash[:name]
|
2278
|
-
[:file, :line, :tags, :catalog].each { |getter|
|
2279
|
-
if hash.respond_to?(getter)
|
2280
|
-
setter = getter.to_s + "="
|
2281
|
-
if val = hash.send(getter)
|
2282
|
-
self.send(setter, val)
|
2283
|
-
end
|
2284
|
-
end
|
2285
|
-
}
|
1879
|
+
def initialize(resource)
|
1880
|
+
raise Puppet::DevError, "Got TransObject instead of Resource or hash" if resource.is_a?(Puppet::TransObject)
|
1881
|
+
resource = self.class.hash2resource(resource) unless resource.is_a?(Puppet::Resource)
|
1882
|
+
|
1883
|
+
# The list of parameter/property instances.
|
1884
|
+
@parameters = {}
|
2286
1885
|
|
2287
|
-
|
1886
|
+
# Set the title first, so any failures print correctly.
|
1887
|
+
if resource.type.to_s.downcase.to_sym == self.class.name
|
1888
|
+
self.title = resource.title
|
2288
1889
|
else
|
2289
|
-
|
2290
|
-
|
2291
|
-
hash.delete(:title)
|
2292
|
-
end
|
1890
|
+
# This should only ever happen for components
|
1891
|
+
self.title = resource.ref
|
2293
1892
|
end
|
2294
1893
|
|
2295
|
-
|
2296
|
-
|
2297
|
-
|
2298
|
-
|
1894
|
+
[:file, :line, :catalog, :exported, :virtual].each do |getter|
|
1895
|
+
setter = getter.to_s + "="
|
1896
|
+
if val = resource.send(getter)
|
1897
|
+
self.send(setter, val)
|
1898
|
+
end
|
2299
1899
|
end
|
2300
1900
|
|
2301
|
-
|
2302
|
-
hash = self.argclean(hash)
|
1901
|
+
@tags = resource.tags
|
2303
1902
|
|
2304
|
-
|
2305
|
-
# we have the name but before anything else
|
1903
|
+
@original_parameters = resource.to_hash
|
2306
1904
|
|
2307
|
-
|
1905
|
+
set_name(@original_parameters)
|
2308
1906
|
|
2309
|
-
|
2310
|
-
#self.send(namevar.to_s + "=", hash[namevar])
|
2311
|
-
self[namevar] = hash[namevar]
|
2312
|
-
hash.delete(namevar)
|
2313
|
-
if attrs.include?(namevar)
|
2314
|
-
attrs.delete(namevar)
|
2315
|
-
else
|
2316
|
-
self.devfail "My namevar isn't a valid attribute...?"
|
2317
|
-
end
|
2318
|
-
else
|
2319
|
-
self.devfail "I was not passed a namevar"
|
2320
|
-
end
|
1907
|
+
set_default(:provider)
|
2321
1908
|
|
2322
|
-
|
2323
|
-
if self.name != self.title
|
2324
|
-
if obj = self.class[self.name]
|
2325
|
-
if self.class.isomorphic?
|
2326
|
-
raise Puppet::Error, "%s already exists with name %s" %
|
2327
|
-
[obj.title, self.name]
|
2328
|
-
end
|
2329
|
-
else
|
2330
|
-
self.class.alias(self.name, self)
|
2331
|
-
end
|
2332
|
-
end
|
1909
|
+
set_parameters(@original_parameters)
|
2333
1910
|
|
2334
|
-
if
|
2335
|
-
|
2336
|
-
|
2337
|
-
|
2338
|
-
setdefaults(:provider)
|
2339
|
-
end
|
1911
|
+
self.validate if self.respond_to?(:validate)
|
1912
|
+
end
|
1913
|
+
|
1914
|
+
private
|
2340
1915
|
|
2341
|
-
|
2342
|
-
|
2343
|
-
|
2344
|
-
|
1916
|
+
# Set our resource's name.
|
1917
|
+
def set_name(hash)
|
1918
|
+
n = self.class.namevar
|
1919
|
+
self[n] = hash[n]
|
1920
|
+
hash.delete(n)
|
1921
|
+
end
|
1922
|
+
|
1923
|
+
# Set all of the parameters from a hash, in the appropriate order.
|
1924
|
+
def set_parameters(hash)
|
1925
|
+
# Use the order provided by allattrs, but add in any
|
1926
|
+
# extra attributes from the resource so we get failures
|
1927
|
+
# on invalid attributes.
|
1928
|
+
no_values = []
|
1929
|
+
(self.class.allattrs + hash.keys).uniq.each do |attr|
|
1930
|
+
begin
|
1931
|
+
# Set any defaults immediately. This is mostly done so
|
1932
|
+
# that the default provider is available for any other
|
1933
|
+
# property validation.
|
1934
|
+
if hash.has_key?(attr)
|
2345
1935
|
self[attr] = hash[attr]
|
2346
|
-
|
2347
|
-
|
2348
|
-
rescue => detail
|
2349
|
-
error = Puppet::DevError.new( "Could not set %s on %s: %s" % [attr, self.class.name, detail])
|
2350
|
-
error.set_backtrace(detail.backtrace)
|
2351
|
-
raise error
|
1936
|
+
else
|
1937
|
+
no_values << attr
|
2352
1938
|
end
|
2353
|
-
|
1939
|
+
rescue ArgumentError, Puppet::Error, TypeError
|
1940
|
+
raise
|
1941
|
+
rescue => detail
|
1942
|
+
error = Puppet::DevError.new( "Could not set %s on %s: %s" % [attr, self.class.name, detail])
|
1943
|
+
error.set_backtrace(detail.backtrace)
|
1944
|
+
raise error
|
2354
1945
|
end
|
2355
|
-
}
|
2356
|
-
|
2357
|
-
# Set all default values.
|
2358
|
-
self.setdefaults
|
2359
|
-
|
2360
|
-
if hash.length > 0
|
2361
|
-
self.debug hash.inspect
|
2362
|
-
self.fail("Class %s does not accept argument(s) %s" %
|
2363
|
-
[self.class.name, hash.keys.join(" ")])
|
2364
1946
|
end
|
2365
|
-
|
2366
|
-
|
2367
|
-
self.validate
|
1947
|
+
no_values.each do |attr|
|
1948
|
+
set_default(attr)
|
2368
1949
|
end
|
2369
1950
|
end
|
2370
1951
|
|
1952
|
+
public
|
1953
|
+
|
2371
1954
|
# Set up all of our autorequires.
|
2372
1955
|
def finish
|
2373
1956
|
# Scheduling has to be done when the whole config is instantiated, so
|
@@ -2395,14 +1978,6 @@ class Type
|
|
2395
1978
|
#@cache[name] = value
|
2396
1979
|
end
|
2397
1980
|
|
2398
|
-
# def set(name, value)
|
2399
|
-
# send(name.to_s + "=", value)
|
2400
|
-
# end
|
2401
|
-
#
|
2402
|
-
# def get(name)
|
2403
|
-
# send(name)
|
2404
|
-
# end
|
2405
|
-
|
2406
1981
|
# For now, leave the 'name' method functioning like it used to. Once 'title'
|
2407
1982
|
# works everywhere, I'll switch it.
|
2408
1983
|
def name
|
@@ -2414,13 +1989,7 @@ class Type
|
|
2414
1989
|
return nil unless catalog
|
2415
1990
|
|
2416
1991
|
unless defined?(@parent)
|
2417
|
-
|
2418
|
-
if implicit?
|
2419
|
-
parents = catalog.relationship_graph.adjacent(self, :direction => :in)
|
2420
|
-
else
|
2421
|
-
parents = catalog.adjacent(self, :direction => :in)
|
2422
|
-
end
|
2423
|
-
if parents
|
1992
|
+
if parents = catalog.adjacent(self, :direction => :in)
|
2424
1993
|
# We should never have more than one parent, so let's just ignore
|
2425
1994
|
# it if we happen to.
|
2426
1995
|
@parent = parents.shift
|
@@ -2435,7 +2004,7 @@ class Type
|
|
2435
2004
|
def ref
|
2436
2005
|
"%s[%s]" % [self.class.name.to_s.capitalize, self.title]
|
2437
2006
|
end
|
2438
|
-
|
2007
|
+
|
2439
2008
|
def self_refresh?
|
2440
2009
|
self.class.self_refresh
|
2441
2010
|
end
|
@@ -2503,6 +2072,12 @@ class Type
|
|
2503
2072
|
return trans
|
2504
2073
|
end
|
2505
2074
|
|
2075
|
+
%w{exported virtual}.each do |m|
|
2076
|
+
define_method(m+"?") do
|
2077
|
+
self.send(m)
|
2078
|
+
end
|
2079
|
+
end
|
2080
|
+
|
2506
2081
|
end # Puppet::Type
|
2507
2082
|
end
|
2508
2083
|
|