puppet 2.6.18 → 2.7.1
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 +733 -187
- data/LICENSE +13 -13
- data/README.md +5 -9
- data/Rakefile +1 -1
- data/conf/auth.conf +8 -3
- data/conf/redhat/puppet.spec +21 -110
- data/conf/solaris/pkginfo +3 -4
- data/conf/suse/puppet.spec +1 -1
- data/ext/cert_inspector +140 -0
- data/ext/nagios/naggen +12 -5
- data/ext/puppet-test +11 -5
- data/ext/vim/README +1 -2
- data/ext/yaml_nodes.rb +11 -5
- data/install.rb +1 -54
- data/lib/puppet.rb +6 -10
- data/lib/puppet/application.rb +23 -32
- data/lib/puppet/application/agent.rb +228 -7
- data/lib/puppet/application/apply.rb +108 -36
- data/lib/puppet/application/catalog.rb +4 -0
- data/lib/puppet/application/cert.rb +128 -17
- data/lib/puppet/application/certificate.rb +18 -0
- data/lib/puppet/application/certificate_request.rb +4 -0
- data/lib/puppet/application/certificate_revocation_list.rb +4 -0
- data/lib/puppet/application/config.rb +4 -0
- data/lib/puppet/application/describe.rb +53 -0
- data/lib/puppet/application/device.rb +255 -0
- data/lib/puppet/application/doc.rb +92 -6
- data/lib/puppet/application/face_base.rb +246 -0
- data/lib/puppet/application/facts.rb +4 -0
- data/lib/puppet/application/file.rb +4 -0
- data/lib/puppet/application/filebucket.rb +102 -0
- data/lib/puppet/application/help.rb +4 -0
- data/lib/puppet/application/indirection_base.rb +4 -0
- data/lib/puppet/application/inspect.rb +21 -23
- data/lib/puppet/application/key.rb +4 -0
- data/lib/puppet/application/kick.rb +131 -4
- data/lib/puppet/application/man.rb +4 -0
- data/lib/puppet/application/master.rb +108 -40
- data/lib/puppet/application/node.rb +4 -0
- data/lib/puppet/application/parser.rb +5 -0
- data/lib/puppet/application/plugin.rb +3 -0
- data/lib/puppet/application/queue.rb +75 -13
- data/lib/puppet/application/report.rb +4 -0
- data/lib/puppet/application/resource.rb +115 -23
- data/lib/puppet/application/resource_type.rb +4 -0
- data/lib/puppet/application/secret_agent.rb +6 -0
- data/lib/puppet/application/status.rb +4 -0
- data/lib/puppet/configurer.rb +57 -61
- data/lib/puppet/configurer/fact_handler.rb +1 -6
- data/lib/puppet/daemon.rb +2 -2
- data/lib/puppet/defaults.rb +30 -88
- data/lib/puppet/dsl/resource_type_api.rb +19 -31
- data/lib/puppet/external/nagios/parser.rb +1 -1
- data/lib/puppet/face.rb +12 -0
- data/lib/puppet/face/catalog.rb +130 -0
- data/lib/puppet/face/catalog/select.rb +49 -0
- data/lib/puppet/face/certificate.rb +115 -0
- data/lib/puppet/face/certificate_request.rb +55 -0
- data/lib/puppet/face/certificate_revocation_list.rb +60 -0
- data/lib/puppet/face/config.rb +45 -0
- data/lib/puppet/face/facts.rb +81 -0
- data/lib/puppet/face/file.rb +47 -0
- data/lib/puppet/face/file/download.rb +54 -0
- data/lib/puppet/face/file/store.rb +21 -0
- data/lib/puppet/face/help.rb +131 -0
- data/lib/puppet/face/help/action.erb +53 -0
- data/lib/puppet/face/help/face.erb +79 -0
- data/lib/puppet/face/help/global.erb +19 -0
- data/lib/puppet/face/help/man.erb +136 -0
- data/lib/puppet/face/key.rb +15 -0
- data/lib/puppet/face/man.rb +93 -0
- data/lib/puppet/face/node.rb +43 -0
- data/lib/puppet/face/parser.rb +42 -0
- data/lib/puppet/face/plugin.rb +55 -0
- data/lib/puppet/face/report.rb +56 -0
- data/lib/puppet/face/resource.rb +53 -0
- data/lib/puppet/face/resource_type.rb +81 -0
- data/lib/puppet/face/secret_agent.rb +54 -0
- data/lib/puppet/face/status.rb +52 -0
- data/lib/puppet/feature/ssh.rb +4 -0
- data/lib/puppet/file_bucket/dipper.rb +3 -3
- data/lib/puppet/file_bucket/file.rb +6 -5
- data/lib/puppet/file_bucket/file/indirection_hooks.rb +9 -0
- data/lib/puppet/file_serving/configuration.rb +1 -2
- data/lib/puppet/file_serving/content.rb +2 -1
- data/lib/puppet/file_serving/{terminus_selector.rb → indirection_hooks.rb} +3 -2
- data/lib/puppet/file_serving/metadata.rb +2 -1
- data/lib/puppet/file_serving/mount/modules.rb +5 -4
- data/lib/puppet/indirector.rb +16 -43
- data/lib/puppet/indirector/catalog/active_record.rb +1 -1
- data/lib/puppet/indirector/catalog/compiler.rb +5 -15
- data/lib/puppet/indirector/catalog/static_compiler.rb +137 -0
- data/lib/puppet/indirector/certificate_request/ca.rb +8 -0
- data/lib/puppet/indirector/certificate_status.rb +4 -0
- data/lib/puppet/indirector/certificate_status/file.rb +82 -0
- data/lib/puppet/indirector/certificate_status/rest.rb +10 -0
- data/lib/puppet/indirector/couch.rb +5 -3
- data/lib/puppet/indirector/exec.rb +3 -3
- data/lib/puppet/indirector/face.rb +127 -0
- data/lib/puppet/indirector/facts/network_device.rb +25 -0
- data/lib/puppet/indirector/file.rb +79 -0
- data/lib/puppet/indirector/file_bucket_file/file.rb +0 -4
- data/lib/puppet/indirector/indirection.rb +1 -2
- data/lib/puppet/indirector/inventory/yaml.rb +81 -0
- data/lib/puppet/indirector/report/processor.rb +0 -2
- data/lib/puppet/indirector/request.rb +0 -4
- data/lib/puppet/indirector/resource/ral.rb +0 -4
- data/lib/puppet/indirector/resource_type/parser.rb +19 -3
- data/lib/puppet/indirector/rest.rb +11 -5
- data/lib/puppet/indirector/run/local.rb +0 -4
- data/lib/puppet/indirector/ssl_file.rb +1 -5
- data/lib/puppet/indirector/terminus.rb +3 -26
- data/lib/puppet/indirector/yaml.rb +0 -5
- data/lib/puppet/interface.rb +156 -0
- data/lib/puppet/interface/action.rb +284 -0
- data/lib/puppet/interface/action_builder.rb +74 -0
- data/lib/puppet/interface/action_manager.rb +70 -0
- data/lib/puppet/interface/documentation.rb +230 -0
- data/lib/puppet/interface/face_collection.rb +137 -0
- data/lib/puppet/interface/option.rb +108 -0
- data/lib/puppet/interface/option_builder.rb +54 -0
- data/lib/puppet/interface/option_manager.rb +67 -0
- data/lib/puppet/metatype/manager.rb +20 -7
- data/lib/puppet/module.rb +1 -1
- data/lib/puppet/network/client.rb +179 -0
- data/lib/puppet/network/client/ca.rb +56 -0
- data/lib/puppet/network/client/file.rb +6 -0
- data/lib/puppet/network/client/proxy.rb +27 -0
- data/lib/puppet/network/client/report.rb +26 -0
- data/lib/puppet/network/client/runner.rb +10 -0
- data/lib/puppet/network/client/status.rb +4 -0
- data/lib/puppet/network/format.rb +1 -1
- data/lib/puppet/network/formats.rb +63 -0
- data/lib/puppet/network/handler/ca.rb +106 -16
- data/lib/puppet/network/handler/filebucket.rb +2 -4
- data/lib/puppet/network/handler/fileserver.rb +3 -2
- data/lib/puppet/network/handler/master.rb +5 -3
- data/lib/puppet/network/handler/report.rb +0 -2
- data/lib/puppet/network/handler/runner.rb +0 -2
- data/lib/puppet/network/handler/status.rb +0 -2
- data/lib/puppet/network/http/api/v1.rb +11 -3
- data/lib/puppet/network/http/handler.rb +26 -35
- data/lib/puppet/network/http/rack/rest.rb +2 -7
- data/lib/puppet/network/http/webrick.rb +1 -2
- data/lib/puppet/network/http_pool.rb +8 -17
- data/lib/puppet/network/http_server/mongrel.rb +1 -0
- data/lib/puppet/network/http_server/webrick.rb +155 -0
- data/lib/puppet/network/rest_authconfig.rb +4 -3
- data/lib/puppet/network/rest_authorization.rb +2 -2
- data/lib/puppet/network/rights.rb +4 -9
- data/lib/puppet/network/server.rb +1 -1
- data/lib/puppet/network/xmlrpc/client.rb +211 -0
- data/lib/puppet/node.rb +2 -1
- data/lib/puppet/node/environment.rb +30 -3
- data/lib/puppet/node/facts.rb +15 -15
- data/lib/puppet/node/inventory.rb +7 -0
- data/lib/puppet/parser/ast.rb +6 -2
- data/lib/puppet/parser/ast/astarray.rb +12 -23
- data/lib/puppet/parser/ast/caseopt.rb +12 -24
- data/lib/puppet/parser/ast/definition.rb +17 -0
- data/lib/puppet/parser/ast/hostclass.rb +29 -0
- data/lib/puppet/parser/ast/leaf.rb +2 -2
- data/lib/puppet/parser/ast/node.rb +20 -0
- data/lib/puppet/parser/ast/resource.rb +42 -50
- data/lib/puppet/parser/ast/resource_instance.rb +9 -0
- data/lib/puppet/parser/ast/resource_override.rb +2 -3
- data/lib/puppet/parser/ast/resource_reference.rb +1 -1
- data/lib/puppet/parser/ast/top_level_construct.rb +4 -0
- data/lib/puppet/parser/ast/vardef.rb +1 -1
- data/lib/puppet/parser/compiler.rb +16 -17
- data/lib/puppet/parser/functions/create_resources.rb +47 -0
- data/lib/puppet/parser/functions/extlookup.rb +2 -7
- data/lib/puppet/parser/functions/fqdn_rand.rb +2 -2
- data/lib/puppet/parser/functions/sha1.rb +1 -1
- data/lib/puppet/parser/grammar.ra +67 -144
- data/lib/puppet/parser/lexer.rb +1 -1
- data/lib/puppet/parser/parser.rb +1190 -1262
- data/lib/puppet/parser/parser_support.rb +48 -73
- data/lib/puppet/parser/resource.rb +2 -19
- data/lib/puppet/parser/scope.rb +33 -103
- data/lib/puppet/parser/templatewrapper.rb +21 -22
- data/lib/puppet/parser/type_loader.rb +60 -35
- data/lib/puppet/provider/aixobject.rb +393 -0
- data/lib/puppet/provider/augeas/augeas.rb +37 -15
- data/lib/puppet/provider/cisco.rb +9 -0
- data/lib/puppet/provider/cron/crontab.rb +1 -7
- data/lib/puppet/provider/exec/posix.rb +3 -6
- data/lib/puppet/provider/exec/shell.rb +2 -11
- data/lib/puppet/provider/file/posix.rb +1 -1
- data/lib/puppet/provider/file/win32.rb +1 -1
- data/lib/puppet/provider/group/aix.rb +141 -0
- data/lib/puppet/provider/group/directoryservice.rb +0 -14
- data/lib/puppet/provider/host/parsed.rb +23 -55
- data/lib/puppet/provider/interface/base.rb +0 -0
- data/lib/puppet/provider/interface/cisco.rb +27 -0
- data/lib/puppet/provider/mcx/mcxcontent.rb +57 -96
- data/lib/puppet/provider/mount/parsed.rb +1 -1
- data/lib/puppet/provider/naginator.rb +1 -9
- data/lib/puppet/provider/nameservice/directoryservice.rb +41 -26
- data/lib/puppet/provider/network_device.rb +68 -0
- data/lib/puppet/provider/package/appdmg.rb +13 -13
- data/lib/puppet/provider/package/aptitude.rb +0 -1
- data/lib/puppet/provider/package/pip.rb +109 -0
- data/lib/puppet/provider/package/pkgdmg.rb +24 -32
- data/lib/puppet/provider/package/pkgutil.rb +175 -0
- data/lib/puppet/provider/package/yum.rb +8 -1
- data/lib/puppet/provider/service/daemontools.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +1 -1
- data/lib/puppet/provider/service/smf.rb +3 -3
- data/lib/puppet/provider/service/upstart.rb +73 -0
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +9 -10
- data/lib/puppet/provider/user/aix.rb +353 -0
- data/lib/puppet/provider/user/directoryservice.rb +0 -14
- data/lib/puppet/provider/user/user_role_add.rb +17 -32
- data/lib/puppet/provider/vlan/cisco.rb +28 -0
- data/lib/puppet/provider/zfs/solaris.rb +1 -1
- data/lib/puppet/provider/zone/solaris.rb +3 -0
- data/lib/puppet/provider/zpool/solaris.rb +7 -5
- data/lib/puppet/rails.rb +1 -1
- data/lib/puppet/rails/benchmark.rb +1 -1
- data/lib/puppet/rails/fact_name.rb +1 -0
- data/lib/puppet/rails/host.rb +0 -7
- data/lib/puppet/reference/configuration.rb +26 -101
- data/lib/puppet/reports/store.rb +3 -7
- data/lib/puppet/resource.rb +1 -1
- data/lib/puppet/resource/catalog.rb +86 -36
- data/lib/puppet/resource/type.rb +10 -15
- data/lib/puppet/resource/type_collection.rb +55 -63
- data/lib/puppet/simple_graph.rb +370 -269
- data/lib/puppet/ssl/base.rb +0 -8
- data/lib/puppet/ssl/certificate.rb +0 -6
- data/lib/puppet/ssl/certificate_authority.rb +24 -109
- data/lib/puppet/ssl/certificate_authority/interface.rb +19 -66
- data/lib/puppet/ssl/certificate_factory.rb +91 -112
- data/lib/puppet/ssl/certificate_request.rb +15 -98
- data/lib/puppet/ssl/certificate_revocation_list.rb +1 -1
- data/lib/puppet/ssl/host.rb +85 -51
- data/lib/puppet/ssl/inventory.rb +1 -1
- data/lib/puppet/sslcertificates.rb +146 -0
- data/lib/puppet/sslcertificates/ca.rb +375 -0
- data/lib/puppet/sslcertificates/certificate.rb +255 -0
- data/lib/puppet/sslcertificates/inventory.rb +38 -0
- data/lib/puppet/sslcertificates/support.rb +146 -0
- data/lib/puppet/status.rb +1 -1
- data/lib/puppet/transaction.rb +163 -94
- data/lib/puppet/transaction/event.rb +1 -1
- data/lib/puppet/transaction/event_manager.rb +19 -3
- data/lib/puppet/transaction/report.rb +9 -3
- data/lib/puppet/type.rb +107 -62
- data/lib/puppet/type/augeas.rb +10 -14
- data/lib/puppet/type/cron.rb +13 -14
- data/lib/puppet/type/exec.rb +0 -9
- data/lib/puppet/type/file.rb +20 -29
- data/lib/puppet/type/file/ctime.rb +1 -1
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/group.rb +1 -1
- data/lib/puppet/type/file/mode.rb +1 -1
- data/lib/puppet/type/file/mtime.rb +1 -1
- data/lib/puppet/type/file/selcontext.rb +1 -1
- data/lib/puppet/type/file/source.rb +3 -3
- data/lib/puppet/type/file/type.rb +1 -1
- data/lib/puppet/type/group.rb +36 -0
- data/lib/puppet/type/host.rb +18 -43
- data/lib/puppet/type/interface.rb +109 -0
- data/lib/puppet/type/k5login.rb +1 -4
- data/lib/puppet/type/macauthorization.rb +3 -3
- data/lib/puppet/type/mcx.rb +2 -21
- data/lib/puppet/type/router.rb +14 -0
- data/lib/puppet/type/schedule.rb +2 -0
- data/lib/puppet/type/service.rb +2 -0
- data/lib/puppet/type/sshkey.rb +6 -1
- data/lib/puppet/type/tidy.rb +12 -12
- data/lib/puppet/type/user.rb +36 -9
- data/lib/puppet/type/vlan.rb +26 -0
- data/lib/puppet/type/whit.rb +13 -1
- data/lib/puppet/type/zfs.rb +100 -8
- data/lib/puppet/type/zone.rb +45 -1
- data/lib/puppet/type/zpool.rb +1 -0
- data/lib/puppet/util.rb +63 -91
- data/lib/puppet/util/autoload.rb +16 -14
- data/lib/puppet/util/classgen.rb +13 -1
- data/lib/puppet/util/command_line.rb +109 -22
- data/lib/puppet/util/log.rb +1 -0
- data/lib/puppet/util/log/destinations.rb +16 -4
- data/lib/puppet/util/logging.rb +11 -0
- data/lib/puppet/util/monkey_patches.rb +7 -77
- data/lib/puppet/util/network_device.rb +17 -0
- data/lib/puppet/util/network_device/base.rb +27 -0
- data/lib/puppet/util/network_device/cisco.rb +4 -0
- data/lib/puppet/util/network_device/cisco/device.rb +256 -0
- data/lib/puppet/util/network_device/cisco/facts.rb +72 -0
- data/lib/puppet/util/network_device/cisco/interface.rb +82 -0
- data/lib/puppet/util/network_device/config.rb +93 -0
- data/lib/puppet/util/network_device/ipcalc.rb +68 -0
- data/lib/puppet/util/network_device/transport.rb +3 -0
- data/lib/puppet/util/network_device/transport/base.rb +26 -0
- data/lib/puppet/util/network_device/transport/ssh.rb +121 -0
- data/lib/puppet/util/network_device/transport/telnet.rb +42 -0
- data/lib/puppet/util/rdoc.rb +4 -10
- data/lib/puppet/util/rdoc/parser.rb +34 -23
- data/lib/puppet/util/reference.rb +7 -8
- data/lib/puppet/util/selinux.rb +2 -2
- data/lib/puppet/util/settings.rb +1 -6
- data/lib/puppet/util/settings/file_setting.rb +0 -1
- data/lib/puppet/util/suidmanager.rb +30 -79
- data/lib/puppet/util/zaml.rb +41 -40
- data/man/man5/puppet.conf.5 +291 -873
- data/man/man8/filebucket.8 +47 -71
- data/man/man8/pi.8 +44 -10
- data/man/man8/puppet-agent.8 +154 -0
- data/man/man8/puppet-apply.8 +75 -0
- data/man/man8/puppet-catalog.8 +286 -0
- data/man/man8/puppet-cert.8 +97 -0
- data/man/man8/puppet-certificate.8 +229 -0
- data/man/man8/puppet-certificate_request.8 +168 -0
- data/man/man8/puppet-certificate_revocation_list.8 +165 -0
- data/man/man8/puppet-config.8 +80 -0
- data/man/man8/puppet-describe.8 +51 -0
- data/man/man8/puppet-device.8 +86 -0
- data/man/man8/puppet-doc.8 +101 -0
- data/man/man8/puppet-facts.8 +217 -0
- data/man/man8/puppet-file.8 +225 -0
- data/man/man8/puppet-filebucket.8 +81 -0
- data/man/man8/puppet-help.8 +71 -0
- data/man/man8/puppet-inspect.8 +28 -0
- data/man/man8/puppet-key.8 +126 -0
- data/man/man8/puppet-kick.8 +95 -0
- data/man/man8/puppet-man.8 +74 -0
- data/man/man8/puppet-master.8 +74 -0
- data/man/man8/puppet-node.8 +171 -0
- data/man/man8/puppet-parser.8 +71 -0
- data/man/man8/puppet-plugin.8 +77 -0
- data/man/man8/puppet-queue.8 +55 -0
- data/man/man8/puppet-report.8 +187 -0
- data/man/man8/puppet-resource.8 +84 -0
- data/man/man8/puppet-resource_type.8 +214 -0
- data/man/man8/puppet-secret_agent.8 +74 -0
- data/man/man8/puppet-status.8 +150 -0
- data/man/man8/puppet.8 +2 -2
- data/man/man8/puppetca.8 +64 -136
- data/man/man8/puppetd.8 +99 -228
- data/man/man8/puppetdoc.8 +41 -48
- data/man/man8/puppetmasterd.8 +54 -32
- data/man/man8/puppetqd.8 +45 -10
- data/man/man8/puppetrun.8 +56 -134
- data/man/man8/ralsh.8 +48 -49
- data/spec/fixtures/faulty_face/puppet/face/syntax.rb +8 -0
- data/spec/fixtures/integration/provider/mailalias/aliases/test1 +28 -0
- data/spec/fixtures/unit/parser/lexer/aliastest.pp +16 -0
- data/spec/fixtures/unit/parser/lexer/append.pp +11 -0
- data/spec/fixtures/unit/parser/lexer/argumentdefaults.pp +14 -0
- data/spec/fixtures/unit/parser/lexer/arithmetic_expression.pp +8 -0
- data/spec/fixtures/unit/parser/lexer/arraytrailingcomma.pp +3 -0
- data/spec/fixtures/unit/parser/lexer/casestatement.pp +65 -0
- data/spec/fixtures/unit/parser/lexer/classheirarchy.pp +15 -0
- data/spec/fixtures/unit/parser/lexer/classincludes.pp +17 -0
- data/spec/fixtures/unit/parser/lexer/classpathtest.pp +11 -0
- data/spec/fixtures/unit/parser/lexer/collection.pp +10 -0
- data/spec/fixtures/unit/parser/lexer/collection_override.pp +8 -0
- data/spec/fixtures/unit/parser/lexer/collection_within_virtual_definitions.pp +20 -0
- data/spec/fixtures/unit/parser/lexer/componentmetaparams.pp +11 -0
- data/spec/fixtures/unit/parser/lexer/componentrequire.pp +8 -0
- data/spec/fixtures/unit/parser/lexer/deepclassheirarchy.pp +23 -0
- data/spec/fixtures/unit/parser/lexer/defineoverrides.pp +17 -0
- data/spec/fixtures/unit/parser/lexer/emptyclass.pp +9 -0
- data/spec/fixtures/unit/parser/lexer/emptyexec.pp +3 -0
- data/spec/fixtures/unit/parser/lexer/emptyifelse.pp +9 -0
- data/spec/fixtures/unit/parser/lexer/falsevalues.pp +3 -0
- data/spec/fixtures/unit/parser/lexer/filecreate.pp +11 -0
- data/spec/fixtures/unit/parser/lexer/fqdefinition.pp +5 -0
- data/spec/fixtures/unit/parser/lexer/fqparents.pp +11 -0
- data/spec/fixtures/unit/parser/lexer/funccomma.pp +5 -0
- data/spec/fixtures/unit/parser/lexer/hash.pp +33 -0
- data/spec/fixtures/unit/parser/lexer/ifexpression.pp +12 -0
- data/spec/fixtures/unit/parser/lexer/implicititeration.pp +15 -0
- data/spec/fixtures/unit/parser/lexer/multilinecomments.pp +10 -0
- data/spec/fixtures/unit/parser/lexer/multipleclass.pp +9 -0
- data/spec/fixtures/unit/parser/lexer/multipleinstances.pp +7 -0
- data/spec/fixtures/unit/parser/lexer/multisubs.pp +13 -0
- data/spec/fixtures/unit/parser/lexer/namevartest.pp +9 -0
- data/spec/fixtures/unit/parser/lexer/scopetest.pp +13 -0
- data/spec/fixtures/unit/parser/lexer/selectorvalues.pp +49 -0
- data/spec/fixtures/unit/parser/lexer/simpledefaults.pp +5 -0
- data/spec/fixtures/unit/parser/lexer/simpleselector.pp +38 -0
- data/spec/fixtures/unit/parser/lexer/singleary.pp +19 -0
- data/spec/fixtures/unit/parser/lexer/singlequote.pp +11 -0
- data/spec/fixtures/unit/parser/lexer/singleselector.pp +22 -0
- data/spec/fixtures/unit/parser/lexer/subclass_name_duplication.pp +11 -0
- data/spec/fixtures/unit/parser/lexer/tag.pp +9 -0
- data/spec/fixtures/unit/parser/lexer/tagged.pp +35 -0
- data/spec/fixtures/unit/parser/lexer/virtualresources.pp +14 -0
- data/spec/fixtures/unit/provider/host/parsed/valid_hosts +19 -0
- data/spec/fixtures/unit/provider/mount/parsed/aix.filesystems +144 -0
- data/spec/fixtures/unit/provider/mount/parsed/aix.mount +7 -0
- data/spec/fixtures/unit/provider/mount/parsed/darwin.mount +6 -0
- data/spec/fixtures/unit/provider/mount/parsed/freebsd.fstab +8 -0
- data/spec/fixtures/unit/provider/mount/parsed/freebsd.mount +3 -0
- data/spec/fixtures/unit/provider/mount/parsed/hpux.mount +17 -0
- data/spec/fixtures/unit/provider/mount/parsed/linux.fstab +11 -0
- data/spec/fixtures/unit/provider/mount/parsed/linux.mount +5 -0
- data/spec/fixtures/unit/provider/mount/parsed/netbsd.fstab +9 -0
- data/spec/fixtures/unit/provider/mount/parsed/netbsd.mount +8 -0
- data/spec/fixtures/unit/provider/mount/parsed/openbsd.fstab +4 -0
- data/spec/fixtures/unit/provider/mount/parsed/openbsd.mount +4 -0
- data/spec/fixtures/unit/provider/mount/parsed/solaris.fstab +11 -0
- data/spec/fixtures/unit/provider/mount/parsed/solaris.mount +6 -0
- data/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys +7 -0
- data/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys1 +3 -0
- data/spec/fixtures/unit/provider/ssh_authorized_key/parsed/authorized_keys2 +1 -0
- data/spec/fixtures/unit/reports/tagmail/tagmail_failers.conf +3 -0
- data/spec/fixtures/unit/reports/tagmail/tagmail_passers.conf +30 -0
- data/spec/fixtures/unit/util/rdoc/basic.pp +16 -0
- data/spec/integration/application/apply_spec.rb +2 -5
- data/spec/integration/application/doc_spec.rb +5 -6
- data/spec/integration/configurer_spec.rb +10 -6
- data/spec/integration/defaults_spec.rb +18 -52
- data/spec/integration/faces/documentation_spec.rb +55 -0
- data/spec/integration/file_serving/content_spec.rb +10 -3
- data/spec/integration/file_serving/fileset_spec.rb +2 -3
- data/spec/integration/file_serving/metadata_spec.rb +10 -3
- data/spec/integration/file_serving/terminus_helper_spec.rb +2 -3
- data/spec/integration/indirector/catalog/compiler_spec.rb +7 -12
- data/spec/integration/indirector/catalog/queue_spec.rb +3 -4
- data/spec/integration/indirector/direct_file_server_spec.rb +2 -2
- data/spec/integration/indirector/file_content/file_server_spec.rb +7 -7
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +2 -2
- data/spec/integration/indirector/node/ldap_spec.rb +3 -4
- data/spec/integration/network/client_spec.rb +18 -0
- data/spec/integration/network/formats_spec.rb +3 -4
- data/spec/integration/network/handler_spec.rb +3 -4
- data/spec/integration/network/server/mongrel_spec.rb +3 -4
- data/spec/integration/network/server/webrick_spec.rb +4 -4
- data/spec/integration/node/environment_spec.rb +2 -3
- data/spec/integration/node/facts_spec.rb +6 -6
- data/spec/integration/node_spec.rb +16 -16
- data/spec/integration/parser/collector_spec.rb +3 -4
- data/spec/integration/parser/compiler_spec.rb +43 -3
- data/spec/integration/parser/functions/require_spec.rb +2 -3
- data/spec/integration/parser/functions_spec.rb +3 -4
- data/spec/integration/parser/parser_spec.rb +7 -6
- data/spec/integration/parser/ruby_manifest_spec.rb +2 -3
- data/spec/integration/provider/mailalias/aliases_spec.rb +5 -19
- data/spec/integration/provider/mount_spec.rb +2 -2
- data/spec/integration/provider/package_spec.rb +3 -4
- data/spec/integration/provider/service/init_spec.rb +4 -6
- data/spec/integration/reference/providers_spec.rb +2 -3
- data/spec/integration/reports_spec.rb +2 -2
- data/spec/integration/resource/catalog_spec.rb +6 -7
- data/spec/integration/resource/type_collection_spec.rb +2 -3
- data/spec/integration/ssl/certificate_authority_spec.rb +7 -7
- data/spec/integration/ssl/certificate_request_spec.rb +7 -7
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +2 -2
- data/spec/integration/ssl/host_spec.rb +4 -4
- data/spec/integration/transaction/report_spec.rb +3 -3
- data/spec/integration/transaction_spec.rb +61 -6
- data/spec/integration/type/file_spec.rb +10 -8
- data/spec/integration/type/package_spec.rb +2 -3
- data/spec/integration/type/tidy_spec.rb +2 -3
- data/spec/integration/type_spec.rb +2 -14
- data/spec/integration/util/autoload_spec.rb +2 -3
- data/spec/integration/util/feature_spec.rb +2 -3
- data/spec/integration/util/file_locking_spec.rb +3 -4
- data/spec/integration/util/rdoc/parser_spec.rb +3 -4
- data/spec/integration/util/settings_spec.rb +2 -3
- data/spec/lib/matchers/json.rb +111 -0
- data/spec/lib/puppet/face/basetest.rb +46 -0
- data/spec/lib/puppet/face/huzzah.rb +7 -0
- data/spec/lib/puppet/face/version_matching.rb +12 -0
- data/spec/lib/puppet_spec/files.rb +38 -5
- data/spec/lib/puppet_spec/fixtures.rb +28 -0
- data/spec/lib/puppet_spec/matchers.rb +87 -0
- data/spec/lib/puppet_spec/verbose.rb +0 -0
- data/spec/monkey_patches/alias_should_to_must.rb +0 -0
- data/spec/monkey_patches/publicize_methods.rb +0 -0
- data/spec/shared_behaviours/all_parsedfile_providers.rb +21 -0
- data/spec/shared_behaviours/an_indirector_face.rb +6 -0
- data/spec/shared_behaviours/documentation_on_faces.rb +263 -0
- data/spec/shared_behaviours/file_server_terminus.rb +1 -1
- data/spec/shared_behaviours/file_serving.rb +61 -70
- data/spec/shared_behaviours/memory_terminus.rb +0 -0
- data/spec/shared_behaviours/path_parameters.rb +0 -0
- data/spec/shared_behaviours/things_that_declare_options.rb +150 -0
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +33 -75
- data/spec/unit/agent/locker_spec.rb +2 -3
- data/spec/unit/agent_spec.rb +2 -2
- data/spec/unit/application/agent_spec.rb +51 -76
- data/spec/unit/application/apply_spec.rb +86 -150
- data/spec/unit/application/cert_spec.rb +8 -30
- data/spec/unit/application/certificate_spec.rb +20 -0
- data/spec/unit/application/config_spec.rb +9 -0
- data/spec/unit/application/describe_spec.rb +2 -3
- data/spec/unit/application/device_spec.rb +342 -0
- data/spec/unit/application/doc_spec.rb +11 -18
- data/spec/unit/application/face_base_spec.rb +360 -0
- data/spec/unit/application/facts_spec.rb +27 -0
- data/spec/unit/application/filebucket_spec.rb +7 -18
- data/spec/unit/application/indirection_base_spec.rb +42 -0
- data/spec/unit/application/inspect_spec.rb +7 -13
- data/spec/unit/application/kick_spec.rb +15 -38
- data/spec/unit/application/master_spec.rb +25 -81
- data/spec/unit/application/queue_spec.rb +12 -22
- data/spec/unit/application/resource_spec.rb +19 -53
- data/spec/unit/application/secret_agent_spec.rb +32 -0
- data/spec/unit/application_spec.rb +65 -34
- data/spec/unit/configurer/downloader_spec.rb +2 -3
- data/spec/unit/configurer/fact_handler_spec.rb +39 -46
- data/spec/unit/configurer/plugin_handler_spec.rb +2 -3
- data/spec/unit/configurer_spec.rb +329 -411
- data/spec/unit/daemon_spec.rb +7 -14
- data/spec/unit/dsl/resource_api_spec.rb +2 -3
- data/spec/unit/dsl/resource_type_api_spec.rb +24 -37
- data/spec/unit/face/catalog_spec.rb +7 -0
- data/spec/unit/face/certificate_request_spec.rb +7 -0
- data/spec/unit/face/certificate_revocation_list_spec.rb +7 -0
- data/spec/unit/face/certificate_spec.rb +23 -0
- data/spec/unit/face/config_spec.rb +24 -0
- data/spec/unit/face/facts_spec.rb +23 -0
- data/spec/unit/face/file_spec.rb +12 -0
- data/spec/unit/face/help_spec.rb +129 -0
- data/spec/unit/face/key_spec.rb +7 -0
- data/spec/unit/face/node_spec.rb +7 -0
- data/spec/unit/face/plugin_spec.rb +10 -0
- data/spec/unit/face/report_spec.rb +7 -0
- data/spec/unit/face/resource_spec.rb +7 -0
- data/spec/unit/face/resource_type_spec.rb +7 -0
- data/spec/unit/face/secret_agent_spec.rb +25 -0
- data/spec/unit/face_spec.rb +1 -0
- data/spec/unit/file_bucket/dipper_spec.rb +7 -8
- data/spec/unit/file_bucket/file_spec.rb +7 -16
- data/spec/unit/file_collection/lookup_spec.rb +2 -3
- data/spec/unit/file_collection_spec.rb +2 -3
- data/spec/unit/file_serving/base_spec.rb +2 -3
- data/spec/unit/file_serving/configuration/parser_spec.rb +2 -3
- data/spec/unit/file_serving/configuration_spec.rb +31 -40
- data/spec/unit/file_serving/content_spec.rb +6 -3
- data/spec/unit/file_serving/fileset_spec.rb +2 -3
- data/spec/unit/file_serving/{terminus_selector_spec.rb → indirection_hooks_spec.rb} +14 -13
- data/spec/unit/file_serving/metadata_spec.rb +6 -3
- data/spec/unit/file_serving/mount/file_spec.rb +2 -3
- data/spec/unit/file_serving/mount/modules_spec.rb +2 -11
- data/spec/unit/file_serving/mount/plugins_spec.rb +2 -3
- data/spec/unit/file_serving/mount_spec.rb +2 -3
- data/spec/unit/file_serving/terminus_helper_spec.rb +2 -2
- data/spec/unit/indirector/active_record_spec.rb +5 -7
- data/spec/unit/indirector/catalog/active_record_spec.rb +2 -3
- data/spec/unit/indirector/catalog/compiler_spec.rb +30 -50
- data/spec/unit/indirector/catalog/queue_spec.rb +2 -3
- data/spec/unit/indirector/catalog/rest_spec.rb +2 -3
- data/spec/unit/indirector/catalog/yaml_spec.rb +2 -3
- data/spec/unit/indirector/certificate/ca_spec.rb +2 -2
- data/spec/unit/indirector/certificate/file_spec.rb +2 -2
- data/spec/unit/indirector/certificate/rest_spec.rb +2 -3
- data/spec/unit/indirector/certificate_request/ca_spec.rb +47 -2
- data/spec/unit/indirector/certificate_request/file_spec.rb +2 -2
- data/spec/unit/indirector/certificate_request/rest_spec.rb +2 -3
- data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +2 -2
- data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +2 -2
- data/spec/unit/indirector/certificate_revocation_list/rest_spec.rb +2 -3
- data/spec/unit/indirector/certificate_status/file_spec.rb +187 -0
- data/spec/unit/indirector/certificate_status/rest_spec.rb +14 -0
- data/spec/unit/indirector/code_spec.rb +6 -8
- data/spec/unit/indirector/direct_file_server_spec.rb +6 -7
- data/spec/unit/indirector/envelope_spec.rb +2 -3
- data/spec/unit/indirector/exec_spec.rb +12 -13
- data/spec/unit/indirector/face_spec.rb +68 -0
- data/spec/unit/indirector/facts/active_record_spec.rb +2 -3
- data/spec/unit/indirector/facts/couch_spec.rb +71 -66
- data/spec/unit/indirector/facts/facter_spec.rb +2 -2
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +20 -20
- data/spec/unit/indirector/facts/network_device_spec.rb +89 -0
- data/spec/unit/indirector/facts/rest_spec.rb +2 -3
- data/spec/unit/indirector/facts/yaml_spec.rb +2 -3
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +17 -18
- data/spec/unit/indirector/file_bucket_file/rest_spec.rb +2 -3
- data/spec/unit/indirector/file_content/file_server_spec.rb +2 -2
- data/spec/unit/indirector/file_content/file_spec.rb +2 -2
- data/spec/unit/indirector/file_content/rest_spec.rb +2 -3
- data/spec/unit/indirector/file_metadata/file_server_spec.rb +2 -2
- data/spec/unit/indirector/file_metadata/file_spec.rb +2 -2
- data/spec/unit/indirector/file_metadata/rest_spec.rb +2 -3
- data/spec/unit/indirector/file_server_spec.rb +8 -7
- data/spec/unit/indirector/file_spec.rb +179 -0
- data/spec/unit/indirector/indirection_spec.rb +3 -24
- data/spec/unit/indirector/inventory/yaml_spec.rb +220 -0
- data/spec/unit/indirector/key/ca_spec.rb +2 -2
- data/spec/unit/indirector/key/file_spec.rb +2 -2
- data/spec/unit/indirector/ldap_spec.rb +6 -8
- data/spec/unit/indirector/memory_spec.rb +5 -7
- data/spec/unit/indirector/node/active_record_spec.rb +2 -3
- data/spec/unit/indirector/node/exec_spec.rb +3 -4
- data/spec/unit/indirector/node/ldap_spec.rb +3 -4
- data/spec/unit/indirector/node/memory_spec.rb +2 -3
- data/spec/unit/indirector/node/plain_spec.rb +2 -3
- data/spec/unit/indirector/node/rest_spec.rb +2 -3
- data/spec/unit/indirector/node/yaml_spec.rb +2 -3
- data/spec/unit/indirector/plain_spec.rb +5 -7
- data/spec/unit/indirector/queue_spec.rb +11 -14
- data/spec/unit/indirector/report/processor_spec.rb +7 -9
- data/spec/unit/indirector/report/rest_spec.rb +2 -3
- data/spec/unit/indirector/report/yaml_spec.rb +3 -4
- data/spec/unit/indirector/request_spec.rb +3 -25
- data/spec/unit/indirector/resource/ral_spec.rb +3 -4
- data/spec/unit/indirector/resource/rest_spec.rb +2 -3
- data/spec/unit/indirector/resource_type/parser_spec.rb +87 -13
- data/spec/unit/indirector/resource_type/rest_spec.rb +2 -3
- data/spec/unit/indirector/rest_spec.rb +45 -16
- data/spec/unit/indirector/run/local_spec.rb +2 -3
- data/spec/unit/indirector/run/rest_spec.rb +2 -3
- data/spec/unit/indirector/ssl_file_spec.rb +9 -27
- data/spec/unit/indirector/status/rest_spec.rb +2 -3
- data/spec/unit/indirector/terminus_spec.rb +180 -187
- data/spec/unit/indirector/yaml_spec.rb +9 -23
- data/spec/unit/indirector_spec.rb +61 -79
- data/spec/unit/interface/action_builder_spec.rb +214 -0
- data/spec/unit/interface/action_manager_spec.rb +282 -0
- data/spec/unit/interface/action_spec.rb +545 -0
- data/spec/unit/interface/documentation_spec.rb +34 -0
- data/spec/unit/interface/face_collection_spec.rb +180 -0
- data/spec/unit/interface/option_builder_spec.rb +77 -0
- data/spec/unit/interface/option_spec.rb +100 -0
- data/spec/unit/interface_spec.rb +228 -0
- data/spec/unit/module_spec.rb +34 -10
- data/spec/unit/network/authconfig_spec.rb +3 -4
- data/spec/unit/network/authstore_spec.rb +3 -4
- data/spec/unit/network/client_spec.rb +45 -0
- data/spec/unit/network/format_handler_spec.rb +2 -3
- data/spec/unit/network/format_spec.rb +2 -3
- data/spec/unit/network/formats_spec.rb +107 -3
- data/spec/unit/network/handler/fileserver_spec.rb +3 -4
- data/spec/unit/network/http/api/v1_spec.rb +61 -27
- data/spec/unit/network/http/compression_spec.rb +2 -3
- data/spec/unit/network/http/handler_spec.rb +78 -109
- data/spec/unit/network/http/mongrel/rest_spec.rb +3 -4
- data/spec/unit/network/http/mongrel_spec.rb +6 -6
- data/spec/unit/network/http/rack/rest_spec.rb +2 -20
- data/spec/unit/network/http/rack/xmlrpc_spec.rb +2 -3
- data/spec/unit/network/http/rack_spec.rb +2 -3
- data/spec/unit/network/http/webrick/rest_spec.rb +3 -4
- data/spec/unit/network/http/webrick_spec.rb +4 -8
- data/spec/unit/network/http_pool_spec.rb +82 -95
- data/spec/unit/network/http_spec.rb +2 -2
- data/spec/unit/network/rest_authconfig_spec.rb +9 -42
- data/spec/unit/network/rights_spec.rb +6 -7
- data/spec/unit/network/server_spec.rb +2 -2
- data/spec/unit/network/xmlrpc/client_spec.rb +172 -0
- data/spec/unit/node/environment_spec.rb +63 -7
- data/spec/unit/node/facts_spec.rb +9 -13
- data/spec/unit/node_spec.rb +5 -13
- data/spec/unit/other/selinux_spec.rb +2 -3
- data/spec/unit/other/transbucket_spec.rb +2 -3
- data/spec/unit/other/transobject_spec.rb +2 -3
- data/spec/unit/parameter/path_spec.rb +2 -2
- data/spec/unit/parameter/value_collection_spec.rb +2 -3
- data/spec/unit/parameter/value_spec.rb +2 -3
- data/spec/unit/parameter_spec.rb +2 -3
- data/spec/unit/parser/ast/arithmetic_operator_spec.rb +2 -13
- data/spec/unit/parser/ast/astarray_spec.rb +18 -36
- data/spec/unit/parser/ast/asthash_spec.rb +4 -4
- data/spec/unit/parser/ast/boolean_operator_spec.rb +2 -3
- data/spec/unit/parser/ast/casestatement_spec.rb +17 -14
- data/spec/unit/parser/ast/collection_spec.rb +2 -3
- data/spec/unit/parser/ast/collexpr_spec.rb +2 -3
- data/spec/unit/parser/ast/comparison_operator_spec.rb +4 -5
- data/spec/unit/parser/ast/definition_spec.rb +21 -0
- data/spec/unit/parser/ast/function_spec.rb +3 -4
- data/spec/unit/parser/ast/hostclass_spec.rb +72 -0
- data/spec/unit/parser/ast/ifstatement_spec.rb +2 -3
- data/spec/unit/parser/ast/in_operator_spec.rb +2 -3
- data/spec/unit/parser/ast/leaf_spec.rb +23 -19
- data/spec/unit/parser/ast/match_operator_spec.rb +2 -3
- data/spec/unit/parser/ast/minus_spec.rb +2 -3
- data/spec/unit/parser/ast/node_spec.rb +30 -0
- data/spec/unit/parser/ast/nop_spec.rb +2 -3
- data/spec/unit/parser/ast/not_spec.rb +2 -3
- data/spec/unit/parser/ast/relationship_spec.rb +2 -3
- data/spec/unit/parser/ast/resource_defaults_spec.rb +2 -3
- data/spec/unit/parser/ast/resource_override_spec.rb +2 -3
- data/spec/unit/parser/ast/resource_reference_spec.rb +21 -8
- data/spec/unit/parser/ast/resource_spec.rb +24 -13
- data/spec/unit/parser/ast/selector_spec.rb +3 -4
- data/spec/unit/parser/ast/vardef_spec.rb +15 -9
- data/spec/unit/parser/ast_spec.rb +2 -3
- data/spec/unit/parser/collector_spec.rb +2 -3
- data/spec/unit/parser/compiler_spec.rb +62 -35
- data/spec/unit/parser/files_spec.rb +2 -3
- data/spec/unit/parser/functions/create_resources_spec.rb +137 -0
- data/spec/unit/parser/functions/defined_spec.rb +5 -3
- data/spec/unit/parser/functions/extlookup_spec.rb +10 -10
- data/spec/unit/parser/functions/fqdn_rand_spec.rb +15 -13
- data/spec/unit/parser/functions/generate_spec.rb +5 -3
- data/spec/unit/parser/functions/include_spec.rb +5 -3
- data/spec/unit/parser/functions/inline_template_spec.rb +6 -17
- data/spec/unit/parser/functions/realize_spec.rb +5 -3
- data/spec/unit/parser/functions/regsubst_spec.rb +5 -3
- data/spec/unit/parser/functions/require_spec.rb +5 -3
- data/spec/unit/parser/functions/shellquote_spec.rb +8 -6
- data/spec/unit/parser/functions/split_spec.rb +5 -3
- data/spec/unit/parser/functions/sprintf_spec.rb +5 -3
- data/spec/unit/parser/functions/tag_spec.rb +5 -3
- data/spec/unit/parser/functions/template_spec.rb +6 -21
- data/spec/unit/parser/functions/versioncmp_spec.rb +5 -3
- data/spec/unit/parser/functions_spec.rb +2 -3
- data/spec/unit/parser/lexer_spec.rb +3 -7
- data/spec/unit/parser/parser_spec.rb +71 -90
- data/spec/unit/parser/relationship_spec.rb +2 -3
- data/spec/unit/parser/resource_spec.rb +6 -65
- data/spec/unit/parser/scope_spec.rb +28 -179
- data/spec/unit/parser/templatewrapper_spec.rb +25 -43
- data/spec/unit/parser/type_loader_spec.rb +120 -78
- data/spec/unit/property/ensure_spec.rb +2 -3
- data/spec/unit/property/keyvalue_spec.rb +4 -8
- data/spec/unit/property/list_spec.rb +2 -3
- data/spec/unit/property/ordered_list_spec.rb +2 -3
- data/spec/unit/property_spec.rb +2 -3
- data/spec/unit/provider/augeas/augeas_spec.rb +80 -3
- data/spec/unit/provider/cisco_spec.rb +16 -0
- data/spec/unit/provider/confine/exists_spec.rb +2 -3
- data/spec/unit/provider/confine/false_spec.rb +2 -3
- data/spec/unit/provider/confine/feature_spec.rb +2 -3
- data/spec/unit/provider/confine/true_spec.rb +2 -3
- data/spec/unit/provider/confine/variable_spec.rb +2 -3
- data/spec/unit/provider/confine_collection_spec.rb +2 -3
- data/spec/unit/provider/confine_spec.rb +2 -3
- data/spec/unit/provider/confiner_spec.rb +2 -3
- data/spec/unit/provider/exec/posix_spec.rb +2 -2
- data/spec/unit/provider/exec/shell_spec.rb +2 -2
- data/spec/unit/provider/group/groupadd_spec.rb +2 -3
- data/spec/unit/provider/group/ldap_spec.rb +2 -2
- data/spec/unit/provider/host/parsed_spec.rb +197 -0
- data/spec/unit/provider/interface/cisco_spec.rb +58 -0
- data/spec/unit/provider/ldap_spec.rb +2 -2
- data/spec/unit/provider/macauthorization_spec.rb +2 -2
- data/spec/unit/provider/mcx/mcxcontent_spec.rb +2 -21
- data/spec/unit/provider/mount/parsed_spec.rb +61 -86
- data/spec/unit/provider/mount_spec.rb +2 -3
- data/spec/unit/provider/naginator_spec.rb +2 -3
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +2 -63
- data/spec/unit/provider/network_device_spec.rb +153 -0
- data/spec/unit/provider/package/aix_spec.rb +2 -3
- data/spec/unit/provider/package/apt_spec.rb +2 -3
- data/spec/unit/provider/package/dpkg_spec.rb +2 -3
- data/spec/unit/provider/package/freebsd_spec.rb +2 -3
- data/spec/unit/provider/package/gem_spec.rb +2 -3
- data/spec/unit/provider/package/hpux_spec.rb +2 -3
- data/spec/unit/provider/package/macports_spec.rb +2 -2
- data/spec/unit/provider/package/nim_spec.rb +2 -3
- data/spec/unit/provider/package/pip_spec.rb +180 -0
- data/spec/unit/provider/package/pkg_spec.rb +2 -3
- data/spec/unit/provider/package/pkgdmg_spec.rb +49 -56
- data/spec/unit/provider/package/pkgutil_spec.rb +182 -0
- data/spec/unit/provider/package/yum_spec.rb +66 -0
- data/spec/unit/provider/package/zypper_spec.rb +2 -3
- data/spec/unit/provider/parsedfile_spec.rb +2 -3
- data/spec/unit/provider/selboolean_spec.rb +2 -3
- data/spec/unit/provider/selmodule_spec.rb +2 -2
- data/spec/unit/provider/service/daemontools_spec.rb +2 -2
- data/spec/unit/provider/service/debian_spec.rb +2 -2
- data/spec/unit/provider/service/freebsd_spec.rb +2 -3
- data/spec/unit/provider/service/init_spec.rb +3 -3
- data/spec/unit/provider/service/launchd_spec.rb +2 -2
- data/spec/unit/provider/service/redhat_spec.rb +2 -2
- data/spec/unit/provider/service/runit_spec.rb +2 -2
- data/spec/unit/provider/service/smf_spec.rb +137 -0
- data/spec/unit/provider/service/src_spec.rb +7 -7
- data/spec/unit/provider/service/upstart.rb +48 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +28 -47
- data/spec/unit/provider/sshkey/parsed_spec.rb +2 -3
- data/spec/unit/provider/user/hpux_spec.rb +2 -3
- data/spec/unit/provider/user/ldap_spec.rb +2 -2
- data/spec/unit/provider/user/user_role_add_spec.rb +15 -53
- data/spec/unit/provider/user/useradd_spec.rb +2 -3
- data/spec/unit/provider/vlan/cisco_spec.rb +56 -0
- data/spec/unit/provider/zfs/solaris_spec.rb +4 -4
- data/spec/unit/provider/zone/solaris_spec.rb +2 -3
- data/spec/unit/provider/zpool/solaris_spec.rb +33 -4
- data/spec/unit/provider_spec.rb +2 -3
- data/spec/unit/puppet/provider/README.markdown +4 -0
- data/spec/unit/puppet/type/README.markdown +4 -0
- data/spec/unit/puppet_spec.rb +2 -2
- data/spec/unit/rails/host_spec.rb +2 -11
- data/spec/unit/rails/param_value_spec.rb +2 -3
- data/spec/unit/rails/resource_spec.rb +2 -3
- data/spec/unit/rails_spec.rb +2 -3
- data/spec/unit/relationship_spec.rb +2 -2
- data/spec/unit/reports/http_spec.rb +2 -3
- data/spec/unit/reports/rrdgraph_spec.rb +2 -3
- data/spec/unit/reports/store_spec.rb +2 -17
- data/spec/unit/reports/tagmail_spec.rb +4 -8
- data/spec/unit/reports_spec.rb +2 -3
- data/spec/unit/resource/catalog_spec.rb +15 -74
- data/spec/unit/resource/status_spec.rb +3 -4
- data/spec/unit/resource/type_collection_helper_spec.rb +2 -3
- data/spec/unit/resource/type_collection_spec.rb +69 -81
- data/spec/unit/resource/type_spec.rb +26 -44
- data/spec/unit/resource_spec.rb +3 -4
- data/spec/unit/run_spec.rb +2 -3
- data/spec/unit/simple_graph_spec.rb +434 -80
- data/spec/unit/ssl/base_spec.rb +3 -4
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +56 -96
- data/spec/unit/ssl/certificate_authority_spec.rb +71 -246
- data/spec/unit/ssl/certificate_factory_spec.rb +72 -93
- data/spec/unit/ssl/certificate_request_spec.rb +11 -76
- data/spec/unit/ssl/certificate_revocation_list_spec.rb +4 -5
- data/spec/unit/ssl/certificate_spec.rb +2 -34
- data/spec/unit/ssl/host_spec.rb +202 -207
- data/spec/unit/ssl/inventory_spec.rb +4 -5
- data/spec/unit/ssl/key_spec.rb +2 -3
- data/spec/unit/sslcertificates/ca_spec.rb +110 -0
- data/spec/unit/status_spec.rb +8 -5
- data/spec/unit/transaction/event_manager_spec.rb +2 -3
- data/spec/unit/transaction/event_spec.rb +7 -8
- data/spec/unit/transaction/report_spec.rb +25 -14
- data/spec/unit/transaction/resource_harness_spec.rb +2 -4
- data/spec/unit/transaction_spec.rb +31 -28
- data/spec/unit/transportable_spec.rb +0 -0
- data/spec/unit/type/augeas_spec.rb +3 -4
- data/spec/unit/type/component_spec.rb +2 -3
- data/spec/unit/type/computer_spec.rb +2 -3
- data/spec/unit/type/cron_spec.rb +12 -3
- data/spec/unit/type/exec_spec.rb +2 -32
- data/spec/unit/type/file/checksum_spec.rb +2 -3
- data/spec/unit/type/file/content_spec.rb +2 -3
- data/spec/unit/type/file/ctime.rb +2 -3
- data/spec/unit/type/file/ensure_spec.rb +2 -3
- data/spec/unit/type/file/group_spec.rb +2 -3
- data/spec/unit/type/file/mtime.rb +2 -3
- data/spec/unit/type/file/owner_spec.rb +2 -3
- data/spec/unit/type/file/selinux_spec.rb +2 -3
- data/spec/unit/type/file/source_spec.rb +9 -10
- data/spec/unit/type/file/type.rb +2 -3
- data/spec/unit/type/file_spec.rb +15 -30
- data/spec/unit/type/filebucket_spec.rb +2 -3
- data/spec/unit/type/group_spec.rb +4 -5
- data/spec/unit/type/host_spec.rb +129 -0
- data/spec/unit/type/interface_spec.rb +98 -0
- data/spec/unit/type/macauthorization_spec.rb +2 -3
- data/spec/unit/type/maillist_spec.rb +2 -3
- data/spec/unit/type/mcx_spec.rb +2 -23
- data/spec/unit/type/mount_spec.rb +41 -18
- data/spec/unit/type/nagios_spec.rb +2 -3
- data/spec/unit/type/noop_metaparam_spec.rb +2 -3
- data/spec/unit/type/package_spec.rb +2 -3
- data/spec/unit/type/resources_spec.rb +3 -4
- data/spec/unit/type/schedule_spec.rb +19 -12
- data/spec/unit/type/selboolean_spec.rb +2 -3
- data/spec/unit/type/selmodule_spec.rb +2 -3
- data/spec/unit/type/service_spec.rb +6 -3
- data/spec/unit/type/ssh_authorized_key_spec.rb +2 -3
- data/spec/unit/type/sshkey_spec.rb +70 -0
- data/spec/unit/type/stage_spec.rb +2 -3
- data/spec/unit/type/tidy_spec.rb +4 -4
- data/spec/unit/type/user_spec.rb +2 -11
- data/spec/unit/type/vlan_spec.rb +45 -0
- data/spec/unit/type/whit_spec.rb +4 -5
- data/spec/unit/type/zfs_spec.rb +2 -3
- data/spec/unit/type/zone_spec.rb +22 -3
- data/spec/unit/type/zpool_spec.rb +2 -3
- data/spec/unit/type_spec.rb +2 -69
- data/spec/unit/util/autoload/file_cache_spec.rb +2 -3
- data/spec/unit/util/autoload_spec.rb +6 -7
- data/spec/unit/util/backups_spec.rb +2 -3
- data/spec/unit/util/cache_accumulator_spec.rb +2 -3
- data/spec/unit/util/cacher_spec.rb +3 -4
- data/spec/unit/util/checksums_spec.rb +2 -2
- data/spec/unit/util/command_line_spec.rb +11 -8
- data/spec/unit/util/constant_inflector_spec.rb +2 -2
- data/spec/unit/util/errors_spec.rb +2 -3
- data/spec/unit/util/execution_spec.rb +2 -3
- data/spec/unit/util/execution_stub_spec.rb +2 -3
- data/spec/unit/util/feature_spec.rb +2 -3
- data/spec/unit/util/file_locking_spec.rb +4 -5
- data/spec/unit/util/filetype_spec.rb +2 -3
- data/spec/unit/util/inline_docs_spec.rb +2 -3
- data/spec/unit/util/ldap/connection_spec.rb +2 -2
- data/spec/unit/util/ldap/generator_spec.rb +2 -2
- data/spec/unit/util/ldap/manager_spec.rb +2 -2
- data/spec/unit/util/loadedfile_spec.rb +2 -3
- data/spec/unit/util/log/destinations_spec.rb +2 -3
- data/spec/unit/util/log_spec.rb +6 -7
- data/spec/unit/util/logging_spec.rb +27 -3
- data/spec/unit/util/metric_spec.rb +2 -3
- data/spec/unit/util/monkey_patches_spec.rb +48 -10
- data/spec/unit/util/nagios_maker_spec.rb +2 -2
- data/spec/unit/util/network_device/cisco/device_spec.rb +408 -0
- data/spec/unit/util/network_device/cisco/facts_spec.rb +63 -0
- data/spec/unit/util/network_device/cisco/interface_spec.rb +89 -0
- data/spec/unit/util/network_device/config_spec.rb +102 -0
- data/spec/unit/util/network_device/ipcalc_spec.rb +63 -0
- data/spec/unit/util/network_device/transport/base_spec.rb +42 -0
- data/spec/unit/util/network_device/transport/ssh_spec.rb +219 -0
- data/spec/unit/util/network_device/transport/telnet_spec.rb +76 -0
- data/spec/unit/util/network_device_spec.rb +50 -0
- data/spec/unit/util/package_spec.rb +2 -3
- data/spec/unit/util/posix_spec.rb +2 -3
- data/spec/unit/util/pson_spec.rb +3 -4
- data/spec/unit/util/queue/stomp_spec.rb +4 -5
- data/spec/unit/util/queue_spec.rb +2 -3
- data/spec/unit/util/rdoc/parser_spec.rb +17 -12
- data/spec/unit/util/rdoc_spec.rb +19 -58
- data/spec/unit/util/reference_serializer_spec.rb +2 -3
- data/spec/unit/util/resource_template_spec.rb +2 -3
- data/spec/unit/util/run_mode_spec.rb +2 -3
- data/spec/unit/util/selinux_spec.rb +4 -5
- data/spec/unit/util/settings/file_setting_spec.rb +2 -7
- data/spec/unit/util/settings_spec.rb +2 -24
- data/spec/unit/util/storage_spec.rb +2 -3
- data/spec/unit/util/tagging_spec.rb +2 -2
- data/spec/unit/util/user_attr_spec.rb +2 -3
- data/spec/unit/util/warnings_spec.rb +2 -3
- data/spec/unit/util/zaml_spec.rb +23 -53
- data/spec/watchr.rb +146 -0
- data/tasks/rake/gem.rake +5 -4
- data/tasks/rake/git_workflow.rake +62 -51
- data/tasks/rake/manpages.rake +69 -0
- data/test/certmgr/certmgr.rb +308 -0
- data/test/certmgr/inventory.rb +69 -0
- data/test/certmgr/support.rb +105 -0
- data/test/data/providers/host/parsed/valid_hosts +19 -0
- data/test/language/ast.rb +1 -1
- data/test/language/ast/variable.rb +1 -1
- data/test/language/functions.rb +8 -9
- data/test/language/parser.rb +44 -52
- data/test/language/scope.rb +13 -24
- data/test/language/snippets.rb +11 -2
- data/test/language/transportable.rb +1 -1
- data/test/lib/puppettest.rb +2 -2
- data/test/lib/puppettest/exetest.rb +1 -1
- data/test/lib/puppettest/parsertesting.rb +5 -8
- data/test/lib/puppettest/servertest.rb +1 -0
- data/test/lib/puppettest/support/assertions.rb +6 -1
- data/test/lib/puppettest/support/utils.rb +0 -19
- data/test/network/authconfig.rb +1 -1
- data/test/network/authorization.rb +1 -1
- data/test/network/authstore.rb +1 -1
- data/test/network/client/ca.rb +69 -0
- data/test/network/client/dipper.rb +34 -0
- data/test/network/client_request.rb +1 -1
- data/test/network/handler/ca.rb +273 -0
- data/test/network/handler/fileserver.rb +1 -1
- data/test/network/handler/master.rb +13 -9
- data/test/network/handler/report.rb +1 -1
- data/test/network/handler/runner.rb +1 -1
- data/test/network/rights.rb +1 -1
- data/test/network/server/mongrel_test.rb +99 -0
- data/test/network/server/webrick.rb +128 -0
- data/test/network/xmlrpc/client.rb +45 -0
- data/test/network/xmlrpc/processor.rb +1 -1
- data/test/network/xmlrpc/server.rb +1 -1
- data/test/network/xmlrpc/webrick_servlet.rb +1 -1
- data/test/other/provider.rb +1 -1
- data/test/other/puppet.rb +1 -1
- data/test/other/relationships.rb +11 -18
- data/test/other/report.rb +1 -1
- data/test/other/transactions.rb +2 -35
- data/test/puppet/defaults.rb +1 -1
- data/test/puppet/errortest.rb +1 -1
- data/test/puppet/tc_suidmanager.rb +120 -0
- data/test/rails/rails.rb +2 -1
- data/test/rails/railsparameter.rb +2 -2
- data/test/ral/manager/attributes.rb +1 -1
- data/test/ral/manager/instances.rb +1 -1
- data/test/ral/manager/manager.rb +1 -1
- data/test/ral/manager/provider.rb +1 -1
- data/test/ral/manager/type.rb +1 -1
- data/test/ral/providers/cron/crontab.rb +1 -1
- data/test/ral/providers/group.rb +1 -1
- data/test/ral/providers/host/parsed.rb +1 -203
- data/test/ral/providers/mailalias/aliases.rb +1 -1
- data/test/ral/providers/nameservice.rb +1 -1
- data/test/ral/providers/package.rb +1 -1
- data/test/ral/providers/package/aptitude.rb +1 -1
- data/test/ral/providers/package/aptrpm.rb +1 -1
- data/test/ral/providers/parsedfile.rb +1 -1
- data/test/ral/providers/port/parsed.rb +1 -1
- data/test/ral/providers/provider.rb +1 -1
- data/test/ral/providers/service/base.rb +1 -1
- data/test/ral/providers/sshkey/parsed.rb +1 -1
- data/test/ral/providers/user.rb +1 -1
- data/test/ral/providers/user/useradd.rb +1 -1
- data/test/ral/type/cron.rb +1 -1
- data/test/ral/type/exec.rb +1 -42
- data/test/ral/type/file.rb +1 -1
- data/test/ral/type/file/target.rb +6 -19
- data/test/ral/type/fileignoresource.rb +1 -1
- data/test/ral/type/filesources.rb +61 -1
- data/test/ral/type/host.rb +1 -1
- data/test/ral/type/mailalias.rb +1 -1
- data/test/ral/type/port.rb +1 -1
- data/test/ral/type/resources.rb +1 -1
- data/test/ral/type/service.rb +1 -1
- data/test/ral/type/sshkey.rb +1 -1
- data/test/ral/type/user.rb +1 -1
- data/test/ral/type/yumrepo.rb +1 -1
- data/test/ral/type/zone.rb +1 -1
- data/test/test +2 -2
- data/test/util/classgen.rb +1 -1
- data/test/util/execution.rb +1 -1
- data/test/util/fileparsing.rb +1 -1
- data/test/util/inifile.rb +1 -1
- data/test/util/instance_loader.rb +1 -1
- data/test/util/log.rb +1 -1
- data/test/util/metrics.rb +1 -1
- data/test/util/package.rb +1 -1
- data/test/util/pidlock.rb +1 -1
- data/test/util/settings.rb +1 -1
- data/test/util/storage.rb +1 -1
- data/test/util/subclass_loader.rb +1 -1
- data/test/util/utiltest.rb +1 -1
- metadata +312 -48
- data/CHANGELOG.old +0 -1705
- data/CONTRIBUTING.md +0 -299
- data/COPYING +0 -340
- data/README.queueing +0 -126
- data/ext/upload_facts.rb +0 -120
- data/ext/vim/ftplugin/puppet.vim +0 -94
- data/ext/vim/indent/puppet.vim +0 -76
- data/lib/puppet/indirector/errors.rb +0 -5
- data/lib/puppet/indirector/facts/inventory_service.rb +0 -20
- data/lib/puppet/indirector/file_bucket_file/selector.rb +0 -53
- data/lib/puppet/indirector/file_content/selector.rb +0 -30
- data/lib/puppet/indirector/file_metadata/selector.rb +0 -30
- data/lib/puppet/indirector/resource/validator.rb +0 -8
- data/lib/puppet/util/command_line/filebucket +0 -97
- data/lib/puppet/util/command_line/pi +0 -48
- data/lib/puppet/util/command_line/puppet +0 -73
- data/lib/puppet/util/command_line/puppetca +0 -131
- data/lib/puppet/util/command_line/puppetd +0 -188
- data/lib/puppet/util/command_line/puppetdoc +0 -67
- data/lib/puppet/util/command_line/puppetmasterd +0 -70
- data/lib/puppet/util/command_line/puppetqd +0 -53
- data/lib/puppet/util/command_line/puppetrun +0 -125
- data/lib/puppet/util/command_line/ralsh +0 -89
- data/spec/integration/file_bucket/file_spec.rb +0 -44
- data/spec/integration/indirector/bucket_file/rest_spec.rb +0 -77
- data/spec/integration/indirector/certificate/rest_spec.rb +0 -69
- data/spec/integration/indirector/certificate_request/rest_spec.rb +0 -89
- data/spec/integration/indirector/certificate_revocation_list/rest_spec.rb +0 -85
- data/spec/integration/indirector/report/rest_spec.rb +0 -93
- data/spec/shared_behaviours/file_serving_model.rb +0 -73
- data/spec/unit/indirector/facts/inventory_service_spec.rb +0 -22
- data/spec/unit/indirector/file_bucket_file/selector_spec.rb +0 -29
- data/spec/unit/indirector/file_content/selector_spec.rb +0 -10
- data/spec/unit/indirector/file_metadata/selector_spec.rb +0 -11
- data/spec/unit/network/handler/ca_spec.rb +0 -87
- data/spec/unit/network/rest_authorization_spec.rb +0 -43
- data/spec/unit/provider/package/appdmg_spec.rb +0 -42
- data/spec/unit/type/k5login_spec.rb +0 -115
- data/spec/unit/util/suidmanager_spec.rb +0 -220
- data/spec/unit/util_spec.rb +0 -104
data/lib/puppet/resource/type.rb
CHANGED
@@ -13,8 +13,8 @@ class Puppet::Resource::Type
|
|
13
13
|
|
14
14
|
RESOURCE_SUPERTYPES = [:hostclass, :node, :definition]
|
15
15
|
|
16
|
-
attr_accessor :file, :line, :doc, :code, :ruby_code, :parent, :resource_type_collection
|
17
|
-
attr_reader :type, :namespace, :arguments, :behaves_like
|
16
|
+
attr_accessor :file, :line, :doc, :code, :ruby_code, :parent, :resource_type_collection
|
17
|
+
attr_reader :type, :namespace, :arguments, :behaves_like, :module_name
|
18
18
|
|
19
19
|
RESOURCE_SUPERTYPES.each do |t|
|
20
20
|
define_method("#{t}?") { self.type == t }
|
@@ -34,13 +34,13 @@ class Puppet::Resource::Type
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def to_pson_data_hash
|
37
|
-
data = [:
|
38
|
-
next hash unless value = self.send(param)
|
37
|
+
data = [:doc, :line, :file, :parent].inject({}) do |hash, param|
|
38
|
+
next hash unless (value = self.send(param)) and (value != "")
|
39
39
|
hash[param.to_s] = value
|
40
40
|
hash
|
41
41
|
end
|
42
42
|
|
43
|
-
data['arguments'] = arguments.dup
|
43
|
+
data['arguments'] = arguments.dup unless arguments.empty?
|
44
44
|
|
45
45
|
data['name'] = name
|
46
46
|
data['type'] = type
|
@@ -62,13 +62,11 @@ class Puppet::Resource::Type
|
|
62
62
|
|
63
63
|
# Now evaluate the code associated with this class or definition.
|
64
64
|
def evaluate_code(resource)
|
65
|
-
scope = resource.scope
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
end
|
66
|
+
static_parent = evaluate_parent_type(resource)
|
67
|
+
scope = static_parent || resource.scope
|
70
68
|
|
71
|
-
scope =
|
69
|
+
scope = scope.newscope(:namespace => namespace, :source => self, :resource => resource, :dynamic => !static_parent) unless resource.title == :main
|
72
70
|
scope.compiler.add_class(name) unless definition?
|
73
71
|
|
74
72
|
set_resource_parameters(resource, scope)
|
@@ -92,6 +90,8 @@ class Puppet::Resource::Type
|
|
92
90
|
end
|
93
91
|
|
94
92
|
set_arguments(options[:arguments])
|
93
|
+
|
94
|
+
@module_name = options[:module_name]
|
95
95
|
end
|
96
96
|
|
97
97
|
# This is only used for node names, and really only when the node name
|
@@ -261,11 +261,6 @@ class Puppet::Resource::Type
|
|
261
261
|
|
262
262
|
end
|
263
263
|
|
264
|
-
# Create a new subscope in which to evaluate our code.
|
265
|
-
def subscope(scope, resource)
|
266
|
-
scope.newscope :resource => resource, :namespace => self.namespace, :source => self
|
267
|
-
end
|
268
|
-
|
269
264
|
# Check whether a given argument is valid.
|
270
265
|
def valid_parameter?(param)
|
271
266
|
param = param.to_s
|
@@ -1,10 +1,12 @@
|
|
1
1
|
class Puppet::Resource::TypeCollection
|
2
2
|
attr_reader :environment
|
3
|
+
attr_accessor :parse_failed
|
3
4
|
|
4
5
|
def clear
|
5
6
|
@hostclasses.clear
|
6
7
|
@definitions.clear
|
7
8
|
@nodes.clear
|
9
|
+
@watched_files.clear
|
8
10
|
end
|
9
11
|
|
10
12
|
def initialize(env)
|
@@ -19,6 +21,12 @@ class Puppet::Resource::TypeCollection
|
|
19
21
|
@watched_files = {}
|
20
22
|
end
|
21
23
|
|
24
|
+
def import_ast(ast, modname)
|
25
|
+
ast.instantiate(modname).each do |instance|
|
26
|
+
add(instance)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
22
30
|
def inspect
|
23
31
|
"TypeCollection" + { :hostclasses => @hostclasses.keys, :definitions => @definitions.keys, :nodes => @nodes.keys }.inspect
|
24
32
|
end
|
@@ -96,50 +104,8 @@ class Puppet::Resource::TypeCollection
|
|
96
104
|
@definitions[munge_name(name)]
|
97
105
|
end
|
98
106
|
|
99
|
-
def find(namespaces, name, type)
|
100
|
-
#Array("") == [] for some reason
|
101
|
-
namespaces = [namespaces] unless namespaces.is_a?(Array)
|
102
|
-
|
103
|
-
if name =~ /^::/
|
104
|
-
return send(type, name.sub(/^::/, ''))
|
105
|
-
end
|
106
|
-
|
107
|
-
namespaces.each do |namespace|
|
108
|
-
ary = namespace.split("::")
|
109
|
-
|
110
|
-
while ary.length > 0
|
111
|
-
tmp_namespace = ary.join("::")
|
112
|
-
if r = find_partially_qualified(tmp_namespace, name, type)
|
113
|
-
return r
|
114
|
-
end
|
115
|
-
|
116
|
-
# Delete the second to last object, which reduces our namespace by one.
|
117
|
-
ary.pop
|
118
|
-
end
|
119
|
-
|
120
|
-
if result = send(type, name)
|
121
|
-
return result
|
122
|
-
end
|
123
|
-
end
|
124
|
-
nil
|
125
|
-
end
|
126
|
-
|
127
|
-
def find_or_load(namespaces, name, type)
|
128
|
-
name = name.downcase
|
129
|
-
namespaces = [namespaces] unless namespaces.is_a?(Array)
|
130
|
-
namespaces = namespaces.collect { |ns| ns.downcase }
|
131
|
-
|
132
|
-
# This could be done in the load_until, but the knowledge seems to
|
133
|
-
# belong here.
|
134
|
-
if r = find(namespaces, name, type)
|
135
|
-
return r
|
136
|
-
end
|
137
|
-
|
138
|
-
loader.load_until(namespaces, name) { find(namespaces, name, type) }
|
139
|
-
end
|
140
|
-
|
141
107
|
def find_node(namespaces, name)
|
142
|
-
|
108
|
+
@nodes[munge_name(name)]
|
143
109
|
end
|
144
110
|
|
145
111
|
def find_hostclass(namespaces, name)
|
@@ -156,24 +122,6 @@ class Puppet::Resource::TypeCollection
|
|
156
122
|
end
|
157
123
|
end
|
158
124
|
|
159
|
-
def perform_initial_import
|
160
|
-
parser = Puppet::Parser::Parser.new(environment)
|
161
|
-
if code = Puppet.settings.uninterpolated_value(:code, environment.to_s) and code != ""
|
162
|
-
parser.string = code
|
163
|
-
else
|
164
|
-
file = Puppet.settings.value(:manifest, environment.to_s)
|
165
|
-
parser.file = file
|
166
|
-
end
|
167
|
-
parser.parse
|
168
|
-
rescue => detail
|
169
|
-
@parse_failed = true
|
170
|
-
|
171
|
-
msg = "Could not parse for environment #{environment}: #{detail}"
|
172
|
-
error = Puppet::Error.new(msg)
|
173
|
-
error.set_backtrace(detail.backtrace)
|
174
|
-
raise error
|
175
|
-
end
|
176
|
-
|
177
125
|
def require_reparse?
|
178
126
|
@parse_failed || stale?
|
179
127
|
end
|
@@ -206,8 +154,52 @@ class Puppet::Resource::TypeCollection
|
|
206
154
|
|
207
155
|
private
|
208
156
|
|
209
|
-
|
210
|
-
|
157
|
+
# Return a list of all possible fully-qualified names that might be
|
158
|
+
# meant by the given name, in the context of namespaces.
|
159
|
+
def resolve_namespaces(namespaces, name)
|
160
|
+
name = name.downcase
|
161
|
+
if name =~ /^::/
|
162
|
+
# name is explicitly fully qualified, so just return it, sans
|
163
|
+
# initial "::".
|
164
|
+
return [name.sub(/^::/, '')]
|
165
|
+
end
|
166
|
+
if name == ""
|
167
|
+
# The name "" has special meaning--it always refers to a "main"
|
168
|
+
# hostclass which contains all toplevel resources.
|
169
|
+
return [""]
|
170
|
+
end
|
171
|
+
|
172
|
+
namespaces = [namespaces] unless namespaces.is_a?(Array)
|
173
|
+
namespaces = namespaces.collect { |ns| ns.downcase }
|
174
|
+
|
175
|
+
result = []
|
176
|
+
namespaces.each do |namespace|
|
177
|
+
ary = namespace.split("::")
|
178
|
+
|
179
|
+
# Search each namespace nesting in innermost-to-outermost order.
|
180
|
+
while ary.length > 0
|
181
|
+
result << "#{ary.join("::")}::#{name}"
|
182
|
+
ary.pop
|
183
|
+
end
|
184
|
+
|
185
|
+
# Finally, search the toplevel namespace.
|
186
|
+
result << name
|
187
|
+
end
|
188
|
+
|
189
|
+
return result.uniq
|
190
|
+
end
|
191
|
+
|
192
|
+
# Resolve namespaces and find the given object. Autoload it if
|
193
|
+
# necessary.
|
194
|
+
def find_or_load(namespaces, name, type)
|
195
|
+
resolve_namespaces(namespaces, name).each do |fqname|
|
196
|
+
if result = send(type, fqname) || loader.try_load_fqname(type, fqname)
|
197
|
+
return result
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
# Nothing found.
|
202
|
+
return nil
|
211
203
|
end
|
212
204
|
|
213
205
|
def munge_name(name)
|
data/lib/puppet/simple_graph.rb
CHANGED
@@ -1,133 +1,48 @@
|
|
1
|
-
# Created by Luke A. Kanies on 2007-11-07.
|
2
|
-
# Copyright (c) 2007. All rights reserved.
|
3
|
-
|
4
1
|
require 'puppet/external/dot'
|
5
2
|
require 'puppet/relationship'
|
6
3
|
require 'set'
|
7
4
|
|
8
5
|
# A hopefully-faster graph class to replace the use of GRATR.
|
9
6
|
class Puppet::SimpleGraph
|
10
|
-
#
|
11
|
-
class
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
def adjacent(options)
|
28
|
-
direction = options[:direction] || :out
|
29
|
-
options[:type] ||= :vertices
|
30
|
-
|
31
|
-
return send(direction.to_s + "_edges") if options[:type] == :edges
|
32
|
-
|
33
|
-
@adjacencies[direction].keys.reject { |vertex| @adjacencies[direction][vertex].empty? }
|
34
|
-
end
|
35
|
-
|
36
|
-
# Add an edge to our list.
|
37
|
-
def add_edge(direction, edge)
|
38
|
-
opposite_adjacencies(direction, edge) << edge
|
39
|
-
end
|
40
|
-
|
41
|
-
# Return all known edges.
|
42
|
-
def edges
|
43
|
-
in_edges + out_edges
|
44
|
-
end
|
45
|
-
|
46
|
-
# Test whether we share an edge with a given vertex.
|
47
|
-
def has_edge?(direction, vertex)
|
48
|
-
return(vertex_adjacencies(direction, vertex).length > 0 ? true : false)
|
49
|
-
end
|
50
|
-
|
51
|
-
# Create methods for returning the degree and edges.
|
52
|
-
[:in, :out].each do |direction|
|
53
|
-
# LAK:NOTE If you decide to create methods for directly
|
54
|
-
# testing the degree, you'll have to get the values and flatten
|
55
|
-
# the results -- you might have duplicate edges, which can give
|
56
|
-
# a false impression of what the degree is. That's just
|
57
|
-
# as expensive as just getting the edge list, so I've decided
|
58
|
-
# to only add this method.
|
59
|
-
define_method("#{direction}_edges") do
|
60
|
-
@adjacencies[direction].values.inject([]) { |total, adjacent| total += adjacent.to_a; total }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# The other vertex in the edge.
|
65
|
-
def other_vertex(direction, edge)
|
66
|
-
case direction
|
67
|
-
when :in; edge.source
|
68
|
-
else
|
69
|
-
edge.target
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# Remove an edge from our list. Assumes that we've already checked
|
74
|
-
# that the edge is valid.
|
75
|
-
def remove_edge(direction, edge)
|
76
|
-
opposite_adjacencies(direction, edge).delete(edge)
|
77
|
-
end
|
78
|
-
|
79
|
-
def to_s
|
80
|
-
vertex.to_s
|
81
|
-
end
|
82
|
-
|
83
|
-
def inspect
|
84
|
-
{ :@adjacencies => @adjacencies, :@vertex => @vertex.to_s }.inspect
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
# These methods exist so we don't need a Hash with a default proc.
|
90
|
-
|
91
|
-
# Look up the adjacencies for a vertex at the other end of an
|
92
|
-
# edge.
|
93
|
-
def opposite_adjacencies(direction, edge)
|
94
|
-
opposite_vertex = other_vertex(direction, edge)
|
95
|
-
vertex_adjacencies(direction, opposite_vertex)
|
96
|
-
end
|
97
|
-
|
98
|
-
# Look up the adjacencies for a given vertex.
|
99
|
-
def vertex_adjacencies(direction, vertex)
|
100
|
-
@adjacencies[direction][vertex] ||= Set.new
|
101
|
-
@adjacencies[direction][vertex]
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
7
|
+
#
|
8
|
+
# All public methods of this class must maintain (assume ^ ensure) the following invariants, where "=~=" means
|
9
|
+
# equiv. up to order:
|
10
|
+
#
|
11
|
+
# @in_to.keys =~= @out_to.keys =~= all vertices
|
12
|
+
# @in_to.values.collect { |x| x.values }.flatten =~= @out_from.values.collect { |x| x.values }.flatten =~= all edges
|
13
|
+
# @in_to[v1][v2] =~= @out_from[v2][v1] =~= all edges from v1 to v2
|
14
|
+
# @in_to [v].keys =~= vertices with edges leading to v
|
15
|
+
# @out_from[v].keys =~= vertices with edges leading from v
|
16
|
+
# no operation may shed reference loops (for gc)
|
17
|
+
# recursive operation must scale with the depth of the spanning trees, or better (e.g. no recursion over the set
|
18
|
+
# of all vertices, etc.)
|
19
|
+
#
|
20
|
+
# This class is intended to be used with DAGs. However, if the
|
21
|
+
# graph has a cycle, it will not cause non-termination of any of the
|
22
|
+
# algorithms.
|
23
|
+
#
|
105
24
|
def initialize
|
106
|
-
@
|
107
|
-
@
|
25
|
+
@in_to = {}
|
26
|
+
@out_from = {}
|
27
|
+
@upstream_from = {}
|
28
|
+
@downstream_from = {}
|
108
29
|
end
|
109
30
|
|
110
31
|
# Clear our graph.
|
111
32
|
def clear
|
112
|
-
@
|
113
|
-
@
|
114
|
-
@
|
115
|
-
|
116
|
-
|
117
|
-
# Which resources a given resource depends upon.
|
118
|
-
def dependents(resource)
|
119
|
-
tree_from_vertex(resource).keys
|
33
|
+
@in_to.clear
|
34
|
+
@out_from.clear
|
35
|
+
@upstream_from.clear
|
36
|
+
@downstream_from.clear
|
120
37
|
end
|
121
38
|
|
122
39
|
# Which resources depend upon the given resource.
|
123
40
|
def dependencies(resource)
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
# in the :in direction.
|
130
|
-
@reversal.tree_from_vertex(resource, :out).keys
|
41
|
+
vertex?(resource) ? upstream_from_vertex(resource).keys : []
|
42
|
+
end
|
43
|
+
|
44
|
+
def dependents(resource)
|
45
|
+
vertex?(resource) ? downstream_from_vertex(resource).keys : []
|
131
46
|
end
|
132
47
|
|
133
48
|
# Whether our graph is directed. Always true. Used to produce dot files.
|
@@ -137,8 +52,7 @@ class Puppet::SimpleGraph
|
|
137
52
|
|
138
53
|
# Determine all of the leaf nodes below a given vertex.
|
139
54
|
def leaves(vertex, direction = :out)
|
140
|
-
|
141
|
-
l = tree.keys.find_all { |c| adjacent(c, :direction => direction).empty? }
|
55
|
+
tree_from_vertex(vertex, direction).keys.find_all { |c| adjacent(c, :direction => direction).empty? }
|
142
56
|
end
|
143
57
|
|
144
58
|
# Collect all of the edges that the passed events match. Returns
|
@@ -153,9 +67,7 @@ class Puppet::SimpleGraph
|
|
153
67
|
# Get all of the edges that this vertex should forward events
|
154
68
|
# to, which is the same thing as saying all edges directly below
|
155
69
|
# This vertex in the graph.
|
156
|
-
|
157
|
-
edge.match?(event.name)
|
158
|
-
end
|
70
|
+
@out_from[source].values.flatten.find_all { |edge| edge.match?(event.name) }
|
159
71
|
end
|
160
72
|
|
161
73
|
# Return a reversed version of this graph.
|
@@ -163,197 +75,268 @@ class Puppet::SimpleGraph
|
|
163
75
|
result = self.class.new
|
164
76
|
vertices.each { |vertex| result.add_vertex(vertex) }
|
165
77
|
edges.each do |edge|
|
166
|
-
|
167
|
-
result.add_edge(newedge)
|
78
|
+
result.add_edge edge.class.new(edge.target, edge.source, edge.label)
|
168
79
|
end
|
169
80
|
result
|
170
81
|
end
|
171
82
|
|
172
83
|
# Return the size of the graph.
|
173
84
|
def size
|
174
|
-
|
85
|
+
vertices.size
|
175
86
|
end
|
176
87
|
|
177
|
-
# Return the graph as an array.
|
178
88
|
def to_a
|
179
|
-
|
89
|
+
vertices
|
90
|
+
end
|
91
|
+
|
92
|
+
# This is a simple implementation of Tarjan's algorithm to find strongly
|
93
|
+
# connected components in the graph; this is a fairly ugly implementation,
|
94
|
+
# because I can't just decorate the vertices themselves.
|
95
|
+
#
|
96
|
+
# This method has an unhealthy relationship with the find_cycles_in_graph
|
97
|
+
# method below, which contains the knowledge of how the state object is
|
98
|
+
# maintained.
|
99
|
+
def tarjan(root, s)
|
100
|
+
# initialize the recursion stack we use to work around the nasty lack of a
|
101
|
+
# decent Ruby stack.
|
102
|
+
recur = [{ :node => root }]
|
103
|
+
|
104
|
+
while not recur.empty? do
|
105
|
+
frame = recur.last
|
106
|
+
vertex = frame[:node]
|
107
|
+
|
108
|
+
case frame[:step]
|
109
|
+
when nil then
|
110
|
+
s[:index][vertex] = s[:number]
|
111
|
+
s[:lowlink][vertex] = s[:number]
|
112
|
+
s[:number] = s[:number] + 1
|
113
|
+
|
114
|
+
s[:stack].push(vertex)
|
115
|
+
s[:seen][vertex] = true
|
116
|
+
|
117
|
+
frame[:children] = adjacent(vertex)
|
118
|
+
frame[:step] = :children
|
119
|
+
|
120
|
+
when :children then
|
121
|
+
if frame[:children].length > 0 then
|
122
|
+
child = frame[:children].shift
|
123
|
+
if ! s[:index][child] then
|
124
|
+
# Never seen, need to recurse.
|
125
|
+
frame[:step] = :after_recursion
|
126
|
+
frame[:child] = child
|
127
|
+
recur.push({ :node => child })
|
128
|
+
elsif s[:seen][child] then
|
129
|
+
s[:lowlink][vertex] = [s[:lowlink][vertex], s[:index][child]].min
|
130
|
+
end
|
131
|
+
else
|
132
|
+
if s[:lowlink][vertex] == s[:index][vertex] then
|
133
|
+
this_scc = []
|
134
|
+
begin
|
135
|
+
top = s[:stack].pop
|
136
|
+
s[:seen][top] = false
|
137
|
+
this_scc << top
|
138
|
+
end until top == vertex
|
139
|
+
# NOTE: if we don't reverse we get the components in the opposite
|
140
|
+
# order to what a human being would expect; reverse should be an
|
141
|
+
# O(1) operation, without even copying, because we know the length
|
142
|
+
# of the source, but I worry that an implementation will get this
|
143
|
+
# wrong. Still, the worst case is O(n) for n vertices as we can't
|
144
|
+
# possibly put a vertex into two SCCs.
|
145
|
+
#
|
146
|
+
# Also, my feeling is that most implementations are going to do
|
147
|
+
# better with a reverse operation than a string of 'unshift'
|
148
|
+
# insertions at the head of the array; if they were going to mess
|
149
|
+
# up the performance of one, it would be unshift.
|
150
|
+
s[:scc] << this_scc.reverse
|
151
|
+
end
|
152
|
+
recur.pop # done with this node, finally.
|
153
|
+
end
|
154
|
+
|
155
|
+
when :after_recursion then
|
156
|
+
s[:lowlink][vertex] = [s[:lowlink][vertex], s[:lowlink][frame[:child]]].min
|
157
|
+
frame[:step] = :children
|
158
|
+
|
159
|
+
else
|
160
|
+
fail "#{frame[:step]} is an unknown step"
|
161
|
+
end
|
162
|
+
end
|
180
163
|
end
|
181
164
|
|
182
|
-
#
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
165
|
+
# Find all cycles in the graph by detecting all the strongly connected
|
166
|
+
# components, then eliminating everything with a size of one as
|
167
|
+
# uninteresting - which it is, because it can't be a cycle. :)
|
168
|
+
#
|
169
|
+
# This has an unhealthy relationship with the 'tarjan' method above, which
|
170
|
+
# it uses to implement the detection of strongly connected components.
|
171
|
+
def find_cycles_in_graph
|
172
|
+
state = {
|
173
|
+
:number => 0, :index => {}, :lowlink => {}, :scc => [],
|
174
|
+
:stack => [], :seen => {}
|
175
|
+
}
|
176
|
+
|
177
|
+
# we usually have a disconnected graph, must walk all possible roots
|
178
|
+
vertices.each do |vertex|
|
179
|
+
if ! state[:index][vertex] then
|
180
|
+
tarjan vertex, state
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
state[:scc].select { |c| c.length > 1 }
|
185
|
+
end
|
187
186
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
187
|
+
# Perform a BFS on the sub graph representing the cycle, with a view to
|
188
|
+
# generating a sufficient set of paths to report the cycle meaningfully, and
|
189
|
+
# ideally usefully, for the end user.
|
190
|
+
#
|
191
|
+
# BFS is preferred because it will generally report the shortest paths
|
192
|
+
# through the graph first, which are more likely to be interesting to the
|
193
|
+
# user. I think; it would be interesting to verify that. --daniel 2011-01-23
|
194
|
+
def paths_in_cycle(cycle, max_paths = 1)
|
195
|
+
raise ArgumentError, "negative or zero max_paths" if max_paths < 1
|
196
|
+
|
197
|
+
# Calculate our filtered outbound vertex lists...
|
198
|
+
adj = {}
|
199
|
+
cycle.each do |vertex|
|
200
|
+
adj[vertex] = adjacent(vertex).select{|s| cycle.member? s}
|
193
201
|
end
|
194
202
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
203
|
+
found = []
|
204
|
+
|
205
|
+
# frame struct is vertex, [path]
|
206
|
+
stack = [[cycle.first, []]]
|
207
|
+
while frame = stack.shift do
|
208
|
+
if frame[1].member?(frame[0]) then
|
209
|
+
found << frame[1] + [frame[0]]
|
210
|
+
break if found.length >= max_paths
|
211
|
+
else
|
212
|
+
adj[frame[0]].each do |to|
|
213
|
+
stack.push [to, frame[1] + [frame[0]]]
|
214
|
+
end
|
202
215
|
end
|
203
216
|
end
|
204
217
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
218
|
+
return found
|
219
|
+
end
|
220
|
+
|
221
|
+
def report_cycles_in_graph
|
222
|
+
cycles = find_cycles_in_graph
|
223
|
+
n = cycles.length # where is "pluralize"? --daniel 2011-01-22
|
224
|
+
return if n == 0
|
225
|
+
s = n == 1 ? '' : 's'
|
226
|
+
|
227
|
+
message = "Found #{n} dependency cycle#{s}:\n"
|
228
|
+
cycles.each do |cycle|
|
229
|
+
paths = paths_in_cycle(cycle)
|
230
|
+
message += paths.map{ |path| '(' + path.join(" => ") + ')'}.join("\n") + "\n"
|
209
231
|
end
|
210
232
|
|
211
|
-
|
233
|
+
if Puppet[:graph] then
|
234
|
+
filename = write_cycles_to_graph(cycles)
|
235
|
+
message += "Cycle graph written to #{filename}."
|
236
|
+
else
|
237
|
+
message += "Try the '--graph' option and opening the "
|
238
|
+
message += "resulting '.dot' file in OmniGraffle or GraphViz"
|
239
|
+
end
|
240
|
+
|
241
|
+
raise Puppet::Error, message
|
242
|
+
end
|
243
|
+
|
244
|
+
def write_cycles_to_graph(cycles)
|
245
|
+
# This does not use the DOT graph library, just writes the content
|
246
|
+
# directly. Given the complexity of this, there didn't seem much point
|
247
|
+
# using a heavy library to generate exactly the same content. --daniel 2011-01-27
|
248
|
+
Puppet.settings.use(:graphing)
|
249
|
+
|
250
|
+
graph = ["digraph Resource_Cycles {"]
|
251
|
+
graph << ' label = "Resource Cycles"'
|
252
|
+
|
253
|
+
cycles.each do |cycle|
|
254
|
+
paths_in_cycle(cycle, 10).each do |path|
|
255
|
+
graph << path.map { |v| '"' + v.to_s.gsub(/"/, '\\"') + '"' }.join(" -> ")
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
graph << '}'
|
260
|
+
|
261
|
+
filename = File.join(Puppet[:graphdir], "cycles.dot")
|
262
|
+
File.open(filename, "w") { |f| f.puts graph }
|
263
|
+
return filename
|
212
264
|
end
|
213
265
|
|
214
266
|
# Add a new vertex to the graph.
|
215
267
|
def add_vertex(vertex)
|
216
|
-
@
|
217
|
-
|
218
|
-
setup_vertex(vertex)
|
219
|
-
true # don't return the VertexWrapper instance.
|
268
|
+
@in_to[vertex] ||= {}
|
269
|
+
@out_from[vertex] ||= {}
|
220
270
|
end
|
221
271
|
|
222
272
|
# Remove a vertex from the graph.
|
223
|
-
def remove_vertex!(
|
224
|
-
return
|
225
|
-
@
|
226
|
-
@
|
227
|
-
@
|
228
|
-
@
|
273
|
+
def remove_vertex!(v)
|
274
|
+
return unless vertex?(v)
|
275
|
+
@upstream_from.clear
|
276
|
+
@downstream_from.clear
|
277
|
+
(@in_to[v].values+@out_from[v].values).flatten.each { |e| remove_edge!(e) }
|
278
|
+
@in_to.delete(v)
|
279
|
+
@out_from.delete(v)
|
229
280
|
end
|
230
281
|
|
231
282
|
# Test whether a given vertex is in the graph.
|
232
|
-
def vertex?(
|
233
|
-
@
|
283
|
+
def vertex?(v)
|
284
|
+
@in_to.include?(v)
|
234
285
|
end
|
235
286
|
|
236
287
|
# Return a list of all vertices.
|
237
288
|
def vertices
|
238
|
-
@
|
289
|
+
@in_to.keys
|
239
290
|
end
|
240
291
|
|
241
292
|
# Add a new edge. The graph user has to create the edge instance,
|
242
293
|
# since they have to specify what kind of edge it is.
|
243
|
-
def add_edge(
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
[
|
251
|
-
@vertices[edge.source].add_edge :out, edge
|
252
|
-
@vertices[edge.target].add_edge :in, edge
|
253
|
-
@edges << edge
|
254
|
-
true
|
294
|
+
def add_edge(e,*a)
|
295
|
+
return add_relationship(e,*a) unless a.empty?
|
296
|
+
@upstream_from.clear
|
297
|
+
@downstream_from.clear
|
298
|
+
add_vertex(e.source)
|
299
|
+
add_vertex(e.target)
|
300
|
+
@in_to[ e.target][e.source] ||= []; @in_to[ e.target][e.source] |= [e]
|
301
|
+
@out_from[e.source][e.target] ||= []; @out_from[e.source][e.target] |= [e]
|
255
302
|
end
|
256
303
|
|
257
|
-
|
258
|
-
|
259
|
-
def edge(source, target)
|
260
|
-
@edges.each_with_index { |test_edge, index| return test_edge if test_edge.source == source and test_edge.target == target }
|
304
|
+
def add_relationship(source, target, label = nil)
|
305
|
+
add_edge Puppet::Relationship.new(source, target, label)
|
261
306
|
end
|
262
307
|
|
263
|
-
|
264
|
-
|
265
|
-
|
308
|
+
# Find all matching edges.
|
309
|
+
def edges_between(source, target)
|
310
|
+
(@out_from[source] || {})[target] || []
|
266
311
|
end
|
267
312
|
|
268
313
|
# Is there an edge between the two vertices?
|
269
314
|
def edge?(source, target)
|
270
|
-
|
271
|
-
|
272
|
-
@vertices[source].has_edge?(:out, target)
|
315
|
+
vertex?(source) and vertex?(target) and @out_from[source][target]
|
273
316
|
end
|
274
317
|
|
275
318
|
def edges
|
276
|
-
@
|
319
|
+
@in_to.values.collect { |x| x.values }.flatten
|
277
320
|
end
|
278
321
|
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
@vertices[edge.target].remove_edge(:in, edge)
|
322
|
+
def each_edge
|
323
|
+
@in_to.each { |t,ns| ns.each { |s,es| es.each { |e| yield e }}}
|
324
|
+
end
|
283
325
|
|
284
|
-
|
285
|
-
|
326
|
+
# Remove an edge from our graph.
|
327
|
+
def remove_edge!(e)
|
328
|
+
if edge?(e.source,e.target)
|
329
|
+
@upstream_from.clear
|
330
|
+
@downstream_from.clear
|
331
|
+
@in_to [e.target].delete e.source if (@in_to [e.target][e.source] -= [e]).empty?
|
332
|
+
@out_from[e.source].delete e.target if (@out_from[e.source][e.target] -= [e]).empty?
|
333
|
+
end
|
286
334
|
end
|
287
335
|
|
288
336
|
# Find adjacent edges.
|
289
|
-
def adjacent(
|
290
|
-
return [] unless
|
291
|
-
|
292
|
-
end
|
293
|
-
|
294
|
-
private
|
295
|
-
|
296
|
-
# An internal method that skips the validation, so we don't have
|
297
|
-
# duplicate validation calls.
|
298
|
-
def setup_vertex(vertex)
|
299
|
-
@vertices[vertex] = VertexWrapper.new(vertex)
|
300
|
-
end
|
301
|
-
|
302
|
-
public
|
303
|
-
|
304
|
-
# # For some reason, unconnected vertices do not show up in
|
305
|
-
# # this graph.
|
306
|
-
# def to_jpg(path, name)
|
307
|
-
# gv = vertices
|
308
|
-
# Dir.chdir(path) do
|
309
|
-
# induced_subgraph(gv).write_to_graphic_file('jpg', name)
|
310
|
-
# end
|
311
|
-
# end
|
312
|
-
|
313
|
-
# Take container information from another graph and use it
|
314
|
-
# to replace any container vertices with their respective leaves.
|
315
|
-
# This creates direct relationships where there were previously
|
316
|
-
# indirect relationships through the containers.
|
317
|
-
def splice!(other, type)
|
318
|
-
# We have to get the container list via a topological sort on the
|
319
|
-
# configuration graph, because otherwise containers that contain
|
320
|
-
# other containers will add those containers back into the
|
321
|
-
# graph. We could get a similar affect by only setting relationships
|
322
|
-
# to container leaves, but that would result in many more
|
323
|
-
# relationships.
|
324
|
-
stage_class = Puppet::Type.type(:stage)
|
325
|
-
whit_class = Puppet::Type.type(:whit)
|
326
|
-
containers = other.topsort.find_all { |v| (v.is_a?(type) or v.is_a?(stage_class)) and vertex?(v) }
|
327
|
-
containers.each do |container|
|
328
|
-
# Get the list of children from the other graph.
|
329
|
-
children = other.adjacent(container, :direction => :out)
|
330
|
-
|
331
|
-
# MQR TODO: Luke suggests that it should be possible to refactor the system so that
|
332
|
-
# container nodes are retained, thus obviating the need for the whit.
|
333
|
-
children = [whit_class.new(:name => container.name, :catalog => other)] if children.empty?
|
334
|
-
|
335
|
-
# First create new edges for each of the :in edges
|
336
|
-
[:in, :out].each do |dir|
|
337
|
-
edges = adjacent(container, :direction => dir, :type => :edges)
|
338
|
-
edges.each do |edge|
|
339
|
-
children.each do |child|
|
340
|
-
if dir == :in
|
341
|
-
s = edge.source
|
342
|
-
t = child
|
343
|
-
else
|
344
|
-
s = child
|
345
|
-
t = edge.target
|
346
|
-
end
|
347
|
-
|
348
|
-
add_edge(s, t, edge.label)
|
349
|
-
end
|
350
|
-
|
351
|
-
# Now get rid of the edge, so remove_vertex! works correctly.
|
352
|
-
remove_edge!(edge)
|
353
|
-
end
|
354
|
-
end
|
355
|
-
remove_vertex!(container)
|
356
|
-
end
|
337
|
+
def adjacent(v, options = {})
|
338
|
+
return [] unless ns = (options[:direction] == :in) ? @in_to[v] : @out_from[v]
|
339
|
+
(options[:type] == :edges) ? ns.values.flatten : ns.keys
|
357
340
|
end
|
358
341
|
|
359
342
|
# Just walk the tree and pass each edge.
|
@@ -385,6 +368,60 @@ class Puppet::SimpleGraph
|
|
385
368
|
predecessor
|
386
369
|
end
|
387
370
|
|
371
|
+
def downstream_from_vertex(v)
|
372
|
+
return @downstream_from[v] if @downstream_from[v]
|
373
|
+
result = @downstream_from[v] = {}
|
374
|
+
@out_from[v].keys.each do |node|
|
375
|
+
result[node] = 1
|
376
|
+
result.update(downstream_from_vertex(node))
|
377
|
+
end
|
378
|
+
result
|
379
|
+
end
|
380
|
+
|
381
|
+
def direct_dependents_of(v)
|
382
|
+
(@out_from[v] || {}).keys
|
383
|
+
end
|
384
|
+
|
385
|
+
def upstream_from_vertex(v)
|
386
|
+
return @upstream_from[v] if @upstream_from[v]
|
387
|
+
result = @upstream_from[v] = {}
|
388
|
+
@in_to[v].keys.each do |node|
|
389
|
+
result[node] = 1
|
390
|
+
result.update(upstream_from_vertex(node))
|
391
|
+
end
|
392
|
+
result
|
393
|
+
end
|
394
|
+
|
395
|
+
def direct_dependencies_of(v)
|
396
|
+
(@in_to[v] || {}).keys
|
397
|
+
end
|
398
|
+
|
399
|
+
# Return an array of the edge-sets between a series of n+1 vertices (f=v0,v1,v2...t=vn)
|
400
|
+
# connecting the two given verticies. The ith edge set is an array containing all the
|
401
|
+
# edges between v(i) and v(i+1); these are (by definition) never empty.
|
402
|
+
#
|
403
|
+
# * if f == t, the list is empty
|
404
|
+
# * if they are adjacent the result is an array consisting of
|
405
|
+
# a single array (the edges from f to t)
|
406
|
+
# * and so on by induction on a vertex m between them
|
407
|
+
# * if there is no path from f to t, the result is nil
|
408
|
+
#
|
409
|
+
# This implementation is not particularly efficient; it's used in testing where clarity
|
410
|
+
# is more important than last-mile efficiency.
|
411
|
+
#
|
412
|
+
def path_between(f,t)
|
413
|
+
if f==t
|
414
|
+
[]
|
415
|
+
elsif direct_dependents_of(f).include?(t)
|
416
|
+
[edges_between(f,t)]
|
417
|
+
elsif dependents(f).include?(t)
|
418
|
+
m = (dependents(f) & direct_dependencies_of(t)).first
|
419
|
+
path_between(f,m) + path_between(m,t)
|
420
|
+
else
|
421
|
+
nil
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
388
425
|
# LAK:FIXME This is just a paste of the GRATR code with slight modifications.
|
389
426
|
|
390
427
|
# Return a DOT::DOTDigraph for directed graphs or a DOT::DOTSubgraph for an
|
@@ -426,18 +463,6 @@ class Puppet::SimpleGraph
|
|
426
463
|
system('dotty', dotfile)
|
427
464
|
end
|
428
465
|
|
429
|
-
# Use +dot+ to create a graphical representation of the graph. Returns the
|
430
|
-
# filename of the graphics file.
|
431
|
-
def write_to_graphic_file (fmt='png', dotfile='graph')
|
432
|
-
src = dotfile + '.dot'
|
433
|
-
dot = dotfile + '.' + fmt
|
434
|
-
|
435
|
-
File.open(src, 'w') {|f| f << self.to_dot << "\n"}
|
436
|
-
|
437
|
-
system( "dot -T#{fmt} #{src} -o #{dot}" )
|
438
|
-
dot
|
439
|
-
end
|
440
|
-
|
441
466
|
# Produce the graph files if requested.
|
442
467
|
def write_graph(name)
|
443
468
|
return unless Puppet[:graph]
|
@@ -449,4 +474,80 @@ class Puppet::SimpleGraph
|
|
449
474
|
f.puts to_dot("name" => name.to_s.capitalize)
|
450
475
|
}
|
451
476
|
end
|
477
|
+
|
478
|
+
# This flag may be set to true to use the new YAML serialzation
|
479
|
+
# format (where @vertices is a simple list of vertices rather than a
|
480
|
+
# list of VertexWrapper objects). Deserialization supports both
|
481
|
+
# formats regardless of the setting of this flag.
|
482
|
+
class << self
|
483
|
+
attr_accessor :use_new_yaml_format
|
484
|
+
end
|
485
|
+
self.use_new_yaml_format = false
|
486
|
+
|
487
|
+
# Stub class to allow graphs to be represented in YAML using the old
|
488
|
+
# (version 2.6) format.
|
489
|
+
class VertexWrapper
|
490
|
+
attr_reader :vertex, :adjacencies
|
491
|
+
def initialize(vertex, adjacencies)
|
492
|
+
@vertex = vertex
|
493
|
+
@adjacencies = adjacencies
|
494
|
+
end
|
495
|
+
|
496
|
+
def inspect
|
497
|
+
{ :@adjacencies => @adjacencies, :@vertex => @vertex.to_s }.inspect
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
# instance_variable_get is used by Object.to_zaml to get instance
|
502
|
+
# variables. Override it so that we can simulate the presence of
|
503
|
+
# instance variables @edges and @vertices for serialization.
|
504
|
+
def instance_variable_get(v)
|
505
|
+
case v.to_s
|
506
|
+
when '@edges' then
|
507
|
+
edges
|
508
|
+
when '@vertices' then
|
509
|
+
if self.class.use_new_yaml_format
|
510
|
+
vertices
|
511
|
+
else
|
512
|
+
result = {}
|
513
|
+
vertices.each do |vertex|
|
514
|
+
adjacencies = {}
|
515
|
+
[:in, :out].each do |direction|
|
516
|
+
adjacencies[direction] = {}
|
517
|
+
adjacent(vertex, :direction => direction, :type => :edges).each do |edge|
|
518
|
+
other_vertex = direction == :in ? edge.source : edge.target
|
519
|
+
(adjacencies[direction][other_vertex] ||= Set.new).add(edge)
|
520
|
+
end
|
521
|
+
end
|
522
|
+
result[vertex] = Puppet::SimpleGraph::VertexWrapper.new(vertex, adjacencies)
|
523
|
+
end
|
524
|
+
result
|
525
|
+
end
|
526
|
+
else
|
527
|
+
super(v)
|
528
|
+
end
|
529
|
+
end
|
530
|
+
|
531
|
+
def to_yaml_properties
|
532
|
+
other_vars = instance_variables.
|
533
|
+
map {|v| v.to_s}.
|
534
|
+
reject { |v| %w{@in_to @out_from @upstream_from @downstream_from}.include?(v) }
|
535
|
+
|
536
|
+
(other_vars + %w{@vertices @edges}).sort.uniq
|
537
|
+
end
|
538
|
+
|
539
|
+
def yaml_initialize(tag, var)
|
540
|
+
initialize()
|
541
|
+
vertices = var.delete('vertices')
|
542
|
+
edges = var.delete('edges')
|
543
|
+
if vertices.is_a?(Hash)
|
544
|
+
# Support old (2.6) format
|
545
|
+
vertices = vertices.keys
|
546
|
+
end
|
547
|
+
vertices.each { |v| add_vertex(v) }
|
548
|
+
edges.each { |e| add_edge(e) }
|
549
|
+
var.each do |varname, value|
|
550
|
+
instance_variable_set("@#{varname}", value)
|
551
|
+
end
|
552
|
+
end
|
452
553
|
end
|