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
@@ -0,0 +1,1061 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
4
|
+
|
5
|
+
describe Puppet::Resource::Catalog, "when compiling" do
|
6
|
+
it "should be an Expirer" do
|
7
|
+
Puppet::Resource::Catalog.ancestors.should be_include(Puppet::Util::Cacher::Expirer)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should always be expired if it's not applying" do
|
11
|
+
@catalog = Puppet::Resource::Catalog.new("host")
|
12
|
+
@catalog.expects(:applying?).returns false
|
13
|
+
@catalog.should be_dependent_data_expired(Time.now)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should not be expired if it's applying and the timestamp is late enough" do
|
17
|
+
@catalog = Puppet::Resource::Catalog.new("host")
|
18
|
+
@catalog.expire
|
19
|
+
@catalog.expects(:applying?).returns true
|
20
|
+
@catalog.should_not be_dependent_data_expired(Time.now)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should be able to write its list of classes to the class file" do
|
24
|
+
@catalog = Puppet::Resource::Catalog.new("host")
|
25
|
+
|
26
|
+
@catalog.add_class "foo", "bar"
|
27
|
+
|
28
|
+
Puppet.settings.expects(:value).with(:classfile).returns "/class/file"
|
29
|
+
|
30
|
+
fh = mock 'filehandle'
|
31
|
+
File.expects(:open).with("/class/file", "w").yields fh
|
32
|
+
|
33
|
+
fh.expects(:puts).with "foo\nbar"
|
34
|
+
|
35
|
+
@catalog.write_class_file
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "when compiling" do
|
39
|
+
it "should accept tags" do
|
40
|
+
config = Puppet::Resource::Catalog.new("mynode")
|
41
|
+
config.tag("one")
|
42
|
+
config.tags.should == %w{one}
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should accept multiple tags at once" do
|
46
|
+
config = Puppet::Resource::Catalog.new("mynode")
|
47
|
+
config.tag("one", "two")
|
48
|
+
config.tags.should == %w{one two}
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should convert all tags to strings" do
|
52
|
+
config = Puppet::Resource::Catalog.new("mynode")
|
53
|
+
config.tag("one", :two)
|
54
|
+
config.tags.should == %w{one two}
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should tag with both the qualified name and the split name" do
|
58
|
+
config = Puppet::Resource::Catalog.new("mynode")
|
59
|
+
config.tag("one::two")
|
60
|
+
config.tags.include?("one").should be_true
|
61
|
+
config.tags.include?("one::two").should be_true
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should accept classes" do
|
65
|
+
config = Puppet::Resource::Catalog.new("mynode")
|
66
|
+
config.add_class("one")
|
67
|
+
config.classes.should == %w{one}
|
68
|
+
config.add_class("two", "three")
|
69
|
+
config.classes.should == %w{one two three}
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should tag itself with passed class names" do
|
73
|
+
config = Puppet::Resource::Catalog.new("mynode")
|
74
|
+
config.add_class("one")
|
75
|
+
config.tags.should == %w{one}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "when extracting" do
|
80
|
+
it "should return extraction result as the method result" do
|
81
|
+
config = Puppet::Resource::Catalog.new("mynode")
|
82
|
+
config.expects(:extraction_format).returns(:whatever)
|
83
|
+
config.expects(:extract_to_whatever).returns(:result)
|
84
|
+
config.extract.should == :result
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "when extracting transobjects" do
|
89
|
+
|
90
|
+
def mkscope
|
91
|
+
@parser = Puppet::Parser::Parser.new :Code => ""
|
92
|
+
@node = Puppet::Node.new("mynode")
|
93
|
+
@compiler = Puppet::Parser::Compiler.new(@node, @parser)
|
94
|
+
|
95
|
+
# XXX This is ridiculous.
|
96
|
+
@compiler.send(:evaluate_main)
|
97
|
+
@scope = @compiler.topscope
|
98
|
+
end
|
99
|
+
|
100
|
+
def mkresource(type, name)
|
101
|
+
Puppet::Parser::Resource.new(:type => type, :title => name, :source => @source, :scope => @scope)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should always create a TransBucket for the 'main' class" do
|
105
|
+
config = Puppet::Resource::Catalog.new("mynode")
|
106
|
+
|
107
|
+
@scope = mkscope
|
108
|
+
@source = mock 'source'
|
109
|
+
|
110
|
+
main = mkresource("class", :main)
|
111
|
+
config.add_vertex(main)
|
112
|
+
|
113
|
+
bucket = stub 'bucket', :file= => nil, :line= => nil, :classes= => nil
|
114
|
+
bucket.expects(:type=).with("Class")
|
115
|
+
bucket.expects(:name=).with(:main)
|
116
|
+
main.stubs(:builtin?).returns(false)
|
117
|
+
|
118
|
+
Puppet::TransBucket.expects(:new).returns bucket
|
119
|
+
|
120
|
+
config.extract_to_transportable.should equal(bucket)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Now try it with a more complicated graph -- a three tier graph, each tier
|
124
|
+
it "should transform arbitrarily deep graphs into isomorphic trees" do
|
125
|
+
config = Puppet::Resource::Catalog.new("mynode")
|
126
|
+
|
127
|
+
@scope = mkscope
|
128
|
+
@scope.stubs(:tags).returns([])
|
129
|
+
@source = mock 'source'
|
130
|
+
|
131
|
+
# Create our scopes.
|
132
|
+
top = mkresource "class", :main
|
133
|
+
topbucket = []
|
134
|
+
topbucket.expects(:classes=).with([])
|
135
|
+
top.expects(:to_trans).returns(topbucket)
|
136
|
+
topres = mkresource "file", "/top"
|
137
|
+
topres.expects(:to_trans).returns(:topres)
|
138
|
+
config.add_edge top, topres
|
139
|
+
|
140
|
+
middle = mkresource "class", "middle"
|
141
|
+
middle.expects(:to_trans).returns([])
|
142
|
+
config.add_edge top, middle
|
143
|
+
midres = mkresource "file", "/mid"
|
144
|
+
midres.expects(:to_trans).returns(:midres)
|
145
|
+
config.add_edge middle, midres
|
146
|
+
|
147
|
+
bottom = mkresource "class", "bottom"
|
148
|
+
bottom.expects(:to_trans).returns([])
|
149
|
+
config.add_edge middle, bottom
|
150
|
+
botres = mkresource "file", "/bot"
|
151
|
+
botres.expects(:to_trans).returns(:botres)
|
152
|
+
config.add_edge bottom, botres
|
153
|
+
|
154
|
+
toparray = config.extract_to_transportable
|
155
|
+
|
156
|
+
# This is annoying; it should look like:
|
157
|
+
# [[[:botres], :midres], :topres]
|
158
|
+
# but we can't guarantee sort order.
|
159
|
+
toparray.include?(:topres).should be_true
|
160
|
+
|
161
|
+
midarray = toparray.find { |t| t.is_a?(Array) }
|
162
|
+
midarray.include?(:midres).should be_true
|
163
|
+
botarray = midarray.find { |t| t.is_a?(Array) }
|
164
|
+
botarray.include?(:botres).should be_true
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe " when converting to a Puppet::Resource catalog" do
|
169
|
+
before do
|
170
|
+
@original = Puppet::Resource::Catalog.new("mynode")
|
171
|
+
@original.tag(*%w{one two three})
|
172
|
+
@original.add_class *%w{four five six}
|
173
|
+
|
174
|
+
@top = Puppet::TransObject.new 'top', "class"
|
175
|
+
@topobject = Puppet::TransObject.new '/topobject', "file"
|
176
|
+
@middle = Puppet::TransObject.new 'middle', "class"
|
177
|
+
@middleobject = Puppet::TransObject.new '/middleobject', "file"
|
178
|
+
@bottom = Puppet::TransObject.new 'bottom', "class"
|
179
|
+
@bottomobject = Puppet::TransObject.new '/bottomobject', "file"
|
180
|
+
|
181
|
+
@resources = [@top, @topobject, @middle, @middleobject, @bottom, @bottomobject]
|
182
|
+
|
183
|
+
@original.add_resource(*@resources)
|
184
|
+
|
185
|
+
@original.add_edge(@top, @topobject)
|
186
|
+
@original.add_edge(@top, @middle)
|
187
|
+
@original.add_edge(@middle, @middleobject)
|
188
|
+
@original.add_edge(@middle, @bottom)
|
189
|
+
@original.add_edge(@bottom, @bottomobject)
|
190
|
+
|
191
|
+
@catalog = @original.to_resource
|
192
|
+
end
|
193
|
+
|
194
|
+
it "should copy over the version" do
|
195
|
+
@original.version = "foo"
|
196
|
+
@original.to_resource.version.should == "foo"
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should add all resources as Puppet::Resource instances" do
|
200
|
+
@resources.each { |resource| @catalog.resource(resource.ref).should be_instance_of(Puppet::Resource) }
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should copy the tag list to the new catalog" do
|
204
|
+
@catalog.tags.sort.should == @original.tags.sort
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should copy the class list to the new catalog" do
|
208
|
+
@catalog.classes.should == @original.classes
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should duplicate the original edges" do
|
212
|
+
@original.edges.each do |edge|
|
213
|
+
@catalog.edge?(@catalog.resource(edge.source.ref), @catalog.resource(edge.target.ref)).should be_true
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should set itself as the catalog for each converted resource" do
|
218
|
+
@catalog.vertices.each { |v| v.catalog.object_id.should equal(@catalog.object_id) }
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
describe "when converting to a RAL catalog" do
|
223
|
+
before do
|
224
|
+
@original = Puppet::Resource::Catalog.new("mynode")
|
225
|
+
@original.tag(*%w{one two three})
|
226
|
+
@original.add_class *%w{four five six}
|
227
|
+
|
228
|
+
@top = Puppet::Resource.new :class, 'top'
|
229
|
+
@topobject = Puppet::Resource.new :file, '/topobject'
|
230
|
+
@middle = Puppet::Resource.new :class, 'middle'
|
231
|
+
@middleobject = Puppet::Resource.new :file, '/middleobject'
|
232
|
+
@bottom = Puppet::Resource.new :class, 'bottom'
|
233
|
+
@bottomobject = Puppet::Resource.new :file, '/bottomobject'
|
234
|
+
|
235
|
+
@resources = [@top, @topobject, @middle, @middleobject, @bottom, @bottomobject]
|
236
|
+
|
237
|
+
@original.add_resource(*@resources)
|
238
|
+
|
239
|
+
@original.add_edge(@top, @topobject)
|
240
|
+
@original.add_edge(@top, @middle)
|
241
|
+
@original.add_edge(@middle, @middleobject)
|
242
|
+
@original.add_edge(@middle, @bottom)
|
243
|
+
@original.add_edge(@bottom, @bottomobject)
|
244
|
+
|
245
|
+
@catalog = @original.to_ral
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should add all resources as RAL instances" do
|
249
|
+
@resources.each { |resource| @catalog.resource(resource.ref).should be_instance_of(Puppet::Type) }
|
250
|
+
end
|
251
|
+
|
252
|
+
it "should copy the tag list to the new catalog" do
|
253
|
+
@catalog.tags.sort.should == @original.tags.sort
|
254
|
+
end
|
255
|
+
|
256
|
+
it "should copy the class list to the new catalog" do
|
257
|
+
@catalog.classes.should == @original.classes
|
258
|
+
end
|
259
|
+
|
260
|
+
it "should duplicate the original edges" do
|
261
|
+
@original.edges.each do |edge|
|
262
|
+
@catalog.edge?(@catalog.resource(edge.source.ref), @catalog.resource(edge.target.ref)).should be_true
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
it "should set itself as the catalog for each converted resource" do
|
267
|
+
@catalog.vertices.each { |v| v.catalog.object_id.should equal(@catalog.object_id) }
|
268
|
+
end
|
269
|
+
|
270
|
+
# This tests #931.
|
271
|
+
it "should not lose track of resources whose names vary" do
|
272
|
+
changer = Puppet::TransObject.new 'changer', 'test'
|
273
|
+
|
274
|
+
config = Puppet::Resource::Catalog.new('test')
|
275
|
+
config.add_resource(changer)
|
276
|
+
config.add_resource(@top)
|
277
|
+
|
278
|
+
config.add_edge(@top, changer)
|
279
|
+
|
280
|
+
resource = stub 'resource', :name => "changer2", :title => "changer2", :ref => "Test[changer2]", :catalog= => nil, :remove => nil
|
281
|
+
|
282
|
+
#changer is going to get duplicated as part of a fix for aliases 1094
|
283
|
+
changer.expects(:dup).returns(changer)
|
284
|
+
changer.expects(:to_ral).returns(resource)
|
285
|
+
|
286
|
+
newconfig = nil
|
287
|
+
|
288
|
+
proc { @catalog = config.to_ral }.should_not raise_error
|
289
|
+
@catalog.resource("Test[changer2]").should equal(resource)
|
290
|
+
end
|
291
|
+
|
292
|
+
after do
|
293
|
+
# Remove all resource instances.
|
294
|
+
@catalog.clear(true)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
describe "when filtering" do
|
299
|
+
before :each do
|
300
|
+
@original = Puppet::Resource::Catalog.new("mynode")
|
301
|
+
@original.tag(*%w{one two three})
|
302
|
+
@original.add_class *%w{four five six}
|
303
|
+
|
304
|
+
@r1 = stub_everything 'r1', :ref => "File[/a]"
|
305
|
+
@r1.stubs(:respond_to?).with(:ref).returns(true)
|
306
|
+
@r1.stubs(:dup).returns(@r1)
|
307
|
+
@r1.stubs(:is_a?).returns(Puppet::Resource).returns(true)
|
308
|
+
|
309
|
+
@r2 = stub_everything 'r2', :ref => "File[/b]"
|
310
|
+
@r2.stubs(:respond_to?).with(:ref).returns(true)
|
311
|
+
@r2.stubs(:dup).returns(@r2)
|
312
|
+
@r2.stubs(:is_a?).returns(Puppet::Resource).returns(true)
|
313
|
+
|
314
|
+
@resources = [@r1,@r2]
|
315
|
+
|
316
|
+
@original.add_resource(@r1,@r2)
|
317
|
+
end
|
318
|
+
|
319
|
+
it "should transform the catalog to a resource catalog" do
|
320
|
+
@original.expects(:to_catalog).with { |h,b| h == :to_resource }
|
321
|
+
|
322
|
+
@original.filter
|
323
|
+
end
|
324
|
+
|
325
|
+
it "should scan each catalog resource in turn and apply filtering block" do
|
326
|
+
@resources.each { |r| r.expects(:test?) }
|
327
|
+
@original.filter do |r|
|
328
|
+
r.test?
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
it "should filter out resources which produce true when the filter block is evaluated" do
|
333
|
+
@original.filter do |r|
|
334
|
+
r == @r1
|
335
|
+
end.resource("File[/a]").should be_nil
|
336
|
+
end
|
337
|
+
|
338
|
+
it "should not consider edges against resources that were filtered out" do
|
339
|
+
@original.add_edge(@r1,@r2)
|
340
|
+
@original.filter do |r|
|
341
|
+
r == @r1
|
342
|
+
end.edge(@r1,@r2).should be_empty
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
describe "when functioning as a resource container" do
|
347
|
+
before do
|
348
|
+
@catalog = Puppet::Resource::Catalog.new("host")
|
349
|
+
@one = Puppet::Type.type(:notify).new :name => "one"
|
350
|
+
@two = Puppet::Type.type(:notify).new :name => "two"
|
351
|
+
@dupe = Puppet::Type.type(:notify).new :name => "one"
|
352
|
+
end
|
353
|
+
|
354
|
+
it "should provide a method to add one or more resources" do
|
355
|
+
@catalog.add_resource @one, @two
|
356
|
+
@catalog.resource(@one.ref).should equal(@one)
|
357
|
+
@catalog.resource(@two.ref).should equal(@two)
|
358
|
+
end
|
359
|
+
|
360
|
+
it "should add resources to the relationship graph if it exists" do
|
361
|
+
relgraph = @catalog.relationship_graph
|
362
|
+
@catalog.add_resource @one
|
363
|
+
relgraph.should be_vertex(@one)
|
364
|
+
end
|
365
|
+
|
366
|
+
it "should yield added resources if a block is provided" do
|
367
|
+
yielded = []
|
368
|
+
@catalog.add_resource(@one, @two) { |r| yielded << r }
|
369
|
+
yielded.length.should == 2
|
370
|
+
end
|
371
|
+
|
372
|
+
it "should set itself as the resource's catalog if it is not a relationship graph" do
|
373
|
+
@one.expects(:catalog=).with(@catalog)
|
374
|
+
@catalog.add_resource @one
|
375
|
+
end
|
376
|
+
|
377
|
+
it "should make all vertices available by resource reference" do
|
378
|
+
@catalog.add_resource(@one)
|
379
|
+
@catalog.resource(@one.ref).should equal(@one)
|
380
|
+
@catalog.vertices.find { |r| r.ref == @one.ref }.should equal(@one)
|
381
|
+
end
|
382
|
+
|
383
|
+
it "should canonize how resources are referred to during retrieval when both type and title are provided" do
|
384
|
+
@catalog.add_resource(@one)
|
385
|
+
|
386
|
+
@catalog.resource("notify", "one").should equal(@one)
|
387
|
+
end
|
388
|
+
|
389
|
+
it "should canonize how resources are referred to during retrieval when just the title is provided" do
|
390
|
+
@catalog.add_resource(@one)
|
391
|
+
|
392
|
+
@catalog.resource("notify[one]", nil).should equal(@one)
|
393
|
+
end
|
394
|
+
|
395
|
+
it "should not allow two resources with the same resource reference" do
|
396
|
+
@catalog.add_resource(@one)
|
397
|
+
|
398
|
+
proc { @catalog.add_resource(@dupe) }.should raise_error(Puppet::Resource::Catalog::DuplicateResourceError)
|
399
|
+
end
|
400
|
+
|
401
|
+
it "should not store objects that do not respond to :ref" do
|
402
|
+
proc { @catalog.add_resource("thing") }.should raise_error(ArgumentError)
|
403
|
+
end
|
404
|
+
|
405
|
+
it "should remove all resources when asked" do
|
406
|
+
@catalog.add_resource @one
|
407
|
+
@catalog.add_resource @two
|
408
|
+
@one.expects :remove
|
409
|
+
@two.expects :remove
|
410
|
+
@catalog.clear(true)
|
411
|
+
end
|
412
|
+
|
413
|
+
it "should support a mechanism for finishing resources" do
|
414
|
+
@one.expects :finish
|
415
|
+
@two.expects :finish
|
416
|
+
@catalog.add_resource @one
|
417
|
+
@catalog.add_resource @two
|
418
|
+
|
419
|
+
@catalog.finalize
|
420
|
+
end
|
421
|
+
|
422
|
+
it "should make default resources when finalizing" do
|
423
|
+
@catalog.expects(:make_default_resources)
|
424
|
+
@catalog.finalize
|
425
|
+
end
|
426
|
+
|
427
|
+
it "should add default resources to the catalog upon creation" do
|
428
|
+
@catalog.make_default_resources
|
429
|
+
@catalog.resource(:schedule, "daily").should_not be_nil
|
430
|
+
end
|
431
|
+
|
432
|
+
it "should optionally support an initialization block and should finalize after such blocks" do
|
433
|
+
@one.expects :finish
|
434
|
+
@two.expects :finish
|
435
|
+
config = Puppet::Resource::Catalog.new("host") do |conf|
|
436
|
+
conf.add_resource @one
|
437
|
+
conf.add_resource @two
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
it "should inform the resource that it is the resource's catalog" do
|
442
|
+
@one.expects(:catalog=).with(@catalog)
|
443
|
+
@catalog.add_resource @one
|
444
|
+
end
|
445
|
+
|
446
|
+
it "should be able to find resources by reference" do
|
447
|
+
@catalog.add_resource @one
|
448
|
+
@catalog.resource(@one.ref).should equal(@one)
|
449
|
+
end
|
450
|
+
|
451
|
+
it "should be able to find resources by reference or by type/title tuple" do
|
452
|
+
@catalog.add_resource @one
|
453
|
+
@catalog.resource("notify", "one").should equal(@one)
|
454
|
+
end
|
455
|
+
|
456
|
+
it "should have a mechanism for removing resources" do
|
457
|
+
@catalog.add_resource @one
|
458
|
+
@one.expects :remove
|
459
|
+
@catalog.remove_resource(@one)
|
460
|
+
@catalog.resource(@one.ref).should be_nil
|
461
|
+
@catalog.vertex?(@one).should be_false
|
462
|
+
end
|
463
|
+
|
464
|
+
it "should have a method for creating aliases for resources" do
|
465
|
+
@catalog.add_resource @one
|
466
|
+
@catalog.alias(@one, "other")
|
467
|
+
@catalog.resource("notify", "other").should equal(@one)
|
468
|
+
end
|
469
|
+
|
470
|
+
it "should ignore conflicting aliases that point to the aliased resource" do
|
471
|
+
@catalog.alias(@one, "other")
|
472
|
+
lambda { @catalog.alias(@one, "other") }.should_not raise_error
|
473
|
+
end
|
474
|
+
|
475
|
+
it "should create aliases for resources isomorphic resources whose names do not match their titles" do
|
476
|
+
resource = Puppet::Type::File.new(:title => "testing", :path => "/something")
|
477
|
+
|
478
|
+
@catalog.add_resource(resource)
|
479
|
+
|
480
|
+
@catalog.resource(:file, "/something").should equal(resource)
|
481
|
+
end
|
482
|
+
|
483
|
+
it "should not create aliases for resources non-isomorphic resources whose names do not match their titles" do
|
484
|
+
resource = Puppet::Type.type(:exec).new(:title => "testing", :command => "echo", :path => %w{/bin /usr/bin /usr/local/bin})
|
485
|
+
|
486
|
+
@catalog.add_resource(resource)
|
487
|
+
|
488
|
+
# Yay, I've already got a 'should' method
|
489
|
+
@catalog.resource(:exec, "echo").object_id.should == nil.object_id
|
490
|
+
end
|
491
|
+
|
492
|
+
# This test is the same as the previous, but the behaviour should be explicit.
|
493
|
+
it "should alias using the class name from the resource reference, not the resource class name" do
|
494
|
+
@catalog.add_resource @one
|
495
|
+
@catalog.alias(@one, "other")
|
496
|
+
@catalog.resource("notify", "other").should equal(@one)
|
497
|
+
end
|
498
|
+
|
499
|
+
it "should ignore conflicting aliases that point to the aliased resource" do
|
500
|
+
@catalog.alias(@one, "other")
|
501
|
+
lambda { @catalog.alias(@one, "other") }.should_not raise_error
|
502
|
+
end
|
503
|
+
|
504
|
+
it "should fail to add an alias if the aliased name already exists" do
|
505
|
+
@catalog.add_resource @one
|
506
|
+
proc { @catalog.alias @two, "one" }.should raise_error(ArgumentError)
|
507
|
+
end
|
508
|
+
|
509
|
+
it "should not fail when a resource has duplicate aliases created" do
|
510
|
+
@catalog.add_resource @one
|
511
|
+
proc { @catalog.alias @one, "one" }.should_not raise_error
|
512
|
+
end
|
513
|
+
|
514
|
+
it "should not create aliases that point back to the resource" do
|
515
|
+
@catalog.alias(@one, "one")
|
516
|
+
@catalog.resource(:notify, "one").should be_nil
|
517
|
+
end
|
518
|
+
|
519
|
+
it "should be able to look resources up by their aliases" do
|
520
|
+
@catalog.add_resource @one
|
521
|
+
@catalog.alias @one, "two"
|
522
|
+
@catalog.resource(:notify, "two").should equal(@one)
|
523
|
+
end
|
524
|
+
|
525
|
+
it "should remove resource aliases when the target resource is removed" do
|
526
|
+
@catalog.add_resource @one
|
527
|
+
@catalog.alias(@one, "other")
|
528
|
+
@one.expects :remove
|
529
|
+
@catalog.remove_resource(@one)
|
530
|
+
@catalog.resource("notify", "other").should be_nil
|
531
|
+
end
|
532
|
+
|
533
|
+
it "should add an alias for the namevar when the title and name differ on isomorphic resource types" do
|
534
|
+
resource = Puppet::Type.type(:file).new :path => "/something", :title => "other", :content => "blah"
|
535
|
+
resource.expects(:isomorphic?).returns(true)
|
536
|
+
@catalog.add_resource(resource)
|
537
|
+
@catalog.resource(:file, "other").should equal(resource)
|
538
|
+
@catalog.resource(:file, "/something").ref.should == resource.ref
|
539
|
+
end
|
540
|
+
|
541
|
+
it "should not add an alias for the namevar when the title and name differ on non-isomorphic resource types" do
|
542
|
+
resource = Puppet::Type.type(:file).new :path => "/something", :title => "other", :content => "blah"
|
543
|
+
resource.expects(:isomorphic?).returns(false)
|
544
|
+
@catalog.add_resource(resource)
|
545
|
+
@catalog.resource(:file, resource.title).should equal(resource)
|
546
|
+
# We can't use .should here, because the resources respond to that method.
|
547
|
+
if @catalog.resource(:file, resource.name)
|
548
|
+
raise "Aliased non-isomorphic resource"
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
it "should provide a method to create additional resources that also registers the resource" do
|
553
|
+
args = {:name => "/yay", :ensure => :file}
|
554
|
+
resource = stub 'file', :ref => "File[/yay]", :catalog= => @catalog, :title => "/yay", :[] => "/yay"
|
555
|
+
Puppet::Type.type(:file).expects(:new).with(args).returns(resource)
|
556
|
+
@catalog.create_resource :file, args
|
557
|
+
@catalog.resource("File[/yay]").should equal(resource)
|
558
|
+
end
|
559
|
+
end
|
560
|
+
|
561
|
+
describe "when applying" do
|
562
|
+
before :each do
|
563
|
+
@catalog = Puppet::Resource::Catalog.new("host")
|
564
|
+
|
565
|
+
@catalog.retrieval_duration = Time.now
|
566
|
+
@transaction = mock 'transaction'
|
567
|
+
Puppet::Transaction.stubs(:new).returns(@transaction)
|
568
|
+
@transaction.stubs(:evaluate)
|
569
|
+
@transaction.stubs(:cleanup)
|
570
|
+
@transaction.stubs(:addtimes)
|
571
|
+
end
|
572
|
+
|
573
|
+
it "should create and evaluate a transaction" do
|
574
|
+
@transaction.expects(:evaluate)
|
575
|
+
@catalog.apply
|
576
|
+
end
|
577
|
+
|
578
|
+
it "should provide the catalog time to the transaction" do
|
579
|
+
@transaction.expects(:addtimes).with do |arg|
|
580
|
+
arg[:config_retrieval].should be_instance_of(Time)
|
581
|
+
true
|
582
|
+
end
|
583
|
+
@catalog.apply
|
584
|
+
end
|
585
|
+
|
586
|
+
it "should clean up the transaction" do
|
587
|
+
@transaction.expects :cleanup
|
588
|
+
@catalog.apply
|
589
|
+
end
|
590
|
+
|
591
|
+
it "should return the transaction" do
|
592
|
+
@catalog.apply.should equal(@transaction)
|
593
|
+
end
|
594
|
+
|
595
|
+
it "should yield the transaction if a block is provided" do
|
596
|
+
@catalog.apply do |trans|
|
597
|
+
trans.should equal(@transaction)
|
598
|
+
end
|
599
|
+
end
|
600
|
+
|
601
|
+
it "should default to not being a host catalog" do
|
602
|
+
@catalog.host_config.should be_nil
|
603
|
+
end
|
604
|
+
|
605
|
+
it "should pass supplied tags on to the transaction" do
|
606
|
+
@transaction.expects(:tags=).with(%w{one two})
|
607
|
+
@catalog.apply(:tags => %w{one two})
|
608
|
+
end
|
609
|
+
|
610
|
+
it "should set ignoreschedules on the transaction if specified in apply()" do
|
611
|
+
@transaction.expects(:ignoreschedules=).with(true)
|
612
|
+
@catalog.apply(:ignoreschedules => true)
|
613
|
+
end
|
614
|
+
|
615
|
+
it "should remove resources created mid-transaction" do
|
616
|
+
args = {:name => "/yay", :ensure => :file}
|
617
|
+
resource = stub 'file', :ref => "File[/yay]", :catalog= => @catalog, :title => "/yay", :[] => "/yay"
|
618
|
+
@transaction = mock 'transaction'
|
619
|
+
Puppet::Transaction.stubs(:new).returns(@transaction)
|
620
|
+
@transaction.stubs(:evaluate)
|
621
|
+
@transaction.stubs(:cleanup)
|
622
|
+
@transaction.stubs(:addtimes)
|
623
|
+
Puppet::Type.type(:file).expects(:new).with(args).returns(resource)
|
624
|
+
resource.expects :remove
|
625
|
+
@catalog.apply do |trans|
|
626
|
+
@catalog.create_resource :file, args
|
627
|
+
@catalog.resource("File[/yay]").should equal(resource)
|
628
|
+
end
|
629
|
+
@catalog.resource("File[/yay]").should be_nil
|
630
|
+
end
|
631
|
+
|
632
|
+
it "should remove resources added mid-transaction" do
|
633
|
+
@transaction = mock 'transaction'
|
634
|
+
Puppet::Transaction.stubs(:new).returns(@transaction)
|
635
|
+
@transaction.stubs(:evaluate)
|
636
|
+
@transaction.stubs(:cleanup)
|
637
|
+
@transaction.stubs(:addtimes)
|
638
|
+
file = Puppet::Type.type(:file).new(:name => "/yay", :ensure => :file)
|
639
|
+
@catalog.apply do |trans|
|
640
|
+
@catalog.add_resource file
|
641
|
+
@catalog.resource("File[/yay]").should_not be_nil
|
642
|
+
end
|
643
|
+
@catalog.resource("File[/yay]").should be_nil
|
644
|
+
end
|
645
|
+
|
646
|
+
it "should expire cached data in the resources both before and after the transaction" do
|
647
|
+
@catalog.expects(:expire).times(2)
|
648
|
+
@catalog.apply
|
649
|
+
end
|
650
|
+
|
651
|
+
describe "host catalogs" do
|
652
|
+
|
653
|
+
# super() doesn't work in the setup method for some reason
|
654
|
+
before do
|
655
|
+
@catalog.host_config = true
|
656
|
+
Puppet::Util::Storage.stubs(:store)
|
657
|
+
end
|
658
|
+
|
659
|
+
it "should send a report if reporting is enabled" do
|
660
|
+
Puppet[:report] = true
|
661
|
+
@transaction.expects :send_report
|
662
|
+
@transaction.stubs :any_failed? => false
|
663
|
+
@catalog.apply
|
664
|
+
end
|
665
|
+
|
666
|
+
it "should send a report if report summaries are enabled" do
|
667
|
+
Puppet[:summarize] = true
|
668
|
+
@transaction.expects :send_report
|
669
|
+
@transaction.stubs :any_failed? => false
|
670
|
+
@catalog.apply
|
671
|
+
end
|
672
|
+
|
673
|
+
it "should initialize the state database before applying a catalog" do
|
674
|
+
Puppet::Util::Storage.expects(:load)
|
675
|
+
|
676
|
+
# Short-circuit the apply, so we know we're loading before the transaction
|
677
|
+
Puppet::Transaction.expects(:new).raises ArgumentError
|
678
|
+
proc { @catalog.apply }.should raise_error(ArgumentError)
|
679
|
+
end
|
680
|
+
|
681
|
+
it "should sync the state database after applying" do
|
682
|
+
Puppet::Util::Storage.expects(:store)
|
683
|
+
@transaction.stubs :any_failed? => false
|
684
|
+
@catalog.apply
|
685
|
+
end
|
686
|
+
|
687
|
+
after { Puppet.settings.clear }
|
688
|
+
end
|
689
|
+
|
690
|
+
describe "non-host catalogs" do
|
691
|
+
|
692
|
+
before do
|
693
|
+
@catalog.host_config = false
|
694
|
+
end
|
695
|
+
|
696
|
+
it "should never send reports" do
|
697
|
+
Puppet[:report] = true
|
698
|
+
Puppet[:summarize] = true
|
699
|
+
@transaction.expects(:send_report).never
|
700
|
+
@catalog.apply
|
701
|
+
end
|
702
|
+
|
703
|
+
it "should never modify the state database" do
|
704
|
+
Puppet::Util::Storage.expects(:load).never
|
705
|
+
Puppet::Util::Storage.expects(:store).never
|
706
|
+
@catalog.apply
|
707
|
+
end
|
708
|
+
|
709
|
+
after { Puppet.settings.clear }
|
710
|
+
end
|
711
|
+
end
|
712
|
+
|
713
|
+
describe "when creating a relationship graph" do
|
714
|
+
before do
|
715
|
+
Puppet::Type.type(:component)
|
716
|
+
@catalog = Puppet::Resource::Catalog.new("host")
|
717
|
+
@compone = Puppet::Type::Component.new :name => "one"
|
718
|
+
@comptwo = Puppet::Type::Component.new :name => "two", :require => "Class[one]"
|
719
|
+
@file = Puppet::Type.type(:file)
|
720
|
+
@one = @file.new :path => "/one"
|
721
|
+
@two = @file.new :path => "/two"
|
722
|
+
@sub = @file.new :path => "/two/subdir"
|
723
|
+
@catalog.add_edge @compone, @one
|
724
|
+
@catalog.add_edge @comptwo, @two
|
725
|
+
|
726
|
+
@three = @file.new :path => "/three"
|
727
|
+
@four = @file.new :path => "/four", :require => "File[/three]"
|
728
|
+
@five = @file.new :path => "/five"
|
729
|
+
@catalog.add_resource @compone, @comptwo, @one, @two, @three, @four, @five, @sub
|
730
|
+
|
731
|
+
@relationships = @catalog.relationship_graph
|
732
|
+
end
|
733
|
+
|
734
|
+
it "should be able to create a relationship graph" do
|
735
|
+
@relationships.should be_instance_of(Puppet::SimpleGraph)
|
736
|
+
end
|
737
|
+
|
738
|
+
it "should not have any components" do
|
739
|
+
@relationships.vertices.find { |r| r.instance_of?(Puppet::Type::Component) }.should be_nil
|
740
|
+
end
|
741
|
+
|
742
|
+
it "should have all non-component resources from the catalog" do
|
743
|
+
# The failures print out too much info, so i just do a class comparison
|
744
|
+
@relationships.vertex?(@five).should be_true
|
745
|
+
end
|
746
|
+
|
747
|
+
it "should have all resource relationships set as edges" do
|
748
|
+
@relationships.edge?(@three, @four).should be_true
|
749
|
+
end
|
750
|
+
|
751
|
+
it "should copy component relationships to all contained resources" do
|
752
|
+
@relationships.edge?(@one, @two).should be_true
|
753
|
+
end
|
754
|
+
|
755
|
+
it "should add automatic relationships to the relationship graph" do
|
756
|
+
@relationships.edge?(@two, @sub).should be_true
|
757
|
+
end
|
758
|
+
|
759
|
+
it "should get removed when the catalog is cleaned up" do
|
760
|
+
@relationships.expects(:clear)
|
761
|
+
@catalog.clear
|
762
|
+
@catalog.instance_variable_get("@relationship_graph").should be_nil
|
763
|
+
end
|
764
|
+
|
765
|
+
it "should write :relationships and :expanded_relationships graph files if the catalog is a host catalog" do
|
766
|
+
@catalog.clear
|
767
|
+
graph = Puppet::SimpleGraph.new
|
768
|
+
Puppet::SimpleGraph.expects(:new).returns graph
|
769
|
+
|
770
|
+
graph.expects(:write_graph).with(:relationships)
|
771
|
+
graph.expects(:write_graph).with(:expanded_relationships)
|
772
|
+
|
773
|
+
@catalog.host_config = true
|
774
|
+
|
775
|
+
@catalog.relationship_graph
|
776
|
+
end
|
777
|
+
|
778
|
+
it "should not write graph files if the catalog is not a host catalog" do
|
779
|
+
@catalog.clear
|
780
|
+
graph = Puppet::SimpleGraph.new
|
781
|
+
Puppet::SimpleGraph.expects(:new).returns graph
|
782
|
+
|
783
|
+
graph.expects(:write_graph).never
|
784
|
+
|
785
|
+
@catalog.host_config = false
|
786
|
+
|
787
|
+
@catalog.relationship_graph
|
788
|
+
end
|
789
|
+
|
790
|
+
it "should create a new relationship graph after clearing the old one" do
|
791
|
+
@relationships.expects(:clear)
|
792
|
+
@catalog.clear
|
793
|
+
@catalog.relationship_graph.should be_instance_of(Puppet::SimpleGraph)
|
794
|
+
end
|
795
|
+
|
796
|
+
it "should remove removed resources from the relationship graph if it exists" do
|
797
|
+
@catalog.remove_resource(@one)
|
798
|
+
@catalog.relationship_graph.vertex?(@one).should be_false
|
799
|
+
end
|
800
|
+
end
|
801
|
+
|
802
|
+
describe "when writing dot files" do
|
803
|
+
before do
|
804
|
+
@catalog = Puppet::Resource::Catalog.new("host")
|
805
|
+
@name = :test
|
806
|
+
@file = File.join(Puppet[:graphdir], @name.to_s + ".dot")
|
807
|
+
end
|
808
|
+
|
809
|
+
it "should only write when it is a host catalog" do
|
810
|
+
File.expects(:open).with(@file).never
|
811
|
+
@catalog.host_config = false
|
812
|
+
Puppet[:graph] = true
|
813
|
+
@catalog.write_graph(@name)
|
814
|
+
end
|
815
|
+
|
816
|
+
after do
|
817
|
+
Puppet.settings.clear
|
818
|
+
end
|
819
|
+
end
|
820
|
+
|
821
|
+
describe "when indirecting" do
|
822
|
+
before do
|
823
|
+
@indirection = stub 'indirection', :name => :catalog
|
824
|
+
|
825
|
+
Puppet::Util::Cacher.expire
|
826
|
+
end
|
827
|
+
|
828
|
+
it "should redirect to the indirection for retrieval" do
|
829
|
+
Puppet::Resource::Catalog.stubs(:indirection).returns(@indirection)
|
830
|
+
@indirection.expects(:find)
|
831
|
+
Puppet::Resource::Catalog.find(:myconfig)
|
832
|
+
end
|
833
|
+
|
834
|
+
it "should default to the 'compiler' terminus" do
|
835
|
+
Puppet::Resource::Catalog.indirection.terminus_class.should == :compiler
|
836
|
+
end
|
837
|
+
|
838
|
+
after do
|
839
|
+
Puppet::Util::Cacher.expire
|
840
|
+
end
|
841
|
+
end
|
842
|
+
|
843
|
+
describe "when converting to yaml" do
|
844
|
+
before do
|
845
|
+
@catalog = Puppet::Resource::Catalog.new("me")
|
846
|
+
@catalog.add_edge("one", "two")
|
847
|
+
end
|
848
|
+
|
849
|
+
it "should be able to be dumped to yaml" do
|
850
|
+
YAML.dump(@catalog).should be_instance_of(String)
|
851
|
+
end
|
852
|
+
end
|
853
|
+
|
854
|
+
describe "when converting from yaml" do
|
855
|
+
before do
|
856
|
+
@catalog = Puppet::Resource::Catalog.new("me")
|
857
|
+
@catalog.add_edge("one", "two")
|
858
|
+
|
859
|
+
text = YAML.dump(@catalog)
|
860
|
+
@newcatalog = YAML.load(text)
|
861
|
+
end
|
862
|
+
|
863
|
+
it "should get converted back to a catalog" do
|
864
|
+
@newcatalog.should be_instance_of(Puppet::Resource::Catalog)
|
865
|
+
end
|
866
|
+
|
867
|
+
it "should have all vertices" do
|
868
|
+
@newcatalog.vertex?("one").should be_true
|
869
|
+
@newcatalog.vertex?("two").should be_true
|
870
|
+
end
|
871
|
+
|
872
|
+
it "should have all edges" do
|
873
|
+
@newcatalog.edge?("one", "two").should be_true
|
874
|
+
end
|
875
|
+
end
|
876
|
+
end
|
877
|
+
|
878
|
+
describe Puppet::Resource::Catalog, "when converting to json" do
|
879
|
+
confine "Missing 'json' library" => Puppet.features.json?
|
880
|
+
|
881
|
+
before do
|
882
|
+
@catalog = Puppet::Resource::Catalog.new("myhost")
|
883
|
+
end
|
884
|
+
|
885
|
+
def json_output_should
|
886
|
+
@catalog.class.expects(:json_create).with { |hash| yield hash }
|
887
|
+
end
|
888
|
+
|
889
|
+
# LAK:NOTE For all of these tests, we convert back to the resource so we can
|
890
|
+
# trap the actual data structure then.
|
891
|
+
it "should set its json_class to 'Puppet::Resource::Catalog'" do
|
892
|
+
json_output_should { |hash| hash['json_class'] == "Puppet::Resource::Catalog" }
|
893
|
+
|
894
|
+
JSON.parse @catalog.to_json
|
895
|
+
end
|
896
|
+
|
897
|
+
it "should set its data as a hash" do
|
898
|
+
json_output_should { |hash| hash['data'].is_a?(Hash) }
|
899
|
+
JSON.parse @catalog.to_json
|
900
|
+
end
|
901
|
+
|
902
|
+
[:name, :version, :tags].each do |param|
|
903
|
+
it "should set its #{param} to the #{param} of the resource" do
|
904
|
+
@catalog.send(param.to_s + "=", "testing") unless @catalog.send(param)
|
905
|
+
|
906
|
+
json_output_should { |hash| hash['data'][param.to_s] == @catalog.send(param) }
|
907
|
+
JSON.parse @catalog.to_json
|
908
|
+
end
|
909
|
+
end
|
910
|
+
|
911
|
+
it "should convert its resources to a JSON-encoded array and store it as the 'resources' data" do
|
912
|
+
one = stub 'one', :to_json => '"one_resource"', :ref => "Foo[one]"
|
913
|
+
two = stub 'two', :to_json => '"two_resource"', :ref => "Foo[two]"
|
914
|
+
|
915
|
+
@catalog.add_resource(one)
|
916
|
+
@catalog.add_resource(two)
|
917
|
+
|
918
|
+
# TODO this should really guarantee sort order
|
919
|
+
json_output_should { |hash| JSON.parse(hash['data']['resources']).sort == ["one_resource", "two_resource"].sort }
|
920
|
+
JSON.parse @catalog.to_json
|
921
|
+
end
|
922
|
+
|
923
|
+
it "should convert its edges to a JSON-encoded array and store it as the 'edges' data" do
|
924
|
+
one = stub 'one', :to_json => '"one_resource"', :ref => 'Foo[one]'
|
925
|
+
two = stub 'two', :to_json => '"two_resource"', :ref => 'Foo[two]'
|
926
|
+
three = stub 'three', :to_json => '"three_resource"', :ref => 'Foo[three]'
|
927
|
+
|
928
|
+
@catalog.add_edge(one, two)
|
929
|
+
@catalog.add_edge(two, three)
|
930
|
+
|
931
|
+
@catalog.edge(one, two).expects(:to_json).returns '"one_two_json"'
|
932
|
+
@catalog.edge(two, three).expects(:to_json).returns '"two_three_json"'
|
933
|
+
|
934
|
+
json_output_should { |hash| JSON.parse(hash['data']['edges']).sort == %w{one_two_json two_three_json}.sort }
|
935
|
+
JSON.parse @catalog.to_json
|
936
|
+
end
|
937
|
+
end
|
938
|
+
|
939
|
+
describe Puppet::Resource::Catalog, "when converting from json" do
|
940
|
+
confine "Missing 'json' library" => Puppet.features.json?
|
941
|
+
|
942
|
+
def json_result_should
|
943
|
+
Puppet::Resource::Catalog.expects(:new).with { |hash| yield hash }
|
944
|
+
end
|
945
|
+
|
946
|
+
before do
|
947
|
+
@data = {
|
948
|
+
'name' => "myhost"
|
949
|
+
}
|
950
|
+
@json = {
|
951
|
+
'json_class' => 'Puppet::Resource::Catalog',
|
952
|
+
'data' => @data
|
953
|
+
}
|
954
|
+
|
955
|
+
@catalog = Puppet::Resource::Catalog.new("myhost")
|
956
|
+
Puppet::Resource::Catalog.stubs(:new).returns @catalog
|
957
|
+
end
|
958
|
+
|
959
|
+
it "should be extended with the JSON utility module" do
|
960
|
+
Puppet::Resource::Catalog.metaclass.ancestors.should be_include(Puppet::Util::Json)
|
961
|
+
end
|
962
|
+
|
963
|
+
it "should create it with the provided name" do
|
964
|
+
Puppet::Resource::Catalog.expects(:new).with('myhost').returns @catalog
|
965
|
+
JSON.parse @json.to_json
|
966
|
+
end
|
967
|
+
|
968
|
+
it "should set the provided version on the catalog if one is set" do
|
969
|
+
@data['version'] = 50
|
970
|
+
@catalog.expects(:version=).with(@data['version'])
|
971
|
+
|
972
|
+
JSON.parse @json.to_json
|
973
|
+
end
|
974
|
+
|
975
|
+
it "should set any provided tags on the catalog" do
|
976
|
+
@data['tags'] = %w{one two}
|
977
|
+
@catalog.expects(:tag).with("one", "two")
|
978
|
+
|
979
|
+
JSON.parse @json.to_json
|
980
|
+
end
|
981
|
+
|
982
|
+
it 'should convert the resources list into resources and add each of them' do
|
983
|
+
@data['resources'] = [Puppet::Resource.new(:file, "/foo"), Puppet::Resource.new(:file, "/bar")]
|
984
|
+
|
985
|
+
@catalog.expects(:add_resource).times(2).with { |res| res.type == "File" }
|
986
|
+
|
987
|
+
JSON.parse @json.to_json
|
988
|
+
end
|
989
|
+
|
990
|
+
it 'should convert resources even if they do not include "json_class" information' do
|
991
|
+
@data['resources'] = [Puppet::Resource.new(:file, "/foo")]
|
992
|
+
|
993
|
+
@data['resources'][0].expects(:to_json).returns "{\"title\":\"\\/foo\",\"tags\":[\"file\"],\"type\":\"File\"}"
|
994
|
+
|
995
|
+
@catalog.expects(:add_resource).with { |res| res.type == "File" }
|
996
|
+
|
997
|
+
JSON.parse @json.to_json
|
998
|
+
end
|
999
|
+
|
1000
|
+
it 'should convert the edges list into edges and add each of them' do
|
1001
|
+
one = Puppet::Relationship.new("osource", "otarget", :event => "one", :callback => "refresh")
|
1002
|
+
two = Puppet::Relationship.new("tsource", "ttarget", :event => "two", :callback => "refresh")
|
1003
|
+
|
1004
|
+
@data['edges'] = [one, two]
|
1005
|
+
|
1006
|
+
@catalog.stubs(:resource).returns("eh")
|
1007
|
+
|
1008
|
+
@catalog.expects(:add_edge).with { |edge| edge.event == "one" }
|
1009
|
+
@catalog.expects(:add_edge).with { |edge| edge.event == "two" }
|
1010
|
+
|
1011
|
+
JSON.parse @json.to_json
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
it "should be able to convert relationships that do not include 'json_class' information" do
|
1015
|
+
one = Puppet::Relationship.new("osource", "otarget", :event => "one", :callback => "refresh")
|
1016
|
+
one.expects(:to_json).returns "{\"event\":\"one\",\"callback\":\"refresh\",\"source\":\"osource\",\"target\":\"otarget\"}"
|
1017
|
+
|
1018
|
+
@data['edges'] = [one]
|
1019
|
+
|
1020
|
+
@catalog.stubs(:resource).returns("eh")
|
1021
|
+
|
1022
|
+
@catalog.expects(:add_edge).with { |edge| edge.event == "one" }
|
1023
|
+
|
1024
|
+
JSON.parse @json.to_json
|
1025
|
+
end
|
1026
|
+
|
1027
|
+
it "should set the source and target for each edge to the actual resource" do
|
1028
|
+
edge = Puppet::Relationship.new("source", "target")
|
1029
|
+
|
1030
|
+
@data['edges'] = [edge]
|
1031
|
+
|
1032
|
+
@catalog.expects(:resource).with("source").returns("source_resource")
|
1033
|
+
@catalog.expects(:resource).with("target").returns("target_resource")
|
1034
|
+
|
1035
|
+
@catalog.expects(:add_edge).with { |edge| edge.source == "source_resource" and edge.target == "target_resource" }
|
1036
|
+
|
1037
|
+
JSON.parse @json.to_json
|
1038
|
+
end
|
1039
|
+
|
1040
|
+
it "should fail if the source resource cannot be found" do
|
1041
|
+
edge = Puppet::Relationship.new("source", "target")
|
1042
|
+
|
1043
|
+
@data['edges'] = [edge]
|
1044
|
+
|
1045
|
+
@catalog.expects(:resource).with("source").returns(nil)
|
1046
|
+
@catalog.stubs(:resource).with("target").returns("target_resource")
|
1047
|
+
|
1048
|
+
lambda { JSON.parse @json.to_json }.should raise_error(ArgumentError)
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
it "should fail if the target resource cannot be found" do
|
1052
|
+
edge = Puppet::Relationship.new("source", "target")
|
1053
|
+
|
1054
|
+
@data['edges'] = [edge]
|
1055
|
+
|
1056
|
+
@catalog.stubs(:resource).with("source").returns("source_resource")
|
1057
|
+
@catalog.expects(:resource).with("target").returns(nil)
|
1058
|
+
|
1059
|
+
lambda { JSON.parse @json.to_json }.should raise_error(ArgumentError)
|
1060
|
+
end
|
1061
|
+
end
|