puppet 0.24.5 → 0.24.6

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 (354) hide show
  1. data/CHANGELOG +206 -0
  2. data/Rakefile +53 -0
  3. data/bin/filebucket +0 -0
  4. data/bin/puppet +32 -11
  5. data/bin/puppetca +1 -0
  6. data/bin/puppetd +0 -0
  7. data/bin/puppetdoc +0 -0
  8. data/bin/puppetmasterd +0 -0
  9. data/bin/puppetrun +16 -8
  10. data/bin/ralsh +0 -0
  11. data/conf/debian/rules +0 -0
  12. data/conf/gentoo/init.d/puppetmaster +0 -0
  13. data/conf/osx/PackageInfo.plist +36 -0
  14. data/conf/osx/createpackage.sh +167 -0
  15. data/conf/osx/preflight +12 -0
  16. data/conf/redhat/client.init +1 -1
  17. data/conf/redhat/puppet.spec +34 -6
  18. data/conf/redhat/server.init +42 -7
  19. data/conf/redhat/server.sysconfig +22 -0
  20. data/conf/solaris/smf/svc-puppetd +0 -0
  21. data/conf/solaris/smf/svc-puppetmasterd +0 -0
  22. data/examples/etc/init.d/sleeper +0 -0
  23. data/examples/mac_dscl.pp +0 -0
  24. data/examples/mac_dscl_revert.pp +0 -0
  25. data/examples/mac_netinfo.pp +0 -0
  26. data/examples/mac_pkgdmg.pp +0 -0
  27. data/ext/bin/sleeper +0 -0
  28. data/ext/module_puppet +0 -0
  29. data/ext/nagios/check_puppet.rb +0 -0
  30. data/ext/passenger/README +63 -0
  31. data/ext/passenger/apache2.conf +29 -0
  32. data/ext/passenger/config.ru +40 -0
  33. data/ext/puppet-test +0 -0
  34. data/ext/puppetlast +6 -31
  35. data/ext/puppetstoredconfigclean.rb +87 -0
  36. data/install.rb +75 -20
  37. data/lib/puppet.rb +1 -1
  38. data/lib/puppet/daemon.rb +0 -0
  39. data/lib/puppet/defaults.rb +3 -7
  40. data/lib/puppet/external/base64.rb +0 -0
  41. data/lib/puppet/external/nagios.rb +0 -0
  42. data/lib/puppet/external/nagios/base.rb +0 -0
  43. data/lib/puppet/file_serving/fileset.rb +2 -2
  44. data/lib/puppet/file_serving/metadata.rb +3 -3
  45. data/lib/puppet/indirector/facts/facter.rb +3 -2
  46. data/lib/puppet/indirector/yaml.rb +10 -1
  47. data/lib/puppet/module.rb +36 -12
  48. data/lib/puppet/network/authstore.rb +0 -0
  49. data/lib/puppet/network/client/master.rb +12 -11
  50. data/lib/puppet/network/handler/filebucket.rb +0 -0
  51. data/lib/puppet/network/handler/fileserver.rb +38 -46
  52. data/lib/puppet/network/handler/master.rb +1 -1
  53. data/lib/puppet/network/handler/report.rb +0 -0
  54. data/lib/puppet/network/handler/resource.rb +0 -0
  55. data/lib/puppet/network/handler/runner.rb +0 -0
  56. data/lib/puppet/network/http_server/rack.rb +148 -0
  57. data/lib/puppet/network/rights.rb +0 -0
  58. data/lib/puppet/network/xmlrpc/client.rb +5 -5
  59. data/lib/puppet/node.rb +5 -9
  60. data/lib/puppet/node/environment.rb +1 -17
  61. data/lib/puppet/node/facts.rb +0 -0
  62. data/lib/puppet/parameter.rb +1 -28
  63. data/lib/puppet/parser/ast.rb +6 -0
  64. data/lib/puppet/parser/ast/arithmetic_operator.rb +41 -0
  65. data/lib/puppet/parser/ast/boolean_operator.rb +48 -0
  66. data/lib/puppet/parser/ast/collexpr.rb +6 -1
  67. data/lib/puppet/parser/ast/comparison_operator.rb +37 -0
  68. data/lib/puppet/parser/ast/minus.rb +23 -0
  69. data/lib/puppet/parser/ast/nop.rb +11 -0
  70. data/lib/puppet/parser/ast/not.rb +19 -0
  71. data/lib/puppet/parser/ast/resource_override.rb +23 -16
  72. data/lib/puppet/parser/ast/resource_reference.rb +10 -6
  73. data/lib/puppet/parser/ast/vardef.rb +2 -2
  74. data/lib/puppet/parser/collector.rb +2 -1
  75. data/lib/puppet/parser/functions.rb +7 -217
  76. data/lib/puppet/parser/functions/defined.rb +27 -0
  77. data/lib/puppet/parser/functions/fail.rb +4 -0
  78. data/lib/puppet/parser/functions/file.rb +21 -0
  79. data/lib/puppet/parser/functions/fqdn_rand.rb +15 -0
  80. data/lib/puppet/parser/functions/generate.rb +35 -0
  81. data/lib/puppet/parser/functions/include.rb +26 -0
  82. data/lib/puppet/parser/functions/realize.rb +14 -0
  83. data/lib/puppet/parser/functions/search.rb +7 -0
  84. data/lib/puppet/parser/functions/sha1.rb +6 -0
  85. data/lib/puppet/parser/functions/tag.rb +6 -0
  86. data/lib/puppet/parser/functions/tagged.rb +18 -0
  87. data/lib/puppet/parser/functions/template.rb +22 -0
  88. data/lib/puppet/parser/lexer.rb +15 -5
  89. data/lib/puppet/parser/parser.rb +1073 -715
  90. data/lib/puppet/parser/parser_support.rb +18 -13
  91. data/lib/puppet/parser/resource.rb +1 -1
  92. data/lib/puppet/parser/resource/param.rb +10 -2
  93. data/lib/puppet/parser/scope.rb +63 -5
  94. data/lib/puppet/parser/templatewrapper.rb +61 -15
  95. data/lib/puppet/property.rb +7 -1
  96. data/lib/puppet/property/keyvalue.rb +96 -0
  97. data/lib/puppet/property/list.rb +78 -0
  98. data/lib/puppet/provider/confine.rb +1 -1
  99. data/lib/puppet/provider/confine/variable.rb +10 -1
  100. data/lib/puppet/provider/cron/crontab.rb +0 -0
  101. data/lib/puppet/provider/mailalias/aliases.rb +0 -0
  102. data/lib/puppet/provider/maillist/mailman.rb +0 -0
  103. data/lib/puppet/provider/mount/parsed.rb +0 -0
  104. data/lib/puppet/provider/nameservice.rb +24 -39
  105. data/lib/puppet/provider/nameservice/directoryservice.rb +12 -3
  106. data/lib/puppet/provider/nameservice/netinfo.rb +12 -2
  107. data/lib/puppet/provider/nameservice/objectadd.rb +1 -10
  108. data/lib/puppet/provider/package/appdmg.rb +1 -1
  109. data/lib/puppet/provider/package/apple.rb +0 -0
  110. data/lib/puppet/provider/package/apt.rb +14 -21
  111. data/lib/puppet/provider/package/aptitude.rb +0 -0
  112. data/lib/puppet/provider/package/blastwave.rb +2 -0
  113. data/lib/puppet/provider/package/darwinport.rb +0 -0
  114. data/lib/puppet/provider/package/dpkg.rb +33 -51
  115. data/lib/puppet/provider/package/fink.rb +1 -1
  116. data/lib/puppet/provider/package/freebsd.rb +0 -0
  117. data/lib/puppet/provider/package/gem.rb +0 -0
  118. data/lib/puppet/provider/package/hpux.rb +46 -0
  119. data/lib/puppet/provider/package/openbsd.rb +0 -0
  120. data/lib/puppet/provider/package/pkgdmg.rb +1 -1
  121. data/lib/puppet/provider/package/portage.rb +3 -1
  122. data/lib/puppet/provider/package/ports.rb +3 -3
  123. data/lib/puppet/provider/package/rpm.rb +8 -1
  124. data/lib/puppet/provider/package/rug.rb +2 -2
  125. data/lib/puppet/provider/package/sun.rb +2 -0
  126. data/lib/puppet/provider/package/sunfreeware.rb +3 -0
  127. data/lib/puppet/provider/package/yum.rb +24 -17
  128. data/lib/puppet/provider/package/yumhelper.py +92 -11
  129. data/lib/puppet/provider/parsedfile.rb +0 -0
  130. data/lib/puppet/provider/port/parsed.rb +0 -0
  131. data/lib/puppet/provider/selboolean/getsetsebool.rb +47 -0
  132. data/lib/puppet/provider/selmodule/semodule.rb +143 -0
  133. data/lib/puppet/provider/service/base.rb +0 -0
  134. data/lib/puppet/provider/service/daemontools.rb +154 -0
  135. data/lib/puppet/provider/service/debian.rb +1 -1
  136. data/lib/puppet/provider/service/freebsd.rb +2 -0
  137. data/lib/puppet/provider/service/gentoo.rb +2 -0
  138. data/lib/puppet/provider/service/init.rb +0 -0
  139. data/lib/puppet/provider/service/redhat.rb +1 -1
  140. data/lib/puppet/provider/service/runit.rb +93 -0
  141. data/lib/puppet/provider/service/smf.rb +2 -0
  142. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +7 -1
  143. data/lib/puppet/provider/sshkey/parsed.rb +0 -0
  144. data/lib/puppet/provider/user/hpux.rb +30 -0
  145. data/lib/puppet/provider/user/user_role_add.rb +156 -0
  146. data/lib/puppet/provider/user/useradd.rb +23 -14
  147. data/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb +17 -0
  148. data/lib/puppet/rails/database/schema.rb +0 -8
  149. data/lib/puppet/rails/resource.rb +6 -6
  150. data/lib/puppet/reference/configuration.rb +0 -7
  151. data/lib/puppet/reports.rb +0 -0
  152. data/lib/puppet/reports/rrdgraph.rb +3 -2
  153. data/lib/puppet/sslcertificates.rb +0 -0
  154. data/lib/puppet/sslcertificates/inventory.rb +3 -2
  155. data/lib/puppet/sslcertificates/support.rb +3 -0
  156. data/lib/puppet/transaction/report.rb +1 -7
  157. data/lib/puppet/transportable.rb +10 -7
  158. data/lib/puppet/type.rb +2110 -14
  159. data/lib/puppet/type/cron.rb +0 -0
  160. data/lib/puppet/type/exec.rb +0 -0
  161. data/lib/puppet/type/file.rb +12 -2
  162. data/lib/puppet/type/file/checksum.rb +4 -0
  163. data/lib/puppet/type/file/content.rb +0 -0
  164. data/lib/puppet/type/file/ensure.rb +0 -0
  165. data/lib/puppet/type/file/group.rb +30 -43
  166. data/lib/puppet/type/file/mode.rb +0 -0
  167. data/lib/puppet/type/file/owner.rb +0 -0
  168. data/lib/puppet/type/file/selcontext.rb +104 -0
  169. data/lib/puppet/type/file/source.rb +0 -0
  170. data/lib/puppet/type/file/type.rb +0 -0
  171. data/lib/puppet/type/filebucket.rb +0 -0
  172. data/lib/puppet/type/group.rb +0 -8
  173. data/lib/puppet/type/host.rb +0 -0
  174. data/lib/puppet/type/mailalias.rb +0 -0
  175. data/lib/puppet/type/maillist.rb +0 -0
  176. data/lib/puppet/type/mount.rb +0 -0
  177. data/lib/puppet/type/package.rb +2 -2
  178. data/lib/puppet/type/port.rb +0 -0
  179. data/lib/puppet/type/schedule.rb +0 -0
  180. data/lib/puppet/type/selboolean.rb +31 -0
  181. data/lib/puppet/type/selmodule.rb +54 -0
  182. data/lib/puppet/type/ssh_authorized_key.rb +3 -3
  183. data/lib/puppet/type/sshkey.rb +0 -0
  184. data/lib/puppet/type/tidy.rb +0 -0
  185. data/lib/puppet/type/user.rb +153 -137
  186. data/lib/puppet/type/yumrepo.rb +18 -2
  187. data/lib/puppet/type/zone.rb +5 -1
  188. data/lib/puppet/util.rb +7 -7
  189. data/lib/puppet/util/filetype.rb +7 -0
  190. data/lib/puppet/util/instance_loader.rb +0 -0
  191. data/lib/puppet/util/ldap/connection.rb +11 -1
  192. data/lib/puppet/util/ldap/manager.rb +1 -1
  193. data/lib/puppet/util/loadedfile.rb +0 -0
  194. data/lib/puppet/util/log.rb +42 -43
  195. data/lib/puppet/util/metric.rb +23 -9
  196. data/lib/puppet/util/posix.rb +69 -18
  197. data/lib/puppet/util/selinux.rb +139 -0
  198. data/lib/puppet/util/settings.rb +5 -7
  199. data/lib/puppet/util/user_attr.rb +21 -0
  200. data/test/certmgr/ca.rb +0 -0
  201. data/test/certmgr/certmgr.rb +0 -0
  202. data/test/certmgr/inventory.rb +0 -0
  203. data/test/certmgr/support.rb +0 -0
  204. data/test/data/providers/ssh_authorized_key/parsed/authorized_keys1 +3 -0
  205. data/test/data/snippets/append.pp +11 -0
  206. data/test/data/snippets/arithmetic_expression.pp +8 -0
  207. data/test/data/snippets/arraytrailingcomma.pp +3 -0
  208. data/test/data/snippets/emptyifelse.pp +9 -0
  209. data/test/data/snippets/funccomma.pp +5 -0
  210. data/test/data/snippets/ifexpression.rb +6 -0
  211. data/test/data/snippets/subclass_name_duplication.pp +0 -0
  212. data/test/executables/filebucket.rb +0 -0
  213. data/test/executables/puppetbin.rb +0 -0
  214. data/test/executables/puppetca.rb +0 -0
  215. data/test/executables/puppetd.rb +0 -0
  216. data/test/executables/puppetmasterd.rb +0 -0
  217. data/test/executables/puppetmodule.rb +0 -0
  218. data/test/language/ast.rb +0 -0
  219. data/test/language/ast/casestatement.rb +0 -0
  220. data/test/language/ast/resource.rb +0 -0
  221. data/test/language/ast/resource_reference.rb +0 -28
  222. data/test/language/ast/selector.rb +0 -0
  223. data/test/language/ast/variable.rb +0 -0
  224. data/test/language/functions.rb +91 -12
  225. data/test/language/parser.rb +21 -0
  226. data/test/language/resource.rb +0 -0
  227. data/test/language/scope.rb +28 -0
  228. data/test/language/snippets.rb +14 -0
  229. data/test/language/transportable.rb +0 -0
  230. data/test/lib/puppettest.rb +0 -0
  231. data/test/lib/puppettest/reporttesting.rb +0 -2
  232. data/test/lib/puppettest/runnable_test.rb +2 -0
  233. data/test/lib/puppettest/support/resources.rb +0 -0
  234. data/test/network/authconfig.rb +0 -0
  235. data/test/network/authorization.rb +0 -0
  236. data/test/network/authstore.rb +0 -0
  237. data/test/network/client/ca.rb +0 -0
  238. data/test/network/client/client.rb +0 -0
  239. data/test/network/client/dipper.rb +0 -0
  240. data/test/network/client/master.rb +2 -6
  241. data/test/network/client/resource.rb +0 -0
  242. data/test/network/client_request.rb +0 -0
  243. data/test/network/daemon.rb +0 -0
  244. data/test/network/handler/bucket.rb +0 -0
  245. data/test/network/handler/ca.rb +0 -0
  246. data/test/network/handler/fileserver.rb +8 -0
  247. data/test/network/handler/handler.rb +0 -0
  248. data/test/network/handler/master.rb +3 -1
  249. data/test/network/handler/report.rb +0 -0
  250. data/test/network/handler/resource.rb +0 -0
  251. data/test/network/handler/runner.rb +0 -0
  252. data/test/network/rights.rb +0 -0
  253. data/test/network/server/mongrel_test.rb +0 -0
  254. data/test/network/server/webrick.rb +0 -0
  255. data/test/network/xmlrpc/client.rb +0 -0
  256. data/test/network/xmlrpc/processor.rb +0 -0
  257. data/test/network/xmlrpc/server.rb +0 -0
  258. data/test/network/xmlrpc/webrick_servlet.rb +0 -0
  259. data/test/other/dsl.rb +0 -0
  260. data/test/other/events.rb +0 -0
  261. data/test/other/overrides.rb +0 -0
  262. data/test/other/provider.rb +0 -0
  263. data/test/other/puppet.rb +0 -0
  264. data/test/other/relationships.rb +0 -0
  265. data/test/other/report.rb +2 -4
  266. data/test/other/transactions.rb +1 -1
  267. data/test/puppet/conffiles.rb +0 -0
  268. data/test/puppet/defaults.rb +0 -0
  269. data/test/puppet/errortest.rb +0 -0
  270. data/test/puppet/tc_suidmanager.rb +0 -0
  271. data/test/rails/ast.rb +0 -0
  272. data/test/rails/configuration.rb +0 -0
  273. data/test/rails/host.rb +0 -0
  274. data/test/rails/rails.rb +0 -0
  275. data/test/rails/railsparameter.rb +0 -0
  276. data/test/rails/railsresource.rb +0 -0
  277. data/test/ral/manager/attributes.rb +0 -0
  278. data/test/ral/manager/instances.rb +0 -0
  279. data/test/ral/manager/manager.rb +0 -0
  280. data/test/ral/manager/provider.rb +0 -0
  281. data/test/ral/manager/type.rb +0 -0
  282. data/test/ral/providers/cron/crontab.rb +0 -0
  283. data/test/ral/providers/group.rb +14 -13
  284. data/test/ral/providers/host/netinfo.rb +0 -0
  285. data/test/ral/providers/host/parsed.rb +0 -0
  286. data/test/ral/providers/mailalias/aliases.rb +0 -0
  287. data/test/ral/providers/mount/netinfo.rb +0 -0
  288. data/test/ral/providers/nameservice.rb +0 -0
  289. data/test/ral/providers/package.rb +0 -31
  290. data/test/ral/providers/package/aptitude.rb +1 -2
  291. data/test/ral/providers/package/aptrpm.rb +2 -2
  292. data/test/ral/providers/parsedfile.rb +0 -0
  293. data/test/ral/providers/port/parsed.rb +0 -0
  294. data/test/ral/providers/provider.rb +0 -0
  295. data/test/ral/providers/service/base.rb +0 -0
  296. data/test/ral/providers/service/debian.rb +0 -0
  297. data/test/ral/providers/sshkey/parsed.rb +0 -0
  298. data/test/ral/providers/user.rb +8 -8
  299. data/test/ral/providers/user/useradd.rb +0 -0
  300. data/test/ral/type/basic.rb +0 -0
  301. data/test/ral/type/cron.rb +0 -0
  302. data/test/ral/type/exec.rb +0 -0
  303. data/test/ral/type/file.rb +0 -0
  304. data/test/ral/type/file/target.rb +0 -0
  305. data/test/ral/type/filebucket.rb +0 -0
  306. data/test/ral/type/fileignoresource.rb +0 -0
  307. data/test/ral/type/filesources.rb +1 -3
  308. data/test/ral/type/group.rb +0 -0
  309. data/test/ral/type/host.rb +0 -0
  310. data/test/ral/type/mailalias.rb +1 -2
  311. data/test/ral/type/parameter.rb +0 -0
  312. data/test/ral/type/port.rb +0 -0
  313. data/test/ral/type/property.rb +0 -0
  314. data/test/ral/type/resources.rb +0 -0
  315. data/test/ral/type/service.rb +0 -0
  316. data/test/ral/type/sshkey.rb +0 -0
  317. data/test/ral/type/tidy.rb +0 -0
  318. data/test/ral/type/user.rb +0 -50
  319. data/test/ral/type/yumrepo.rb +7 -1
  320. data/test/ral/type/zone.rb +0 -0
  321. data/test/test +0 -0
  322. data/test/util/autoload.rb +0 -0
  323. data/test/util/classgen.rb +0 -0
  324. data/test/util/execution.rb +0 -0
  325. data/test/util/features.rb +0 -0
  326. data/test/util/fileparsing.rb +0 -0
  327. data/test/util/filetype.rb +0 -0
  328. data/test/util/inifile.rb +0 -0
  329. data/test/util/instance_loader.rb +0 -0
  330. data/test/util/log.rb +0 -59
  331. data/test/util/metrics.rb +0 -0
  332. data/test/util/package.rb +0 -0
  333. data/test/util/pidlock.rb +0 -0
  334. data/test/util/settings.rb +0 -0
  335. data/test/util/storage.rb +0 -0
  336. data/test/util/subclass_loader.rb +0 -0
  337. data/test/util/utiltest.rb +0 -0
  338. metadata +54 -19
  339. data/lib/puppet/metatype/attributes.rb +0 -685
  340. data/lib/puppet/metatype/closure.rb +0 -49
  341. data/lib/puppet/metatype/container.rb +0 -50
  342. data/lib/puppet/metatype/evaluation.rb +0 -163
  343. data/lib/puppet/metatype/instances.rb +0 -305
  344. data/lib/puppet/metatype/metaparams.rb +0 -423
  345. data/lib/puppet/metatype/providers.rb +0 -247
  346. data/lib/puppet/metatype/relationships.rb +0 -115
  347. data/lib/puppet/metatype/schedules.rb +0 -33
  348. data/lib/puppet/metatype/tags.rb +0 -38
  349. data/lib/puppet/util/plist.rb +0 -23
  350. data/lib/puppet/util/plist/generator.rb +0 -225
  351. data/lib/puppet/util/plist/parser.rb +0 -226
  352. data/test/ral/providers/package/apt.rb +0 -169
  353. data/test/ral/providers/package/dpkg.rb +0 -64
  354. data/test/util/posixtest.rb +0 -169
@@ -1,49 +0,0 @@
1
- class Puppet::Type
2
- attr_writer :implicit
3
-
4
- # Is this type's name isomorphic with the object? That is, if the
5
- # name conflicts, does it necessarily mean that the objects conflict?
6
- # Defaults to true.
7
- def self.isomorphic?
8
- if defined? @isomorphic
9
- return @isomorphic
10
- else
11
- return true
12
- end
13
- end
14
-
15
- def implicit?
16
- if defined? @implicit and @implicit
17
- return true
18
- else
19
- return false
20
- end
21
- end
22
-
23
- def isomorphic?
24
- self.class.isomorphic?
25
- end
26
-
27
- # is the instance a managed instance? A 'yes' here means that
28
- # the instance was created from the language, vs. being created
29
- # in order resolve other questions, such as finding a package
30
- # in a list
31
- def managed?
32
- # Once an object is managed, it always stays managed; but an object
33
- # that is listed as unmanaged might become managed later in the process,
34
- # so we have to check that every time
35
- if defined? @managed and @managed
36
- return @managed
37
- else
38
- @managed = false
39
- properties.each { |property|
40
- s = property.should
41
- if s and ! property.class.unmanaged
42
- @managed = true
43
- break
44
- end
45
- }
46
- return @managed
47
- end
48
- end
49
- end
@@ -1,50 +0,0 @@
1
- class Puppet::Type
2
-
3
- # this is a retarded hack method to get around the difference between
4
- # component children and file children
5
- def self.depthfirst?
6
- if defined? @depthfirst
7
- return @depthfirst
8
- else
9
- return false
10
- end
11
- end
12
-
13
- def depthfirst?
14
- self.class.depthfirst?
15
- end
16
-
17
- # Add a hook for testing for recursion.
18
- def parentof?(child)
19
- if (self == child)
20
- debug "parent is equal to child"
21
- return true
22
- elsif defined? @parent and @parent.parentof?(child)
23
- debug "My parent is parent of child"
24
- return true
25
- else
26
- return false
27
- end
28
- end
29
-
30
- # Remove an object. The argument determines whether the object's
31
- # subscriptions get eliminated, too.
32
- def remove(rmdeps = true)
33
- # This is hackish (mmm, cut and paste), but it works for now, and it's
34
- # better than warnings.
35
- @parameters.each do |name, obj|
36
- obj.remove
37
- end
38
- @parameters.clear
39
- self.class.delete(self)
40
-
41
- @parent = nil
42
-
43
- # Remove the reference to the provider.
44
- if self.provider
45
- @provider.clear
46
- @provider = nil
47
- end
48
- end
49
- end
50
-
@@ -1,163 +0,0 @@
1
- class Puppet::Type
2
- # This method is responsible for collecting property changes we always
3
- # descend into the children before we evaluate our current properties.
4
- # This returns any changes resulting from testing, thus 'collect' rather
5
- # than 'each'.
6
- def evaluate
7
- if self.provider.is_a?(Puppet::Provider)
8
- unless provider.class.suitable?
9
- raise Puppet::Error, "Provider %s is not functional on this platform" % provider.class.name
10
- end
11
- end
12
- #Puppet.err "Evaluating %s" % self.path.join(":")
13
- unless defined? @evalcount
14
- self.err "No evalcount defined on '%s' of type '%s'" %
15
- [self.title,self.class]
16
- @evalcount = 0
17
- end
18
- @evalcount += 1
19
-
20
- if p = self.provider and p.respond_to?(:prefetch)
21
- p.prefetch
22
- end
23
-
24
- # this only operates on properties, not properties + children
25
- # it's important that we call retrieve() on the type instance,
26
- # not directly on the property, because it allows the type to override
27
- # the method, like pfile does
28
- currentvalues = self.retrieve
29
-
30
- changes = propertychanges(currentvalues).flatten
31
-
32
- # now record how many changes we've resulted in
33
- if changes.length > 0
34
- self.debug "%s change(s)" %
35
- [changes.length]
36
- end
37
-
38
- # If we're in noop mode, we don't want to store the checked time,
39
- # because it will result in the resource not getting scheduled if
40
- # someone were to apply the catalog in non-noop mode.
41
- # We're going to go ahead and record that we checked if there were
42
- # no changes, since it's unlikely it will affect the scheduling.
43
- noop = noop?
44
- if ! noop or (noop && changes.length == 0)
45
- self.cache(:checked, Time.now)
46
- end
47
- return changes.flatten
48
- end
49
-
50
- # Flush the provider, if it supports it. This is called by the
51
- # transaction.
52
- def flush
53
- if self.provider and self.provider.respond_to?(:flush)
54
- self.provider.flush
55
- end
56
- end
57
-
58
- # if all contained objects are in sync, then we're in sync
59
- # FIXME I don't think this is used on the type instances any more,
60
- # it's really only used for testing
61
- def insync?(is)
62
- insync = true
63
-
64
- if property = @parameters[:ensure]
65
- unless is.include? property
66
- raise Puppet::DevError,
67
- "The is value is not in the is array for '%s'" %
68
- [property.name]
69
- end
70
- ensureis = is[property]
71
- if property.insync?(ensureis) and property.should == :absent
72
- return true
73
- end
74
- end
75
-
76
- properties.each { |property|
77
- unless is.include? property
78
- raise Puppet::DevError,
79
- "The is value is not in the is array for '%s'" %
80
- [property.name]
81
- end
82
-
83
- propis = is[property]
84
- unless property.insync?(propis)
85
- property.debug("Not in sync: %s vs %s" %
86
- [propis.inspect, property.should.inspect])
87
- insync = false
88
- #else
89
- # property.debug("In sync")
90
- end
91
- }
92
-
93
- #self.debug("%s sync status is %s" % [self,insync])
94
- return insync
95
- end
96
-
97
- # retrieve the current value of all contained properties
98
- def retrieve
99
- return currentpropvalues
100
- end
101
-
102
- # get a hash of the current properties.
103
- def currentpropvalues(override_value = nil)
104
- # it's important to use the method here, as it follows the order
105
- # in which they're defined in the object
106
- return properties().inject({}) { | prophash, property|
107
- prophash[property] = override_value.nil? ?
108
- property.retrieve :
109
- override_value
110
- prophash
111
- }
112
- end
113
-
114
- # Are we running in noop mode?
115
- def noop?
116
- if defined?(@noop)
117
- @noop
118
- else
119
- Puppet[:noop]
120
- end
121
- end
122
-
123
- def noop
124
- noop?
125
- end
126
-
127
- # Retrieve the changes associated with all of the properties.
128
- def propertychanges(currentvalues)
129
- # If we are changing the existence of the object, then none of
130
- # the other properties matter.
131
- changes = []
132
- ensureparam = @parameters[:ensure]
133
-
134
- # This allows resource types to have 'ensure' be a parameter, which allows them to
135
- # just pass the parameter on to other generated resources.
136
- ensureparam = nil unless ensureparam.is_a?(Puppet::Property)
137
- if ensureparam && !currentvalues.include?(ensureparam)
138
- raise Puppet::DevError, "Parameter ensure defined but missing from current values"
139
- end
140
-
141
- if ensureparam and ! ensureparam.insync?(currentvalues[ensureparam])
142
- changes << Puppet::Transaction::Change.new(ensureparam, currentvalues[ensureparam])
143
- # Else, if the 'ensure' property is correctly absent, then do
144
- # nothing
145
- elsif ensureparam and currentvalues[ensureparam] == :absent
146
- return []
147
- else
148
- changes = properties().find_all { |property|
149
- currentvalues[property] ||= :absent
150
- ! property.insync?(currentvalues[property])
151
- }.collect { |property|
152
- Puppet::Transaction::Change.new(property, currentvalues[property])
153
- }
154
- end
155
-
156
- if Puppet[:debug] and changes.length > 0
157
- self.debug("Changing " + changes.collect { |ch| ch.property.name }.join(","))
158
- end
159
-
160
- changes
161
- end
162
- end
163
-
@@ -1,305 +0,0 @@
1
- require 'puppet/transportable'
2
-
3
- class Puppet::Type
4
- # Make 'new' private, so people have to use create instead.
5
- class << self
6
- private :new
7
- end
8
-
9
- # retrieve a named instance of the current type
10
- def self.[](name)
11
- @objects[name] || @aliases[name]
12
- end
13
-
14
- # add an instance by name to the class list of instances
15
- def self.[]=(name,object)
16
- newobj = nil
17
- if object.is_a?(Puppet::Type)
18
- newobj = object
19
- else
20
- raise Puppet::DevError, "must pass a Puppet::Type object"
21
- end
22
-
23
- if exobj = @objects[name] and self.isomorphic?
24
- msg = "Object '%s[%s]' already exists" %
25
- [newobj.class.name, name]
26
-
27
- if exobj.file and exobj.line
28
- msg += ("in file %s at line %s" %
29
- [object.file, object.line])
30
- end
31
- if object.file and object.line
32
- msg += ("and cannot be redefined in file %s at line %s" %
33
- [object.file, object.line])
34
- end
35
- error = Puppet::Error.new(msg)
36
- raise error
37
- else
38
- #Puppet.info("adding %s of type %s to class list" %
39
- # [name,object.class])
40
- @objects[name] = newobj
41
- end
42
- end
43
-
44
- # Create an alias. We keep these in a separate hash so that we don't encounter
45
- # the objects multiple times when iterating over them.
46
- def self.alias(name, obj)
47
- if @objects.include?(name)
48
- unless @objects[name] == obj
49
- raise Puppet::Error.new(
50
- "Cannot create alias %s: object already exists" %
51
- [name]
52
- )
53
- end
54
- end
55
-
56
- if @aliases.include?(name)
57
- unless @aliases[name] == obj
58
- raise Puppet::Error.new(
59
- "Object %s already has alias %s" %
60
- [@aliases[name].name, name]
61
- )
62
- end
63
- end
64
-
65
- @aliases[name] = obj
66
- end
67
-
68
- # remove all of the instances of a single type
69
- def self.clear
70
- if defined? @objects
71
- @objects.each do |name, obj|
72
- obj.remove(true)
73
- end
74
- @objects.clear
75
- end
76
- if defined? @aliases
77
- @aliases.clear
78
- end
79
- end
80
-
81
- # Force users to call this, so that we can merge objects if
82
- # necessary.
83
- def self.create(args)
84
- # Don't modify the original hash; instead, create a duplicate and modify it.
85
- # We have to dup and use the ! so that it stays a TransObject if it is
86
- # one.
87
- hash = args.dup
88
- symbolizehash!(hash)
89
-
90
- # If we're the base class, then pass the info on appropriately
91
- if self == Puppet::Type
92
- type = nil
93
- if hash.is_a? Puppet::TransObject
94
- type = hash.type
95
- else
96
- # If we're using the type to determine object type, then delete it
97
- if type = hash[:type]
98
- hash.delete(:type)
99
- end
100
- end
101
-
102
- # If they've specified a type and called on the base, then
103
- # delegate to the subclass.
104
- if type
105
- if typeklass = self.type(type)
106
- return typeklass.create(hash)
107
- else
108
- raise Puppet::Error, "Unknown type %s" % type
109
- end
110
- else
111
- raise Puppet::Error, "No type found for %s" % hash.inspect
112
- end
113
- end
114
-
115
- # Handle this new object being implicit
116
- implicit = hash[:implicit] || false
117
- if hash.include?(:implicit)
118
- hash.delete(:implicit)
119
- end
120
-
121
- name = nil
122
- unless hash.is_a? Puppet::TransObject
123
- hash = self.hash2trans(hash)
124
- end
125
-
126
- # XXX This will have to change when transobjects change to using titles
127
- title = hash.name
128
-
129
- # if the object already exists
130
- if self.isomorphic? and retobj = self[title]
131
- # if only one of our objects is implicit, then it's easy to see
132
- # who wins -- the non-implicit one.
133
- if retobj.implicit? and ! implicit
134
- Puppet.notice "Removing implicit %s" % retobj.title
135
- # Remove all of the objects, but do not remove their subscriptions.
136
- retobj.remove(false)
137
-
138
- # now pass through and create the new object
139
- elsif implicit
140
- Puppet.debug "Ignoring implicit %s[%s]" % [self.name, title]
141
- return nil
142
- else
143
- raise Puppet::Error, "%s is already being managed" % retobj.ref
144
- end
145
- end
146
-
147
- # create it anew
148
- # if there's a failure, destroy the object if it got that far, but raise
149
- # the error.
150
- begin
151
- obj = new(hash)
152
- rescue => detail
153
- Puppet.err "Could not create %s: %s" % [title, detail.to_s]
154
- if obj
155
- obj.remove(true)
156
- elsif obj = self[title]
157
- obj.remove(true)
158
- end
159
- raise
160
- end
161
-
162
- if implicit
163
- obj.implicit = true
164
- end
165
-
166
- # Store the object by title
167
- self[obj.title] = obj
168
-
169
- return obj
170
- end
171
-
172
- # remove a specified object
173
- def self.delete(resource)
174
- return unless defined? @objects
175
- if @objects.include?(resource.title)
176
- @objects.delete(resource.title)
177
- end
178
- if @aliases.include?(resource.title)
179
- @aliases.delete(resource.title)
180
- end
181
- if @aliases.has_value?(resource)
182
- names = []
183
- @aliases.each do |name, otherres|
184
- if otherres == resource
185
- names << name
186
- end
187
- end
188
- names.each { |name| @aliases.delete(name) }
189
- end
190
- end
191
-
192
- # iterate across each of the type's instances
193
- def self.each
194
- return unless defined? @objects
195
- @objects.each { |name,instance|
196
- yield instance
197
- }
198
- end
199
-
200
- # does the type have an object with the given name?
201
- def self.has_key?(name)
202
- return @objects.has_key?(name)
203
- end
204
-
205
- # Convert a hash to a TransObject.
206
- def self.hash2trans(hash)
207
- title = nil
208
- if hash.include? :title
209
- title = hash[:title]
210
- hash.delete(:title)
211
- elsif hash.include? self.namevar
212
- title = hash[self.namevar]
213
- hash.delete(self.namevar)
214
-
215
- if hash.include? :name
216
- raise ArgumentError, "Cannot provide both name and %s to %s" %
217
- [self.namevar, self.name]
218
- end
219
- elsif hash[:name]
220
- title = hash[:name]
221
- hash.delete :name
222
- end
223
-
224
- if catalog = hash[:catalog]
225
- hash.delete(:catalog)
226
- end
227
-
228
- raise(Puppet::Error, "You must specify a title for objects of type %s" % self.to_s) unless title
229
-
230
- if hash.include? :type
231
- unless self.validattr? :type
232
- hash.delete :type
233
- end
234
- end
235
-
236
- # okay, now make a transobject out of hash
237
- begin
238
- trans = Puppet::TransObject.new(title, self.name.to_s)
239
- trans.catalog = catalog if catalog
240
- hash.each { |param, value|
241
- trans[param] = value
242
- }
243
- rescue => detail
244
- raise Puppet::Error, "Could not create %s: %s" %
245
- [name, detail]
246
- end
247
-
248
- return trans
249
- end
250
-
251
- # Retrieve all known instances. Either requires providers or must be overridden.
252
- def self.instances
253
- unless defined?(@providers) and ! @providers.empty?
254
- raise Puppet::DevError, "%s has no providers and has not overridden 'instances'" % self.name
255
- end
256
-
257
- # Put the default provider first, then the rest of the suitable providers.
258
- provider_instances = {}
259
- providers_by_source.collect do |provider|
260
- provider.instances.collect do |instance|
261
- # First try to get the resource if it already exists
262
- # Skip instances that map to a managed resource with a different provider
263
- next if resource = self[instance.name] and resource.provider.class != instance.class
264
-
265
- # We always want to use the "first" provider instance we find, unless the resource
266
- # is already managed and has a different provider set
267
- if other = provider_instances[instance.name]
268
- Puppet.warning "%s %s found in both %s and %s; skipping the %s version" %
269
- [self.name.to_s.capitalize, instance.name, other.class.name, instance.class.name, instance.class.name]
270
- next
271
- end
272
- provider_instances[instance.name] = instance
273
-
274
- if resource
275
- resource.provider = instance
276
- resource
277
- else
278
- create(:name => instance.name, :provider => instance, :check => :all)
279
- end
280
- end
281
- end.flatten.compact
282
- end
283
-
284
- # Return a list of one suitable provider per source, with the default provider first.
285
- def self.providers_by_source
286
- # Put the default provider first, then the rest of the suitable providers.
287
- sources = []
288
- [defaultprovider, suitableprovider].flatten.uniq.collect do |provider|
289
- next if sources.include?(provider.source)
290
-
291
- sources << provider.source
292
- provider
293
- end.compact
294
- end
295
-
296
- # Create the path for logging and such.
297
- def pathbuilder
298
- if p = parent
299
- [p.pathbuilder, self.ref].flatten
300
- else
301
- [self.ref]
302
- end
303
- end
304
- end
305
-