puppet 0.25.5 → 2.6.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.

Files changed (1474) hide show
  1. data/CHANGELOG +667 -0
  2. data/LICENSE +2 -2
  3. data/README +5 -1
  4. data/README.queueing +1 -1
  5. data/README.rst +7 -4
  6. data/Rakefile +6 -18
  7. data/bin/filebucket +0 -94
  8. data/bin/pi +2 -47
  9. data/bin/puppet +2 -69
  10. data/bin/puppetca +2 -100
  11. data/bin/puppetd +2 -158
  12. data/bin/puppetdoc +2 -63
  13. data/bin/puppetmasterd +2 -64
  14. data/bin/puppetqd +2 -51
  15. data/bin/puppetrun +2 -127
  16. data/bin/ralsh +2 -87
  17. data/conf/epm.list +2 -2
  18. data/conf/osx/PackageInfo.plist +1 -1
  19. data/conf/redhat/client.init +11 -8
  20. data/conf/redhat/puppet.conf +1 -1
  21. data/conf/redhat/puppet.spec +1 -1
  22. data/conf/redhat/rundir-perms.patch +13 -13
  23. data/conf/redhat/server.init +11 -5
  24. data/conf/solaris/pkginfo +2 -2
  25. data/conf/solaris/smf/puppetd.xml +3 -3
  26. data/conf/solaris/smf/puppetmasterd.xml +3 -3
  27. data/conf/suse/client.init +3 -2
  28. data/conf/suse/puppet.spec +22 -18
  29. data/conf/suse/server.init +12 -11
  30. data/examples/modules/sample-module/README.txt +3 -3
  31. data/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb +4 -4
  32. data/ext/extlookup.rb +94 -96
  33. data/ext/nagios/check_puppet.rb +94 -88
  34. data/ext/nagios/naggen +3 -3
  35. data/ext/puppet-test +27 -3
  36. data/ext/puppetlisten/puppetlisten.rb +39 -39
  37. data/ext/puppetlisten/puppetrun.rb +6 -6
  38. data/ext/puppetstoredconfigclean.rb +49 -43
  39. data/ext/pure_ruby_dsl/dsl_test.rb +7 -0
  40. data/ext/regexp_nodes/regexp_nodes.rb +133 -133
  41. data/ext/yaml_nodes.rb +99 -0
  42. data/install.rb +109 -118
  43. data/lib/puppet.rb +118 -131
  44. data/lib/puppet/agent.rb +86 -119
  45. data/lib/puppet/agent/locker.rb +28 -30
  46. data/lib/puppet/application.rb +276 -184
  47. data/lib/puppet/application/agent.rb +266 -0
  48. data/lib/puppet/application/apply.rb +165 -0
  49. data/lib/puppet/application/cert.rb +85 -0
  50. data/lib/puppet/application/describe.rb +203 -0
  51. data/lib/puppet/application/doc.rb +215 -0
  52. data/lib/puppet/application/filebucket.rb +73 -73
  53. data/lib/puppet/application/kick.rb +212 -0
  54. data/lib/puppet/application/master.rb +156 -0
  55. data/lib/puppet/application/queue.rb +91 -0
  56. data/lib/puppet/application/resource.rb +118 -0
  57. data/lib/puppet/configurer.rb +214 -197
  58. data/lib/puppet/configurer/downloader.rb +63 -63
  59. data/lib/puppet/configurer/fact_handler.rb +51 -51
  60. data/lib/puppet/configurer/plugin_handler.rb +19 -19
  61. data/lib/puppet/daemon.rb +100 -103
  62. data/lib/puppet/defaults.rb +793 -796
  63. data/lib/puppet/dsl.rb +5 -269
  64. data/lib/puppet/dsl/resource_api.rb +120 -0
  65. data/lib/puppet/dsl/resource_type_api.rb +40 -0
  66. data/lib/puppet/error.rb +34 -36
  67. data/lib/puppet/external/base64.rb +8 -8
  68. data/lib/puppet/external/dot.rb +262 -262
  69. data/lib/puppet/external/event-loop/better-definers.rb +297 -297
  70. data/lib/puppet/external/event-loop/event-loop.rb +264 -272
  71. data/lib/puppet/external/event-loop/signal-system.rb +161 -163
  72. data/lib/puppet/external/lock.rb +41 -41
  73. data/lib/puppet/external/nagios.rb +32 -32
  74. data/lib/puppet/external/nagios/base.rb +453 -458
  75. data/lib/puppet/external/nagios/parser.rb +264 -287
  76. data/lib/puppet/external/pson/common.rb +8 -5
  77. data/lib/puppet/external/pson/pure/generator.rb +26 -26
  78. data/lib/puppet/external/pson/pure/parser.rb +43 -48
  79. data/lib/puppet/feature/base.rb +21 -1
  80. data/lib/puppet/feature/pson.rb +4 -4
  81. data/lib/puppet/feature/rack.rb +14 -14
  82. data/lib/puppet/feature/rails.rb +23 -25
  83. data/lib/puppet/file_bucket.rb +4 -0
  84. data/lib/puppet/file_bucket/dipper.rb +99 -0
  85. data/lib/puppet/file_bucket/file.rb +136 -0
  86. data/lib/puppet/file_bucket/file/indirection_hooks.rb +9 -0
  87. data/lib/puppet/file_collection.rb +20 -20
  88. data/lib/puppet/file_collection/lookup.rb +11 -11
  89. data/lib/puppet/file_serving/base.rb +67 -71
  90. data/lib/puppet/file_serving/configuration.rb +84 -86
  91. data/lib/puppet/file_serving/configuration/parser.rb +103 -102
  92. data/lib/puppet/file_serving/content.rb +34 -33
  93. data/lib/puppet/file_serving/fileset.rb +131 -133
  94. data/lib/puppet/file_serving/indirection_hooks.rb +17 -17
  95. data/lib/puppet/file_serving/metadata.rb +98 -95
  96. data/lib/puppet/file_serving/mount.rb +22 -22
  97. data/lib/puppet/file_serving/mount/file.rb +101 -106
  98. data/lib/puppet/file_serving/mount/modules.rb +15 -15
  99. data/lib/puppet/file_serving/mount/plugins.rb +15 -16
  100. data/lib/puppet/file_serving/terminus_helper.rb +13 -13
  101. data/lib/puppet/indirector.rb +48 -49
  102. data/lib/puppet/indirector/active_record.rb +19 -19
  103. data/lib/puppet/indirector/catalog/active_record.rb +25 -25
  104. data/lib/puppet/indirector/catalog/compiler.rb +134 -145
  105. data/lib/puppet/indirector/catalog/rest.rb +1 -1
  106. data/lib/puppet/indirector/catalog/yaml.rb +13 -13
  107. data/lib/puppet/indirector/certificate/ca.rb +3 -3
  108. data/lib/puppet/indirector/certificate/file.rb +3 -3
  109. data/lib/puppet/indirector/certificate/rest.rb +8 -8
  110. data/lib/puppet/indirector/certificate_request/ca.rb +7 -7
  111. data/lib/puppet/indirector/certificate_request/file.rb +2 -2
  112. data/lib/puppet/indirector/certificate_request/rest.rb +3 -3
  113. data/lib/puppet/indirector/certificate_revocation_list/ca.rb +2 -2
  114. data/lib/puppet/indirector/certificate_revocation_list/file.rb +2 -2
  115. data/lib/puppet/indirector/certificate_revocation_list/rest.rb +3 -3
  116. data/lib/puppet/indirector/couch.rb +76 -0
  117. data/lib/puppet/indirector/direct_file_server.rb +11 -11
  118. data/lib/puppet/indirector/envelope.rb +4 -4
  119. data/lib/puppet/indirector/exec.rb +38 -42
  120. data/lib/puppet/indirector/facts/active_record.rb +24 -24
  121. data/lib/puppet/indirector/facts/couch.rb +31 -0
  122. data/lib/puppet/indirector/facts/facter.rb +63 -61
  123. data/lib/puppet/indirector/facts/memory.rb +4 -4
  124. data/lib/puppet/indirector/facts/rest.rb +1 -1
  125. data/lib/puppet/indirector/facts/yaml.rb +2 -2
  126. data/lib/puppet/indirector/file.rb +67 -46
  127. data/lib/puppet/indirector/file_bucket_file/file.rb +146 -0
  128. data/lib/puppet/indirector/file_bucket_file/rest.rb +8 -0
  129. data/lib/puppet/indirector/file_content/file.rb +1 -1
  130. data/lib/puppet/indirector/file_content/file_server.rb +1 -1
  131. data/lib/puppet/indirector/file_content/rest.rb +1 -1
  132. data/lib/puppet/indirector/file_metadata/file.rb +11 -11
  133. data/lib/puppet/indirector/file_metadata/file_server.rb +1 -1
  134. data/lib/puppet/indirector/file_metadata/rest.rb +1 -1
  135. data/lib/puppet/indirector/file_server.rb +44 -44
  136. data/lib/puppet/indirector/indirection.rb +249 -260
  137. data/lib/puppet/indirector/key/ca.rb +5 -5
  138. data/lib/puppet/indirector/key/file.rb +29 -29
  139. data/lib/puppet/indirector/ldap.rb +62 -64
  140. data/lib/puppet/indirector/memory.rb +13 -13
  141. data/lib/puppet/indirector/node/active_record.rb +6 -6
  142. data/lib/puppet/indirector/node/exec.rb +40 -44
  143. data/lib/puppet/indirector/node/ldap.rb +246 -212
  144. data/lib/puppet/indirector/node/memory.rb +5 -5
  145. data/lib/puppet/indirector/node/plain.rb +12 -12
  146. data/lib/puppet/indirector/node/rest.rb +2 -2
  147. data/lib/puppet/indirector/node/yaml.rb +2 -2
  148. data/lib/puppet/indirector/plain.rb +4 -4
  149. data/lib/puppet/indirector/queue.rb +49 -51
  150. data/lib/puppet/indirector/report/processor.rb +34 -37
  151. data/lib/puppet/indirector/report/rest.rb +3 -3
  152. data/lib/puppet/indirector/request.rb +171 -157
  153. data/lib/puppet/indirector/resource/ral.rb +48 -0
  154. data/lib/puppet/indirector/resource/rest.rb +5 -0
  155. data/lib/puppet/indirector/resource_type.rb +5 -0
  156. data/lib/puppet/indirector/resource_type/parser.rb +27 -0
  157. data/lib/puppet/indirector/resource_type/rest.rb +7 -0
  158. data/lib/puppet/indirector/rest.rb +83 -79
  159. data/lib/puppet/indirector/run/local.rb +8 -0
  160. data/lib/puppet/indirector/run/rest.rb +6 -0
  161. data/lib/puppet/indirector/ssl_file.rb +165 -165
  162. data/lib/puppet/indirector/status.rb +3 -0
  163. data/lib/puppet/indirector/status/local.rb +7 -0
  164. data/lib/puppet/indirector/status/rest.rb +5 -0
  165. data/lib/puppet/indirector/terminus.rb +129 -133
  166. data/lib/puppet/indirector/yaml.rb +47 -49
  167. data/lib/puppet/metatype/manager.rb +120 -114
  168. data/lib/puppet/module.rb +182 -124
  169. data/lib/puppet/network/authconfig.rb +146 -156
  170. data/lib/puppet/network/authorization.rb +63 -70
  171. data/lib/puppet/network/authstore.rb +226 -232
  172. data/lib/puppet/network/client.rb +141 -152
  173. data/lib/puppet/network/client/ca.rb +47 -49
  174. data/lib/puppet/network/client/file.rb +3 -3
  175. data/lib/puppet/network/client/proxy.rb +19 -19
  176. data/lib/puppet/network/client/report.rb +17 -21
  177. data/lib/puppet/network/client/runner.rb +5 -7
  178. data/lib/puppet/network/client/status.rb +1 -1
  179. data/lib/puppet/network/client_request.rb +20 -22
  180. data/lib/puppet/network/format.rb +79 -81
  181. data/lib/puppet/network/format_handler.rb +135 -130
  182. data/lib/puppet/network/formats.rb +128 -154
  183. data/lib/puppet/network/handler.rb +43 -46
  184. data/lib/puppet/network/handler/ca.rb +129 -135
  185. data/lib/puppet/network/handler/filebucket.rb +39 -170
  186. data/lib/puppet/network/handler/fileserver.rb +624 -656
  187. data/lib/puppet/network/handler/master.rb +62 -75
  188. data/lib/puppet/network/handler/report.rb +60 -67
  189. data/lib/puppet/network/handler/runner.rb +20 -20
  190. data/lib/puppet/network/handler/status.rb +9 -9
  191. data/lib/puppet/network/http.rb +12 -12
  192. data/lib/puppet/network/http/api/v1.rb +49 -44
  193. data/lib/puppet/network/http/compression.rb +111 -0
  194. data/lib/puppet/network/http/handler.rb +183 -183
  195. data/lib/puppet/network/http/mongrel.rb +46 -48
  196. data/lib/puppet/network/http/mongrel/rest.rb +73 -66
  197. data/lib/puppet/network/http/rack.rb +45 -45
  198. data/lib/puppet/network/http/rack/httphandler.rb +7 -7
  199. data/lib/puppet/network/http/rack/rest.rb +84 -61
  200. data/lib/puppet/network/http/rack/xmlrpc.rb +49 -49
  201. data/lib/puppet/network/http/webrick.rb +108 -112
  202. data/lib/puppet/network/http/webrick/rest.rb +60 -57
  203. data/lib/puppet/network/http_pool.rb +95 -83
  204. data/lib/puppet/network/http_server/mongrel.rb +90 -90
  205. data/lib/puppet/network/http_server/webrick.rb +139 -148
  206. data/lib/puppet/network/rest_authconfig.rb +76 -71
  207. data/lib/puppet/network/rest_authorization.rb +11 -13
  208. data/lib/puppet/network/rights.rb +217 -226
  209. data/lib/puppet/network/server.rb +147 -151
  210. data/lib/puppet/network/xmlrpc/client.rb +197 -205
  211. data/lib/puppet/network/xmlrpc/processor.rb +68 -72
  212. data/lib/puppet/network/xmlrpc/server.rb +10 -10
  213. data/lib/puppet/network/xmlrpc/webrick_servlet.rb +94 -100
  214. data/lib/puppet/node.rb +99 -107
  215. data/lib/puppet/node/environment.rb +109 -62
  216. data/lib/puppet/node/facts.rb +48 -43
  217. data/lib/puppet/parameter.rb +246 -498
  218. data/lib/puppet/parameter/value.rb +63 -0
  219. data/lib/puppet/parameter/value_collection.rb +143 -0
  220. data/lib/puppet/parser.rb +4 -0
  221. data/lib/puppet/parser/ast.rb +81 -67
  222. data/lib/puppet/parser/ast/arithmetic_operator.rb +27 -29
  223. data/lib/puppet/parser/ast/astarray.rb +50 -50
  224. data/lib/puppet/parser/ast/asthash.rb +37 -0
  225. data/lib/puppet/parser/ast/boolean_operator.rb +33 -35
  226. data/lib/puppet/parser/ast/branch.rb +29 -31
  227. data/lib/puppet/parser/ast/caseopt.rb +50 -56
  228. data/lib/puppet/parser/ast/casestatement.rb +30 -30
  229. data/lib/puppet/parser/ast/collection.rb +43 -37
  230. data/lib/puppet/parser/ast/collexpr.rb +66 -69
  231. data/lib/puppet/parser/ast/comparison_operator.rb +32 -35
  232. data/lib/puppet/parser/ast/else.rb +13 -13
  233. data/lib/puppet/parser/ast/function.rb +34 -43
  234. data/lib/puppet/parser/ast/ifstatement.rb +23 -27
  235. data/lib/puppet/parser/ast/in_operator.rb +24 -0
  236. data/lib/puppet/parser/ast/leaf.rb +173 -156
  237. data/lib/puppet/parser/ast/match_operator.rb +16 -19
  238. data/lib/puppet/parser/ast/minus.rb +13 -13
  239. data/lib/puppet/parser/ast/nop.rb +6 -6
  240. data/lib/puppet/parser/ast/not.rb +9 -9
  241. data/lib/puppet/parser/ast/relationship.rb +60 -0
  242. data/lib/puppet/parser/ast/resource.rb +58 -57
  243. data/lib/puppet/parser/ast/resource_defaults.rb +16 -16
  244. data/lib/puppet/parser/ast/resource_override.rb +51 -51
  245. data/lib/puppet/parser/ast/resource_reference.rb +17 -72
  246. data/lib/puppet/parser/ast/resourceparam.rb +20 -17
  247. data/lib/puppet/parser/ast/selector.rb +30 -34
  248. data/lib/puppet/parser/ast/tag.rb +16 -16
  249. data/lib/puppet/parser/ast/vardef.rb +20 -16
  250. data/lib/puppet/parser/collector.rb +181 -189
  251. data/lib/puppet/parser/compiler.rb +395 -364
  252. data/lib/puppet/parser/files.rb +65 -69
  253. data/lib/puppet/parser/functions.rb +85 -97
  254. data/lib/puppet/parser/functions/defined.rb +23 -23
  255. data/lib/puppet/parser/functions/fail.rb +2 -2
  256. data/lib/puppet/parser/functions/file.rb +21 -19
  257. data/lib/puppet/parser/functions/fqdn_rand.rb +7 -7
  258. data/lib/puppet/parser/functions/generate.rb +24 -26
  259. data/lib/puppet/parser/functions/include.rb +16 -18
  260. data/lib/puppet/parser/functions/inline_template.rb +16 -17
  261. data/lib/puppet/parser/functions/realize.rb +8 -8
  262. data/lib/puppet/parser/functions/regsubst.rb +74 -59
  263. data/lib/puppet/parser/functions/require.rb +35 -33
  264. data/lib/puppet/parser/functions/search.rb +5 -5
  265. data/lib/puppet/parser/functions/sha1.rb +3 -4
  266. data/lib/puppet/parser/functions/shellquote.rb +31 -33
  267. data/lib/puppet/parser/functions/split.rb +8 -8
  268. data/lib/puppet/parser/functions/sprintf.rb +10 -9
  269. data/lib/puppet/parser/functions/tag.rb +3 -3
  270. data/lib/puppet/parser/functions/tagged.rb +13 -13
  271. data/lib/puppet/parser/functions/template.rb +18 -19
  272. data/lib/puppet/parser/functions/versioncmp.rb +17 -14
  273. data/lib/puppet/parser/grammar.ra +485 -422
  274. data/lib/puppet/parser/lexer.rb +500 -442
  275. data/lib/puppet/parser/parser.rb +1438 -1084
  276. data/lib/puppet/parser/parser_support.rb +227 -502
  277. data/lib/puppet/parser/relationship.rb +43 -0
  278. data/lib/puppet/parser/resource.rb +280 -375
  279. data/lib/puppet/parser/resource/param.rb +18 -18
  280. data/lib/puppet/parser/scope.rb +450 -447
  281. data/lib/puppet/parser/templatewrapper.rb +92 -94
  282. data/lib/puppet/parser/type_loader.rb +146 -0
  283. data/lib/puppet/parser/yaml_trimmer.rb +6 -8
  284. data/lib/puppet/property.rb +290 -453
  285. data/lib/puppet/property/ensure.rb +92 -0
  286. data/lib/puppet/property/keyvalue.rb +74 -82
  287. data/lib/puppet/property/list.rb +71 -81
  288. data/lib/puppet/property/ordered_list.rb +15 -15
  289. data/lib/puppet/provider.rb +229 -241
  290. data/lib/puppet/provider/augeas/augeas.rb +318 -320
  291. data/lib/puppet/provider/computer/computer.rb +13 -13
  292. data/lib/puppet/provider/confine.rb +63 -63
  293. data/lib/puppet/provider/confine/exists.rb +14 -14
  294. data/lib/puppet/provider/confine/false.rb +12 -12
  295. data/lib/puppet/provider/confine/feature.rb +10 -10
  296. data/lib/puppet/provider/confine/true.rb +13 -13
  297. data/lib/puppet/provider/confine/variable.rb +51 -54
  298. data/lib/puppet/provider/confine_collection.rb +38 -38
  299. data/lib/puppet/provider/confiner.rb +10 -14
  300. data/lib/puppet/provider/cron/crontab.rb +172 -173
  301. data/lib/puppet/provider/file/posix.rb +99 -0
  302. data/lib/puppet/provider/file/win32.rb +74 -0
  303. data/lib/puppet/provider/group/directoryservice.rb +6 -6
  304. data/lib/puppet/provider/group/groupadd.rb +18 -20
  305. data/lib/puppet/provider/group/ldap.rb +40 -43
  306. data/lib/puppet/provider/group/pw.rb +23 -23
  307. data/lib/puppet/provider/host/parsed.rb +51 -50
  308. data/lib/puppet/provider/ldap.rb +121 -123
  309. data/lib/puppet/provider/macauthorization/macauthorization.rb +263 -272
  310. data/lib/puppet/provider/mailalias/aliases.rb +34 -31
  311. data/lib/puppet/provider/maillist/mailman.rb +87 -93
  312. data/lib/puppet/provider/mcx/mcxcontent.rb +155 -151
  313. data/lib/puppet/provider/mount.rb +36 -40
  314. data/lib/puppet/provider/mount/parsed.rb +28 -26
  315. data/lib/puppet/provider/naginator.rb +46 -48
  316. data/lib/puppet/provider/nameservice.rb +215 -257
  317. data/lib/puppet/provider/nameservice/directoryservice.rb +455 -471
  318. data/lib/puppet/provider/nameservice/objectadd.rb +21 -21
  319. data/lib/puppet/provider/nameservice/pw.rb +13 -13
  320. data/lib/puppet/provider/package.rb +18 -20
  321. data/lib/puppet/provider/package/aix.rb +128 -0
  322. data/lib/puppet/provider/package/appdmg.rb +78 -82
  323. data/lib/puppet/provider/package/apple.rb +39 -40
  324. data/lib/puppet/provider/package/apt.rb +95 -104
  325. data/lib/puppet/provider/package/aptitude.rb +19 -21
  326. data/lib/puppet/provider/package/aptrpm.rb +70 -72
  327. data/lib/puppet/provider/package/blastwave.rb +88 -94
  328. data/lib/puppet/provider/package/darwinport.rb +67 -69
  329. data/lib/puppet/provider/package/dpkg.rb +123 -97
  330. data/lib/puppet/provider/package/fink.rb +66 -68
  331. data/lib/puppet/provider/package/freebsd.rb +38 -40
  332. data/lib/puppet/provider/package/gem.rb +98 -102
  333. data/lib/puppet/provider/package/hpux.rb +37 -39
  334. data/lib/puppet/provider/package/nim.rb +35 -0
  335. data/lib/puppet/provider/package/openbsd.rb +100 -75
  336. data/lib/puppet/provider/package/pkg.rb +108 -0
  337. data/lib/puppet/provider/package/pkgdmg.rb +95 -87
  338. data/lib/puppet/provider/package/portage.rb +101 -104
  339. data/lib/puppet/provider/package/ports.rb +71 -73
  340. data/lib/puppet/provider/package/portupgrade.rb +251 -0
  341. data/lib/puppet/provider/package/rpm.rb +113 -115
  342. data/lib/puppet/provider/package/rug.rb +46 -46
  343. data/lib/puppet/provider/package/sun.rb +135 -151
  344. data/lib/puppet/provider/package/sunfreeware.rb +5 -5
  345. data/lib/puppet/provider/package/up2date.rb +31 -31
  346. data/lib/puppet/provider/package/urpmi.rb +51 -51
  347. data/lib/puppet/provider/package/yum.rb +90 -98
  348. data/lib/puppet/provider/package/zypper.rb +52 -0
  349. data/lib/puppet/provider/parsedfile.rb +306 -329
  350. data/lib/puppet/provider/port/parsed.rb +5 -5
  351. data/lib/puppet/provider/selboolean/getsetsebool.rb +34 -34
  352. data/lib/puppet/provider/selmodule/semodule.rb +103 -111
  353. data/lib/puppet/provider/service/base.rb +134 -139
  354. data/lib/puppet/provider/service/bsd.rb +48 -0
  355. data/lib/puppet/provider/service/daemontools.rb +158 -162
  356. data/lib/puppet/provider/service/debian.rb +36 -36
  357. data/lib/puppet/provider/service/freebsd.rb +118 -38
  358. data/lib/puppet/provider/service/gentoo.rb +33 -39
  359. data/lib/puppet/provider/service/init.rb +125 -125
  360. data/lib/puppet/provider/service/launchd.rb +234 -254
  361. data/lib/puppet/provider/service/redhat.rb +58 -58
  362. data/lib/puppet/provider/service/runit.rb +74 -74
  363. data/lib/puppet/provider/service/smf.rb +81 -85
  364. data/lib/puppet/provider/service/src.rb +87 -0
  365. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +73 -81
  366. data/lib/puppet/provider/sshkey/parsed.rb +24 -21
  367. data/lib/puppet/provider/user/directoryservice.rb +71 -71
  368. data/lib/puppet/provider/user/hpux.rb +20 -20
  369. data/lib/puppet/provider/user/ldap.rb +106 -110
  370. data/lib/puppet/provider/user/pw.rb +33 -37
  371. data/lib/puppet/provider/user/user_role_add.rb +168 -183
  372. data/lib/puppet/provider/user/useradd.rb +50 -51
  373. data/lib/puppet/provider/zfs/solaris.rb +35 -35
  374. data/lib/puppet/provider/zone/solaris.rb +206 -205
  375. data/lib/puppet/provider/zpool/solaris.rb +95 -97
  376. data/lib/puppet/rails.rb +115 -122
  377. data/lib/puppet/rails/benchmark.rb +43 -49
  378. data/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +8 -12
  379. data/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb +8 -12
  380. data/lib/puppet/rails/database/003_add_environment_to_host.rb +6 -10
  381. data/lib/puppet/rails/database/schema.rb +100 -97
  382. data/lib/puppet/rails/fact_name.rb +1 -1
  383. data/lib/puppet/rails/fact_value.rb +5 -5
  384. data/lib/puppet/rails/host.rb +252 -249
  385. data/lib/puppet/rails/param_name.rb +15 -15
  386. data/lib/puppet/rails/param_value.rb +55 -55
  387. data/lib/puppet/rails/puppet_tag.rb +4 -4
  388. data/lib/puppet/rails/resource.rb +189 -203
  389. data/lib/puppet/rails/resource_tag.rb +19 -19
  390. data/lib/puppet/rails/source_file.rb +5 -5
  391. data/lib/puppet/reference/configuration.rb +53 -56
  392. data/lib/puppet/reference/function.rb +1 -1
  393. data/lib/puppet/reference/indirection.rb +13 -13
  394. data/lib/puppet/reference/metaparameter.rb +40 -40
  395. data/lib/puppet/reference/network.rb +16 -16
  396. data/lib/puppet/reference/providers.rb +97 -98
  397. data/lib/puppet/reference/report.rb +1 -1
  398. data/lib/puppet/reference/type.rb +67 -70
  399. data/lib/puppet/relationship.rb +65 -67
  400. data/lib/puppet/reports.rb +32 -34
  401. data/lib/puppet/reports/http.rb +22 -0
  402. data/lib/puppet/reports/log.rb +7 -6
  403. data/lib/puppet/reports/rrdgraph.rb +105 -114
  404. data/lib/puppet/reports/store.rb +53 -56
  405. data/lib/puppet/reports/tagmail.rb +149 -157
  406. data/lib/puppet/resource.rb +428 -194
  407. data/lib/puppet/resource/catalog.rb +496 -512
  408. data/lib/puppet/resource/status.rb +58 -0
  409. data/lib/puppet/resource/type.rb +311 -0
  410. data/lib/puppet/resource/type_collection.rb +217 -0
  411. data/lib/puppet/resource/type_collection_helper.rb +7 -0
  412. data/lib/puppet/run.rb +77 -0
  413. data/lib/puppet/simple_graph.rb +381 -413
  414. data/lib/puppet/ssl.rb +2 -1
  415. data/lib/puppet/ssl/base.rb +60 -43
  416. data/lib/puppet/ssl/certificate.rb +21 -21
  417. data/lib/puppet/ssl/certificate_authority.rb +215 -229
  418. data/lib/puppet/ssl/certificate_authority/interface.rb +84 -68
  419. data/lib/puppet/ssl/certificate_factory.rb +119 -119
  420. data/lib/puppet/ssl/certificate_request.rb +52 -45
  421. data/lib/puppet/ssl/certificate_revocation_list.rb +78 -78
  422. data/lib/puppet/ssl/host.rb +230 -228
  423. data/lib/puppet/ssl/inventory.rb +33 -33
  424. data/lib/puppet/ssl/key.rb +37 -37
  425. data/lib/puppet/sslcertificates.rb +124 -123
  426. data/lib/puppet/sslcertificates/ca.rb +327 -344
  427. data/lib/puppet/sslcertificates/certificate.rb +197 -224
  428. data/lib/puppet/sslcertificates/inventory.rb +27 -29
  429. data/lib/puppet/sslcertificates/support.rb +113 -119
  430. data/lib/puppet/status.rb +28 -0
  431. data/lib/puppet/transaction.rb +349 -696
  432. data/lib/puppet/transaction/change.rb +80 -85
  433. data/lib/puppet/transaction/event.rb +54 -14
  434. data/lib/puppet/transaction/event_manager.rb +99 -0
  435. data/lib/puppet/transaction/report.rb +121 -59
  436. data/lib/puppet/transaction/resource_harness.rb +150 -0
  437. data/lib/puppet/transportable.rb +215 -226
  438. data/lib/puppet/type.rb +1644 -1849
  439. data/lib/puppet/type/augeas.rb +153 -134
  440. data/lib/puppet/type/component.rb +63 -65
  441. data/lib/puppet/type/computer.rb +44 -44
  442. data/lib/puppet/type/cron.rb +364 -384
  443. data/lib/puppet/type/exec.rb +583 -521
  444. data/lib/puppet/type/file.rb +786 -823
  445. data/lib/puppet/type/file/checksum.rb +23 -240
  446. data/lib/puppet/type/file/content.rb +193 -129
  447. data/lib/puppet/type/file/ensure.rb +149 -153
  448. data/lib/puppet/type/file/group.rb +94 -104
  449. data/lib/puppet/type/file/mode.rb +109 -122
  450. data/lib/puppet/type/file/owner.rb +39 -131
  451. data/lib/puppet/type/file/selcontext.rb +69 -73
  452. data/lib/puppet/type/file/source.rb +165 -153
  453. data/lib/puppet/type/file/target.rb +56 -60
  454. data/lib/puppet/type/file/type.rb +18 -18
  455. data/lib/puppet/type/filebucket.rb +91 -92
  456. data/lib/puppet/type/group.rb +77 -82
  457. data/lib/puppet/type/host.rb +85 -85
  458. data/lib/puppet/type/k5login.rb +65 -65
  459. data/lib/puppet/type/macauthorization.rb +141 -143
  460. data/lib/puppet/type/mailalias.rb +37 -37
  461. data/lib/puppet/type/maillist.rb +51 -51
  462. data/lib/puppet/type/mcx.rb +62 -62
  463. data/lib/puppet/type/mount.rb +199 -193
  464. data/lib/puppet/type/notify.rb +33 -33
  465. data/lib/puppet/type/package.rb +301 -298
  466. data/lib/puppet/type/port.rb +4 -4
  467. data/lib/puppet/type/resources.rb +107 -123
  468. data/lib/puppet/type/schedule.rb +317 -326
  469. data/lib/puppet/type/selboolean.rb +19 -19
  470. data/lib/puppet/type/selmodule.rb +34 -34
  471. data/lib/puppet/type/service.rb +152 -152
  472. data/lib/puppet/type/ssh_authorized_key.rb +74 -78
  473. data/lib/puppet/type/sshkey.rb +52 -56
  474. data/lib/puppet/type/stage.rb +18 -0
  475. data/lib/puppet/type/tidy.rb +289 -300
  476. data/lib/puppet/type/user.rb +300 -312
  477. data/lib/puppet/type/yumrepo.rb +300 -335
  478. data/lib/puppet/type/zfs.rb +36 -36
  479. data/lib/puppet/type/zone.rb +376 -347
  480. data/lib/puppet/type/zpool.rb +71 -77
  481. data/lib/puppet/util.rb +383 -387
  482. data/lib/puppet/util/autoload.rb +125 -143
  483. data/lib/puppet/util/autoload/file_cache.rb +78 -101
  484. data/lib/puppet/util/backups.rb +66 -66
  485. data/lib/puppet/util/cacher.rb +112 -120
  486. data/lib/puppet/util/checksums.rb +119 -84
  487. data/lib/puppet/util/classgen.rb +157 -167
  488. data/lib/puppet/util/command_line.rb +95 -0
  489. data/lib/puppet/util/command_line/filebucket +97 -0
  490. data/lib/puppet/util/command_line/pi +48 -0
  491. data/lib/puppet/util/command_line/puppet +69 -0
  492. data/lib/puppet/util/command_line/puppetca +110 -0
  493. data/lib/puppet/util/command_line/puppetd +186 -0
  494. data/lib/puppet/util/command_line/puppetdoc +67 -0
  495. data/lib/puppet/util/command_line/puppetmasterd +65 -0
  496. data/lib/puppet/util/command_line/puppetqd +53 -0
  497. data/lib/puppet/util/command_line/puppetrun +128 -0
  498. data/lib/puppet/util/command_line/ralsh +89 -0
  499. data/lib/puppet/util/constant_inflector.rb +7 -7
  500. data/lib/puppet/util/diff.rb +59 -56
  501. data/lib/puppet/util/docs.rb +97 -99
  502. data/lib/puppet/util/errors.rb +53 -44
  503. data/lib/puppet/util/execution.rb +15 -15
  504. data/lib/puppet/util/feature.rb +62 -72
  505. data/lib/puppet/util/file_locking.rb +33 -33
  506. data/lib/puppet/util/fileparsing.rb +292 -318
  507. data/lib/puppet/util/filetype.rb +246 -263
  508. data/lib/puppet/util/graph.rb +16 -18
  509. data/lib/puppet/util/inifile.rb +170 -184
  510. data/lib/puppet/util/inline_docs.rb +26 -0
  511. data/lib/puppet/util/instance_loader.rb +58 -58
  512. data/lib/puppet/util/ldap/connection.rb +57 -59
  513. data/lib/puppet/util/ldap/generator.rb +31 -31
  514. data/lib/puppet/util/ldap/manager.rb +233 -235
  515. data/lib/puppet/util/loadedfile.rb +49 -51
  516. data/lib/puppet/util/log.rb +210 -494
  517. data/lib/puppet/util/log/destination.rb +49 -0
  518. data/lib/puppet/util/log/destinations.rb +217 -0
  519. data/lib/puppet/util/log_paths.rb +15 -17
  520. data/lib/puppet/util/logging.rb +34 -13
  521. data/lib/puppet/util/metaid.rb +15 -15
  522. data/lib/puppet/util/methodhelper.rb +24 -26
  523. data/lib/puppet/util/metric.rb +123 -125
  524. data/lib/puppet/util/monkey_patches.rb +21 -20
  525. data/lib/puppet/util/nagios_maker.rb +41 -41
  526. data/lib/puppet/util/package.rb +24 -26
  527. data/lib/puppet/util/pidlock.rb +49 -49
  528. data/lib/puppet/util/posix.rb +115 -115
  529. data/lib/puppet/util/provider_features.rb +147 -155
  530. data/lib/puppet/util/pson.rb +5 -5
  531. data/lib/puppet/util/queue.rb +55 -55
  532. data/lib/puppet/util/queue/stomp.rb +27 -27
  533. data/lib/puppet/util/rails/cache_accumulator.rb +49 -49
  534. data/lib/puppet/util/rails/collection_merger.rb +13 -13
  535. data/lib/puppet/util/rails/reference_serializer.rb +26 -26
  536. data/lib/puppet/util/rdoc.rb +77 -74
  537. data/lib/puppet/util/rdoc/code_objects.rb +235 -217
  538. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +732 -676
  539. data/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +38 -12
  540. data/lib/puppet/util/rdoc/parser.rb +418 -392
  541. data/lib/puppet/util/reference.rb +168 -174
  542. data/lib/puppet/util/resource_template.rb +17 -17
  543. data/lib/puppet/util/run_mode.rb +81 -0
  544. data/lib/puppet/util/selinux.rb +184 -200
  545. data/lib/puppet/util/settings.rb +886 -919
  546. data/lib/puppet/util/settings/boolean_setting.rb +20 -23
  547. data/lib/puppet/util/settings/file_setting.rb +98 -99
  548. data/lib/puppet/util/settings/setting.rb +71 -87
  549. data/lib/puppet/util/storage.rb +73 -84
  550. data/lib/puppet/util/subclass_loader.rb +59 -66
  551. data/lib/puppet/util/suidmanager.rb +87 -84
  552. data/lib/puppet/util/tagging.rb +37 -39
  553. data/lib/puppet/util/user_attr.rb +14 -14
  554. data/lib/puppet/util/warnings.rb +20 -20
  555. data/lib/puppet/util/zaml.rb +242 -241
  556. data/man/man5/puppet.conf.5 +148 -76
  557. data/man/man8/filebucket.8 +6 -6
  558. data/man/man8/pi.8 +5 -5
  559. data/man/man8/puppet.8 +2 -73
  560. data/man/man8/puppetca.8 +47 -32
  561. data/man/man8/puppetd.8 +118 -76
  562. data/man/man8/puppetdoc.8 +16 -12
  563. data/man/man8/puppetmasterd.8 +4 -4
  564. data/man/man8/puppetqd.8 +4 -4
  565. data/man/man8/puppetrun.8 +23 -22
  566. data/man/man8/ralsh.8 +16 -17
  567. data/spec/fixtures/yaml/test.local.yaml +16 -0
  568. data/spec/integration/application/apply_spec.rb +33 -0
  569. data/spec/integration/configurer_spec.rb +35 -0
  570. data/spec/integration/defaults_spec.rb +258 -0
  571. data/spec/integration/file_serving/content_spec.rb +20 -0
  572. data/spec/integration/file_serving/fileset_spec.rb +14 -0
  573. data/spec/integration/file_serving/metadata_spec.rb +21 -0
  574. data/spec/integration/file_serving/terminus_helper_spec.rb +22 -0
  575. data/spec/integration/indirector/bucket_file/rest_spec.rb +68 -0
  576. data/spec/integration/indirector/catalog/compiler_spec.rb +68 -0
  577. data/spec/integration/indirector/catalog/queue_spec.rb +61 -0
  578. data/spec/integration/indirector/certificate/rest_spec.rb +68 -0
  579. data/spec/integration/indirector/certificate_request/rest_spec.rb +88 -0
  580. data/spec/integration/indirector/certificate_revocation_list/rest_spec.rb +76 -0
  581. data/spec/integration/indirector/direct_file_server_spec.rb +73 -0
  582. data/spec/integration/indirector/file_content/file_server_spec.rb +94 -0
  583. data/spec/integration/indirector/file_metadata/file_server_spec.rb +18 -0
  584. data/spec/integration/indirector/node/ldap_spec.rb +15 -0
  585. data/spec/integration/indirector/report/rest_spec.rb +96 -0
  586. data/spec/integration/indirector/rest_spec.rb +524 -0
  587. data/spec/integration/network/client_spec.rb +19 -0
  588. data/spec/integration/network/formats_spec.rb +110 -0
  589. data/spec/integration/network/handler_spec.rb +25 -0
  590. data/spec/integration/network/server/mongrel_spec.rb +66 -0
  591. data/spec/integration/network/server/webrick_spec.rb +85 -0
  592. data/spec/integration/node/environment_spec.rb +58 -0
  593. data/spec/integration/node/facts_spec.rb +47 -0
  594. data/spec/integration/node_spec.rb +93 -0
  595. data/spec/integration/parser/collector_spec.rb +38 -0
  596. data/spec/integration/parser/compiler_spec.rb +29 -0
  597. data/spec/integration/parser/functions/require_spec.rb +44 -0
  598. data/spec/integration/parser/parser_spec.rb +113 -0
  599. data/spec/integration/provider/mailalias/aliases_spec.rb +25 -0
  600. data/spec/integration/provider/package_spec.rb +26 -0
  601. data/spec/integration/provider/service/init_spec.rb +32 -0
  602. data/spec/integration/reference/providers_spec.rb +17 -0
  603. data/spec/integration/reports_spec.rb +18 -0
  604. data/spec/integration/resource/catalog_spec.rb +61 -0
  605. data/spec/integration/resource/type_collection_spec.rb +96 -0
  606. data/spec/integration/ssl/certificate_authority_spec.rb +135 -0
  607. data/spec/integration/ssl/certificate_request_spec.rb +61 -0
  608. data/spec/integration/ssl/certificate_revocation_list_spec.rb +42 -0
  609. data/spec/integration/ssl/host_spec.rb +90 -0
  610. data/spec/integration/transaction/report_spec.rb +29 -0
  611. data/spec/integration/transaction_spec.rb +284 -0
  612. data/spec/integration/type/file_spec.rb +506 -0
  613. data/spec/integration/type/package_spec.rb +25 -0
  614. data/spec/integration/type/tidy_spec.rb +32 -0
  615. data/spec/integration/type_spec.rb +22 -0
  616. data/spec/integration/util/autoload_spec.rb +114 -0
  617. data/spec/integration/util/feature_spec.rb +54 -0
  618. data/spec/integration/util/file_locking_spec.rb +37 -0
  619. data/spec/integration/util/rdoc/parser_spec.rb +59 -0
  620. data/spec/integration/util/settings_spec.rb +30 -0
  621. data/spec/lib/puppet_spec/files.rb +16 -6
  622. data/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +27 -27
  623. data/spec/monkey_patches/alias_should_to_must.rb +4 -4
  624. data/spec/shared_behaviours/file_server_terminus.rb +28 -28
  625. data/spec/shared_behaviours/file_serving.rb +53 -53
  626. data/spec/shared_behaviours/memory_terminus.rb +22 -22
  627. data/spec/spec.opts +1 -0
  628. data/spec/spec_helper.rb +61 -18
  629. data/spec/spec_specs/runnable_spec.rb +95 -0
  630. data/spec/unit/agent/locker_spec.rb +100 -0
  631. data/spec/unit/agent_spec.rb +281 -0
  632. data/spec/unit/application/agent_spec.rb +588 -0
  633. data/spec/unit/application/apply_spec.rb +387 -0
  634. data/spec/unit/application/cert_spec.rb +194 -0
  635. data/spec/unit/application/describe_spec.rb +84 -0
  636. data/spec/unit/application/doc_spec.rb +368 -0
  637. data/spec/unit/application/filebucket_spec.rb +223 -0
  638. data/spec/unit/application/kick_spec.rb +313 -0
  639. data/spec/unit/application/master_spec.rb +453 -0
  640. data/spec/unit/application/queue_spec.rb +186 -0
  641. data/spec/unit/application/resource_spec.rb +233 -0
  642. data/spec/unit/application_spec.rb +531 -0
  643. data/spec/unit/configurer/downloader_spec.rb +188 -0
  644. data/spec/unit/configurer/fact_handler_spec.rb +164 -0
  645. data/spec/unit/configurer/plugin_handler_spec.rb +112 -0
  646. data/spec/unit/configurer_spec.rb +494 -0
  647. data/spec/unit/daemon_spec.rb +306 -0
  648. data/spec/unit/dsl/resource_api_spec.rb +181 -0
  649. data/spec/unit/dsl/resource_type_api_spec.rb +46 -0
  650. data/spec/unit/file_bucket/dipper_spec.rb +122 -0
  651. data/spec/unit/file_bucket/file_spec.rb +230 -0
  652. data/spec/unit/file_collection/lookup_spec.rb +46 -0
  653. data/spec/unit/file_collection_spec.rb +53 -0
  654. data/spec/unit/file_serving/base_spec.rb +132 -0
  655. data/spec/unit/file_serving/configuration/parser_spec.rb +181 -0
  656. data/spec/unit/file_serving/configuration_spec.rb +249 -0
  657. data/spec/unit/file_serving/content_spec.rb +118 -0
  658. data/spec/unit/file_serving/fileset_spec.rb +347 -0
  659. data/spec/unit/file_serving/indirection_hooks_spec.rb +63 -0
  660. data/spec/unit/file_serving/metadata_spec.rb +286 -0
  661. data/spec/unit/file_serving/mount/file_spec.rb +196 -0
  662. data/spec/unit/file_serving/mount/modules_spec.rb +63 -0
  663. data/spec/unit/file_serving/mount/plugins_spec.rb +61 -0
  664. data/spec/unit/file_serving/mount_spec.rb +32 -0
  665. data/spec/unit/file_serving/terminus_helper_spec.rb +98 -0
  666. data/spec/unit/indirector/active_record_spec.rb +76 -0
  667. data/spec/unit/indirector/catalog/active_record_spec.rb +141 -0
  668. data/spec/unit/indirector/catalog/compiler_spec.rb +275 -0
  669. data/spec/unit/indirector/catalog/queue_spec.rb +20 -0
  670. data/spec/unit/indirector/catalog/rest_spec.rb +11 -0
  671. data/spec/unit/indirector/catalog/yaml_spec.rb +25 -0
  672. data/spec/unit/indirector/certificate/ca_spec.rb +28 -0
  673. data/spec/unit/indirector/certificate/file_spec.rb +28 -0
  674. data/spec/unit/indirector/certificate/rest_spec.rb +58 -0
  675. data/spec/unit/indirector/certificate_request/ca_spec.rb +19 -0
  676. data/spec/unit/indirector/certificate_request/file_spec.rb +19 -0
  677. data/spec/unit/indirector/certificate_request/rest_spec.rb +23 -0
  678. data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +21 -0
  679. data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +20 -0
  680. data/spec/unit/indirector/certificate_revocation_list/rest_spec.rb +23 -0
  681. data/spec/unit/indirector/code_spec.rb +33 -0
  682. data/spec/unit/indirector/direct_file_server_spec.rb +84 -0
  683. data/spec/unit/indirector/envelope_spec.rb +47 -0
  684. data/spec/unit/indirector/exec_spec.rb +56 -0
  685. data/spec/unit/indirector/facts/active_record_spec.rb +104 -0
  686. data/spec/unit/indirector/facts/couch_spec.rb +98 -0
  687. data/spec/unit/indirector/facts/facter_spec.rb +143 -0
  688. data/spec/unit/indirector/facts/rest_spec.rb +11 -0
  689. data/spec/unit/indirector/facts/yaml_spec.rb +26 -0
  690. data/spec/unit/indirector/file_bucket_file/file_spec.rb +290 -0
  691. data/spec/unit/indirector/file_bucket_file/rest_spec.rb +11 -0
  692. data/spec/unit/indirector/file_content/file_server_spec.rb +18 -0
  693. data/spec/unit/indirector/file_content/file_spec.rb +18 -0
  694. data/spec/unit/indirector/file_content/rest_spec.rb +11 -0
  695. data/spec/unit/indirector/file_metadata/file_server_spec.rb +18 -0
  696. data/spec/unit/indirector/file_metadata/file_spec.rb +52 -0
  697. data/spec/unit/indirector/file_metadata/rest_spec.rb +9 -0
  698. data/spec/unit/indirector/file_server_spec.rb +267 -0
  699. data/spec/unit/indirector/file_spec.rb +181 -0
  700. data/spec/unit/indirector/indirection_spec.rb +795 -0
  701. data/spec/unit/indirector/key/ca_spec.rb +28 -0
  702. data/spec/unit/indirector/key/file_spec.rb +104 -0
  703. data/spec/unit/indirector/ldap_spec.rb +143 -0
  704. data/spec/unit/indirector/memory_spec.rb +29 -0
  705. data/spec/unit/indirector/node/active_record_spec.rb +41 -0
  706. data/spec/unit/indirector/node/exec_spec.rb +70 -0
  707. data/spec/unit/indirector/node/ldap_spec.rb +456 -0
  708. data/spec/unit/indirector/node/memory_spec.rb +19 -0
  709. data/spec/unit/indirector/node/plain_spec.rb +19 -0
  710. data/spec/unit/indirector/node/rest_spec.rb +13 -0
  711. data/spec/unit/indirector/node/yaml_spec.rb +25 -0
  712. data/spec/unit/indirector/plain_spec.rb +29 -0
  713. data/spec/unit/indirector/queue_spec.rb +123 -0
  714. data/spec/unit/indirector/report/processor_spec.rb +81 -0
  715. data/spec/unit/indirector/report/rest_spec.rb +28 -0
  716. data/spec/unit/indirector/request_spec.rb +304 -0
  717. data/spec/unit/indirector/resource/ral_spec.rb +129 -0
  718. data/spec/unit/indirector/resource/rest_spec.rb +11 -0
  719. data/spec/unit/indirector/resource_type/parser_spec.rb +75 -0
  720. data/spec/unit/indirector/resource_type/rest_spec.rb +15 -0
  721. data/spec/unit/indirector/rest_spec.rb +455 -0
  722. data/spec/unit/indirector/run/local_spec.rb +20 -0
  723. data/spec/unit/indirector/run/rest_spec.rb +11 -0
  724. data/spec/unit/indirector/ssl_file_spec.rb +281 -0
  725. data/spec/unit/indirector/status/rest_spec.rb +11 -0
  726. data/spec/unit/indirector/terminus_spec.rb +245 -0
  727. data/spec/unit/indirector/yaml_spec.rb +146 -0
  728. data/spec/unit/indirector_spec.rb +157 -0
  729. data/spec/unit/module_spec.rb +547 -0
  730. data/spec/unit/network/authconfig_spec.rb +292 -0
  731. data/spec/unit/network/authstore_spec.rb +370 -0
  732. data/spec/unit/network/client_spec.rb +45 -0
  733. data/spec/unit/network/format_handler_spec.rb +336 -0
  734. data/spec/unit/network/format_spec.rb +198 -0
  735. data/spec/unit/network/formats_spec.rb +337 -0
  736. data/spec/unit/network/handler/fileserver_spec.rb +172 -0
  737. data/spec/unit/network/http/api/v1_spec.rb +122 -0
  738. data/spec/unit/network/http/compression_spec.rb +199 -0
  739. data/spec/unit/network/http/handler_spec.rb +455 -0
  740. data/spec/unit/network/http/mongrel/rest_spec.rb +249 -0
  741. data/spec/unit/network/http/mongrel/{xmlrpc.rb → xmlrpc_spec.rb} +0 -0
  742. data/spec/unit/network/http/mongrel_spec.rb +131 -0
  743. data/spec/unit/network/http/rack/rest_spec.rb +249 -0
  744. data/spec/unit/network/http/rack/xmlrpc_spec.rb +157 -0
  745. data/spec/unit/network/http/rack_spec.rb +102 -0
  746. data/spec/unit/network/http/webrick/rest_spec.rb +180 -0
  747. data/spec/unit/network/http/webrick/{xmlrpc.rb → xmlrpc_spec.rb} +0 -0
  748. data/spec/unit/network/http/webrick_spec.rb +339 -0
  749. data/spec/unit/network/http_pool_spec.rb +206 -0
  750. data/spec/unit/network/http_spec.rb +35 -0
  751. data/spec/unit/network/rest_authconfig_spec.rb +148 -0
  752. data/spec/unit/network/rest_authorization_spec.rb +43 -0
  753. data/spec/unit/network/rights_spec.rb +519 -0
  754. data/spec/unit/network/server_spec.rb +534 -0
  755. data/spec/unit/network/xmlrpc/client_spec.rb +171 -0
  756. data/spec/unit/node/environment_spec.rb +248 -0
  757. data/spec/unit/node/facts_spec.rb +102 -0
  758. data/spec/unit/node_spec.rb +210 -0
  759. data/spec/unit/other/selinux_spec.rb +94 -0
  760. data/spec/unit/other/transbucket_spec.rb +188 -0
  761. data/spec/unit/other/transobject_spec.rb +112 -0
  762. data/spec/unit/parameter/value_collection_spec.rb +167 -0
  763. data/spec/unit/parameter/value_spec.rb +88 -0
  764. data/spec/unit/parameter_spec.rb +172 -0
  765. data/spec/unit/parser/ast/arithmetic_operator_spec.rb +73 -0
  766. data/spec/unit/parser/ast/astarray_spec.rb +72 -0
  767. data/spec/unit/parser/ast/asthash_spec.rb +98 -0
  768. data/spec/unit/parser/ast/boolean_operator_spec.rb +53 -0
  769. data/spec/unit/parser/ast/casestatement_spec.rb +161 -0
  770. data/spec/unit/parser/ast/collection_spec.rb +63 -0
  771. data/spec/unit/parser/ast/collexpr_spec.rb +115 -0
  772. data/spec/unit/parser/ast/comparison_operator_spec.rb +116 -0
  773. data/spec/unit/parser/ast/function_spec.rb +83 -0
  774. data/spec/unit/parser/ast/ifstatement_spec.rb +76 -0
  775. data/spec/unit/parser/ast/in_operator_spec.rb +60 -0
  776. data/spec/unit/parser/ast/leaf_spec.rb +362 -0
  777. data/spec/unit/parser/ast/match_operator_spec.rb +50 -0
  778. data/spec/unit/parser/ast/minus_spec.rb +36 -0
  779. data/spec/unit/parser/ast/nop_spec.rb +20 -0
  780. data/spec/unit/parser/ast/not_spec.rb +30 -0
  781. data/spec/unit/parser/ast/relationship_spec.rb +88 -0
  782. data/spec/unit/parser/ast/resource_defaults_spec.rb +22 -0
  783. data/spec/unit/parser/ast/resource_override_spec.rb +51 -0
  784. data/spec/unit/parser/ast/resource_reference_spec.rb +46 -0
  785. data/spec/unit/parser/ast/resource_spec.rb +120 -0
  786. data/spec/unit/parser/ast/selector_spec.rb +139 -0
  787. data/spec/unit/parser/ast/vardef_spec.rb +60 -0
  788. data/spec/unit/parser/ast_spec.rb +111 -0
  789. data/spec/unit/parser/collector_spec.rb +559 -0
  790. data/spec/unit/parser/compiler_spec.rb +754 -0
  791. data/spec/unit/parser/files_spec.rb +201 -0
  792. data/spec/unit/parser/functions/defined_spec.rb +50 -0
  793. data/spec/unit/parser/functions/fqdn_rand_spec.rb +62 -0
  794. data/spec/unit/parser/functions/generate_spec.rb +41 -0
  795. data/spec/unit/parser/functions/inline_template_spec.rb +59 -0
  796. data/spec/unit/parser/functions/realize_spec.rb +51 -0
  797. data/spec/unit/parser/functions/regsubst_spec.rb +192 -0
  798. data/spec/unit/parser/functions/require_spec.rb +74 -0
  799. data/spec/unit/parser/functions/shellquote_spec.rb +81 -0
  800. data/spec/unit/parser/functions/split_spec.rb +49 -0
  801. data/spec/unit/parser/functions/sprintf_spec.rb +41 -0
  802. data/spec/unit/parser/functions/tag_spec.rb +24 -0
  803. data/spec/unit/parser/functions/template_spec.rb +62 -0
  804. data/spec/unit/parser/functions/versioncmp_spec.rb +29 -0
  805. data/spec/unit/parser/functions_spec.rb +102 -0
  806. data/spec/unit/parser/lexer_spec.rb +646 -0
  807. data/spec/unit/parser/parser_spec.rb +412 -0
  808. data/spec/unit/parser/relationship_spec.rb +70 -0
  809. data/spec/unit/parser/resource_spec.rb +564 -0
  810. data/spec/unit/parser/scope_spec.rb +629 -0
  811. data/spec/unit/parser/templatewrapper_spec.rb +144 -0
  812. data/spec/unit/parser/type_loader_spec.rb +201 -0
  813. data/spec/unit/property/ensure_spec.rb +13 -0
  814. data/spec/unit/property/keyvalue_spec.rb +168 -0
  815. data/spec/unit/property/list_spec.rb +166 -0
  816. data/spec/unit/property/ordered_list_spec.rb +64 -0
  817. data/spec/unit/property_spec.rb +410 -0
  818. data/spec/unit/provider/augeas/augeas_spec.rb +413 -0
  819. data/spec/unit/provider/confine/exists_spec.rb +81 -0
  820. data/spec/unit/provider/confine/false_spec.rb +53 -0
  821. data/spec/unit/provider/confine/feature_spec.rb +60 -0
  822. data/spec/unit/provider/confine/true_spec.rb +53 -0
  823. data/spec/unit/provider/confine/variable_spec.rb +107 -0
  824. data/spec/unit/provider/confine_collection_spec.rb +134 -0
  825. data/spec/unit/provider/confine_spec.rb +78 -0
  826. data/spec/unit/provider/confiner_spec.rb +63 -0
  827. data/spec/unit/provider/group/groupadd_spec.rb +31 -0
  828. data/spec/unit/provider/group/ldap_spec.rb +105 -0
  829. data/spec/unit/provider/ldap_spec.rb +248 -0
  830. data/spec/unit/provider/macauthorization_spec.rb +147 -0
  831. data/spec/unit/provider/mcx/mcxcontent_spec.rb +175 -0
  832. data/spec/unit/provider/mount/parsed_spec.rb +193 -0
  833. data/spec/unit/provider/mount_spec.rb +130 -0
  834. data/spec/unit/provider/naginator_spec.rb +58 -0
  835. data/spec/unit/provider/package/aix_spec.rb +66 -0
  836. data/spec/unit/provider/package/apt_spec.rb +145 -0
  837. data/spec/unit/provider/package/dpkg_spec.rb +225 -0
  838. data/spec/unit/provider/package/gem_spec.rb +87 -0
  839. data/spec/unit/provider/package/hpux_spec.rb +52 -0
  840. data/spec/unit/provider/package/nim_spec.rb +42 -0
  841. data/spec/unit/provider/package/pkg_spec.rb +63 -0
  842. data/spec/unit/provider/package/pkgdmg_spec.rb +84 -0
  843. data/spec/unit/provider/package/zypper_spec.rb +81 -0
  844. data/spec/unit/provider/parsedfile_spec.rb +95 -0
  845. data/spec/unit/provider/selboolean_spec.rb +37 -0
  846. data/spec/unit/provider/selmodule_spec.rb +66 -0
  847. data/spec/unit/provider/service/daemontools_spec.rb +166 -0
  848. data/spec/unit/provider/service/debian_spec.rb +89 -0
  849. data/spec/unit/provider/service/init_spec.rb +168 -0
  850. data/spec/unit/provider/service/launchd_spec.rb +200 -0
  851. data/spec/unit/provider/service/redhat_spec.rb +121 -0
  852. data/spec/unit/provider/service/runit_spec.rb +140 -0
  853. data/spec/unit/provider/service/src_spec.rb +97 -0
  854. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +228 -0
  855. data/spec/unit/provider/sshkey/parsed_spec.rb +38 -0
  856. data/spec/unit/provider/user/hpux_spec.rb +25 -0
  857. data/spec/unit/provider/user/ldap_spec.rb +279 -0
  858. data/spec/unit/provider/user/user_role_add_spec.rb +249 -0
  859. data/spec/unit/provider/user/useradd_spec.rb +115 -0
  860. data/spec/unit/provider/zfs/solaris_spec.rb +99 -0
  861. data/spec/unit/provider/zone/solaris_spec.rb +55 -0
  862. data/spec/unit/provider/zpool/solaris_spec.rb +179 -0
  863. data/spec/unit/provider_spec.rb +31 -0
  864. data/spec/unit/puppet_spec.rb +12 -0
  865. data/spec/unit/rails/host_spec.rb +163 -0
  866. data/spec/unit/rails/param_value_spec.rb +49 -0
  867. data/spec/unit/rails/resource_spec.rb +123 -0
  868. data/spec/unit/rails_spec.rb +258 -0
  869. data/spec/unit/relationship_spec.rb +236 -0
  870. data/spec/unit/reports/http_spec.rb +56 -0
  871. data/spec/unit/reports/tagmail_spec.rb +94 -0
  872. data/spec/unit/reports_spec.rb +61 -0
  873. data/spec/unit/resource/catalog_spec.rb +1078 -0
  874. data/spec/unit/resource/status_spec.rb +103 -0
  875. data/spec/unit/resource/type_collection_helper_spec.rb +25 -0
  876. data/spec/unit/resource/type_collection_spec.rb +432 -0
  877. data/spec/unit/resource/type_spec.rb +722 -0
  878. data/spec/unit/resource_spec.rb +818 -0
  879. data/spec/unit/run_spec.rb +137 -0
  880. data/spec/unit/simple_graph_spec.rb +544 -0
  881. data/spec/unit/ssl/base_spec.rb +43 -0
  882. data/spec/unit/ssl/certificate_authority/interface_spec.rb +333 -0
  883. data/spec/unit/ssl/certificate_authority_spec.rb +772 -0
  884. data/spec/unit/ssl/certificate_factory_spec.rb +107 -0
  885. data/spec/unit/ssl/certificate_request_spec.rb +220 -0
  886. data/spec/unit/ssl/certificate_revocation_list_spec.rb +168 -0
  887. data/spec/unit/ssl/certificate_spec.rb +124 -0
  888. data/spec/unit/ssl/host_spec.rb +707 -0
  889. data/spec/unit/ssl/inventory_spec.rb +180 -0
  890. data/spec/unit/ssl/key_spec.rb +198 -0
  891. data/spec/unit/status_spec.rb +31 -0
  892. data/spec/unit/transaction/change_spec.rb +193 -0
  893. data/spec/unit/transaction/event_manager_spec.rb +260 -0
  894. data/spec/unit/transaction/event_spec.rb +108 -0
  895. data/spec/unit/transaction/report_spec.rb +234 -0
  896. data/spec/unit/transaction/resource_harness_spec.rb +401 -0
  897. data/spec/unit/transaction_spec.rb +452 -0
  898. data/spec/unit/transportable_spec.rb +0 -0
  899. data/spec/unit/type/augeas_spec.rb +122 -0
  900. data/spec/unit/type/component_spec.rb +63 -0
  901. data/spec/unit/type/computer_spec.rb +81 -0
  902. data/spec/unit/type/cron_spec.rb +33 -0
  903. data/spec/unit/type/exec_spec.rb +162 -0
  904. data/spec/unit/type/file/checksum_spec.rb +73 -0
  905. data/spec/unit/type/file/content_spec.rb +460 -0
  906. data/spec/unit/type/file/ensure_spec.rb +84 -0
  907. data/spec/unit/type/file/group_spec.rb +123 -0
  908. data/spec/unit/type/file/owner_spec.rb +150 -0
  909. data/spec/unit/type/file/selinux_spec.rb +83 -0
  910. data/spec/unit/type/file/source_spec.rb +272 -0
  911. data/spec/unit/type/file_spec.rb +1070 -0
  912. data/spec/unit/type/filebucket_spec.rb +74 -0
  913. data/spec/unit/type/group_spec.rb +57 -0
  914. data/spec/unit/type/macauthorization_spec.rb +111 -0
  915. data/spec/unit/type/maillist_spec.rb +42 -0
  916. data/spec/unit/type/mcx_spec.rb +100 -0
  917. data/spec/unit/type/mount_spec.rb +261 -0
  918. data/spec/unit/type/nagios_spec.rb +63 -0
  919. data/spec/unit/type/noop_metaparam_spec.rb +37 -0
  920. data/spec/unit/type/package_spec.rb +240 -0
  921. data/spec/unit/type/resources_spec.rb +102 -0
  922. data/spec/unit/type/schedule_spec.rb +333 -0
  923. data/spec/unit/type/selboolean_spec.rb +45 -0
  924. data/spec/unit/type/selmodule_spec.rb +18 -0
  925. data/spec/unit/type/service_spec.rb +222 -0
  926. data/spec/unit/type/ssh_authorized_key_spec.rb +152 -0
  927. data/spec/unit/type/stage_spec.rb +9 -0
  928. data/spec/unit/type/tidy_spec.rb +424 -0
  929. data/spec/unit/type/user_spec.rb +281 -0
  930. data/spec/unit/type/zfs_spec.rb +45 -0
  931. data/spec/unit/type/zone_spec.rb +60 -0
  932. data/spec/unit/type/zpool_spec.rb +110 -0
  933. data/spec/unit/type_spec.rb +566 -0
  934. data/spec/unit/util/autoload/file_cache_spec.rb +159 -0
  935. data/spec/unit/util/autoload_spec.rb +120 -0
  936. data/spec/unit/util/backups_spec.rb +159 -0
  937. data/spec/unit/util/cache_accumulator_spec.rb +75 -0
  938. data/spec/unit/util/cacher_spec.rb +185 -0
  939. data/spec/unit/util/checksums_spec.rb +153 -0
  940. data/spec/unit/util/command_line_spec.rb +108 -0
  941. data/spec/unit/util/constant_inflector_spec.rb +70 -0
  942. data/spec/unit/util/errors_spec.rb +38 -0
  943. data/spec/unit/util/feature_spec.rb +72 -0
  944. data/spec/unit/util/file_locking_spec.rb +156 -0
  945. data/spec/unit/util/filetype_spec.rb +100 -0
  946. data/spec/unit/util/inline_docs_spec.rb +32 -0
  947. data/spec/unit/util/json_spec.rb +21 -0
  948. data/spec/unit/util/ldap/connection_spec.rb +169 -0
  949. data/spec/unit/util/ldap/generator_spec.rb +54 -0
  950. data/spec/unit/util/ldap/manager_spec.rb +654 -0
  951. data/spec/unit/util/loadedfile_spec.rb +65 -0
  952. data/spec/unit/util/log/destinations_spec.rb +24 -0
  953. data/spec/unit/util/log_spec.rb +215 -0
  954. data/spec/unit/util/logging_spec.rb +95 -0
  955. data/spec/unit/util/metric_spec.rb +95 -0
  956. data/spec/unit/util/monkey_patches_spec.rb +7 -0
  957. data/spec/unit/util/nagios_maker_spec.rb +126 -0
  958. data/spec/unit/util/package_spec.rb +21 -0
  959. data/spec/unit/util/posix_spec.rb +256 -0
  960. data/spec/unit/util/queue/stomp_spec.rb +140 -0
  961. data/spec/unit/util/queue_spec.rb +96 -0
  962. data/spec/unit/util/rdoc/parser_spec.rb +540 -0
  963. data/spec/unit/util/rdoc_spec.rb +165 -0
  964. data/spec/unit/util/reference_serializer_spec.rb +52 -0
  965. data/spec/unit/util/resource_template_spec.rb +58 -0
  966. data/spec/unit/util/run_mode_spec.rb +51 -0
  967. data/spec/unit/util/selinux_spec.rb +278 -0
  968. data/spec/unit/util/settings/file_setting_spec.rb +256 -0
  969. data/spec/unit/util/settings_spec.rb +1099 -0
  970. data/spec/unit/util/storage_spec.rb +235 -0
  971. data/spec/unit/util/tagging_spec.rb +102 -0
  972. data/spec/unit/util/user_attr_spec.rb +47 -0
  973. data/spec/unit/util/warnings_spec.rb +39 -0
  974. data/spec/unit/util/zaml_spec.rb +38 -0
  975. data/tasks/rake/git_workflow.rake +1 -1
  976. data/tasks/rake/sign.rake +2 -2
  977. data/test/certmgr/ca.rb +61 -61
  978. data/test/certmgr/certmgr.rb +292 -283
  979. data/test/certmgr/inventory.rb +44 -42
  980. data/test/certmgr/support.rb +78 -77
  981. data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +1 -1
  982. data/test/data/snippets/hash.pp +33 -0
  983. data/test/language/ast.rb +68 -117
  984. data/test/language/ast/variable.rb +14 -15
  985. data/test/language/functions.rb +404 -463
  986. data/test/language/parser.rb +670 -1135
  987. data/test/language/scope.rb +198 -402
  988. data/test/language/snippets.rb +439 -447
  989. data/test/language/transportable.rb +67 -66
  990. data/test/lib/puppettest.rb +260 -268
  991. data/test/lib/puppettest/certificates.rb +51 -53
  992. data/test/lib/puppettest/exetest.rb +107 -111
  993. data/test/lib/puppettest/fakes.rb +153 -158
  994. data/test/lib/puppettest/fileparsing.rb +17 -17
  995. data/test/lib/puppettest/filetesting.rb +204 -213
  996. data/test/lib/puppettest/parsertesting.rb +382 -365
  997. data/test/lib/puppettest/railstesting.rb +49 -50
  998. data/test/lib/puppettest/reporttesting.rb +10 -10
  999. data/test/lib/puppettest/resourcetesting.rb +45 -36
  1000. data/test/lib/puppettest/runnable_test.rb +36 -28
  1001. data/test/lib/puppettest/servertest.rb +54 -51
  1002. data/test/lib/puppettest/support/assertions.rb +48 -55
  1003. data/test/lib/puppettest/support/helpers.rb +12 -16
  1004. data/test/lib/puppettest/support/resources.rb +23 -25
  1005. data/test/lib/puppettest/support/utils.rb +138 -148
  1006. data/test/lib/puppettest/testcase.rb +15 -17
  1007. data/test/lib/rake/puppet_test_loader.rb +1 -3
  1008. data/test/lib/rake/puppet_testtask.rb +10 -10
  1009. data/test/network/authconfig.rb +48 -50
  1010. data/test/network/authorization.rb +114 -113
  1011. data/test/network/authstore.rb +454 -406
  1012. data/test/network/client/ca.rb +46 -48
  1013. data/test/network/client/dipper.rb +22 -22
  1014. data/test/network/client_request.rb +20 -20
  1015. data/test/network/handler/ca.rb +251 -252
  1016. data/test/network/handler/fileserver.rb +1071 -1001
  1017. data/test/network/handler/master.rb +58 -58
  1018. data/test/network/handler/report.rb +64 -64
  1019. data/test/network/handler/runner.rb +8 -8
  1020. data/test/network/rights.rb +22 -19
  1021. data/test/network/server/mongrel_test.rb +87 -87
  1022. data/test/network/server/webrick.rb +99 -87
  1023. data/test/network/xmlrpc/client.rb +30 -30
  1024. data/test/network/xmlrpc/processor.rb +52 -53
  1025. data/test/network/xmlrpc/server.rb +10 -11
  1026. data/test/network/xmlrpc/webrick_servlet.rb +21 -18
  1027. data/test/other/provider.rb +69 -84
  1028. data/test/other/puppet.rb +61 -76
  1029. data/test/other/relationships.rb +73 -65
  1030. data/test/other/report.rb +88 -187
  1031. data/test/other/transactions.rb +363 -885
  1032. data/test/puppet/defaults.rb +51 -54
  1033. data/test/puppet/errortest.rb +8 -8
  1034. data/test/puppet/tc_suidmanager.rb +106 -103
  1035. data/test/rails/rails.rb +8 -9
  1036. data/test/rails/railsparameter.rb +60 -54
  1037. data/test/ral/manager/attributes.rb +262 -260
  1038. data/test/ral/manager/instances.rb +77 -78
  1039. data/test/ral/manager/manager.rb +36 -36
  1040. data/test/ral/manager/provider.rb +56 -79
  1041. data/test/ral/manager/type.rb +308 -449
  1042. data/test/ral/providers/cron/crontab.rb +561 -545
  1043. data/test/ral/providers/group.rb +203 -212
  1044. data/test/ral/providers/host/parsed.rb +189 -180
  1045. data/test/ral/providers/mailalias/aliases.rb +40 -40
  1046. data/test/ral/providers/nameservice.rb +21 -21
  1047. data/test/ral/providers/package.rb +207 -214
  1048. data/test/ral/providers/package/aptitude.rb +75 -63
  1049. data/test/ral/providers/package/aptrpm.rb +84 -72
  1050. data/test/ral/providers/parsedfile.rb +510 -509
  1051. data/test/ral/providers/port/parsed.rb +5 -5
  1052. data/test/ral/providers/provider.rb +421 -421
  1053. data/test/ral/providers/service/base.rb +59 -53
  1054. data/test/ral/providers/sshkey/parsed.rb +86 -83
  1055. data/test/ral/providers/user.rb +471 -451
  1056. data/test/ral/providers/user/useradd.rb +168 -177
  1057. data/test/ral/type/cron.rb +406 -393
  1058. data/test/ral/type/exec.rb +721 -641
  1059. data/test/ral/type/file.rb +827 -896
  1060. data/test/ral/type/file/target.rb +295 -251
  1061. data/test/ral/type/fileignoresource.rb +232 -205
  1062. data/test/ral/type/filesources.rb +446 -485
  1063. data/test/ral/type/host.rb +124 -153
  1064. data/test/ral/type/mailalias.rb +28 -31
  1065. data/test/ral/type/port.rb +7 -7
  1066. data/test/ral/type/resources.rb +88 -93
  1067. data/test/ral/type/service.rb +19 -19
  1068. data/test/ral/type/sshkey.rb +120 -160
  1069. data/test/ral/type/user.rb +132 -414
  1070. data/test/ral/type/yumrepo.rb +95 -92
  1071. data/test/ral/type/zone.rb +316 -287
  1072. data/test/test +1 -1
  1073. data/test/util/classgen.rb +182 -167
  1074. data/test/util/execution.rb +18 -18
  1075. data/test/util/fileparsing.rb +580 -540
  1076. data/test/util/inifile.rb +117 -106
  1077. data/test/util/instance_loader.rb +29 -29
  1078. data/test/util/log.rb +202 -198
  1079. data/test/util/metrics.rb +51 -51
  1080. data/test/util/package.rb +11 -12
  1081. data/test/util/pidlock.rb +115 -115
  1082. data/test/util/settings.rb +613 -557
  1083. data/test/util/storage.rb +71 -88
  1084. data/test/util/subclass_loader.rb +69 -72
  1085. data/test/util/utiltest.rb +204 -203
  1086. metadata +493 -395
  1087. data/lib/puppet/agent/runner.rb +0 -65
  1088. data/lib/puppet/application/pi.rb +0 -214
  1089. data/lib/puppet/application/puppet.rb +0 -181
  1090. data/lib/puppet/application/puppetca.rb +0 -71
  1091. data/lib/puppet/application/puppetd.rb +0 -250
  1092. data/lib/puppet/application/puppetdoc.rb +0 -224
  1093. data/lib/puppet/application/puppetmasterd.rb +0 -168
  1094. data/lib/puppet/application/puppetqd.rb +0 -96
  1095. data/lib/puppet/application/puppetrun.rb +0 -210
  1096. data/lib/puppet/application/ralsh.rb +0 -152
  1097. data/lib/puppet/checksum.rb +0 -57
  1098. data/lib/puppet/indirector/checksum/file.rb +0 -33
  1099. data/lib/puppet/indirector/runner/rest.rb +0 -7
  1100. data/lib/puppet/network/client/dipper.rb +0 -85
  1101. data/lib/puppet/network/client/resource.rb +0 -38
  1102. data/lib/puppet/network/handler/resource.rb +0 -190
  1103. data/lib/puppet/parser/ast/definition.rb +0 -207
  1104. data/lib/puppet/parser/ast/hostclass.rb +0 -95
  1105. data/lib/puppet/parser/ast/node.rb +0 -42
  1106. data/lib/puppet/parser/interpreter.rb +0 -84
  1107. data/lib/puppet/parser/loaded_code.rb +0 -119
  1108. data/lib/puppet/parser/resource/reference.rb +0 -99
  1109. data/lib/puppet/resource/reference.rb +0 -90
  1110. data/lib/puppet/util/config_store.rb +0 -61
  1111. data/spec/integration/application/puppet.rb +0 -33
  1112. data/spec/integration/bin/puppetmasterd.rb +0 -122
  1113. data/spec/integration/checksum.rb +0 -48
  1114. data/spec/integration/configurer.rb +0 -18
  1115. data/spec/integration/defaults.rb +0 -230
  1116. data/spec/integration/file_serving/content.rb +0 -20
  1117. data/spec/integration/file_serving/fileset.rb +0 -14
  1118. data/spec/integration/file_serving/metadata.rb +0 -21
  1119. data/spec/integration/file_serving/terminus_helper.rb +0 -22
  1120. data/spec/integration/indirector/catalog/compiler.rb +0 -67
  1121. data/spec/integration/indirector/catalog/queue.rb +0 -61
  1122. data/spec/integration/indirector/certificate/rest.rb +0 -70
  1123. data/spec/integration/indirector/certificate_request/rest.rb +0 -88
  1124. data/spec/integration/indirector/certificate_revocation_list/rest.rb +0 -76
  1125. data/spec/integration/indirector/direct_file_server.rb +0 -73
  1126. data/spec/integration/indirector/file_content/file_server.rb +0 -94
  1127. data/spec/integration/indirector/file_metadata/file_server.rb +0 -18
  1128. data/spec/integration/indirector/node/ldap.rb +0 -15
  1129. data/spec/integration/indirector/report/rest.rb +0 -94
  1130. data/spec/integration/indirector/rest.rb +0 -523
  1131. data/spec/integration/network/client.rb +0 -19
  1132. data/spec/integration/network/formats.rb +0 -110
  1133. data/spec/integration/network/handler.rb +0 -25
  1134. data/spec/integration/network/server/mongrel.rb +0 -66
  1135. data/spec/integration/network/server/webrick.rb +0 -86
  1136. data/spec/integration/node.rb +0 -93
  1137. data/spec/integration/node/environment.rb +0 -58
  1138. data/spec/integration/node/facts.rb +0 -47
  1139. data/spec/integration/parser/compiler.rb +0 -29
  1140. data/spec/integration/parser/functions/require.rb +0 -86
  1141. data/spec/integration/provider/mailalias/aliases.rb +0 -25
  1142. data/spec/integration/provider/package.rb +0 -26
  1143. data/spec/integration/provider/service/init.rb +0 -32
  1144. data/spec/integration/reference/providers.rb +0 -17
  1145. data/spec/integration/reports.rb +0 -18
  1146. data/spec/integration/resource/catalog.rb +0 -61
  1147. data/spec/integration/ssl/certificate_authority.rb +0 -135
  1148. data/spec/integration/ssl/certificate_request.rb +0 -61
  1149. data/spec/integration/ssl/certificate_revocation_list.rb +0 -42
  1150. data/spec/integration/ssl/host.rb +0 -90
  1151. data/spec/integration/transaction.rb +0 -66
  1152. data/spec/integration/transaction/report.rb +0 -29
  1153. data/spec/integration/type.rb +0 -22
  1154. data/spec/integration/type/file.rb +0 -477
  1155. data/spec/integration/type/package.rb +0 -25
  1156. data/spec/integration/type/tidy.rb +0 -27
  1157. data/spec/integration/util/autoload.rb +0 -114
  1158. data/spec/integration/util/feature.rb +0 -54
  1159. data/spec/integration/util/file_locking.rb +0 -37
  1160. data/spec/integration/util/settings.rb +0 -27
  1161. data/spec/unit/agent.rb +0 -259
  1162. data/spec/unit/agent/locker.rb +0 -100
  1163. data/spec/unit/agent/runner.rb +0 -118
  1164. data/spec/unit/application.rb +0 -420
  1165. data/spec/unit/application/filebucket.rb +0 -220
  1166. data/spec/unit/application/pi.rb +0 -84
  1167. data/spec/unit/application/puppet.rb +0 -399
  1168. data/spec/unit/application/puppetca.rb +0 -142
  1169. data/spec/unit/application/puppetd.rb +0 -502
  1170. data/spec/unit/application/puppetdoc.rb +0 -360
  1171. data/spec/unit/application/puppetmasterd.rb +0 -457
  1172. data/spec/unit/application/puppetqd.rb +0 -186
  1173. data/spec/unit/application/puppetrun.rb +0 -289
  1174. data/spec/unit/application/ralsh.rb +0 -254
  1175. data/spec/unit/configurer.rb +0 -339
  1176. data/spec/unit/configurer/downloader.rb +0 -188
  1177. data/spec/unit/configurer/fact_handler.rb +0 -164
  1178. data/spec/unit/configurer/plugin_handler.rb +0 -112
  1179. data/spec/unit/daemon.rb +0 -287
  1180. data/spec/unit/file_collection.rb +0 -53
  1181. data/spec/unit/file_collection/lookup.rb +0 -46
  1182. data/spec/unit/file_serving/base.rb +0 -132
  1183. data/spec/unit/file_serving/configuration.rb +0 -249
  1184. data/spec/unit/file_serving/configuration/parser.rb +0 -181
  1185. data/spec/unit/file_serving/content.rb +0 -110
  1186. data/spec/unit/file_serving/fileset.rb +0 -347
  1187. data/spec/unit/file_serving/indirection_hooks.rb +0 -63
  1188. data/spec/unit/file_serving/metadata.rb +0 -286
  1189. data/spec/unit/file_serving/mount.rb +0 -32
  1190. data/spec/unit/file_serving/mount/file.rb +0 -196
  1191. data/spec/unit/file_serving/mount/modules.rb +0 -63
  1192. data/spec/unit/file_serving/mount/plugins.rb +0 -61
  1193. data/spec/unit/file_serving/terminus_helper.rb +0 -98
  1194. data/spec/unit/indirector.rb +0 -157
  1195. data/spec/unit/indirector/active_record.rb +0 -76
  1196. data/spec/unit/indirector/catalog/active_record.rb +0 -141
  1197. data/spec/unit/indirector/catalog/compiler.rb +0 -261
  1198. data/spec/unit/indirector/catalog/queue.rb +0 -20
  1199. data/spec/unit/indirector/catalog/rest.rb +0 -11
  1200. data/spec/unit/indirector/catalog/yaml.rb +0 -25
  1201. data/spec/unit/indirector/certificate/ca.rb +0 -28
  1202. data/spec/unit/indirector/certificate/file.rb +0 -28
  1203. data/spec/unit/indirector/certificate/rest.rb +0 -57
  1204. data/spec/unit/indirector/certificate_request/ca.rb +0 -19
  1205. data/spec/unit/indirector/certificate_request/file.rb +0 -19
  1206. data/spec/unit/indirector/certificate_request/rest.rb +0 -23
  1207. data/spec/unit/indirector/certificate_revocation_list/ca.rb +0 -21
  1208. data/spec/unit/indirector/certificate_revocation_list/file.rb +0 -20
  1209. data/spec/unit/indirector/certificate_revocation_list/rest.rb +0 -23
  1210. data/spec/unit/indirector/checksum/file.rb +0 -139
  1211. data/spec/unit/indirector/code.rb +0 -33
  1212. data/spec/unit/indirector/direct_file_server.rb +0 -84
  1213. data/spec/unit/indirector/envelope.rb +0 -47
  1214. data/spec/unit/indirector/exec.rb +0 -56
  1215. data/spec/unit/indirector/facts/active_record.rb +0 -104
  1216. data/spec/unit/indirector/facts/facter.rb +0 -142
  1217. data/spec/unit/indirector/facts/rest.rb +0 -11
  1218. data/spec/unit/indirector/facts/yaml.rb +0 -26
  1219. data/spec/unit/indirector/file.rb +0 -161
  1220. data/spec/unit/indirector/file_content/file.rb +0 -18
  1221. data/spec/unit/indirector/file_content/file_server.rb +0 -18
  1222. data/spec/unit/indirector/file_content/rest.rb +0 -11
  1223. data/spec/unit/indirector/file_metadata/file.rb +0 -52
  1224. data/spec/unit/indirector/file_metadata/file_server.rb +0 -18
  1225. data/spec/unit/indirector/file_metadata/rest.rb +0 -9
  1226. data/spec/unit/indirector/file_server.rb +0 -267
  1227. data/spec/unit/indirector/indirection.rb +0 -795
  1228. data/spec/unit/indirector/key/ca.rb +0 -28
  1229. data/spec/unit/indirector/key/file.rb +0 -104
  1230. data/spec/unit/indirector/ldap.rb +0 -143
  1231. data/spec/unit/indirector/memory.rb +0 -29
  1232. data/spec/unit/indirector/node/active_record.rb +0 -34
  1233. data/spec/unit/indirector/node/exec.rb +0 -69
  1234. data/spec/unit/indirector/node/ldap.rb +0 -458
  1235. data/spec/unit/indirector/node/memory.rb +0 -19
  1236. data/spec/unit/indirector/node/plain.rb +0 -19
  1237. data/spec/unit/indirector/node/rest.rb +0 -13
  1238. data/spec/unit/indirector/node/yaml.rb +0 -25
  1239. data/spec/unit/indirector/plain.rb +0 -29
  1240. data/spec/unit/indirector/queue.rb +0 -123
  1241. data/spec/unit/indirector/report/processor.rb +0 -81
  1242. data/spec/unit/indirector/report/rest.rb +0 -28
  1243. data/spec/unit/indirector/request.rb +0 -308
  1244. data/spec/unit/indirector/rest.rb +0 -403
  1245. data/spec/unit/indirector/runner/rest.rb +0 -11
  1246. data/spec/unit/indirector/ssl_file.rb +0 -280
  1247. data/spec/unit/indirector/terminus.rb +0 -245
  1248. data/spec/unit/indirector/yaml.rb +0 -145
  1249. data/spec/unit/module.rb +0 -247
  1250. data/spec/unit/network/authconfig.rb +0 -292
  1251. data/spec/unit/network/authstore.rb +0 -370
  1252. data/spec/unit/network/client.rb +0 -45
  1253. data/spec/unit/network/client/dipper.rb +0 -16
  1254. data/spec/unit/network/format.rb +0 -191
  1255. data/spec/unit/network/format_handler.rb +0 -327
  1256. data/spec/unit/network/formats.rb +0 -365
  1257. data/spec/unit/network/handler/fileserver.rb +0 -176
  1258. data/spec/unit/network/http.rb +0 -35
  1259. data/spec/unit/network/http/api/v1.rb +0 -122
  1260. data/spec/unit/network/http/handler.rb +0 -458
  1261. data/spec/unit/network/http/mongrel.rb +0 -131
  1262. data/spec/unit/network/http/mongrel/rest.rb +0 -232
  1263. data/spec/unit/network/http/rack.rb +0 -102
  1264. data/spec/unit/network/http/rack/rest.rb +0 -199
  1265. data/spec/unit/network/http/rack/xmlrpc.rb +0 -157
  1266. data/spec/unit/network/http/webrick.rb +0 -339
  1267. data/spec/unit/network/http/webrick/rest.rb +0 -157
  1268. data/spec/unit/network/http_pool.rb +0 -206
  1269. data/spec/unit/network/rest_authconfig.rb +0 -146
  1270. data/spec/unit/network/rest_authorization.rb +0 -43
  1271. data/spec/unit/network/rights.rb +0 -519
  1272. data/spec/unit/network/server.rb +0 -534
  1273. data/spec/unit/network/xmlrpc/client.rb +0 -171
  1274. data/spec/unit/node.rb +0 -200
  1275. data/spec/unit/node/environment.rb +0 -187
  1276. data/spec/unit/node/facts.rb +0 -97
  1277. data/spec/unit/other/checksum.rb +0 -92
  1278. data/spec/unit/other/selinux.rb +0 -85
  1279. data/spec/unit/other/transbucket.rb +0 -188
  1280. data/spec/unit/other/transobject.rb +0 -112
  1281. data/spec/unit/parameter.rb +0 -405
  1282. data/spec/unit/parser/ast.rb +0 -41
  1283. data/spec/unit/parser/ast/arithmetic_operator.rb +0 -73
  1284. data/spec/unit/parser/ast/astarray.rb +0 -72
  1285. data/spec/unit/parser/ast/boolean_operator.rb +0 -53
  1286. data/spec/unit/parser/ast/casestatement.rb +0 -135
  1287. data/spec/unit/parser/ast/collection.rb +0 -63
  1288. data/spec/unit/parser/ast/collexpr.rb +0 -115
  1289. data/spec/unit/parser/ast/comparison_operator.rb +0 -92
  1290. data/spec/unit/parser/ast/definition.rb +0 -213
  1291. data/spec/unit/parser/ast/function.rb +0 -83
  1292. data/spec/unit/parser/ast/hostclass.rb +0 -148
  1293. data/spec/unit/parser/ast/ifstatement.rb +0 -76
  1294. data/spec/unit/parser/ast/leaf.rb +0 -298
  1295. data/spec/unit/parser/ast/match_operator.rb +0 -50
  1296. data/spec/unit/parser/ast/minus.rb +0 -36
  1297. data/spec/unit/parser/ast/node.rb +0 -145
  1298. data/spec/unit/parser/ast/nop.rb +0 -20
  1299. data/spec/unit/parser/ast/not.rb +0 -30
  1300. data/spec/unit/parser/ast/resource.rb +0 -103
  1301. data/spec/unit/parser/ast/resource_override.rb +0 -51
  1302. data/spec/unit/parser/ast/resource_reference.rb +0 -69
  1303. data/spec/unit/parser/ast/selector.rb +0 -155
  1304. data/spec/unit/parser/ast/vardef.rb +0 -47
  1305. data/spec/unit/parser/collector.rb +0 -556
  1306. data/spec/unit/parser/compiler.rb +0 -604
  1307. data/spec/unit/parser/files.rb +0 -190
  1308. data/spec/unit/parser/functions.rb +0 -83
  1309. data/spec/unit/parser/functions/fqdn_rand.rb +0 -62
  1310. data/spec/unit/parser/functions/generate.rb +0 -41
  1311. data/spec/unit/parser/functions/inline_template.rb +0 -59
  1312. data/spec/unit/parser/functions/realize.rb +0 -51
  1313. data/spec/unit/parser/functions/regsubst.rb +0 -168
  1314. data/spec/unit/parser/functions/require.rb +0 -69
  1315. data/spec/unit/parser/functions/shellquote.rb +0 -92
  1316. data/spec/unit/parser/functions/split.rb +0 -51
  1317. data/spec/unit/parser/functions/sprintf.rb +0 -42
  1318. data/spec/unit/parser/functions/template.rb +0 -62
  1319. data/spec/unit/parser/functions/versioncmp.rb +0 -29
  1320. data/spec/unit/parser/interpreter.rb +0 -147
  1321. data/spec/unit/parser/lexer.rb +0 -731
  1322. data/spec/unit/parser/loaded_code.rb +0 -215
  1323. data/spec/unit/parser/parser.rb +0 -423
  1324. data/spec/unit/parser/resource.rb +0 -529
  1325. data/spec/unit/parser/resource/reference.rb +0 -111
  1326. data/spec/unit/parser/scope.rb +0 -387
  1327. data/spec/unit/parser/templatewrapper.rb +0 -134
  1328. data/spec/unit/property.rb +0 -305
  1329. data/spec/unit/property/keyvalue.rb +0 -168
  1330. data/spec/unit/property/list.rb +0 -166
  1331. data/spec/unit/property/ordered_list.rb +0 -64
  1332. data/spec/unit/provider.rb +0 -31
  1333. data/spec/unit/provider/augeas/augeas.rb +0 -413
  1334. data/spec/unit/provider/confine.rb +0 -78
  1335. data/spec/unit/provider/confine/exists.rb +0 -81
  1336. data/spec/unit/provider/confine/false.rb +0 -53
  1337. data/spec/unit/provider/confine/feature.rb +0 -60
  1338. data/spec/unit/provider/confine/true.rb +0 -53
  1339. data/spec/unit/provider/confine/variable.rb +0 -107
  1340. data/spec/unit/provider/confine_collection.rb +0 -134
  1341. data/spec/unit/provider/confiner.rb +0 -63
  1342. data/spec/unit/provider/group/groupadd.rb +0 -31
  1343. data/spec/unit/provider/group/ldap.rb +0 -105
  1344. data/spec/unit/provider/ldap.rb +0 -248
  1345. data/spec/unit/provider/macauthorization.rb +0 -147
  1346. data/spec/unit/provider/mcx/mcxcontent.rb +0 -175
  1347. data/spec/unit/provider/mount.rb +0 -130
  1348. data/spec/unit/provider/mount/parsed.rb +0 -194
  1349. data/spec/unit/provider/naginator.rb +0 -58
  1350. data/spec/unit/provider/package/apt.rb +0 -138
  1351. data/spec/unit/provider/package/dpkg.rb +0 -170
  1352. data/spec/unit/provider/package/gem.rb +0 -87
  1353. data/spec/unit/provider/package/hpux.rb +0 -52
  1354. data/spec/unit/provider/package/pkgdmg.rb +0 -73
  1355. data/spec/unit/provider/parsedfile.rb +0 -95
  1356. data/spec/unit/provider/selboolean.rb +0 -37
  1357. data/spec/unit/provider/selmodule.rb +0 -66
  1358. data/spec/unit/provider/service/daemontools.rb +0 -166
  1359. data/spec/unit/provider/service/debian.rb +0 -89
  1360. data/spec/unit/provider/service/init.rb +0 -121
  1361. data/spec/unit/provider/service/launchd.rb +0 -200
  1362. data/spec/unit/provider/service/redhat.rb +0 -96
  1363. data/spec/unit/provider/service/runit.rb +0 -140
  1364. data/spec/unit/provider/ssh_authorized_key/parsed.rb +0 -206
  1365. data/spec/unit/provider/sshkey/parsed.rb +0 -38
  1366. data/spec/unit/provider/user/hpux.rb +0 -25
  1367. data/spec/unit/provider/user/ldap.rb +0 -279
  1368. data/spec/unit/provider/user/user_role_add.rb +0 -249
  1369. data/spec/unit/provider/user/useradd.rb +0 -115
  1370. data/spec/unit/provider/zfs/solaris.rb +0 -99
  1371. data/spec/unit/provider/zone/solaris.rb +0 -42
  1372. data/spec/unit/provider/zpool/solaris.rb +0 -179
  1373. data/spec/unit/rails.rb +0 -133
  1374. data/spec/unit/rails/host.rb +0 -163
  1375. data/spec/unit/rails/param_value.rb +0 -49
  1376. data/spec/unit/rails/resource.rb +0 -107
  1377. data/spec/unit/relationship.rb +0 -236
  1378. data/spec/unit/reports.rb +0 -61
  1379. data/spec/unit/resource.rb +0 -495
  1380. data/spec/unit/resource/catalog.rb +0 -1053
  1381. data/spec/unit/resource/reference.rb +0 -111
  1382. data/spec/unit/simple_graph.rb +0 -551
  1383. data/spec/unit/ssl/certificate.rb +0 -124
  1384. data/spec/unit/ssl/certificate_authority.rb +0 -741
  1385. data/spec/unit/ssl/certificate_authority/interface.rb +0 -269
  1386. data/spec/unit/ssl/certificate_factory.rb +0 -107
  1387. data/spec/unit/ssl/certificate_request.rb +0 -193
  1388. data/spec/unit/ssl/certificate_revocation_list.rb +0 -168
  1389. data/spec/unit/ssl/host.rb +0 -704
  1390. data/spec/unit/ssl/inventory.rb +0 -180
  1391. data/spec/unit/ssl/key.rb +0 -198
  1392. data/spec/unit/transaction.rb +0 -146
  1393. data/spec/unit/transaction/change.rb +0 -187
  1394. data/spec/unit/transaction/event.rb +0 -25
  1395. data/spec/unit/transaction/report.rb +0 -40
  1396. data/spec/unit/type.rb +0 -426
  1397. data/spec/unit/type/augeas.rb +0 -106
  1398. data/spec/unit/type/component.rb +0 -63
  1399. data/spec/unit/type/computer.rb +0 -78
  1400. data/spec/unit/type/cron.rb +0 -33
  1401. data/spec/unit/type/exec.rb +0 -116
  1402. data/spec/unit/type/file.rb +0 -810
  1403. data/spec/unit/type/file/checksum.rb +0 -28
  1404. data/spec/unit/type/file/content.rb +0 -297
  1405. data/spec/unit/type/file/ensure.rb +0 -84
  1406. data/spec/unit/type/file/group.rb +0 -123
  1407. data/spec/unit/type/file/owner.rb +0 -143
  1408. data/spec/unit/type/file/selinux.rb +0 -84
  1409. data/spec/unit/type/file/source.rb +0 -264
  1410. data/spec/unit/type/filebucket.rb +0 -74
  1411. data/spec/unit/type/group.rb +0 -39
  1412. data/spec/unit/type/macauthorization.rb +0 -111
  1413. data/spec/unit/type/maillist.rb +0 -42
  1414. data/spec/unit/type/mcx.rb +0 -100
  1415. data/spec/unit/type/mount.rb +0 -211
  1416. data/spec/unit/type/nagios.rb +0 -63
  1417. data/spec/unit/type/noop_metaparam.rb +0 -37
  1418. data/spec/unit/type/package.rb +0 -236
  1419. data/spec/unit/type/resources.rb +0 -89
  1420. data/spec/unit/type/schedule.rb +0 -333
  1421. data/spec/unit/type/selboolean.rb +0 -45
  1422. data/spec/unit/type/selmodule.rb +0 -18
  1423. data/spec/unit/type/service.rb +0 -230
  1424. data/spec/unit/type/ssh_authorized_key.rb +0 -140
  1425. data/spec/unit/type/tidy.rb +0 -422
  1426. data/spec/unit/type/user.rb +0 -285
  1427. data/spec/unit/type/zfs.rb +0 -45
  1428. data/spec/unit/type/zone.rb +0 -20
  1429. data/spec/unit/type/zpool.rb +0 -110
  1430. data/spec/unit/util/autoload.rb +0 -133
  1431. data/spec/unit/util/autoload/file_cache.rb +0 -183
  1432. data/spec/unit/util/backups.rb +0 -159
  1433. data/spec/unit/util/cache_accumulator.rb +0 -69
  1434. data/spec/unit/util/cacher.rb +0 -185
  1435. data/spec/unit/util/checksums.rb +0 -113
  1436. data/spec/unit/util/constant_inflector.rb +0 -70
  1437. data/spec/unit/util/feature.rb +0 -72
  1438. data/spec/unit/util/file_locking.rb +0 -115
  1439. data/spec/unit/util/filetype.rb +0 -100
  1440. data/spec/unit/util/json.rb +0 -21
  1441. data/spec/unit/util/ldap/connection.rb +0 -169
  1442. data/spec/unit/util/ldap/generator.rb +0 -54
  1443. data/spec/unit/util/ldap/manager.rb +0 -654
  1444. data/spec/unit/util/loadedfile.rb +0 -65
  1445. data/spec/unit/util/log.rb +0 -202
  1446. data/spec/unit/util/metric.rb +0 -95
  1447. data/spec/unit/util/monkey_patches.rb +0 -103
  1448. data/spec/unit/util/nagios_maker.rb +0 -126
  1449. data/spec/unit/util/package.rb +0 -21
  1450. data/spec/unit/util/posix.rb +0 -256
  1451. data/spec/unit/util/queue.rb +0 -96
  1452. data/spec/unit/util/queue/stomp.rb +0 -140
  1453. data/spec/unit/util/reference_serializer.rb +0 -52
  1454. data/spec/unit/util/resource_template.rb +0 -58
  1455. data/spec/unit/util/selinux.rb +0 -280
  1456. data/spec/unit/util/settings.rb +0 -1058
  1457. data/spec/unit/util/settings/file_setting.rb +0 -248
  1458. data/spec/unit/util/storage.rb +0 -248
  1459. data/spec/unit/util/tagging.rb +0 -102
  1460. data/spec/unit/util/user_attr.rb +0 -47
  1461. data/spec/unit/util/warnings.rb +0 -39
  1462. data/spec/unit/util/zaml.rb +0 -38
  1463. data/test/language/ast/casestatement.rb +0 -103
  1464. data/test/language/ast/resource.rb +0 -58
  1465. data/test/language/ast/resource_reference.rb +0 -77
  1466. data/test/language/ast/selector.rb +0 -61
  1467. data/test/language/resource.rb +0 -172
  1468. data/test/lib/puppettest/support/collection.rb +0 -29
  1469. data/test/network/client/resource.rb +0 -52
  1470. data/test/network/handler/bucket.rb +0 -313
  1471. data/test/network/handler/resource.rb +0 -250
  1472. data/test/other/dsl.rb +0 -215
  1473. data/test/other/events.rb +0 -124
  1474. data/test/ral/type/group.rb +0 -170
@@ -9,7 +9,6 @@ require 'puppet/metatype/manager'
9
9
  require 'puppet/util/errors'
10
10
  require 'puppet/util/log_paths'
11
11
  require 'puppet/util/logging'
12
- require 'puppet/resource/reference'
13
12
  require 'puppet/util/cacher'
14
13
  require 'puppet/file_collection/lookup'
15
14
  require 'puppet/util/tagging'
@@ -18,2074 +17,1870 @@ require 'puppet/util/tagging'
18
17
 
19
18
  module Puppet
20
19
  class Type
21
- include Puppet::Util
22
- include Puppet::Util::Errors
23
- include Puppet::Util::LogPaths
24
- include Puppet::Util::Logging
25
- include Puppet::Util::Cacher
26
- include Puppet::FileCollection::Lookup
27
- include Puppet::Util::Tagging
20
+ include Puppet::Util
21
+ include Puppet::Util::Errors
22
+ include Puppet::Util::LogPaths
23
+ include Puppet::Util::Logging
24
+ include Puppet::Util::Cacher
25
+ include Puppet::FileCollection::Lookup
26
+ include Puppet::Util::Tagging
27
+
28
+ ###############################
29
+ # Code related to resource type attributes.
30
+ class << self
31
+ include Puppet::Util::ClassGen
32
+ include Puppet::Util::Warnings
33
+ attr_reader :properties
34
+ end
35
+
36
+ def self.states
37
+ warnonce "The states method is deprecated; use properties"
38
+ properties
39
+ end
40
+
41
+ # All parameters, in the appropriate order. The key_attributes come first, then
42
+ # the provider, then the properties, and finally the params and metaparams
43
+ # in the order they were specified in the files.
44
+ def self.allattrs
45
+ key_attributes | (parameters & [:provider]) | properties.collect { |property| property.name } | parameters | metaparams
46
+ end
47
+
48
+ # Retrieve an attribute alias, if there is one.
49
+ def self.attr_alias(param)
50
+ @attr_aliases[symbolize(param)]
51
+ end
52
+
53
+ # Create an alias to an existing attribute. This will cause the aliased
54
+ # attribute to be valid when setting and retrieving values on the instance.
55
+ def self.set_attr_alias(hash)
56
+ hash.each do |new, old|
57
+ @attr_aliases[symbolize(new)] = symbolize(old)
58
+ end
59
+ end
60
+
61
+ # Find the class associated with any given attribute.
62
+ def self.attrclass(name)
63
+ @attrclasses ||= {}
64
+
65
+ # We cache the value, since this method gets called such a huge number
66
+ # of times (as in, hundreds of thousands in a given run).
67
+ unless @attrclasses.include?(name)
68
+ @attrclasses[name] = case self.attrtype(name)
69
+ when :property; @validproperties[name]
70
+ when :meta; @@metaparamhash[name]
71
+ when :param; @paramhash[name]
72
+ end
73
+ end
74
+ @attrclasses[name]
75
+ end
76
+
77
+ # What type of parameter are we dealing with? Cache the results, because
78
+ # this method gets called so many times.
79
+ def self.attrtype(attr)
80
+ @attrtypes ||= {}
81
+ unless @attrtypes.include?(attr)
82
+ @attrtypes[attr] = case
83
+ when @validproperties.include?(attr); :property
84
+ when @paramhash.include?(attr); :param
85
+ when @@metaparamhash.include?(attr); :meta
86
+ end
87
+ end
88
+
89
+ @attrtypes[attr]
90
+ end
91
+
92
+ def self.eachmetaparam
93
+ @@metaparams.each { |p| yield p.name }
94
+ end
95
+
96
+ # Create the 'ensure' class. This is a separate method so other types
97
+ # can easily call it and create their own 'ensure' values.
98
+ def self.ensurable(&block)
99
+ if block_given?
100
+ self.newproperty(:ensure, :parent => Puppet::Property::Ensure, &block)
101
+ else
102
+ self.newproperty(:ensure, :parent => Puppet::Property::Ensure) do
103
+ self.defaultvalues
104
+ end
105
+ end
106
+ end
107
+
108
+ # Should we add the 'ensure' property to this class?
109
+ def self.ensurable?
110
+ # If the class has all three of these methods defined, then it's
111
+ # ensurable.
112
+ ens = [:exists?, :create, :destroy].inject { |set, method|
113
+ set &&= self.public_method_defined?(method)
114
+ }
115
+
116
+ ens
117
+ end
118
+
119
+ # Deal with any options passed into parameters.
120
+ def self.handle_param_options(name, options)
121
+ # If it's a boolean parameter, create a method to test the value easily
122
+ if options[:boolean]
123
+ define_method(name.to_s + "?") do
124
+ val = self[name]
125
+ if val == :true or val == true
126
+ return true
127
+ end
128
+ end
129
+ end
130
+ end
131
+
132
+ # Is the parameter in question a meta-parameter?
133
+ def self.metaparam?(param)
134
+ @@metaparamhash.include?(symbolize(param))
135
+ end
136
+
137
+ # Find the metaparameter class associated with a given metaparameter name.
138
+ def self.metaparamclass(name)
139
+ @@metaparamhash[symbolize(name)]
140
+ end
141
+
142
+ def self.metaparams
143
+ @@metaparams.collect { |param| param.name }
144
+ end
145
+
146
+ def self.metaparamdoc(metaparam)
147
+ @@metaparamhash[metaparam].doc
148
+ end
149
+
150
+ # Create a new metaparam. Requires a block and a name, stores it in the
151
+ # @parameters array, and does some basic checking on it.
152
+ def self.newmetaparam(name, options = {}, &block)
153
+ @@metaparams ||= []
154
+ @@metaparamhash ||= {}
155
+ name = symbolize(name)
156
+
157
+
158
+ param = genclass(
159
+ name,
160
+ :parent => options[:parent] || Puppet::Parameter,
161
+ :prefix => "MetaParam",
162
+ :hash => @@metaparamhash,
163
+ :array => @@metaparams,
164
+ :attributes => options[:attributes],
165
+
166
+ &block
167
+ )
168
+
169
+ # Grr.
170
+ param.required_features = options[:required_features] if options[:required_features]
171
+
172
+ handle_param_options(name, options)
173
+
174
+ param.metaparam = true
175
+
176
+ param
177
+ end
178
+
179
+ def self.key_attribute_parameters
180
+ @key_attribute_parameters ||= (
181
+ params = @parameters.find_all { |param|
182
+ param.isnamevar? or param.name == :name
183
+ }
184
+ )
185
+ end
28
186
 
29
- ###############################
30
- # Code related to resource type attributes.
31
- class << self
32
- include Puppet::Util::ClassGen
33
- include Puppet::Util::Warnings
34
- attr_reader :properties
35
- end
187
+ def self.key_attributes
188
+ key_attribute_parameters.collect { |p| p.name }
189
+ end
190
+
191
+ def self.title_patterns
192
+ case key_attributes.length
193
+ when 0; []
194
+ when 1;
195
+ identity = lambda {|x| x}
196
+ [ [ /(.*)/m, [ [key_attributes.first, identity ] ] ] ]
197
+ else
198
+ raise Puppet::DevError,"you must specify title patterns when there are two or more key attributes"
199
+ end
200
+ end
201
+
202
+ def uniqueness_key
203
+ to_resource.uniqueness_key
204
+ end
205
+
206
+ # Create a new parameter. Requires a block and a name, stores it in the
207
+ # @parameters array, and does some basic checking on it.
208
+ def self.newparam(name, options = {}, &block)
209
+ options[:attributes] ||= {}
210
+
211
+ param = genclass(
212
+ name,
213
+ :parent => options[:parent] || Puppet::Parameter,
214
+ :attributes => options[:attributes],
215
+ :block => block,
216
+ :prefix => "Parameter",
217
+ :array => @parameters,
36
218
 
37
- def self.states
38
- warnonce "The states method is deprecated; use properties"
39
- properties()
40
- end
219
+ :hash => @paramhash
220
+ )
221
+
222
+ handle_param_options(name, options)
41
223
 
42
- # All parameters, in the appropriate order. The namevar comes first, then
43
- # the provider, then the properties, and finally the params and metaparams
44
- # in the order they were specified in the files.
45
- def self.allattrs
46
- # Cache this, since it gets called multiple times
47
- namevar = self.namevar
224
+ # Grr.
225
+ param.required_features = options[:required_features] if options[:required_features]
48
226
 
49
- order = [namevar]
50
- if self.parameters.include?(:provider)
51
- order << :provider
52
- end
53
- order << [self.properties.collect { |property| property.name },
54
- self.parameters - [:provider],
55
- self.metaparams].flatten.reject { |param|
56
- # we don't want our namevar in there multiple times
57
- param == namevar
58
- }
59
-
60
- order.flatten!
61
-
62
- return order
63
- end
64
-
65
- # Retrieve an attribute alias, if there is one.
66
- def self.attr_alias(param)
67
- @attr_aliases[symbolize(param)]
68
- end
227
+ param.isnamevar if options[:namevar]
69
228
 
70
- # Create an alias to an existing attribute. This will cause the aliased
71
- # attribute to be valid when setting and retrieving values on the instance.
72
- def self.set_attr_alias(hash)
73
- hash.each do |new, old|
74
- @attr_aliases[symbolize(new)] = symbolize(old)
75
- end
76
- end
229
+ param
230
+ end
77
231
 
78
- # Find the class associated with any given attribute.
79
- def self.attrclass(name)
80
- @attrclasses ||= {}
232
+ def self.newstate(name, options = {}, &block)
233
+ Puppet.warning "newstate() has been deprecrated; use newproperty(#{name})"
234
+ newproperty(name, options, &block)
235
+ end
81
236
 
82
- # We cache the value, since this method gets called such a huge number
83
- # of times (as in, hundreds of thousands in a given run).
84
- unless @attrclasses.include?(name)
85
- @attrclasses[name] = case self.attrtype(name)
86
- when :property; @validproperties[name]
87
- when :meta; @@metaparamhash[name]
88
- when :param; @paramhash[name]
89
- end
90
- end
91
- @attrclasses[name]
92
- end
93
-
94
- # What type of parameter are we dealing with? Cache the results, because
95
- # this method gets called so many times.
96
- def self.attrtype(attr)
97
- @attrtypes ||= {}
98
- unless @attrtypes.include?(attr)
99
- @attrtypes[attr] = case
100
- when @validproperties.include?(attr); :property
101
- when @paramhash.include?(attr); :param
102
- when @@metaparamhash.include?(attr); :meta
103
- end
104
- end
237
+ # Create a new property. The first parameter must be the name of the property;
238
+ # this is how users will refer to the property when creating new instances.
239
+ # The second parameter is a hash of options; the options are:
240
+ # * <tt>:parent</tt>: The parent class for the property. Defaults to Puppet::Property.
241
+ # * <tt>:retrieve</tt>: The method to call on the provider or @parent object (if
242
+ # the provider is not set) to retrieve the current value.
243
+ def self.newproperty(name, options = {}, &block)
244
+ name = symbolize(name)
245
+
246
+ # This is here for types that might still have the old method of defining
247
+ # a parent class.
248
+ unless options.is_a? Hash
249
+ raise Puppet::DevError,
250
+ "Options must be a hash, not #{options.inspect}"
251
+ end
252
+
253
+ raise Puppet::DevError, "Class #{self.name} already has a property named #{name}" if @validproperties.include?(name)
254
+
255
+ if parent = options[:parent]
256
+ options.delete(:parent)
257
+ else
258
+ parent = Puppet::Property
259
+ end
260
+
261
+ # We have to create our own, new block here because we want to define
262
+ # an initial :retrieve method, if told to, and then eval the passed
263
+ # block if available.
264
+ prop = genclass(name, :parent => parent, :hash => @validproperties, :attributes => options) do
265
+ # If they've passed a retrieve method, then override the retrieve
266
+ # method on the class.
267
+ if options[:retrieve]
268
+ define_method(:retrieve) do
269
+ provider.send(options[:retrieve])
270
+ end
271
+ end
272
+
273
+ class_eval(&block) if block
274
+ end
275
+
276
+ # If it's the 'ensure' property, always put it first.
277
+ if name == :ensure
278
+ @properties.unshift prop
279
+ else
280
+ @properties << prop
281
+ end
282
+
283
+ prop
284
+ end
285
+
286
+ def self.paramdoc(param)
287
+ @paramhash[param].doc
288
+ end
289
+
290
+ # Return the parameter names
291
+ def self.parameters
292
+ return [] unless defined?(@parameters)
293
+ @parameters.collect { |klass| klass.name }
294
+ end
295
+
296
+ # Find the parameter class associated with a given parameter name.
297
+ def self.paramclass(name)
298
+ @paramhash[name]
299
+ end
300
+
301
+ # Return the property class associated with a name
302
+ def self.propertybyname(name)
303
+ @validproperties[name]
304
+ end
305
+
306
+ def self.validattr?(name)
307
+ name = symbolize(name)
308
+ return true if name == :name
309
+ @validattrs ||= {}
105
310
 
106
- @attrtypes[attr]
311
+ unless @validattrs.include?(name)
312
+ @validattrs[name] = !!(self.validproperty?(name) or self.validparameter?(name) or self.metaparam?(name))
107
313
  end
108
314
 
109
- # Copy an existing class parameter. This allows other types to avoid
110
- # duplicating a parameter definition, and is mostly used by subclasses
111
- # of the File class.
112
- def self.copyparam(klass, name)
113
- param = klass.attrclass(name)
315
+ @validattrs[name]
316
+ end
114
317
 
115
- unless param
116
- raise Puppet::DevError, "Class %s has no param %s" % [klass, name]
117
- end
118
- @parameters << param
119
- @parameters.each { |p| @paramhash[name] = p }
318
+ # does the name reflect a valid property?
319
+ def self.validproperty?(name)
320
+ name = symbolize(name)
321
+ @validproperties.include?(name) && @validproperties[name]
322
+ end
120
323
 
121
- if param.isnamevar?
122
- @namevar = param.name
123
- end
124
- end
125
-
126
- def self.eachmetaparam
127
- @@metaparams.each { |p| yield p.name }
128
- end
129
-
130
- # Create the 'ensure' class. This is a separate method so other types
131
- # can easily call it and create their own 'ensure' values.
132
- def self.ensurable(&block)
133
- if block_given?
134
- self.newproperty(:ensure, :parent => Puppet::Property::Ensure, &block)
324
+ # Return the list of validproperties
325
+ def self.validproperties
326
+ return {} unless defined?(@parameters)
327
+
328
+ @validproperties.keys
329
+ end
330
+
331
+ # does the name reflect a valid parameter?
332
+ def self.validparameter?(name)
333
+ raise Puppet::DevError, "Class #{self} has not defined parameters" unless defined?(@parameters)
334
+ !!(@paramhash.include?(name) or @@metaparamhash.include?(name))
335
+ end
336
+
337
+ # This is a forward-compatibility method - it's the validity interface we'll use in Puppet::Resource.
338
+ def self.valid_parameter?(name)
339
+ validattr?(name)
340
+ end
341
+
342
+ # Return either the attribute alias or the attribute.
343
+ def attr_alias(name)
344
+ name = symbolize(name)
345
+ if synonym = self.class.attr_alias(name)
346
+ return synonym
347
+ else
348
+ return name
349
+ end
350
+ end
351
+
352
+ # Are we deleting this resource?
353
+ def deleting?
354
+ obj = @parameters[:ensure] and obj.should == :absent
355
+ end
356
+
357
+ # Create a new property if it is valid but doesn't exist
358
+ # Returns: true if a new parameter was added, false otherwise
359
+ def add_property_parameter(prop_name)
360
+ if self.class.validproperty?(prop_name) && !@parameters[prop_name]
361
+ self.newattr(prop_name)
362
+ return true
363
+ end
364
+ false
365
+ end
366
+
367
+ #
368
+ # The name_var is the key_attribute in the case that there is only one.
369
+ #
370
+ def name_var
371
+ key_attributes = self.class.key_attributes
372
+ (key_attributes.length == 1) && key_attributes.first
373
+ end
374
+
375
+ # abstract accessing parameters and properties, and normalize
376
+ # access to always be symbols, not strings
377
+ # This returns a value, not an object. It returns the 'is'
378
+ # value, but you can also specifically return 'is' and 'should'
379
+ # values using 'object.is(:property)' or 'object.should(:property)'.
380
+ def [](name)
381
+ name = attr_alias(name)
382
+
383
+ fail("Invalid parameter #{name}(#{name.inspect})") unless self.class.validattr?(name)
384
+
385
+ if name == :name
386
+ name = name_var
387
+ end
388
+
389
+ if obj = @parameters[name]
390
+ # Note that if this is a property, then the value is the "should" value,
391
+ # not the current value.
392
+ obj.value
393
+ else
394
+ return nil
395
+ end
396
+ end
397
+
398
+ # Abstract setting parameters and properties, and normalize
399
+ # access to always be symbols, not strings. This sets the 'should'
400
+ # value on properties, and otherwise just sets the appropriate parameter.
401
+ def []=(name,value)
402
+ name = attr_alias(name)
403
+
404
+ fail("Invalid parameter #{name}") unless self.class.validattr?(name)
405
+
406
+ if name == :name
407
+ name = name_var
408
+ end
409
+ raise Puppet::Error.new("Got nil value for #{name}") if value.nil?
410
+
411
+ property = self.newattr(name)
412
+
413
+ begin
414
+ # make sure the parameter doesn't have any errors
415
+ property.value = value
416
+ rescue => detail
417
+ error = Puppet::Error.new("Parameter #{name} failed: #{detail}")
418
+ error.set_backtrace(detail.backtrace)
419
+ raise error
420
+ end
421
+
422
+ nil
423
+ end
424
+
425
+ # remove a property from the object; useful in testing or in cleanup
426
+ # when an error has been encountered
427
+ def delete(attr)
428
+ attr = symbolize(attr)
429
+ if @parameters.has_key?(attr)
430
+ @parameters.delete(attr)
431
+ else
432
+ raise Puppet::DevError.new("Undefined attribute '#{attr}' in #{self}")
433
+ end
434
+ end
435
+
436
+ # iterate across the existing properties
437
+ def eachproperty
438
+ # properties is a private method
439
+ properties.each { |property|
440
+ yield property
441
+ }
442
+ end
443
+
444
+ # Create a transaction event. Called by Transaction or by
445
+ # a property.
446
+ def event(options = {})
447
+ Puppet::Transaction::Event.new({:resource => self, :file => file, :line => line, :tags => tags, :version => version}.merge(options))
448
+ end
449
+
450
+ # Let the catalog determine whether a given cached value is
451
+ # still valid or has expired.
452
+ def expirer
453
+ catalog
454
+ end
455
+
456
+ # retrieve the 'should' value for a specified property
457
+ def should(name)
458
+ name = attr_alias(name)
459
+ (prop = @parameters[name] and prop.is_a?(Puppet::Property)) ? prop.should : nil
460
+ end
461
+
462
+ # Create the actual attribute instance. Requires either the attribute
463
+ # name or class as the first argument, then an optional hash of
464
+ # attributes to set during initialization.
465
+ def newattr(name)
466
+ if name.is_a?(Class)
467
+ klass = name
468
+ name = klass.name
469
+ end
470
+
471
+ unless klass = self.class.attrclass(name)
472
+ raise Puppet::Error, "Resource type #{self.class.name} does not support parameter #{name}"
473
+ end
474
+
475
+ return @parameters[name] if @parameters.include?(name)
476
+
477
+ @parameters[name] = klass.new(:resource => self)
478
+ end
479
+
480
+ # return the value of a parameter
481
+ def parameter(name)
482
+ @parameters[name.to_sym]
483
+ end
484
+
485
+ def parameters
486
+ @parameters.dup
487
+ end
488
+
489
+ # Is the named property defined?
490
+ def propertydefined?(name)
491
+ name = name.intern unless name.is_a? Symbol
492
+ @parameters.include?(name)
493
+ end
494
+
495
+ # Return an actual property instance by name; to return the value, use 'resource[param]'
496
+ # LAK:NOTE(20081028) Since the 'parameter' method is now a superset of this method,
497
+ # this one should probably go away at some point.
498
+ def property(name)
499
+ (obj = @parameters[symbolize(name)] and obj.is_a?(Puppet::Property)) ? obj : nil
500
+ end
501
+
502
+ # For any parameters or properties that have defaults and have not yet been
503
+ # set, set them now. This method can be handed a list of attributes,
504
+ # and if so it will only set defaults for those attributes.
505
+ def set_default(attr)
506
+ return unless klass = self.class.attrclass(attr)
507
+ return unless klass.method_defined?(:default)
508
+ return if @parameters.include?(klass.name)
509
+
510
+ return unless parameter = newattr(klass.name)
511
+
512
+ if value = parameter.default and ! value.nil?
513
+ parameter.value = value
514
+ else
515
+ @parameters.delete(parameter.name)
516
+ end
517
+ end
518
+
519
+ # Convert our object to a hash. This just includes properties.
520
+ def to_hash
521
+ rethash = {}
522
+
523
+ @parameters.each do |name, obj|
524
+ rethash[name] = obj.value
525
+ end
526
+
527
+ rethash
528
+ end
529
+
530
+ def type
531
+ self.class.name
532
+ end
533
+
534
+ # Return a specific value for an attribute.
535
+ def value(name)
536
+ name = attr_alias(name)
537
+
538
+ (obj = @parameters[name] and obj.respond_to?(:value)) ? obj.value : nil
539
+ end
540
+
541
+ def version
542
+ return 0 unless catalog
543
+ catalog.version
544
+ end
545
+
546
+ # Return all of the property objects, in the order specified in the
547
+ # class.
548
+ def properties
549
+ self.class.properties.collect { |prop| @parameters[prop.name] }.compact
550
+ end
551
+
552
+ # Is this type's name isomorphic with the object? That is, if the
553
+ # name conflicts, does it necessarily mean that the objects conflict?
554
+ # Defaults to true.
555
+ def self.isomorphic?
556
+ if defined?(@isomorphic)
557
+ return @isomorphic
558
+ else
559
+ return true
560
+ end
561
+ end
562
+
563
+ def isomorphic?
564
+ self.class.isomorphic?
565
+ end
566
+
567
+ # is the instance a managed instance? A 'yes' here means that
568
+ # the instance was created from the language, vs. being created
569
+ # in order resolve other questions, such as finding a package
570
+ # in a list
571
+ def managed?
572
+ # Once an object is managed, it always stays managed; but an object
573
+ # that is listed as unmanaged might become managed later in the process,
574
+ # so we have to check that every time
575
+ if @managed
576
+ return @managed
577
+ else
578
+ @managed = false
579
+ properties.each { |property|
580
+ s = property.should
581
+ if s and ! property.class.unmanaged
582
+ @managed = true
583
+ break
584
+ end
585
+ }
586
+ return @managed
587
+ end
588
+ end
589
+
590
+ ###############################
591
+ # Code related to the container behaviour.
592
+
593
+ # this is a retarded hack method to get around the difference between
594
+ # component children and file children
595
+ def self.depthfirst?
596
+ @depthfirst
597
+ end
598
+
599
+ def depthfirst?
600
+ self.class.depthfirst?
601
+ end
602
+
603
+ # Remove an object. The argument determines whether the object's
604
+ # subscriptions get eliminated, too.
605
+ def remove(rmdeps = true)
606
+ # This is hackish (mmm, cut and paste), but it works for now, and it's
607
+ # better than warnings.
608
+ @parameters.each do |name, obj|
609
+ obj.remove
610
+ end
611
+ @parameters.clear
612
+
613
+ @parent = nil
614
+
615
+ # Remove the reference to the provider.
616
+ if self.provider
617
+ @provider.clear
618
+ @provider = nil
619
+ end
620
+ end
621
+
622
+ ###############################
623
+ # Code related to evaluating the resources.
624
+
625
+ # Flush the provider, if it supports it. This is called by the
626
+ # transaction.
627
+ def flush
628
+ self.provider.flush if self.provider and self.provider.respond_to?(:flush)
629
+ end
630
+
631
+ # if all contained objects are in sync, then we're in sync
632
+ # FIXME I don't think this is used on the type instances any more,
633
+ # it's really only used for testing
634
+ def insync?(is)
635
+ insync = true
636
+
637
+ if property = @parameters[:ensure]
638
+ unless is.include? property
639
+ raise Puppet::DevError,
640
+ "The is value is not in the is array for '#{property.name}'"
641
+ end
642
+ ensureis = is[property]
643
+ if property.insync?(ensureis) and property.should == :absent
644
+ return true
645
+ end
646
+ end
647
+
648
+ properties.each { |property|
649
+ unless is.include? property
650
+ raise Puppet::DevError,
651
+ "The is value is not in the is array for '#{property.name}'"
652
+ end
653
+
654
+ propis = is[property]
655
+ unless property.insync?(propis)
656
+ property.debug("Not in sync: #{propis.inspect} vs #{property.should.inspect}")
657
+ insync = false
658
+ #else
659
+ # property.debug("In sync")
660
+ end
661
+ }
662
+
663
+ #self.debug("#{self} sync status is #{insync}")
664
+ insync
665
+ end
666
+
667
+ # retrieve the current value of all contained properties
668
+ def retrieve
669
+ fail "Provider #{provider.class.name} is not functional on this host" if self.provider.is_a?(Puppet::Provider) and ! provider.class.suitable?
670
+
671
+ result = Puppet::Resource.new(type, title)
672
+
673
+ # Provide the name, so we know we'll always refer to a real thing
674
+ result[:name] = self[:name] unless self[:name] == title
675
+
676
+ if ensure_prop = property(:ensure) or (self.class.validattr?(:ensure) and ensure_prop = newattr(:ensure))
677
+ result[:ensure] = ensure_state = ensure_prop.retrieve
678
+ else
679
+ ensure_state = nil
680
+ end
681
+
682
+ properties.each do |property|
683
+ next if property.name == :ensure
684
+ if ensure_state == :absent
685
+ result[property] = :absent
686
+ else
687
+ result[property] = property.retrieve
688
+ end
689
+ end
690
+
691
+ result
692
+ end
693
+
694
+ def retrieve_resource
695
+ resource = retrieve
696
+ resource = Resource.new(type, title, :parameters => resource) if resource.is_a? Hash
697
+ resource
698
+ end
699
+
700
+ # Get a hash of the current properties. Returns a hash with
701
+ # the actual property instance as the key and the current value
702
+ # as the, um, value.
703
+ def currentpropvalues
704
+ # It's important to use the 'properties' method here, as it follows the order
705
+ # in which they're defined in the class. It also guarantees that 'ensure'
706
+ # is the first property, which is important for skipping 'retrieve' on
707
+ # all the properties if the resource is absent.
708
+ ensure_state = false
709
+ return properties.inject({}) do | prophash, property|
710
+ if property.name == :ensure
711
+ ensure_state = property.retrieve
712
+ prophash[property] = ensure_state
713
+ else
714
+ if ensure_state == :absent
715
+ prophash[property] = :absent
135
716
  else
136
- self.newproperty(:ensure, :parent => Puppet::Property::Ensure) do
137
- self.defaultvalues
138
- end
139
- end
140
- end
141
-
142
- # Should we add the 'ensure' property to this class?
143
- def self.ensurable?
144
- # If the class has all three of these methods defined, then it's
145
- # ensurable.
146
- ens = [:exists?, :create, :destroy].inject { |set, method|
147
- set &&= self.public_method_defined?(method)
148
- }
149
-
150
- return ens
151
- end
152
-
153
- # Deal with any options passed into parameters.
154
- def self.handle_param_options(name, options)
155
- # If it's a boolean parameter, create a method to test the value easily
156
- if options[:boolean]
157
- define_method(name.to_s + "?") do
158
- val = self[name]
159
- if val == :true or val == true
160
- return true
161
- end
162
- end
163
- end
164
- end
165
-
166
- # Is the parameter in question a meta-parameter?
167
- def self.metaparam?(param)
168
- @@metaparamhash.include?(symbolize(param))
169
- end
170
-
171
- # Find the metaparameter class associated with a given metaparameter name.
172
- def self.metaparamclass(name)
173
- @@metaparamhash[symbolize(name)]
174
- end
175
-
176
- def self.metaparams
177
- @@metaparams.collect { |param| param.name }
178
- end
179
-
180
- def self.metaparamdoc(metaparam)
181
- @@metaparamhash[metaparam].doc
182
- end
183
-
184
- # Create a new metaparam. Requires a block and a name, stores it in the
185
- # @parameters array, and does some basic checking on it.
186
- def self.newmetaparam(name, options = {}, &block)
187
- @@metaparams ||= []
188
- @@metaparamhash ||= {}
189
- name = symbolize(name)
190
-
191
- param = genclass(name,
192
- :parent => options[:parent] || Puppet::Parameter,
193
- :prefix => "MetaParam",
194
- :hash => @@metaparamhash,
195
- :array => @@metaparams,
196
- :attributes => options[:attributes],
197
- &block
717
+ prophash[property] = property.retrieve
718
+ end
719
+ end
720
+ prophash
721
+ end
722
+ end
723
+
724
+ # Are we running in noop mode?
725
+ def noop?
726
+ # If we're not a host_config, we're almost certainly part of
727
+ # Settings, and we want to ignore 'noop'
728
+ return false if catalog and ! catalog.host_config?
729
+
730
+ if defined?(@noop)
731
+ @noop
732
+ else
733
+ Puppet[:noop]
734
+ end
735
+ end
736
+
737
+ def noop
738
+ noop?
739
+ end
740
+
741
+ ###############################
742
+ # Code related to managing resource instances.
743
+ require 'puppet/transportable'
744
+
745
+ # retrieve a named instance of the current type
746
+ def self.[](name)
747
+ raise "Global resource access is deprecated"
748
+ @objects[name] || @aliases[name]
749
+ end
750
+
751
+ # add an instance by name to the class list of instances
752
+ def self.[]=(name,object)
753
+ raise "Global resource storage is deprecated"
754
+ newobj = nil
755
+ if object.is_a?(Puppet::Type)
756
+ newobj = object
757
+ else
758
+ raise Puppet::DevError, "must pass a Puppet::Type object"
759
+ end
760
+
761
+ if exobj = @objects[name] and self.isomorphic?
762
+ msg = "Object '#{newobj.class.name}[#{name}]' already exists"
763
+
764
+ msg += ("in file #{object.file} at line #{object.line}") if exobj.file and exobj.line
765
+ msg += ("and cannot be redefined in file #{object.file} at line #{object.line}") if object.file and object.line
766
+ error = Puppet::Error.new(msg)
767
+ raise error
768
+ else
769
+ #Puppet.info("adding %s of type %s to class list" %
770
+ # [name,object.class])
771
+ @objects[name] = newobj
772
+ end
773
+ end
774
+
775
+ # Create an alias. We keep these in a separate hash so that we don't encounter
776
+ # the objects multiple times when iterating over them.
777
+ def self.alias(name, obj)
778
+ raise "Global resource aliasing is deprecated"
779
+ if @objects.include?(name)
780
+ unless @objects[name] == obj
781
+ raise Puppet::Error.new(
782
+ "Cannot create alias #{name}: object already exists"
198
783
  )
199
-
200
- # Grr.
201
- if options[:required_features]
202
- param.required_features = options[:required_features]
203
- end
204
-
205
- handle_param_options(name, options)
206
-
207
- param.metaparam = true
208
-
209
- return param
784
+ end
210
785
  end
211
786
 
212
- # Find the namevar
213
- def self.namevar_parameter
214
- @namevar_parameter ||= (
215
- params = @parameters.find_all { |param|
216
- param.isnamevar? or param.name == :name
217
- }
218
-
219
- if params.length > 1
220
- raise Puppet::DevError, "Found multiple namevars for %s" % self.name
221
- elsif params.length == 1
222
- params.first
223
- else
224
- raise Puppet::DevError, "No namevar for %s" % self.name
225
- end
787
+ if @aliases.include?(name)
788
+ unless @aliases[name] == obj
789
+ raise Puppet::Error.new(
790
+ "Object #{@aliases[name].name} already has alias #{name}"
226
791
  )
227
- end
228
-
229
- def self.namevar
230
- @namevar ||= namevar_parameter.name
231
- end
232
-
233
- def self.canonicalize_ref(s)
234
- namevar_parameter.canonicalize(s)
235
- end
236
-
237
- # Create a new parameter. Requires a block and a name, stores it in the
238
- # @parameters array, and does some basic checking on it.
239
- def self.newparam(name, options = {}, &block)
240
- options[:attributes] ||= {}
241
- param = genclass(name,
242
- :parent => options[:parent] || Puppet::Parameter,
243
- :attributes => options[:attributes],
244
- :block => block,
245
- :prefix => "Parameter",
246
- :array => @parameters,
247
- :hash => @paramhash
248
- )
249
-
250
- handle_param_options(name, options)
251
-
252
- # Grr.
253
- if options[:required_features]
254
- param.required_features = options[:required_features]
255
- end
256
-
257
- param.isnamevar if options[:namevar]
258
-
259
- if param.isnamevar?
260
- @namevar = param.name
261
- end
262
-
263
- return param
264
- end
265
-
266
- def self.newstate(name, options = {}, &block)
267
- Puppet.warning "newstate() has been deprecrated; use newproperty(%s)" %
268
- name
269
- newproperty(name, options, &block)
270
- end
271
-
272
- # Create a new property. The first parameter must be the name of the property;
273
- # this is how users will refer to the property when creating new instances.
274
- # The second parameter is a hash of options; the options are:
275
- # * <tt>:parent</tt>: The parent class for the property. Defaults to Puppet::Property.
276
- # * <tt>:retrieve</tt>: The method to call on the provider or @parent object (if
277
- # the provider is not set) to retrieve the current value.
278
- def self.newproperty(name, options = {}, &block)
279
- name = symbolize(name)
280
-
281
- # This is here for types that might still have the old method of defining
282
- # a parent class.
283
- unless options.is_a? Hash
284
- raise Puppet::DevError,
285
- "Options must be a hash, not %s" % options.inspect
286
- end
287
-
288
- if @validproperties.include?(name)
289
- raise Puppet::DevError, "Class %s already has a property named %s" %
290
- [self.name, name]
291
- end
292
-
293
- if parent = options[:parent]
294
- options.delete(:parent)
295
- else
296
- parent = Puppet::Property
297
- end
298
-
299
- # We have to create our own, new block here because we want to define
300
- # an initial :retrieve method, if told to, and then eval the passed
301
- # block if available.
302
- prop = genclass(name, :parent => parent, :hash => @validproperties, :attributes => options) do
303
- # If they've passed a retrieve method, then override the retrieve
304
- # method on the class.
305
- if options[:retrieve]
306
- define_method(:retrieve) do
307
- provider.send(options[:retrieve])
308
- end
309
- end
310
-
311
- if block
312
- class_eval(&block)
313
- end
314
- end
315
-
316
- # If it's the 'ensure' property, always put it first.
317
- if name == :ensure
318
- @properties.unshift prop
319
- else
320
- @properties << prop
321
- end
322
-
323
- return prop
324
- end
325
-
326
- def self.paramdoc(param)
327
- @paramhash[param].doc
328
- end
329
-
330
- # Return the parameter names
331
- def self.parameters
332
- return [] unless defined? @parameters
333
- @parameters.collect { |klass| klass.name }
334
- end
335
-
336
- # Find the parameter class associated with a given parameter name.
337
- def self.paramclass(name)
338
- @paramhash[name]
339
- end
340
-
341
- # Return the property class associated with a name
342
- def self.propertybyname(name)
343
- @validproperties[name]
344
- end
345
-
346
- def self.validattr?(name)
347
- name = symbolize(name)
348
- return true if name == :name
349
- @validattrs ||= {}
792
+ end
793
+ end
794
+
795
+ @aliases[name] = obj
796
+ end
797
+
798
+ # remove all of the instances of a single type
799
+ def self.clear
800
+ raise "Global resource removal is deprecated"
801
+ if defined?(@objects)
802
+ @objects.each do |name, obj|
803
+ obj.remove(true)
804
+ end
805
+ @objects.clear
806
+ end
807
+ @aliases.clear if defined?(@aliases)
808
+ end
809
+
810
+ # Force users to call this, so that we can merge objects if
811
+ # necessary.
812
+ def self.create(args)
813
+ # LAK:DEP Deprecation notice added 12/17/2008
814
+ Puppet.warning "Puppet::Type.create is deprecated; use Puppet::Type.new"
815
+ new(args)
816
+ end
817
+
818
+ # remove a specified object
819
+ def self.delete(resource)
820
+ raise "Global resource removal is deprecated"
821
+ return unless defined?(@objects)
822
+ @objects.delete(resource.title) if @objects.include?(resource.title)
823
+ @aliases.delete(resource.title) if @aliases.include?(resource.title)
824
+ if @aliases.has_value?(resource)
825
+ names = []
826
+ @aliases.each do |name, otherres|
827
+ if otherres == resource
828
+ names << name
829
+ end
830
+ end
831
+ names.each { |name| @aliases.delete(name) }
832
+ end
833
+ end
834
+
835
+ # iterate across each of the type's instances
836
+ def self.each
837
+ raise "Global resource iteration is deprecated"
838
+ return unless defined?(@objects)
839
+ @objects.each { |name,instance|
840
+ yield instance
841
+ }
842
+ end
843
+
844
+ # does the type have an object with the given name?
845
+ def self.has_key?(name)
846
+ raise "Global resource access is deprecated"
847
+ @objects.has_key?(name)
848
+ end
849
+
850
+ # Retrieve all known instances. Either requires providers or must be overridden.
851
+ def self.instances
852
+ raise Puppet::DevError, "#{self.name} has no providers and has not overridden 'instances'" if provider_hash.empty?
853
+
854
+ # Put the default provider first, then the rest of the suitable providers.
855
+ provider_instances = {}
856
+ providers_by_source.collect do |provider|
857
+ provider.instances.collect do |instance|
858
+ # We always want to use the "first" provider instance we find, unless the resource
859
+ # is already managed and has a different provider set
860
+ if other = provider_instances[instance.name]
861
+ Puppet.warning "%s %s found in both %s and %s; skipping the %s version" %
862
+ [self.name.to_s.capitalize, instance.name, other.class.name, instance.class.name, instance.class.name]
863
+ next
864
+ end
865
+ provider_instances[instance.name] = instance
866
+
867
+ new(:name => instance.name, :provider => instance, :audit => :all)
868
+ end
869
+ end.flatten.compact
870
+ end
871
+
872
+ # Return a list of one suitable provider per source, with the default provider first.
873
+ def self.providers_by_source
874
+ # Put the default provider first, then the rest of the suitable providers.
875
+ sources = []
876
+ [defaultprovider, suitableprovider].flatten.uniq.collect do |provider|
877
+ next if sources.include?(provider.source)
878
+
879
+ sources << provider.source
880
+ provider
881
+ end.compact
882
+ end
883
+
884
+ # Convert a simple hash into a Resource instance.
885
+ def self.hash2resource(hash)
886
+ hash = hash.inject({}) { |result, ary| result[ary[0].to_sym] = ary[1]; result }
887
+
888
+ title = hash.delete(:title)
889
+ title ||= hash[:name]
890
+ title ||= hash[key_attributes.first] if key_attributes.length == 1
891
+
892
+ raise Puppet::Error, "Title or name must be provided" unless title
893
+
894
+ # Now create our resource.
895
+ resource = Puppet::Resource.new(self.name, title)
896
+ [:catalog].each do |attribute|
897
+ if value = hash[attribute]
898
+ hash.delete(attribute)
899
+ resource.send(attribute.to_s + "=", value)
900
+ end
901
+ end
902
+
903
+ hash.each do |param, value|
904
+ resource[param] = value
905
+ end
906
+ resource
907
+ end
908
+
909
+ # Create the path for logging and such.
910
+ def pathbuilder
911
+ if p = parent
912
+ [p.pathbuilder, self.ref].flatten
913
+ else
914
+ [self.ref]
915
+ end
916
+ end
917
+
918
+ ###############################
919
+ # Add all of the meta parameters.
920
+ newmetaparam(:noop) do
921
+ desc "Boolean flag indicating whether work should actually
922
+ be done."
923
+
924
+ newvalues(:true, :false)
925
+ munge do |value|
926
+ case value
927
+ when true, :true, "true"; @resource.noop = true
928
+ when false, :false, "false"; @resource.noop = false
929
+ end
930
+ end
931
+ end
932
+
933
+ newmetaparam(:schedule) do
934
+ desc "On what schedule the object should be managed. You must create a
935
+ schedule object, and then reference the name of that object to use
936
+ that for your schedule::
937
+
938
+ schedule { daily:
939
+ period => daily,
940
+ range => \"2-4\"
941
+ }
350
942
 
351
- unless @validattrs.include?(name)
352
- if self.validproperty?(name) or self.validparameter?(name) or self.metaparam?(name)
353
- @validattrs[name] = true
354
- else
355
- @validattrs[name] = false
356
- end
357
- end
943
+ exec { \"/usr/bin/apt-get update\":
944
+ schedule => daily
945
+ }
358
946
 
359
- @validattrs[name]
360
- end
947
+ The creation of the schedule object does not need to appear in the
948
+ configuration before objects that use it."
949
+ end
361
950
 
362
- # does the name reflect a valid property?
363
- def self.validproperty?(name)
364
- name = symbolize(name)
365
- if @validproperties.include?(name)
366
- return @validproperties[name]
367
- else
368
- return false
369
- end
370
- end
371
-
372
- # Return the list of validproperties
373
- def self.validproperties
374
- return {} unless defined? @parameters
951
+ newmetaparam(:audit) do
952
+ desc "Audit specified attributes of resources over time, and report if any have changed.
953
+ This attribute can be used to track changes to any resource over time, and can
954
+ provide an audit trail of every change that happens on any given machine.
375
955
 
376
- return @validproperties.keys
377
- end
956
+ Note that you cannot both audit and manage an attribute - managing it guarantees
957
+ the value, and any changes already get logged."
378
958
 
379
- # does the name reflect a valid parameter?
380
- def self.validparameter?(name)
381
- unless defined? @parameters
382
- raise Puppet::DevError, "Class %s has not defined parameters" % self
383
- end
384
- if @paramhash.include?(name) or @@metaparamhash.include?(name)
385
- return true
386
- else
387
- return false
959
+ validate do |list|
960
+ list = Array(list)
961
+ unless list == [:all]
962
+ list.each do |param|
963
+ next if @resource.class.validattr?(param)
964
+ fail "Cannot audit #{param}: not a valid attribute for #{resource}"
388
965
  end
966
+ end
389
967
  end
390
968
 
391
- # Return either the attribute alias or the attribute.
392
- def attr_alias(name)
393
- name = symbolize(name)
394
- if synonym = self.class.attr_alias(name)
395
- return synonym
396
- else
397
- return name
398
- end
969
+ munge do |args|
970
+ properties_to_audit(args).each do |param|
971
+ next unless resource.class.validproperty?(param)
972
+ resource.newattr(param)
973
+ end
399
974
  end
400
975
 
401
- # Are we deleting this resource?
402
- def deleting?
403
- obj = @parameters[:ensure] and obj.should == :absent
976
+ def all_properties
977
+ resource.class.properties.find_all do |property|
978
+ resource.provider.nil? or resource.provider.class.supports_parameter?(property)
979
+ end.collect do |property|
980
+ property.name
981
+ end
404
982
  end
405
983
 
406
- # Create a new property if it is valid but doesn't exist
407
- # Returns: true if a new parameter was added, false otherwise
408
- def add_property_parameter(prop_name)
409
- if self.class.validproperty?(prop_name) && !@parameters[prop_name]
410
- self.newattr(prop_name)
411
- return true
412
- end
413
- return false
984
+ def properties_to_audit(list)
985
+ if list == :all
986
+ list = all_properties if list == :all
987
+ else
988
+ list = Array(list).collect { |p| p.to_sym }
989
+ end
414
990
  end
991
+ end
415
992
 
416
- # abstract accessing parameters and properties, and normalize
417
- # access to always be symbols, not strings
418
- # This returns a value, not an object. It returns the 'is'
419
- # value, but you can also specifically return 'is' and 'should'
420
- # values using 'object.is(:property)' or 'object.should(:property)'.
421
- def [](name)
422
- name = attr_alias(name)
993
+ newmetaparam(:check) do
994
+ desc "Audit specified attributes of resources over time, and report if any have changed.
995
+ This parameter has been deprecated in favor of 'audit'."
423
996
 
424
- unless self.class.validattr?(name)
425
- fail("Invalid parameter %s(%s)" % [name, name.inspect])
426
- end
427
-
428
- if name == :name
429
- name = self.class.namevar
430
- end
431
-
432
- if obj = @parameters[name]
433
- # Note that if this is a property, then the value is the "should" value,
434
- # not the current value.
435
- obj.value
436
- else
437
- return nil
438
- end
997
+ munge do |args|
998
+ resource.warning "'check' attribute is deprecated; use 'audit' instead"
999
+ resource[:audit] = args
439
1000
  end
1001
+ end
440
1002
 
441
- # Abstract setting parameters and properties, and normalize
442
- # access to always be symbols, not strings. This sets the 'should'
443
- # value on properties, and otherwise just sets the appropriate parameter.
444
- def []=(name,value)
445
- name = attr_alias(name)
446
-
447
- unless self.class.validattr?(name)
448
- fail("Invalid parameter %s" % [name])
449
- end
450
-
451
- if name == :name
452
- name = self.class.namevar
453
- end
454
- if value.nil?
455
- raise Puppet::Error.new("Got nil value for %s" % name)
456
- end
1003
+ newmetaparam(:loglevel) do
1004
+ desc "Sets the level that information will be logged.
1005
+ The log levels have the biggest impact when logs are sent to
1006
+ syslog (which is currently the default)."
1007
+ defaultto :notice
457
1008
 
458
- if obj = @parameters[name]
459
- obj.value = value
460
- return nil
461
- else
462
- self.newattr(name, :value => value)
463
- end
1009
+ newvalues(*Puppet::Util::Log.levels)
1010
+ newvalues(:verbose)
464
1011
 
465
- nil
1012
+ munge do |loglevel|
1013
+ val = super(loglevel)
1014
+ if val == :verbose
1015
+ val = :info
1016
+ end
1017
+ val
466
1018
  end
1019
+ end
467
1020
 
468
- # remove a property from the object; useful in testing or in cleanup
469
- # when an error has been encountered
470
- def delete(attr)
471
- attr = symbolize(attr)
472
- if @parameters.has_key?(attr)
473
- @parameters.delete(attr)
474
- else
475
- raise Puppet::DevError.new("Undefined attribute '#{attr}' in #{self}")
476
- end
477
- end
1021
+ newmetaparam(:alias) do
1022
+ desc "Creates an alias for the object. Puppet uses this internally when you
1023
+ provide a symbolic name::
478
1024
 
479
- # iterate across the existing properties
480
- def eachproperty
481
- # properties() is a private method
482
- properties().each { |property|
483
- yield property
1025
+ file { sshdconfig:
1026
+ path => $operatingsystem ? {
1027
+ solaris => \"/usr/local/etc/ssh/sshd_config\",
1028
+ default => \"/etc/ssh/sshd_config\"
1029
+ },
1030
+ source => \"...\"
484
1031
  }
485
- end
486
-
487
- # Let the catalog determine whether a given cached value is
488
- # still valid or has expired.
489
- def expirer
490
- catalog
491
- end
492
1032
 
493
- # retrieve the 'should' value for a specified property
494
- def should(name)
495
- name = attr_alias(name)
496
- if prop = @parameters[name] and prop.is_a?(Puppet::Property)
497
- return prop.should
498
- else
499
- return nil
500
- end
501
- end
502
-
503
- # Create the actual attribute instance. Requires either the attribute
504
- # name or class as the first argument, then an optional hash of
505
- # attributes to set during initialization.
506
- def newattr(name, options = {})
507
- if name.is_a?(Class)
508
- klass = name
509
- name = klass.name
510
- end
511
-
512
- unless klass = self.class.attrclass(name)
513
- raise Puppet::Error, "Resource type %s does not support parameter %s" % [self.class.name, name]
514
- end
515
-
516
- if @parameters.include?(name)
517
- raise Puppet::Error, "Parameter '%s' is already defined in %s" %
518
- [name, self.ref]
519
- end
520
-
521
- if provider and ! provider.class.supports_parameter?(klass)
522
- missing = klass.required_features.find_all { |f| ! provider.class.feature?(f) }
523
- info "Provider %s does not support features %s; not managing attribute %s" % [provider.class.name, missing.join(", "), name]
524
- return nil
525
- end
1033
+ service { sshd:
1034
+ subscribe => file[sshdconfig]
1035
+ }
526
1036
 
527
- # Add resource information at creation time, so it's available
528
- # during validation.
529
- options[:resource] = self
530
- begin
531
- # make sure the parameter doesn't have any errors
532
- return @parameters[name] = klass.new(options)
533
- rescue => detail
534
- error = Puppet::Error.new("Parameter %s failed: %s" %
535
- [name, detail])
536
- error.set_backtrace(detail.backtrace)
537
- raise error
538
- end
539
- end
1037
+ When you use this feature, the parser sets ``sshdconfig`` as the name,
1038
+ and the library sets that as an alias for the file so the dependency
1039
+ lookup for ``sshd`` works. You can use this parameter yourself,
1040
+ but note that only the library can use these aliases; for instance,
1041
+ the following code will not work::
540
1042
 
541
- # return the value of a parameter
542
- def parameter(name)
543
- @parameters[name.to_sym]
544
- end
1043
+ file { \"/etc/ssh/sshd_config\":
1044
+ owner => root,
1045
+ group => root,
1046
+ alias => sshdconfig
1047
+ }
545
1048
 
546
- # Is the named property defined?
547
- def propertydefined?(name)
548
- unless name.is_a? Symbol
549
- name = name.intern
550
- end
551
- return @parameters.include?(name)
552
- end
1049
+ file { sshdconfig:
1050
+ mode => 644
1051
+ }
553
1052
 
554
- # Return an actual property instance by name; to return the value, use 'resource[param]'
555
- # LAK:NOTE(20081028) Since the 'parameter' method is now a superset of this method,
556
- # this one should probably go away at some point.
557
- def property(name)
558
- if obj = @parameters[symbolize(name)] and obj.is_a?(Puppet::Property)
559
- return obj
560
- else
561
- return nil
562
- end
563
- end
1053
+ There's no way here for the Puppet parser to know that these two stanzas
1054
+ should be affecting the same file.
564
1055
 
565
- # For any parameters or properties that have defaults and have not yet been
566
- # set, set them now. This method can be handed a list of attributes,
567
- # and if so it will only set defaults for those attributes.
568
- def set_default(attr)
569
- return unless klass = self.class.attrclass(attr)
570
- return unless klass.method_defined?(:default)
571
- return if @parameters.include?(klass.name)
1056
+ See the `LanguageTutorial language tutorial`:trac: for more information.
572
1057
 
573
- return unless parameter = newattr(klass.name)
1058
+ "
574
1059
 
575
- if value = parameter.default and ! value.nil?
576
- parameter.value = value
577
- else
578
- @parameters.delete(parameter.name)
579
- end
580
- end
1060
+ munge do |aliases|
1061
+ aliases = [aliases] unless aliases.is_a?(Array)
581
1062
 
582
- # Convert our object to a hash. This just includes properties.
583
- def to_hash
584
- rethash = {}
1063
+ raise(ArgumentError, "Cannot add aliases without a catalog") unless @resource.catalog
585
1064
 
586
- @parameters.each do |name, obj|
587
- rethash[name] = obj.value
1065
+ aliases.each do |other|
1066
+ if obj = @resource.catalog.resource(@resource.class.name, other)
1067
+ unless obj.object_id == @resource.object_id
1068
+ self.fail("#{@resource.title} can not create alias #{other}: object already exists")
1069
+ end
1070
+ next
588
1071
  end
589
1072
 
590
- rethash
1073
+ # Newschool, add it to the catalog.
1074
+ @resource.catalog.alias(@resource, other)
1075
+ end
591
1076
  end
1077
+ end
592
1078
 
593
- # Return a specific value for an attribute.
594
- def value(name)
595
- name = attr_alias(name)
1079
+ newmetaparam(:tag) do
1080
+ desc "Add the specified tags to the associated resource. While all resources
1081
+ are automatically tagged with as much information as possible
1082
+ (e.g., each class and definition containing the resource), it can
1083
+ be useful to add your own tags to a given resource.
596
1084
 
597
- if obj = @parameters[name] and obj.respond_to?(:value)
598
- return obj.value
599
- else
600
- return nil
601
- end
602
- end
1085
+ Tags are currently useful for things like applying a subset of a
1086
+ host's configuration::
603
1087
 
604
- def version
605
- return 0 unless catalog
606
- catalog.version
607
- end
1088
+ puppet agent --test --tags mytag
608
1089
 
609
- # Meta-parameter methods: These methods deal with the results
610
- # of specifying metaparameters
1090
+ This way, when you're testing a configuration you can run just the
1091
+ portion you're testing."
611
1092
 
612
- private
1093
+ munge do |tags|
1094
+ tags = [tags] unless tags.is_a? Array
613
1095
 
614
- # Return all of the property objects, in the order specified in the
615
- # class.
616
- def properties
617
- #debug "%s has %s properties" % [self,@parameters.length]
618
- props = self.class.properties.collect { |prop|
619
- @parameters[prop.name]
620
- }.find_all { |p|
621
- ! p.nil?
622
- }.each do |prop|
623
- unless prop.is_a?(Puppet::Property)
624
- raise Puppet::DevError, "got a non-property %s(%s)" %
625
- [prop.class, prop.class.name]
626
- end
627
- end
628
-
629
- props
1096
+ tags.each do |tag|
1097
+ @resource.tag(tag)
1098
+ end
630
1099
  end
1100
+ end
631
1101
 
632
- public
633
-
634
- # Is this type's name isomorphic with the object? That is, if the
635
- # name conflicts, does it necessarily mean that the objects conflict?
636
- # Defaults to true.
637
- def self.isomorphic?
638
- if defined? @isomorphic
639
- return @isomorphic
640
- else
641
- return true
642
- end
1102
+ class RelationshipMetaparam < Puppet::Parameter
1103
+ class << self
1104
+ attr_accessor :direction, :events, :callback, :subclasses
643
1105
  end
644
1106
 
645
- def isomorphic?
646
- self.class.isomorphic?
647
- end
1107
+ @subclasses = []
648
1108
 
649
- # is the instance a managed instance? A 'yes' here means that
650
- # the instance was created from the language, vs. being created
651
- # in order resolve other questions, such as finding a package
652
- # in a list
653
- def managed?
654
- # Once an object is managed, it always stays managed; but an object
655
- # that is listed as unmanaged might become managed later in the process,
656
- # so we have to check that every time
657
- if defined? @managed and @managed
658
- return @managed
659
- else
660
- @managed = false
661
- properties.each { |property|
662
- s = property.should
663
- if s and ! property.class.unmanaged
664
- @managed = true
665
- break
666
- end
667
- }
668
- return @managed
669
- end
1109
+ def self.inherited(sub)
1110
+ @subclasses << sub
670
1111
  end
671
1112
 
672
- ###############################
673
- # Code related to the container behaviour.
674
-
675
- # this is a retarded hack method to get around the difference between
676
- # component children and file children
677
- def self.depthfirst?
678
- if defined? @depthfirst
679
- return @depthfirst
1113
+ def munge(references)
1114
+ references = [references] unless references.is_a?(Array)
1115
+ references.collect do |ref|
1116
+ if ref.is_a?(Puppet::Resource)
1117
+ ref
680
1118
  else
681
- return false
1119
+ Puppet::Resource.new(ref)
682
1120
  end
1121
+ end
683
1122
  end
684
1123
 
685
- def depthfirst?
686
- self.class.depthfirst?
687
- end
688
-
689
- # Remove an object. The argument determines whether the object's
690
- # subscriptions get eliminated, too.
691
- def remove(rmdeps = true)
692
- # This is hackish (mmm, cut and paste), but it works for now, and it's
693
- # better than warnings.
694
- @parameters.each do |name, obj|
695
- obj.remove
696
- end
697
- @parameters.clear
698
-
699
- @parent = nil
700
-
701
- # Remove the reference to the provider.
702
- if self.provider
703
- @provider.clear
704
- @provider = nil
1124
+ def validate_relationship
1125
+ @value.each do |ref|
1126
+ unless @resource.catalog.resource(ref.to_s)
1127
+ description = self.class.direction == :in ? "dependency" : "dependent"
1128
+ fail "Could not find #{description} #{ref} for #{resource.ref}"
705
1129
  end
1130
+ end
706
1131
  end
707
1132
 
708
- ###############################
709
- # Code related to evaluating the resources.
710
-
711
- # This method is responsible for collecting property changes we always
712
- # descend into the children before we evaluate our current properties.
713
- # This returns any changes resulting from testing, thus 'collect' rather
714
- # than 'each'.
715
- def evaluate
716
- if self.provider.is_a?(Puppet::Provider)
717
- unless provider.class.suitable?
718
- raise Puppet::Error, "Provider %s is not functional on this platform" % provider.class.name
719
- end
720
- end
721
-
722
- # this only operates on properties, not properties + children
723
- # it's important that we call retrieve() on the type instance,
724
- # not directly on the property, because it allows the type to override
725
- # the method, like pfile does
726
- currentvalues = self.retrieve
1133
+ # Create edges from each of our relationships. :in
1134
+ # relationships are specified by the event-receivers, and :out
1135
+ # relationships are specified by the event generator. This
1136
+ # way 'source' and 'target' are consistent terms in both edges
1137
+ # and events -- that is, an event targets edges whose source matches
1138
+ # the event's source. The direction of the relationship determines
1139
+ # which resource is applied first and which resource is considered
1140
+ # to be the event generator.
1141
+ def to_edges
1142
+ @value.collect do |reference|
1143
+ reference.catalog = resource.catalog
727
1144
 
728
- changes = propertychanges(currentvalues).flatten
729
-
730
- # now record how many changes we've resulted in
731
- if changes.length > 0
732
- self.debug "%s change(s)" %
733
- [changes.length]
1145
+ # Either of the two retrieval attempts could have returned
1146
+ # nil.
1147
+ unless related_resource = reference.resolve
1148
+ self.fail "Could not retrieve dependency '#{reference}' of #{@resource.ref}"
734
1149
  end
735
1150
 
736
- # If we're in noop mode, we don't want to store the checked time,
737
- # because it will result in the resource not getting scheduled if
738
- # someone were to apply the catalog in non-noop mode.
739
- # We're going to go ahead and record that we checked if there were
740
- # no changes, since it's unlikely it will affect the scheduling.
741
- noop = noop?
742
- if ! noop or (noop && changes.length == 0)
743
- self.cache(:checked, Time.now)
744
- end
745
- return changes.flatten
746
- end
747
-
748
- # Flush the provider, if it supports it. This is called by the
749
- # transaction.
750
- def flush
751
- if self.provider and self.provider.respond_to?(:flush)
752
- self.provider.flush
753
- end
754
- end
755
-
756
- # if all contained objects are in sync, then we're in sync
757
- # FIXME I don't think this is used on the type instances any more,
758
- # it's really only used for testing
759
- def insync?(is)
760
- insync = true
761
-
762
- if property = @parameters[:ensure]
763
- unless is.include? property
764
- raise Puppet::DevError,
765
- "The is value is not in the is array for '%s'" %
766
- [property.name]
767
- end
768
- ensureis = is[property]
769
- if property.insync?(ensureis) and property.should == :absent
770
- return true
771
- end
772
- end
773
-
774
- properties.each { |property|
775
- unless is.include? property
776
- raise Puppet::DevError,
777
- "The is value is not in the is array for '%s'" %
778
- [property.name]
779
- end
780
-
781
- propis = is[property]
782
- unless property.insync?(propis)
783
- property.debug("Not in sync: %s vs %s" %
784
- [propis.inspect, property.should.inspect])
785
- insync = false
786
- #else
787
- # property.debug("In sync")
788
- end
789
- }
790
-
791
- #self.debug("%s sync status is %s" % [self,insync])
792
- return insync
793
- end
794
-
795
- # retrieve the current value of all contained properties
796
- def retrieve
797
- return currentpropvalues
798
- end
799
-
800
- # Get a hash of the current properties. Returns a hash with
801
- # the actual property instance as the key and the current value
802
- # as the, um, value.
803
- def currentpropvalues
804
- # It's important to use the 'properties' method here, as it follows the order
805
- # in which they're defined in the class. It also guarantees that 'ensure'
806
- # is the first property, which is important for skipping 'retrieve' on
807
- # all the properties if the resource is absent.
808
- ensure_state = false
809
- return properties().inject({}) do | prophash, property|
810
- if property.name == :ensure
811
- ensure_state = property.retrieve
812
- prophash[property] = ensure_state
813
- else
814
- if ensure_state == :absent
815
- prophash[property] = :absent
816
- else
817
- prophash[property] = property.retrieve
818
- end
819
- end
820
- prophash
821
- end
822
- end
823
-
824
- # Are we running in noop mode?
825
- def noop?
826
- if defined?(@noop)
827
- @noop
1151
+ # Are we requiring them, or vice versa? See the method docs
1152
+ # for futher info on this.
1153
+ if self.class.direction == :in
1154
+ source = related_resource
1155
+ target = @resource
828
1156
  else
829
- Puppet[:noop]
830
- end
831
- end
832
-
833
- def noop
834
- noop?
835
- end
836
-
837
- # Retrieve the changes associated with all of the properties.
838
- def propertychanges(currentvalues)
839
- # If we are changing the existence of the object, then none of
840
- # the other properties matter.
841
- changes = []
842
- ensureparam = @parameters[:ensure]
843
-
844
- # This allows resource types to have 'ensure' be a parameter, which allows them to
845
- # just pass the parameter on to other generated resources.
846
- ensureparam = nil unless ensureparam.is_a?(Puppet::Property)
847
- if ensureparam && !currentvalues.include?(ensureparam)
848
- raise Puppet::DevError, "Parameter ensure defined but missing from current values"
1157
+ source = @resource
1158
+ target = related_resource
849
1159
  end
850
1160
 
851
- if ensureparam and ! ensureparam.insync?(currentvalues[ensureparam])
852
- changes << Puppet::Transaction::Change.new(ensureparam, currentvalues[ensureparam])
853
- # Else, if the 'ensure' property is correctly absent, then do
854
- # nothing
855
- elsif ensureparam and currentvalues[ensureparam] == :absent
856
- return []
1161
+ if method = self.class.callback
1162
+ subargs = {
1163
+ :event => self.class.events,
1164
+ :callback => method
1165
+ }
1166
+ self.debug("subscribes to #{related_resource.ref}")
857
1167
  else
858
- changes = properties().find_all { |property|
859
- currentvalues[property] ||= :absent
860
- ! property.insync?(currentvalues[property])
861
- }.collect { |property|
862
- Puppet::Transaction::Change.new(property, currentvalues[property])
863
- }
864
- end
865
-
866
- if Puppet[:debug] and changes.length > 0
867
- self.debug("Changing " + changes.collect { |ch| ch.property.name }.join(","))
1168
+ # If there's no callback, there's no point in even adding
1169
+ # a label.
1170
+ subargs = nil
1171
+ self.debug("requires #{related_resource.ref}")
868
1172
  end
869
1173
 
870
- changes
1174
+ rel = Puppet::Relationship.new(source, target, subargs)
1175
+ end
871
1176
  end
1177
+ end
872
1178
 
873
- ###############################
874
- # Code related to managing resource instances.
875
- require 'puppet/transportable'
1179
+ def self.relationship_params
1180
+ RelationshipMetaparam.subclasses
1181
+ end
876
1182
 
877
- # retrieve a named instance of the current type
878
- def self.[](name)
879
- raise "Global resource access is deprecated"
880
- @objects[name] || @aliases[name]
881
- end
882
1183
 
883
- # add an instance by name to the class list of instances
884
- def self.[]=(name,object)
885
- raise "Global resource storage is deprecated"
886
- newobj = nil
887
- if object.is_a?(Puppet::Type)
888
- newobj = object
889
- else
890
- raise Puppet::DevError, "must pass a Puppet::Type object"
891
- end
892
-
893
- if exobj = @objects[name] and self.isomorphic?
894
- msg = "Object '%s[%s]' already exists" %
895
- [newobj.class.name, name]
896
-
897
- if exobj.file and exobj.line
898
- msg += ("in file %s at line %s" %
899
- [object.file, object.line])
900
- end
901
- if object.file and object.line
902
- msg += ("and cannot be redefined in file %s at line %s" %
903
- [object.file, object.line])
904
- end
905
- error = Puppet::Error.new(msg)
906
- raise error
907
- else
908
- #Puppet.info("adding %s of type %s to class list" %
909
- # [name,object.class])
910
- @objects[name] = newobj
911
- end
912
- end
1184
+ # Note that the order in which the relationships params is defined
1185
+ # matters. The labelled params (notify and subcribe) must be later,
1186
+ # so that if both params are used, those ones win. It's a hackish
1187
+ # solution, but it works.
913
1188
 
914
- # Create an alias. We keep these in a separate hash so that we don't encounter
915
- # the objects multiple times when iterating over them.
916
- def self.alias(name, obj)
917
- raise "Global resource aliasing is deprecated"
918
- if @objects.include?(name)
919
- unless @objects[name] == obj
920
- raise Puppet::Error.new(
921
- "Cannot create alias %s: object already exists" %
922
- [name]
923
- )
924
- end
925
- end
1189
+ newmetaparam(:require, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do
1190
+ desc "One or more objects that this object depends on.
1191
+ This is used purely for guaranteeing that changes to required objects
1192
+ happen before the dependent object. For instance::
926
1193
 
927
- if @aliases.include?(name)
928
- unless @aliases[name] == obj
929
- raise Puppet::Error.new(
930
- "Object %s already has alias %s" %
931
- [@aliases[name].name, name]
932
- )
933
- end
934
- end
1194
+ # Create the destination directory before you copy things down
1195
+ file { \"/usr/local/scripts\":
1196
+ ensure => directory
1197
+ }
935
1198
 
936
- @aliases[name] = obj
937
- end
1199
+ file { \"/usr/local/scripts/myscript\":
1200
+ source => \"puppet://server/module/myscript\",
1201
+ mode => 755,
1202
+ require => File[\"/usr/local/scripts\"]
1203
+ }
938
1204
 
939
- # remove all of the instances of a single type
940
- def self.clear
941
- raise "Global resource removal is deprecated"
942
- if defined? @objects
943
- @objects.each do |name, obj|
944
- obj.remove(true)
945
- end
946
- @objects.clear
947
- end
948
- if defined? @aliases
949
- @aliases.clear
950
- end
951
- end
1205
+ Multiple dependencies can be specified by providing a comma-seperated list
1206
+ of resources, enclosed in square brackets::
1207
+
1208
+ require => [ File[\"/usr/local\"], File[\"/usr/local/scripts\"] ]
1209
+
1210
+ Note that Puppet will autorequire everything that it can, and
1211
+ there are hooks in place so that it's easy for resources to add new
1212
+ ways to autorequire objects, so if you think Puppet could be
1213
+ smarter here, let us know.
1214
+
1215
+ In fact, the above code was redundant -- Puppet will autorequire
1216
+ any parent directories that are being managed; it will
1217
+ automatically realize that the parent directory should be created
1218
+ before the script is pulled down.
1219
+
1220
+ Currently, exec resources will autorequire their CWD (if it is
1221
+ specified) plus any fully qualified paths that appear in the
1222
+ command. For instance, if you had an ``exec`` command that ran
1223
+ the ``myscript`` mentioned above, the above code that pulls the
1224
+ file down would be automatically listed as a requirement to the
1225
+ ``exec`` code, so that you would always be running againts the
1226
+ most recent version.
1227
+ "
1228
+ end
1229
+
1230
+ newmetaparam(:subscribe, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :ALL_EVENTS, :callback => :refresh}) do
1231
+ desc "One or more objects that this object depends on. Changes in the
1232
+ subscribed to objects result in the dependent objects being
1233
+ refreshed (e.g., a service will get restarted). For instance::
1234
+
1235
+ class nagios {
1236
+ file { \"/etc/nagios/nagios.conf\":
1237
+ source => \"puppet://server/module/nagios.conf\",
1238
+ alias => nagconf # just to make things easier for me
1239
+ }
1240
+ service { nagios:
1241
+ ensure => running,
1242
+ subscribe => File[nagconf]
1243
+ }
1244
+ }
952
1245
 
953
- # Force users to call this, so that we can merge objects if
954
- # necessary.
955
- def self.create(args)
956
- # LAK:DEP Deprecation notice added 12/17/2008
957
- Puppet.warning "Puppet::Type.create is deprecated; use Puppet::Type.new"
958
- new(args)
959
- end
1246
+ Currently the ``exec``, ``mount`` and ``service`` type support
1247
+ refreshing.
1248
+ "
1249
+ end
960
1250
 
961
- # remove a specified object
962
- def self.delete(resource)
963
- raise "Global resource removal is deprecated"
964
- return unless defined? @objects
965
- if @objects.include?(resource.title)
966
- @objects.delete(resource.title)
967
- end
968
- if @aliases.include?(resource.title)
969
- @aliases.delete(resource.title)
970
- end
971
- if @aliases.has_value?(resource)
972
- names = []
973
- @aliases.each do |name, otherres|
974
- if otherres == resource
975
- names << name
976
- end
977
- end
978
- names.each { |name| @aliases.delete(name) }
979
- end
980
- end
1251
+ newmetaparam(:before, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do
1252
+ desc %{This parameter is the opposite of **require** -- it guarantees
1253
+ that the specified object is applied later than the specifying
1254
+ object::
981
1255
 
982
- # iterate across each of the type's instances
983
- def self.each
984
- raise "Global resource iteration is deprecated"
985
- return unless defined? @objects
986
- @objects.each { |name,instance|
987
- yield instance
1256
+ file { "/var/nagios/configuration":
1257
+ source => "...",
1258
+ recurse => true,
1259
+ before => Exec["nagios-rebuid"]
988
1260
  }
989
- end
990
1261
 
991
- # does the type have an object with the given name?
992
- def self.has_key?(name)
993
- raise "Global resource access is deprecated"
994
- return @objects.has_key?(name)
995
- end
1262
+ exec { "nagios-rebuild":
1263
+ command => "/usr/bin/make",
1264
+ cwd => "/var/nagios/configuration"
1265
+ }
996
1266
 
997
- # Retrieve all known instances. Either requires providers or must be overridden.
998
- def self.instances
999
- if provider_hash.empty?
1000
- raise Puppet::DevError, "%s has no providers and has not overridden 'instances'" % self.name
1001
- end
1267
+ This will make sure all of the files are up to date before the
1268
+ make command is run.}
1269
+ end
1002
1270
 
1003
- # Put the default provider first, then the rest of the suitable providers.
1004
- provider_instances = {}
1005
- providers_by_source.collect do |provider|
1006
- provider.instances.collect do |instance|
1007
- # We always want to use the "first" provider instance we find, unless the resource
1008
- # is already managed and has a different provider set
1009
- if other = provider_instances[instance.name]
1010
- Puppet.warning "%s %s found in both %s and %s; skipping the %s version" %
1011
- [self.name.to_s.capitalize, instance.name, other.class.name, instance.class.name, instance.class.name]
1012
- next
1013
- end
1014
- provider_instances[instance.name] = instance
1015
-
1016
- new(:name => instance.name, :provider => instance, :check => :all)
1017
- end
1018
- end.flatten.compact
1019
- end
1020
-
1021
- # Return a list of one suitable provider per source, with the default provider first.
1022
- def self.providers_by_source
1023
- # Put the default provider first, then the rest of the suitable providers.
1024
- sources = []
1025
- [defaultprovider, suitableprovider].flatten.uniq.collect do |provider|
1026
- next if sources.include?(provider.source)
1027
-
1028
- sources << provider.source
1029
- provider
1030
- end.compact
1031
- end
1032
-
1033
- # Convert a simple hash into a Resource instance. This is a convenience method,
1034
- # so people can create RAL resources with a hash and get the same behaviour
1035
- # as we get internally when we use Resource instances.
1036
- # This should only be used directly from Ruby -- it's not used when going through
1037
- # normal Puppet usage.
1038
- def self.hash2resource(hash)
1039
- hash = hash.inject({}) { |result, ary| result[ary[0].to_sym] = ary[1]; result }
1040
-
1041
- if title = hash[:title]
1042
- hash.delete(:title)
1043
- else
1044
- if self.namevar != :name
1045
- if hash.include?(:name) and hash.include?(self.namevar)
1046
- raise Puppet::Error, "Cannot provide both name and %s to resources of type %s" % [self.namevar, self.name]
1047
- end
1048
- if title = hash[self.namevar]
1049
- hash.delete(self.namevar)
1050
- end
1051
- end
1052
-
1053
- unless title ||= hash[:name]
1054
- raise Puppet::Error, "You must specify a name or title for resources"
1055
- end
1056
- end
1271
+ newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do
1272
+ desc %{This parameter is the opposite of **subscribe** -- it sends events
1273
+ to the specified object::
1057
1274
 
1275
+ file { "/etc/sshd_config":
1276
+ source => "....",
1277
+ notify => Service[sshd]
1278
+ }
1058
1279
 
1059
- # Now create our resource.
1060
- resource = Puppet::Resource.new(self.name, title)
1061
- [:catalog].each do |attribute|
1062
- if value = hash[attribute]
1063
- hash.delete(attribute)
1064
- resource.send(attribute.to_s + "=", value)
1065
- end
1066
- end
1280
+ service { sshd:
1281
+ ensure => running
1282
+ }
1067
1283
 
1068
- hash.each do |param, value|
1069
- resource[param] = value
1070
- end
1071
- return resource
1072
- end
1284
+ This will restart the sshd service if the sshd config file changes.}
1285
+ end
1073
1286
 
1074
- # Create the path for logging and such.
1075
- def pathbuilder
1076
- if p = parent
1077
- [p.pathbuilder, self.ref].flatten
1078
- else
1079
- [self.ref]
1080
- end
1081
- end
1287
+ newmetaparam(:stage) do
1288
+ desc %{Which run stage a given resource should reside in. This just creates
1289
+ a dependency on or from the named milestone. For instance, saying that
1290
+ this is in the 'bootstrap' stage creates a dependency on the 'bootstrap'
1291
+ milestone.
1082
1292
 
1083
- ###############################
1084
- # Add all of the meta parameters.
1085
- newmetaparam(:noop) do
1086
- desc "Boolean flag indicating whether work should actually
1087
- be done."
1293
+ By default, all classes get directly added to the
1294
+ 'main' stage. You can create new stages as resources:
1088
1295
 
1089
- newvalues(:true, :false)
1090
- munge do |value|
1091
- case value
1092
- when true, :true, "true"; @resource.noop = true
1093
- when false, :false, "false"; @resource.noop = false
1094
- end
1095
- end
1096
- end
1296
+ stage { [pre, post]: }
1097
1297
 
1098
- newmetaparam(:schedule) do
1099
- desc "On what schedule the object should be managed. You must create a
1100
- schedule object, and then reference the name of that object to use
1101
- that for your schedule::
1102
-
1103
- schedule { daily:
1104
- period => daily,
1105
- range => \"2-4\"
1106
- }
1107
-
1108
- exec { \"/usr/bin/apt-get update\":
1109
- schedule => daily
1110
- }
1111
-
1112
- The creation of the schedule object does not need to appear in the
1113
- configuration before objects that use it."
1114
- end
1115
-
1116
- newmetaparam(:check) do
1117
- desc "Propertys which should have their values retrieved
1118
- but which should not actually be modified. This is currently used
1119
- internally, but will eventually be used for querying, so that you
1120
- could specify that you wanted to check the install state of all
1121
- packages, and then query the Puppet client daemon to get reports
1122
- on all packages."
1123
-
1124
- munge do |args|
1125
- # If they've specified all, collect all known properties
1126
- if args == :all
1127
- args = @resource.class.properties.find_all do |property|
1128
- # Only get properties supported by our provider
1129
- if @resource.provider
1130
- @resource.provider.class.supports_parameter?(property)
1131
- else
1132
- true
1133
- end
1134
- end.collect do |property|
1135
- property.name
1136
- end
1137
- end
1138
-
1139
- unless args.is_a?(Array)
1140
- args = [args]
1141
- end
1142
-
1143
- unless defined? @resource
1144
- self.devfail "No parent for %s, %s?" %
1145
- [self.class, self.name]
1146
- end
1147
-
1148
- args.each { |property|
1149
- unless property.is_a?(Symbol)
1150
- property = property.intern
1151
- end
1152
- next if @resource.propertydefined?(property)
1153
-
1154
- unless propertyklass = @resource.class.validproperty?(property)
1155
- if @resource.class.validattr?(property)
1156
- next
1157
- else
1158
- raise Puppet::Error, "%s is not a valid attribute for %s" %
1159
- [property, self.class.name]
1160
- end
1161
- end
1162
- next unless propertyklass.checkable?
1163
- @resource.newattr(property)
1164
- }
1165
- end
1166
- end
1298
+ To order stages, use standard relationships:
1167
1299
 
1168
- newmetaparam(:loglevel) do
1169
- desc "Sets the level that information will be logged.
1170
- The log levels have the biggest impact when logs are sent to
1171
- syslog (which is currently the default)."
1172
- defaultto :notice
1300
+ stage { pre: before => Stage[main] }
1173
1301
 
1174
- newvalues(*Puppet::Util::Log.levels)
1175
- newvalues(:verbose)
1302
+ Or use the new relationship syntax:
1176
1303
 
1177
- munge do |loglevel|
1178
- val = super(loglevel)
1179
- if val == :verbose
1180
- val = :info
1181
- end
1182
- val
1183
- end
1184
- end
1304
+ Stage[pre] -> Stage[main] -> Stage[post]
1185
1305
 
1186
- newmetaparam(:alias) do
1187
- desc "Creates an alias for the object. Puppet uses this internally when you
1188
- provide a symbolic name::
1306
+ Then use the new class parameters to specify a stage:
1189
1307
 
1190
- file { sshdconfig:
1191
- path => $operatingsystem ? {
1192
- solaris => \"/usr/local/etc/ssh/sshd_config\",
1193
- default => \"/etc/ssh/sshd_config\"
1194
- },
1195
- source => \"...\"
1196
- }
1308
+ class { foo: stage => pre }
1197
1309
 
1198
- service { sshd:
1199
- subscribe => file[sshdconfig]
1200
- }
1310
+ Stages can only be set on classes, not individual resources. This will
1311
+ fail::
1201
1312
 
1202
- When you use this feature, the parser sets ``sshdconfig`` as the name,
1203
- and the library sets that as an alias for the file so the dependency
1204
- lookup for ``sshd`` works. You can use this parameter yourself,
1205
- but note that only the library can use these aliases; for instance,
1206
- the following code will not work::
1313
+ file { '/foo': stage => pre, ensure => file }
1314
+ }
1315
+ end
1207
1316
 
1208
- file { \"/etc/ssh/sshd_config\":
1209
- owner => root,
1210
- group => root,
1211
- alias => sshdconfig
1212
- }
1317
+ ###############################
1318
+ # All of the provider plumbing for the resource types.
1319
+ require 'puppet/provider'
1320
+ require 'puppet/util/provider_features'
1213
1321
 
1214
- file { sshdconfig:
1215
- mode => 644
1216
- }
1322
+ # Add the feature handling module.
1323
+ extend Puppet::Util::ProviderFeatures
1217
1324
 
1218
- There's no way here for the Puppet parser to know that these two stanzas
1219
- should be affecting the same file.
1325
+ attr_reader :provider
1220
1326
 
1221
- See the `LanguageTutorial language tutorial`:trac: for more information.
1327
+ # the Type class attribute accessors
1328
+ class << self
1329
+ attr_accessor :providerloader
1330
+ attr_writer :defaultprovider
1331
+ end
1222
1332
 
1223
- "
1333
+ # Find the default provider.
1334
+ def self.defaultprovider
1335
+ unless @defaultprovider
1336
+ suitable = suitableprovider
1224
1337
 
1225
- munge do |aliases|
1226
- unless aliases.is_a?(Array)
1227
- aliases = [aliases]
1228
- end
1338
+ # Find which providers are a default for this system.
1339
+ defaults = suitable.find_all { |provider| provider.default? }
1229
1340
 
1230
- raise(ArgumentError, "Cannot add aliases without a catalog") unless @resource.catalog
1341
+ # If we don't have any default we use suitable providers
1342
+ defaults = suitable if defaults.empty?
1343
+ max = defaults.collect { |provider| provider.specificity }.max
1344
+ defaults = defaults.find_all { |provider| provider.specificity == max }
1231
1345
 
1232
- aliases.each do |other|
1233
- if obj = @resource.catalog.resource(@resource.class.name, other)
1234
- unless obj.object_id == @resource.object_id
1235
- self.fail("%s can not create alias %s: object already exists" % [@resource.title, other])
1236
- end
1237
- next
1238
- end
1346
+ retval = nil
1347
+ if defaults.length > 1
1348
+ Puppet.warning(
1349
+ "Found multiple default providers for #{self.name}: #{defaults.collect { |i| i.name.to_s }.join(", ")}; using #{defaults[0].name}"
1350
+ )
1351
+ retval = defaults.shift
1352
+ elsif defaults.length == 1
1353
+ retval = defaults.shift
1354
+ else
1355
+ raise Puppet::DevError, "Could not find a default provider for #{self.name}"
1356
+ end
1239
1357
 
1240
- # Newschool, add it to the catalog.
1241
- @resource.catalog.alias(@resource, other)
1242
- end
1243
- end
1358
+ @defaultprovider = retval
1244
1359
  end
1245
1360
 
1246
- newmetaparam(:tag) do
1247
- desc "Add the specified tags to the associated resource. While all resources
1248
- are automatically tagged with as much information as possible
1249
- (e.g., each class and definition containing the resource), it can
1250
- be useful to add your own tags to a given resource.
1361
+ @defaultprovider
1362
+ end
1251
1363
 
1252
- Tags are currently useful for things like applying a subset of a
1253
- host's configuration::
1364
+ def self.provider_hash_by_type(type)
1365
+ @provider_hashes ||= {}
1366
+ @provider_hashes[type] ||= {}
1367
+ end
1254
1368
 
1255
- puppetd --test --tags mytag
1369
+ def self.provider_hash
1370
+ Puppet::Type.provider_hash_by_type(self.name)
1371
+ end
1256
1372
 
1257
- This way, when you're testing a configuration you can run just the
1258
- portion you're testing."
1373
+ # Retrieve a provider by name.
1374
+ def self.provider(name)
1375
+ name = Puppet::Util.symbolize(name)
1259
1376
 
1260
- munge do |tags|
1261
- tags = [tags] unless tags.is_a? Array
1377
+ # If we don't have it yet, try loading it.
1378
+ @providerloader.load(name) unless provider_hash.has_key?(name)
1379
+ provider_hash[name]
1380
+ end
1262
1381
 
1263
- tags.each do |tag|
1264
- @resource.tag(tag)
1265
- end
1266
- end
1267
- end
1382
+ # Just list all of the providers.
1383
+ def self.providers
1384
+ provider_hash.keys
1385
+ end
1268
1386
 
1269
- class RelationshipMetaparam < Puppet::Parameter
1270
- class << self
1271
- attr_accessor :direction, :events, :callback, :subclasses
1272
- end
1387
+ def self.validprovider?(name)
1388
+ name = Puppet::Util.symbolize(name)
1273
1389
 
1274
- @subclasses = []
1390
+ (provider_hash.has_key?(name) && provider_hash[name].suitable?)
1391
+ end
1275
1392
 
1276
- def self.inherited(sub)
1277
- @subclasses << sub
1278
- end
1279
-
1280
- def munge(references)
1281
- references = [references] unless references.is_a?(Array)
1282
- references.collect do |ref|
1283
- if ref.is_a?(Puppet::Resource::Reference)
1284
- ref
1285
- else
1286
- Puppet::Resource::Reference.new(ref)
1287
- end
1288
- end
1289
- end
1393
+ # Create a new provider of a type. This method must be called
1394
+ # directly on the type that it's implementing.
1395
+ def self.provide(name, options = {}, &block)
1396
+ name = Puppet::Util.symbolize(name)
1290
1397
 
1291
- def validate_relationship
1292
- @value.each do |ref|
1293
- unless @resource.catalog.resource(ref.to_s)
1294
- description = self.class.direction == :in ? "dependency" : "dependent"
1295
- fail "Could not find %s %s for %s" % [description, ref.to_s, resource.ref]
1296
- end
1297
- end
1298
- end
1299
-
1300
- # Create edges from each of our relationships. :in
1301
- # relationships are specified by the event-receivers, and :out
1302
- # relationships are specified by the event generator. This
1303
- # way 'source' and 'target' are consistent terms in both edges
1304
- # and events -- that is, an event targets edges whose source matches
1305
- # the event's source. The direction of the relationship determines
1306
- # which resource is applied first and which resource is considered
1307
- # to be the event generator.
1308
- def to_edges
1309
- @value.collect do |reference|
1310
- reference.catalog = resource.catalog
1311
-
1312
- # Either of the two retrieval attempts could have returned
1313
- # nil.
1314
- unless related_resource = reference.resolve
1315
- self.fail "Could not retrieve dependency '%s' of %s" % [reference, @resource.ref]
1316
- end
1317
-
1318
- # Are we requiring them, or vice versa? See the method docs
1319
- # for futher info on this.
1320
- if self.class.direction == :in
1321
- source = related_resource
1322
- target = @resource
1323
- else
1324
- source = @resource
1325
- target = related_resource
1326
- end
1327
-
1328
- if method = self.class.callback
1329
- subargs = {
1330
- :event => self.class.events,
1331
- :callback => method
1332
- }
1333
- self.debug("subscribes to %s" % [related_resource.ref])
1334
- else
1335
- # If there's no callback, there's no point in even adding
1336
- # a label.
1337
- subargs = nil
1338
- self.debug("requires %s" % [related_resource.ref])
1339
- end
1340
-
1341
- rel = Puppet::Relationship.new(source, target, subargs)
1342
- end
1343
- end
1398
+ if obj = provider_hash[name]
1399
+ Puppet.debug "Reloading #{name} #{self.name} provider"
1400
+ unprovide(name)
1344
1401
  end
1345
1402
 
1346
- def self.relationship_params
1347
- RelationshipMetaparam.subclasses
1348
- end
1349
-
1350
-
1351
- # Note that the order in which the relationships params is defined
1352
- # matters. The labelled params (notify and subcribe) must be later,
1353
- # so that if both params are used, those ones win. It's a hackish
1354
- # solution, but it works.
1355
-
1356
- newmetaparam(:require, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do
1357
- desc "One or more objects that this object depends on.
1358
- This is used purely for guaranteeing that changes to required objects
1359
- happen before the dependent object. For instance::
1360
-
1361
- # Create the destination directory before you copy things down
1362
- file { \"/usr/local/scripts\":
1363
- ensure => directory
1364
- }
1365
-
1366
- file { \"/usr/local/scripts/myscript\":
1367
- source => \"puppet://server/module/myscript\",
1368
- mode => 755,
1369
- require => File[\"/usr/local/scripts\"]
1370
- }
1371
-
1372
- Multiple dependencies can be specified by providing a comma-seperated list
1373
- of resources, enclosed in square brackets::
1374
-
1375
- require => [ File[\"/usr/local\"], File[\"/usr/local/scripts\"] ]
1376
-
1377
- Note that Puppet will autorequire everything that it can, and
1378
- there are hooks in place so that it's easy for resources to add new
1379
- ways to autorequire objects, so if you think Puppet could be
1380
- smarter here, let us know.
1381
-
1382
- In fact, the above code was redundant -- Puppet will autorequire
1383
- any parent directories that are being managed; it will
1384
- automatically realize that the parent directory should be created
1385
- before the script is pulled down.
1386
-
1387
- Currently, exec resources will autorequire their CWD (if it is
1388
- specified) plus any fully qualified paths that appear in the
1389
- command. For instance, if you had an ``exec`` command that ran
1390
- the ``myscript`` mentioned above, the above code that pulls the
1391
- file down would be automatically listed as a requirement to the
1392
- ``exec`` code, so that you would always be running againts the
1393
- most recent version.
1394
- "
1403
+ parent = if pname = options[:parent]
1404
+ options.delete(:parent)
1405
+ if pname.is_a? Class
1406
+ pname
1407
+ else
1408
+ if provider = self.provider(pname)
1409
+ provider
1410
+ else
1411
+ raise Puppet::DevError,
1412
+ "Could not find parent provider #{pname} of #{name}"
1413
+ end
1414
+ end
1415
+ else
1416
+ Puppet::Provider
1395
1417
  end
1396
1418
 
1397
- newmetaparam(:subscribe, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :ALL_EVENTS, :callback => :refresh}) do
1398
- desc "One or more objects that this object depends on. Changes in the
1399
- subscribed to objects result in the dependent objects being
1400
- refreshed (e.g., a service will get restarted). For instance::
1419
+ options[:resource_type] ||= self
1401
1420
 
1402
- class nagios {
1403
- file { \"/etc/nagios/nagios.conf\":
1404
- source => \"puppet://server/module/nagios.conf\",
1405
- alias => nagconf # just to make things easier for me
1406
- }
1407
- service { nagios:
1408
- running => true,
1409
- subscribe => File[nagconf]
1410
- }
1411
- }
1421
+ self.providify
1412
1422
 
1413
- Currently the ``exec``, ``mount`` and ``service`` type support
1414
- refreshing.
1415
- "
1416
- end
1417
1423
 
1418
- newmetaparam(:before, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do
1419
- desc %{This parameter is the opposite of **require** -- it guarantees
1420
- that the specified object is applied later than the specifying
1421
- object::
1424
+ provider = genclass(
1425
+ name,
1426
+ :parent => parent,
1427
+ :hash => provider_hash,
1428
+ :prefix => "Provider",
1429
+ :block => block,
1430
+ :include => feature_module,
1431
+ :extend => feature_module,
1422
1432
 
1423
- file { "/var/nagios/configuration":
1424
- source => "...",
1425
- recurse => true,
1426
- before => Exec["nagios-rebuid"]
1427
- }
1433
+ :attributes => options
1434
+ )
1428
1435
 
1429
- exec { "nagios-rebuild":
1430
- command => "/usr/bin/make",
1431
- cwd => "/var/nagios/configuration"
1432
- }
1436
+ provider
1437
+ end
1433
1438
 
1434
- This will make sure all of the files are up to date before the
1435
- make command is run.}
1436
- end
1439
+ # Make sure we have a :provider parameter defined. Only gets called if there
1440
+ # are providers.
1441
+ def self.providify
1442
+ return if @paramhash.has_key? :provider
1437
1443
 
1438
- newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do
1439
- desc %{This parameter is the opposite of **subscribe** -- it sends events
1440
- to the specified object::
1444
+ newparam(:provider) do
1445
+ desc "The specific backend for #{self.name.to_s} to use. You will
1446
+ seldom need to specify this -- Puppet will usually discover the
1447
+ appropriate provider for your platform."
1441
1448
 
1442
- file { "/etc/sshd_config":
1443
- source => "....",
1444
- notify => Service[sshd]
1445
- }
1449
+ # This is so we can refer back to the type to get a list of
1450
+ # providers for documentation.
1451
+ class << self
1452
+ attr_accessor :parenttype
1453
+ end
1446
1454
 
1447
- service { sshd:
1448
- ensure => running
1449
- }
1455
+ # We need to add documentation for each provider.
1456
+ def self.doc
1457
+ @doc + " Available providers are:\n\n" + parenttype.providers.sort { |a,b|
1458
+ a.to_s <=> b.to_s
1459
+ }.collect { |i|
1460
+ "* **#{i}**: #{parenttype().provider(i).doc}"
1461
+ }.join("\n")
1462
+ end
1450
1463
 
1451
- This will restart the sshd service if the sshd config file changes.}
1452
- end
1453
-
1454
- ###############################
1455
- # All of the provider plumbing for the resource types.
1456
- require 'puppet/provider'
1457
- require 'puppet/util/provider_features'
1464
+ defaultto {
1465
+ @resource.class.defaultprovider.name
1466
+ }
1458
1467
 
1459
- # Add the feature handling module.
1460
- extend Puppet::Util::ProviderFeatures
1461
-
1462
- attr_reader :provider
1468
+ validate do |provider_class|
1469
+ provider_class = provider_class[0] if provider_class.is_a? Array
1470
+ provider_class = provider_class.class.name if provider_class.is_a?(Puppet::Provider)
1463
1471
 
1464
- # the Type class attribute accessors
1465
- class << self
1466
- attr_accessor :providerloader
1467
- attr_writer :defaultprovider
1468
- end
1469
-
1470
- # Find the default provider.
1471
- def self.defaultprovider
1472
- unless defined? @defaultprovider and @defaultprovider
1473
- suitable = suitableprovider()
1474
-
1475
- # Find which providers are a default for this system.
1476
- defaults = suitable.find_all { |provider| provider.default? }
1477
-
1478
- # If we don't have any default we use suitable providers
1479
- defaults = suitable if defaults.empty?
1480
- max = defaults.collect { |provider| provider.specificity }.max
1481
- defaults = defaults.find_all { |provider| provider.specificity == max }
1482
-
1483
- retval = nil
1484
- if defaults.length > 1
1485
- Puppet.warning(
1486
- "Found multiple default providers for %s: %s; using %s" %
1487
- [self.name, defaults.collect { |i| i.name.to_s }.join(", "),
1488
- defaults[0].name]
1489
- )
1490
- retval = defaults.shift
1491
- elsif defaults.length == 1
1492
- retval = defaults.shift
1493
- else
1494
- raise Puppet::DevError, "Could not find a default provider for %s" %
1495
- self.name
1496
- end
1497
-
1498
- @defaultprovider = retval
1472
+ unless provider = @resource.class.provider(provider_class)
1473
+ raise ArgumentError, "Invalid #{@resource.class.name} provider '#{provider_class}'"
1499
1474
  end
1475
+ end
1500
1476
 
1501
- return @defaultprovider
1502
- end
1477
+ munge do |provider|
1478
+ provider = provider[0] if provider.is_a? Array
1479
+ provider = provider.intern if provider.is_a? String
1480
+ @resource.provider = provider
1503
1481
 
1504
- def self.provider_hash_by_type(type)
1505
- @provider_hashes ||= {}
1506
- @provider_hashes[type] ||= {}
1507
- end
1508
-
1509
- def self.provider_hash
1510
- Puppet::Type.provider_hash_by_type(self.name)
1511
- end
1512
-
1513
- # Retrieve a provider by name.
1514
- def self.provider(name)
1515
- name = Puppet::Util.symbolize(name)
1516
-
1517
- # If we don't have it yet, try loading it.
1518
- unless provider_hash.has_key?(name)
1519
- @providerloader.load(name)
1482
+ if provider.is_a?(Puppet::Provider)
1483
+ provider.class.name
1484
+ else
1485
+ provider
1486
+ end
1487
+ end
1488
+ end.parenttype = self
1489
+ end
1490
+
1491
+ def self.unprovide(name)
1492
+ if provider_hash.has_key? name
1493
+
1494
+ rmclass(
1495
+ name,
1496
+ :hash => provider_hash,
1497
+
1498
+ :prefix => "Provider"
1499
+ )
1500
+ if @defaultprovider and @defaultprovider.name == name
1501
+ @defaultprovider = nil
1502
+ end
1503
+ end
1504
+ end
1505
+
1506
+ # Return an array of all of the suitable providers.
1507
+ def self.suitableprovider
1508
+ providerloader.loadall if provider_hash.empty?
1509
+ provider_hash.find_all { |name, provider|
1510
+ provider.suitable?
1511
+ }.collect { |name, provider|
1512
+ provider
1513
+ }.reject { |p| p.name == :fake } # For testing
1514
+ end
1515
+
1516
+ def provider=(name)
1517
+ if name.is_a?(Puppet::Provider)
1518
+ @provider = name
1519
+ @provider.resource = self
1520
+ elsif klass = self.class.provider(name)
1521
+ @provider = klass.new(self)
1522
+ else
1523
+ raise ArgumentError, "Could not find #{name} provider of #{self.class.name}"
1524
+ end
1525
+ end
1526
+
1527
+ ###############################
1528
+ # All of the relationship code.
1529
+
1530
+ # Specify a block for generating a list of objects to autorequire. This
1531
+ # makes it so that you don't have to manually specify things that you clearly
1532
+ # require.
1533
+ def self.autorequire(name, &block)
1534
+ @autorequires ||= {}
1535
+ @autorequires[name] = block
1536
+ end
1537
+
1538
+ # Yield each of those autorequires in turn, yo.
1539
+ def self.eachautorequire
1540
+ @autorequires ||= {}
1541
+ @autorequires.each { |type, block|
1542
+ yield(type, block)
1543
+ }
1544
+ end
1545
+
1546
+ # Figure out of there are any objects we can automatically add as
1547
+ # dependencies.
1548
+ def autorequire(rel_catalog = nil)
1549
+ rel_catalog ||= catalog
1550
+ raise(Puppet::DevError, "You cannot add relationships without a catalog") unless rel_catalog
1551
+
1552
+ reqs = []
1553
+ self.class.eachautorequire { |type, block|
1554
+ # Ignore any types we can't find, although that would be a bit odd.
1555
+ next unless typeobj = Puppet::Type.type(type)
1556
+
1557
+ # Retrieve the list of names from the block.
1558
+ next unless list = self.instance_eval(&block)
1559
+ list = [list] unless list.is_a?(Array)
1560
+
1561
+ # Collect the current prereqs
1562
+ list.each { |dep|
1563
+ obj = nil
1564
+ # Support them passing objects directly, to save some effort.
1565
+ unless dep.is_a? Puppet::Type
1566
+ # Skip autorequires that we aren't managing
1567
+ unless dep = rel_catalog.resource(type, dep)
1568
+ next
1569
+ end
1520
1570
  end
1521
- return provider_hash[name]
1522
- end
1523
1571
 
1524
- # Just list all of the providers.
1525
- def self.providers
1526
- provider_hash.keys
1527
- end
1572
+ reqs << Puppet::Relationship.new(dep, self)
1573
+ }
1574
+ }
1528
1575
 
1529
- def self.validprovider?(name)
1530
- name = Puppet::Util.symbolize(name)
1576
+ reqs
1577
+ end
1531
1578
 
1532
- return (provider_hash.has_key?(name) && provider_hash[name].suitable?)
1533
- end
1579
+ # Build the dependencies associated with an individual object.
1580
+ def builddepends
1581
+ # Handle the requires
1582
+ self.class.relationship_params.collect do |klass|
1583
+ if param = @parameters[klass.name]
1584
+ param.to_edges
1585
+ end
1586
+ end.flatten.reject { |r| r.nil? }
1587
+ end
1534
1588
 
1535
- # Create a new provider of a type. This method must be called
1536
- # directly on the type that it's implementing.
1537
- def self.provide(name, options = {}, &block)
1538
- name = Puppet::Util.symbolize(name)
1589
+ # Define the initial list of tags.
1590
+ def tags=(list)
1591
+ tag(self.class.name)
1592
+ tag(*list)
1593
+ end
1539
1594
 
1540
- if obj = provider_hash[name]
1541
- Puppet.debug "Reloading %s %s provider" % [name, self.name]
1542
- unprovide(name)
1543
- end
1595
+ # Types (which map to resources in the languages) are entirely composed of
1596
+ # attribute value pairs. Generally, Puppet calls any of these things an
1597
+ # 'attribute', but these attributes always take one of three specific
1598
+ # forms: parameters, metaparams, or properties.
1544
1599
 
1545
- parent = if pname = options[:parent]
1546
- options.delete(:parent)
1547
- if pname.is_a? Class
1548
- pname
1549
- else
1550
- if provider = self.provider(pname)
1551
- provider
1552
- else
1553
- raise Puppet::DevError,
1554
- "Could not find parent provider %s of %s" %
1555
- [pname, name]
1556
- end
1557
- end
1558
- else
1559
- Puppet::Provider
1560
- end
1600
+ # In naming methods, I have tried to consistently name the method so
1601
+ # that it is clear whether it operates on all attributes (thus has 'attr' in
1602
+ # the method name, or whether it operates on a specific type of attributes.
1603
+ attr_writer :title
1604
+ attr_writer :noop
1561
1605
 
1562
- options[:resource_type] ||= self
1606
+ include Enumerable
1563
1607
 
1564
- self.providify
1608
+ # class methods dealing with Type management
1565
1609
 
1566
- provider = genclass(name,
1567
- :parent => parent,
1568
- :hash => provider_hash,
1569
- :prefix => "Provider",
1570
- :block => block,
1571
- :include => feature_module,
1572
- :extend => feature_module,
1573
- :attributes => options
1574
- )
1610
+ public
1575
1611
 
1576
- return provider
1577
- end
1578
-
1579
- # Make sure we have a :provider parameter defined. Only gets called if there
1580
- # are providers.
1581
- def self.providify
1582
- return if @paramhash.has_key? :provider
1583
-
1584
- newparam(:provider) do
1585
- desc "The specific backend for #{self.name.to_s} to use. You will
1586
- seldom need to specify this -- Puppet will usually discover the
1587
- appropriate provider for your platform."
1588
-
1589
- # This is so we can refer back to the type to get a list of
1590
- # providers for documentation.
1591
- class << self
1592
- attr_accessor :parenttype
1593
- end
1594
-
1595
- # We need to add documentation for each provider.
1596
- def self.doc
1597
- @doc + " Available providers are:\n\n" + parenttype().providers.sort { |a,b|
1598
- a.to_s <=> b.to_s
1599
- }.collect { |i|
1600
- "* **%s**: %s" % [i, parenttype().provider(i).doc]
1601
- }.join("\n")
1602
- end
1603
-
1604
- defaultto {
1605
- @resource.class.defaultprovider.name
1606
- }
1607
-
1608
- validate do |provider_class|
1609
- provider_class = provider_class[0] if provider_class.is_a? Array
1610
- if provider_class.is_a?(Puppet::Provider)
1611
- provider_class = provider_class.class.name
1612
- end
1613
-
1614
- unless provider = @resource.class.provider(provider_class)
1615
- raise ArgumentError, "Invalid %s provider '%s'" % [@resource.class.name, provider_class]
1616
- end
1617
- end
1618
-
1619
- munge do |provider|
1620
- provider = provider[0] if provider.is_a? Array
1621
- if provider.is_a? String
1622
- provider = provider.intern
1623
- end
1624
- @resource.provider = provider
1625
-
1626
- if provider.is_a?(Puppet::Provider)
1627
- provider.class.name
1628
- else
1629
- provider
1630
- end
1631
- end
1632
- end.parenttype = self
1633
- end
1634
-
1635
- def self.unprovide(name)
1636
- if provider_hash.has_key? name
1637
- rmclass(name,
1638
- :hash => provider_hash,
1639
- :prefix => "Provider"
1640
- )
1641
- if @defaultprovider and @defaultprovider.name == name
1642
- @defaultprovider = nil
1643
- end
1644
- end
1645
- end
1612
+ # the Type class attribute accessors
1613
+ class << self
1614
+ attr_reader :name
1615
+ attr_accessor :self_refresh
1616
+ include Enumerable, Puppet::Util::ClassGen
1617
+ include Puppet::MetaType::Manager
1646
1618
 
1647
- # Return an array of all of the suitable providers.
1648
- def self.suitableprovider
1649
- if provider_hash.empty?
1650
- providerloader.loadall
1651
- end
1652
- provider_hash.find_all { |name, provider|
1653
- provider.suitable?
1654
- }.collect { |name, provider|
1655
- provider
1656
- }.reject { |p| p.name == :fake } # For testing
1657
- end
1658
-
1659
- def provider=(name)
1660
- if name.is_a?(Puppet::Provider)
1661
- @provider = name
1662
- @provider.resource = self
1663
- elsif klass = self.class.provider(name)
1664
- @provider = klass.new(self)
1665
- else
1666
- raise ArgumentError, "Could not find %s provider of %s" %
1667
- [name, self.class.name]
1668
- end
1669
- end
1619
+ include Puppet::Util
1620
+ include Puppet::Util::Logging
1621
+ end
1670
1622
 
1671
- ###############################
1672
- # All of the relationship code.
1623
+ # all of the variables that must be initialized for each subclass
1624
+ def self.initvars
1625
+ # all of the instances of this class
1626
+ @objects = Hash.new
1627
+ @aliases = Hash.new
1673
1628
 
1674
- # Specify a block for generating a list of objects to autorequire. This
1675
- # makes it so that you don't have to manually specify things that you clearly
1676
- # require.
1677
- def self.autorequire(name, &block)
1678
- @autorequires ||= {}
1679
- @autorequires[name] = block
1680
- end
1629
+ @defaults = {}
1681
1630
 
1682
- # Yield each of those autorequires in turn, yo.
1683
- def self.eachautorequire
1684
- @autorequires ||= {}
1685
- @autorequires.each { |type, block|
1686
- yield(type, block)
1687
- }
1688
- end
1631
+ @parameters ||= []
1689
1632
 
1690
- # Figure out of there are any objects we can automatically add as
1691
- # dependencies.
1692
- def autorequire(rel_catalog = nil)
1693
- rel_catalog ||= catalog
1694
- raise(Puppet::DevError, "You cannot add relationships without a catalog") unless rel_catalog
1695
-
1696
- reqs = []
1697
- self.class.eachautorequire { |type, block|
1698
- # Ignore any types we can't find, although that would be a bit odd.
1699
- next unless typeobj = Puppet::Type.type(type)
1700
-
1701
- # Retrieve the list of names from the block.
1702
- next unless list = self.instance_eval(&block)
1703
- unless list.is_a?(Array)
1704
- list = [list]
1705
- end
1706
-
1707
- # Collect the current prereqs
1708
- list.each { |dep|
1709
- obj = nil
1710
- # Support them passing objects directly, to save some effort.
1711
- unless dep.is_a? Puppet::Type
1712
- # Skip autorequires that we aren't managing
1713
- unless dep = rel_catalog.resource(type, dep)
1714
- next
1715
- end
1716
- end
1717
-
1718
- reqs << Puppet::Relationship.new(dep, self)
1719
- }
1720
- }
1633
+ @validproperties = {}
1634
+ @properties = []
1635
+ @parameters = []
1636
+ @paramhash = {}
1721
1637
 
1722
- return reqs
1723
- end
1724
-
1725
- # Build the dependencies associated with an individual object.
1726
- def builddepends
1727
- # Handle the requires
1728
- self.class.relationship_params.collect do |klass|
1729
- if param = @parameters[klass.name]
1730
- param.to_edges
1731
- end
1732
- end.flatten.reject { |r| r.nil? }
1733
- end
1734
-
1735
- ###############################
1736
- # All of the scheduling code.
1737
-
1738
- # Look up the schedule and set it appropriately. This is done after
1739
- # the instantiation phase, so that the schedule can be anywhere in the
1740
- # file.
1741
- def schedule
1742
- unless catalog
1743
- warning "Cannot schedule without a schedule-containing catalog"
1744
- return nil
1745
- end
1746
-
1747
- unless defined? @schedule
1748
- if name = self[:schedule]
1749
- if sched = catalog.resource(:schedule, name)
1750
- @schedule = sched
1751
- else
1752
- self.fail "Could not find schedule %s" % name
1753
- end
1754
- else
1755
- @schedule = nil
1756
- end
1757
- end
1758
- @schedule
1759
- end
1638
+ @attr_aliases = {}
1760
1639
 
1761
- # Check whether we are scheduled to run right now or not.
1762
- def scheduled?
1763
- return true if Puppet[:ignoreschedules]
1764
- return true unless schedule = self.schedule
1640
+ @paramdoc = Hash.new { |hash,key|
1641
+ key = key.intern if key.is_a?(String)
1642
+ if hash.include?(key)
1643
+ hash[key]
1644
+ else
1645
+ "Param Documentation for #{key} not found"
1646
+ end
1647
+ }
1765
1648
 
1766
- # We use 'checked' here instead of 'synced' because otherwise we'll
1767
- # end up checking most resources most times, because they will generally
1768
- # have been synced a long time ago (e.g., a file only gets updated
1769
- # once a month on the server and its schedule is daily; the last sync time
1770
- # will have been a month ago, so we'd end up checking every run).
1771
- return schedule.match?(self.cached(:checked).to_i)
1772
- end
1649
+ @doc ||= ""
1773
1650
 
1774
- # Define the initial list of tags.
1775
- def tags=(list)
1776
- tag(self.class.name)
1777
- tag(*list)
1651
+ end
1652
+
1653
+ def self.to_s
1654
+ if defined?(@name)
1655
+ "Puppet::Type::#{@name.to_s.capitalize}"
1656
+ else
1657
+ super
1778
1658
  end
1659
+ end
1779
1660
 
1780
- # Types (which map to resources in the languages) are entirely composed of
1781
- # attribute value pairs. Generally, Puppet calls any of these things an
1782
- # 'attribute', but these attributes always take one of three specific
1783
- # forms: parameters, metaparams, or properties.
1661
+ # Create a block to validate that our object is set up entirely. This will
1662
+ # be run before the object is operated on.
1663
+ def self.validate(&block)
1664
+ define_method(:validate, &block)
1665
+ #@validate = block
1666
+ end
1784
1667
 
1785
- # In naming methods, I have tried to consistently name the method so
1786
- # that it is clear whether it operates on all attributes (thus has 'attr' in
1787
- # the method name, or whether it operates on a specific type of attributes.
1788
- attr_writer :title
1789
- attr_writer :noop
1668
+ # The catalog that this resource is stored in.
1669
+ attr_accessor :catalog
1790
1670
 
1791
- include Enumerable
1671
+ # is the resource exported
1672
+ attr_accessor :exported
1792
1673
 
1793
- # class methods dealing with Type management
1674
+ # is the resource virtual (it should not :-))
1675
+ attr_accessor :virtual
1794
1676
 
1795
- public
1677
+ # create a log at specified level
1678
+ def log(msg)
1796
1679
 
1797
- # the Type class attribute accessors
1798
- class << self
1799
- attr_reader :name
1800
- attr_accessor :self_refresh
1801
- include Enumerable, Puppet::Util::ClassGen
1802
- include Puppet::MetaType::Manager
1680
+ Puppet::Util::Log.create(
1803
1681
 
1804
- include Puppet::Util
1805
- include Puppet::Util::Logging
1806
- end
1682
+ :level => @parameters[:loglevel].value,
1683
+ :message => msg,
1807
1684
 
1808
- # all of the variables that must be initialized for each subclass
1809
- def self.initvars
1810
- # all of the instances of this class
1811
- @objects = Hash.new
1812
- @aliases = Hash.new
1685
+ :source => self
1686
+ )
1687
+ end
1813
1688
 
1814
- @defaults = {}
1815
1689
 
1816
- unless defined? @parameters
1817
- @parameters = []
1818
- end
1690
+ # instance methods related to instance intrinsics
1691
+ # e.g., initialize and name
1819
1692
 
1820
- @validproperties = {}
1821
- @properties = []
1822
- @parameters = []
1823
- @paramhash = {}
1693
+ public
1824
1694
 
1825
- @attr_aliases = {}
1695
+ attr_reader :original_parameters
1826
1696
 
1827
- @paramdoc = Hash.new { |hash,key|
1828
- if key.is_a?(String)
1829
- key = key.intern
1830
- end
1831
- if hash.include?(key)
1832
- hash[key]
1833
- else
1834
- "Param Documentation for %s not found" % key
1835
- end
1836
- }
1697
+ # initialize the type instance
1698
+ def initialize(resource)
1699
+ raise Puppet::DevError, "Got TransObject instead of Resource or hash" if resource.is_a?(Puppet::TransObject)
1700
+ resource = self.class.hash2resource(resource) unless resource.is_a?(Puppet::Resource)
1837
1701
 
1838
- unless defined? @doc
1839
- @doc = ""
1840
- end
1841
-
1842
- end
1702
+ # The list of parameter/property instances.
1703
+ @parameters = {}
1843
1704
 
1844
- def self.to_s
1845
- if defined? @name
1846
- "Puppet::Type::" + @name.to_s.capitalize
1847
- else
1848
- super
1849
- end
1705
+ # Set the title first, so any failures print correctly.
1706
+ if resource.type.to_s.downcase.to_sym == self.class.name
1707
+ self.title = resource.title
1708
+ else
1709
+ # This should only ever happen for components
1710
+ self.title = resource.ref
1850
1711
  end
1851
1712
 
1852
- # Create a block to validate that our object is set up entirely. This will
1853
- # be run before the object is operated on.
1854
- def self.validate(&block)
1855
- define_method(:validate, &block)
1856
- #@validate = block
1713
+ [:file, :line, :catalog, :exported, :virtual].each do |getter|
1714
+ setter = getter.to_s + "="
1715
+ if val = resource.send(getter)
1716
+ self.send(setter, val)
1717
+ end
1857
1718
  end
1858
1719
 
1859
- # The catalog that this resource is stored in.
1860
- attr_accessor :catalog
1861
-
1862
- # is the resource exported
1863
- attr_accessor :exported
1720
+ @tags = resource.tags
1864
1721
 
1865
- # is the resource virtual (it should not :-))
1866
- attr_accessor :virtual
1867
-
1868
- # create a log at specified level
1869
- def log(msg)
1870
- Puppet::Util::Log.create(
1871
- :level => @parameters[:loglevel].value,
1872
- :message => msg,
1873
- :source => self
1874
- )
1875
- end
1722
+ @original_parameters = resource.to_hash
1876
1723
 
1724
+ set_name(@original_parameters)
1877
1725
 
1878
- # instance methods related to instance intrinsics
1879
- # e.g., initialize() and name()
1726
+ set_default(:provider)
1880
1727
 
1881
- public
1728
+ set_parameters(@original_parameters)
1882
1729
 
1883
- attr_reader :original_parameters
1730
+ self.validate if self.respond_to?(:validate)
1731
+ end
1884
1732
 
1885
- # initialize the type instance
1886
- def initialize(resource)
1887
- raise Puppet::DevError, "Got TransObject instead of Resource or hash" if resource.is_a?(Puppet::TransObject)
1888
- resource = self.class.hash2resource(resource) unless resource.is_a?(Puppet::Resource)
1733
+ private
1889
1734
 
1890
- # The list of parameter/property instances.
1891
- @parameters = {}
1735
+ # Set our resource's name.
1736
+ def set_name(hash)
1737
+ self[name_var] = hash.delete(name_var) if name_var
1738
+ end
1892
1739
 
1893
- # Set the title first, so any failures print correctly.
1894
- if resource.type.to_s.downcase.to_sym == self.class.name
1895
- self.title = resource.title
1740
+ # Set all of the parameters from a hash, in the appropriate order.
1741
+ def set_parameters(hash)
1742
+ # Use the order provided by allattrs, but add in any
1743
+ # extra attributes from the resource so we get failures
1744
+ # on invalid attributes.
1745
+ no_values = []
1746
+ (self.class.allattrs + hash.keys).uniq.each do |attr|
1747
+ begin
1748
+ # Set any defaults immediately. This is mostly done so
1749
+ # that the default provider is available for any other
1750
+ # property validation.
1751
+ if hash.has_key?(attr)
1752
+ self[attr] = hash[attr]
1896
1753
  else
1897
- # This should only ever happen for components
1898
- self.title = resource.ref
1899
- end
1900
-
1901
- [:file, :line, :catalog, :exported, :virtual].each do |getter|
1902
- setter = getter.to_s + "="
1903
- if val = resource.send(getter)
1904
- self.send(setter, val)
1905
- end
1906
- end
1907
-
1908
- @tags = resource.tags
1909
-
1910
- @original_parameters = resource.to_hash
1911
-
1912
- set_name(@original_parameters)
1913
-
1914
- set_default(:provider)
1915
-
1916
- set_parameters(@original_parameters)
1917
-
1918
- self.validate if self.respond_to?(:validate)
1919
- end
1920
-
1921
- private
1922
-
1923
- # Set our resource's name.
1924
- def set_name(hash)
1925
- n = self.class.namevar
1926
- self[n] = hash[n]
1927
- hash.delete(n)
1754
+ no_values << attr
1755
+ end
1756
+ rescue ArgumentError, Puppet::Error, TypeError
1757
+ raise
1758
+ rescue => detail
1759
+ error = Puppet::DevError.new( "Could not set #{attr} on #{self.class.name}: #{detail}")
1760
+ error.set_backtrace(detail.backtrace)
1761
+ raise error
1762
+ end
1763
+ end
1764
+ no_values.each do |attr|
1765
+ set_default(attr)
1766
+ end
1767
+ end
1768
+
1769
+ public
1770
+
1771
+ # Set up all of our autorequires.
1772
+ def finish
1773
+ # Make sure all of our relationships are valid. Again, must be done
1774
+ # when the entire catalog is instantiated.
1775
+ self.class.relationship_params.collect do |klass|
1776
+ if param = @parameters[klass.name]
1777
+ param.validate_relationship
1778
+ end
1779
+ end.flatten.reject { |r| r.nil? }
1780
+ end
1781
+
1782
+ # For now, leave the 'name' method functioning like it used to. Once 'title'
1783
+ # works everywhere, I'll switch it.
1784
+ def name
1785
+ self[:name]
1786
+ end
1787
+
1788
+ # Look up our parent in the catalog, if we have one.
1789
+ def parent
1790
+ return nil unless catalog
1791
+
1792
+ unless defined?(@parent)
1793
+ if parents = catalog.adjacent(self, :direction => :in)
1794
+ # We should never have more than one parent, so let's just ignore
1795
+ # it if we happen to.
1796
+ @parent = parents.shift
1797
+ else
1798
+ @parent = nil
1799
+ end
1928
1800
  end
1801
+ @parent
1802
+ end
1929
1803
 
1930
- # Set all of the parameters from a hash, in the appropriate order.
1931
- def set_parameters(hash)
1932
- # Use the order provided by allattrs, but add in any
1933
- # extra attributes from the resource so we get failures
1934
- # on invalid attributes.
1935
- no_values = []
1936
- (self.class.allattrs + hash.keys).uniq.each do |attr|
1937
- begin
1938
- # Set any defaults immediately. This is mostly done so
1939
- # that the default provider is available for any other
1940
- # property validation.
1941
- if hash.has_key?(attr)
1942
- self[attr] = hash[attr]
1943
- else
1944
- no_values << attr
1945
- end
1946
- rescue ArgumentError, Puppet::Error, TypeError
1947
- raise
1948
- rescue => detail
1949
- error = Puppet::DevError.new( "Could not set %s on %s: %s" % [attr, self.class.name, detail])
1950
- error.set_backtrace(detail.backtrace)
1951
- raise error
1952
- end
1953
- end
1954
- no_values.each do |attr|
1955
- set_default(attr)
1956
- end
1957
- end
1804
+ # Return the "type[name]" style reference.
1805
+ def ref
1806
+ "#{self.class.name.to_s.capitalize}[#{self.title}]"
1807
+ end
1958
1808
 
1959
- public
1809
+ def self_refresh?
1810
+ self.class.self_refresh
1811
+ end
1960
1812
 
1961
- # Set up all of our autorequires.
1962
- def finish
1963
- # Scheduling has to be done when the whole config is instantiated, so
1964
- # that file order doesn't matter in finding them.
1965
- self.schedule
1813
+ # Mark that we're purging.
1814
+ def purging
1815
+ @purging = true
1816
+ end
1966
1817
 
1967
- # Make sure all of our relationships are valid. Again, must be done
1968
- # when the entire catalog is instantiated.
1969
- self.class.relationship_params.collect do |klass|
1970
- if param = @parameters[klass.name]
1971
- param.validate_relationship
1972
- end
1973
- end.flatten.reject { |r| r.nil? }
1818
+ # Is this resource being purged? Used by transactions to forbid
1819
+ # deletion when there are dependencies.
1820
+ def purging?
1821
+ if defined?(@purging)
1822
+ @purging
1823
+ else
1824
+ false
1974
1825
  end
1826
+ end
1975
1827
 
1976
- # Return a cached value
1977
- def cached(name)
1978
- Puppet::Util::Storage.cache(self)[name]
1979
- #@cache[name] ||= nil
1828
+ # Retrieve the title of an object. If no title was set separately,
1829
+ # then use the object's name.
1830
+ def title
1831
+ unless @title
1832
+ if self.class.validparameter?(name_var)
1833
+ @title = self[:name]
1834
+ elsif self.class.validproperty?(name_var)
1835
+ @title = self.should(name_var)
1836
+ else
1837
+ self.devfail "Could not find namevar #{name_var} for #{self.class.name}"
1838
+ end
1980
1839
  end
1981
1840
 
1982
- # Cache a value
1983
- def cache(name, value)
1984
- Puppet::Util::Storage.cache(self)[name] = value
1985
- #@cache[name] = value
1986
- end
1841
+ @title
1842
+ end
1987
1843
 
1988
- # For now, leave the 'name' method functioning like it used to. Once 'title'
1989
- # works everywhere, I'll switch it.
1990
- def name
1991
- return self[:name]
1992
- end
1844
+ # convert to a string
1845
+ def to_s
1846
+ self.ref
1847
+ end
1993
1848
 
1994
- # Look up our parent in the catalog, if we have one.
1995
- def parent
1996
- return nil unless catalog
1849
+ # Convert to a transportable object
1850
+ def to_trans(ret = true)
1851
+ trans = TransObject.new(self.title, self.class.name)
1997
1852
 
1998
- unless defined?(@parent)
1999
- if parents = catalog.adjacent(self, :direction => :in)
2000
- # We should never have more than one parent, so let's just ignore
2001
- # it if we happen to.
2002
- @parent = parents.shift
2003
- else
2004
- @parent = nil
2005
- end
2006
- end
2007
- @parent
1853
+ values = retrieve_resource
1854
+ values.each do |name, value|
1855
+ name = name.name if name.respond_to? :name
1856
+ trans[name] = value
2008
1857
  end
2009
1858
 
2010
- # Return the "type[name]" style reference.
2011
- def ref
2012
- "%s[%s]" % [self.class.name.to_s.capitalize, self.title]
2013
- end
1859
+ @parameters.each do |name, param|
1860
+ # Avoid adding each instance name twice
1861
+ next if param.class.isnamevar? and param.value == self.title
2014
1862
 
2015
- def self_refresh?
2016
- self.class.self_refresh
1863
+ # We've already got property values
1864
+ next if param.is_a?(Puppet::Property)
1865
+ trans[name] = param.value
2017
1866
  end
2018
1867
 
2019
- # Mark that we're purging.
2020
- def purging
2021
- @purging = true
2022
- end
1868
+ trans.tags = self.tags
2023
1869
 
2024
- # Is this resource being purged? Used by transactions to forbid
2025
- # deletion when there are dependencies.
2026
- def purging?
2027
- if defined? @purging
2028
- @purging
2029
- else
2030
- false
2031
- end
2032
- end
1870
+ # FIXME I'm currently ignoring 'parent' and 'path'
2033
1871
 
2034
- # Retrieve the title of an object. If no title was set separately,
2035
- # then use the object's name.
2036
- def title
2037
- unless defined? @title and @title
2038
- namevar = self.class.namevar
2039
- if self.class.validparameter?(namevar)
2040
- @title = self[:name]
2041
- elsif self.class.validproperty?(namevar)
2042
- @title = self.should(namevar)
2043
- else
2044
- self.devfail "Could not find namevar %s for %s" %
2045
- [namevar, self.class.name]
2046
- end
2047
- end
2048
-
2049
- return @title
2050
- end
2051
-
2052
- # convert to a string
2053
- def to_s
2054
- self.ref
2055
- end
2056
-
2057
- # Convert to a transportable object
2058
- def to_trans(ret = true)
2059
- trans = TransObject.new(self.title, self.class.name)
2060
-
2061
- values = retrieve()
2062
- values.each do |name, value|
2063
- trans[name.name] = value
2064
- end
1872
+ trans
1873
+ end
2065
1874
 
2066
- @parameters.each do |name, param|
2067
- # Avoid adding each instance name as both the name and the namevar
2068
- next if param.class.isnamevar? and param.value == self.title
1875
+ def to_resource
1876
+ # this 'type instance' versus 'resource' distinction seems artificial
1877
+ # I'd like to see it collapsed someday ~JW
1878
+ self.to_trans.to_resource
1879
+ end
2069
1880
 
2070
- # We've already got property values
2071
- next if param.is_a?(Puppet::Property)
2072
- trans[name] = param.value
2073
- end
2074
-
2075
- trans.tags = self.tags
2076
-
2077
- # FIXME I'm currently ignoring 'parent' and 'path'
2078
-
2079
- return trans
2080
- end
2081
-
2082
- %w{exported virtual}.each do |m|
2083
- define_method(m+"?") do
2084
- self.send(m)
2085
- end
2086
- end
2087
-
2088
- end # Puppet::Type
1881
+ def virtual?; !!@virtual; end
1882
+ def exported?; !!@exported; end
1883
+ end
2089
1884
  end
2090
1885
 
2091
1886
  require 'puppet/provider'