puppet 0.9.2 → 0.13.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 (213) hide show
  1. data/CHANGELOG +58 -0
  2. data/README +21 -18
  3. data/Rakefile +176 -36
  4. data/bin/puppet +34 -48
  5. data/bin/puppetca +41 -28
  6. data/bin/puppetd +87 -65
  7. data/bin/puppetdoc +99 -23
  8. data/bin/puppetmasterd +72 -91
  9. data/conf/redhat/client.init +80 -0
  10. data/conf/redhat/client.sysconfig +11 -0
  11. data/conf/redhat/fileserver.conf +12 -0
  12. data/conf/redhat/puppet.spec +130 -0
  13. data/conf/redhat/server.init +89 -0
  14. data/conf/redhat/server.sysconfig +9 -0
  15. data/examples/code/allatonce +2 -2
  16. data/examples/code/assignments +1 -1
  17. data/examples/code/classing +2 -2
  18. data/examples/code/components +2 -2
  19. data/examples/code/file.bl +5 -5
  20. data/examples/code/filedefaults +2 -2
  21. data/examples/code/fileparsing +1 -1
  22. data/examples/code/filerecursion +1 -1
  23. data/examples/code/functions +1 -1
  24. data/examples/code/groups +1 -1
  25. data/examples/code/importing +1 -1
  26. data/examples/code/nodes +1 -1
  27. data/examples/code/one +1 -1
  28. data/examples/code/relationships +2 -2
  29. data/examples/code/simpletests +5 -5
  30. data/examples/code/snippets/argumentdefaults +2 -2
  31. data/examples/code/snippets/casestatement +16 -8
  32. data/examples/code/snippets/classheirarchy.pp +4 -4
  33. data/examples/code/snippets/classincludes.pp +4 -4
  34. data/examples/code/snippets/classpathtest +2 -2
  35. data/examples/code/snippets/componentmetaparams.pp +11 -0
  36. data/examples/code/snippets/dirchmod +5 -5
  37. data/examples/code/snippets/emptyclass.pp +9 -0
  38. data/examples/code/snippets/failmissingexecpath.pp +1 -1
  39. data/examples/code/snippets/falsevalues.pp +1 -1
  40. data/examples/code/snippets/filecreate +5 -5
  41. data/examples/code/snippets/implicititeration +5 -5
  42. data/examples/code/snippets/multipleinstances +4 -4
  43. data/examples/code/snippets/namevartest +3 -3
  44. data/examples/code/snippets/scopetest +1 -1
  45. data/examples/code/snippets/selectorvalues.pp +3 -3
  46. data/examples/code/snippets/simpledefaults +2 -2
  47. data/examples/code/snippets/simpleselector +5 -5
  48. data/examples/code/snippets/singleary.pp +19 -0
  49. data/examples/root/etc/init.d/sleeper +3 -2
  50. data/ext/emacs/puppet-mode-init.el +6 -0
  51. data/ext/emacs/puppet-mode.el +189 -0
  52. data/ext/ldap/puppet.schema +17 -0
  53. data/ext/{module:puppet → module_puppet} +30 -31
  54. data/ext/vim/filetype.vim +9 -0
  55. data/ext/vim/puppet.vim +87 -0
  56. data/install.rb +63 -30
  57. data/lib/puppet.rb +216 -122
  58. data/lib/puppet/client.rb +51 -416
  59. data/lib/puppet/client/ca.rb +17 -0
  60. data/lib/puppet/client/dipper.rb +78 -0
  61. data/lib/puppet/client/file.rb +20 -0
  62. data/lib/puppet/client/log.rb +17 -0
  63. data/lib/puppet/client/master.rb +246 -0
  64. data/lib/puppet/client/proxy.rb +27 -0
  65. data/lib/puppet/client/status.rb +7 -0
  66. data/lib/puppet/config.rb +563 -13
  67. data/lib/puppet/daemon.rb +50 -22
  68. data/lib/puppet/element.rb +4 -4
  69. data/lib/puppet/event-loop.rb +1 -0
  70. data/lib/puppet/event-loop/better-definers.rb +367 -0
  71. data/lib/puppet/event-loop/event-loop.rb +355 -0
  72. data/lib/puppet/event-loop/signal-system.rb +220 -0
  73. data/lib/puppet/event.rb +9 -11
  74. data/lib/puppet/filetype.rb +195 -0
  75. data/lib/puppet/log.rb +35 -12
  76. data/lib/puppet/metric.rb +2 -2
  77. data/lib/puppet/networkclient.rb +145 -0
  78. data/lib/puppet/parameter.rb +335 -0
  79. data/lib/puppet/parser/ast.rb +42 -1453
  80. data/lib/puppet/parser/ast/astarray.rb +88 -0
  81. data/lib/puppet/parser/ast/branch.rb +47 -0
  82. data/lib/puppet/parser/ast/caseopt.rb +66 -0
  83. data/lib/puppet/parser/ast/casestatement.rb +78 -0
  84. data/lib/puppet/parser/ast/classdef.rb +78 -0
  85. data/lib/puppet/parser/ast/compdef.rb +111 -0
  86. data/lib/puppet/parser/ast/component.rb +105 -0
  87. data/lib/puppet/parser/ast/hostclass.rb +82 -0
  88. data/lib/puppet/parser/ast/leaf.rb +86 -0
  89. data/lib/puppet/parser/ast/node.rb +103 -0
  90. data/lib/puppet/parser/ast/nodedef.rb +68 -0
  91. data/lib/puppet/parser/ast/objectdef.rb +336 -0
  92. data/lib/puppet/parser/ast/objectparam.rb +30 -0
  93. data/lib/puppet/parser/ast/objectref.rb +76 -0
  94. data/lib/puppet/parser/ast/selector.rb +60 -0
  95. data/lib/puppet/parser/ast/typedefaults.rb +45 -0
  96. data/lib/puppet/parser/ast/vardef.rb +44 -0
  97. data/lib/puppet/parser/interpreter.rb +31 -14
  98. data/lib/puppet/parser/lexer.rb +2 -4
  99. data/lib/puppet/parser/parser.rb +332 -242
  100. data/lib/puppet/parser/scope.rb +55 -38
  101. data/lib/puppet/server.rb +43 -44
  102. data/lib/puppet/server/authstore.rb +3 -6
  103. data/lib/puppet/server/ca.rb +5 -2
  104. data/lib/puppet/server/filebucket.rb +2 -4
  105. data/lib/puppet/server/fileserver.rb +28 -12
  106. data/lib/puppet/server/logger.rb +15 -4
  107. data/lib/puppet/server/master.rb +62 -7
  108. data/lib/puppet/sslcertificates.rb +41 -607
  109. data/lib/puppet/sslcertificates/ca.rb +291 -0
  110. data/lib/puppet/sslcertificates/certificate.rb +283 -0
  111. data/lib/puppet/statechange.rb +6 -1
  112. data/lib/puppet/storage.rb +67 -56
  113. data/lib/puppet/transaction.rb +25 -9
  114. data/lib/puppet/transportable.rb +102 -22
  115. data/lib/puppet/type.rb +1096 -315
  116. data/lib/puppet/type/component.rb +30 -21
  117. data/lib/puppet/type/cron.rb +409 -448
  118. data/lib/puppet/type/exec.rb +234 -174
  119. data/lib/puppet/type/group.rb +65 -82
  120. data/lib/puppet/type/nameservice.rb +247 -3
  121. data/lib/puppet/type/nameservice/netinfo.rb +29 -40
  122. data/lib/puppet/type/nameservice/objectadd.rb +52 -66
  123. data/lib/puppet/type/nameservice/posix.rb +6 -194
  124. data/lib/puppet/type/package.rb +447 -295
  125. data/lib/puppet/type/package/apt.rb +51 -50
  126. data/lib/puppet/type/package/bsd.rb +82 -0
  127. data/lib/puppet/type/package/dpkg.rb +85 -88
  128. data/lib/puppet/type/package/rpm.rb +67 -63
  129. data/lib/puppet/type/package/sun.rb +119 -98
  130. data/lib/puppet/type/package/yum.rb +41 -37
  131. data/lib/puppet/type/parsedtype.rb +295 -0
  132. data/lib/puppet/type/parsedtype/host.rb +143 -0
  133. data/lib/puppet/type/parsedtype/port.rb +232 -0
  134. data/lib/puppet/type/parsedtype/sshkey.rb +129 -0
  135. data/lib/puppet/type/pfile.rb +484 -460
  136. data/lib/puppet/type/pfile/checksum.rb +237 -181
  137. data/lib/puppet/type/pfile/content.rb +67 -0
  138. data/lib/puppet/type/pfile/ensure.rb +212 -0
  139. data/lib/puppet/type/pfile/group.rb +106 -105
  140. data/lib/puppet/type/pfile/mode.rb +98 -101
  141. data/lib/puppet/type/pfile/source.rb +228 -209
  142. data/lib/puppet/type/pfile/type.rb +18 -21
  143. data/lib/puppet/type/pfile/uid.rb +127 -130
  144. data/lib/puppet/type/pfilebucket.rb +68 -63
  145. data/lib/puppet/type/schedule.rb +341 -0
  146. data/lib/puppet/type/service.rb +351 -255
  147. data/lib/puppet/type/service/base.rb +9 -14
  148. data/lib/puppet/type/service/debian.rb +32 -38
  149. data/lib/puppet/type/service/init.rb +130 -130
  150. data/lib/puppet/type/service/smf.rb +48 -20
  151. data/lib/puppet/type/state.rb +229 -16
  152. data/lib/puppet/type/symlink.rb +51 -63
  153. data/lib/puppet/type/tidy.rb +105 -102
  154. data/lib/puppet/type/user.rb +118 -180
  155. data/lib/puppet/util.rb +100 -6
  156. data/test/certmgr/certmgr.rb +0 -1
  157. data/test/client/client.rb +4 -4
  158. data/test/executables/puppetbin.rb +7 -14
  159. data/test/executables/puppetca.rb +18 -24
  160. data/test/executables/puppetd.rb +7 -16
  161. data/test/executables/puppetmasterd.rb +7 -9
  162. data/test/executables/puppetmodule.rb +11 -16
  163. data/test/language/ast.rb +11 -7
  164. data/test/language/interpreter.rb +1 -1
  165. data/test/language/scope.rb +2 -0
  166. data/test/language/snippets.rb +30 -5
  167. data/test/language/transportable.rb +77 -0
  168. data/test/other/config.rb +316 -0
  169. data/test/other/events.rb +22 -21
  170. data/test/other/log.rb +14 -14
  171. data/test/other/metrics.rb +4 -8
  172. data/test/other/overrides.rb +5 -5
  173. data/test/other/relationships.rb +4 -2
  174. data/test/other/storage.rb +64 -3
  175. data/test/other/transactions.rb +20 -20
  176. data/test/parser/parser.rb +7 -4
  177. data/test/puppet/conffiles.rb +12 -12
  178. data/test/puppet/defaults.rb +13 -11
  179. data/test/puppet/utiltest.rb +14 -11
  180. data/test/puppettest.rb +156 -48
  181. data/test/server/bucket.rb +2 -2
  182. data/test/server/fileserver.rb +6 -6
  183. data/test/server/logger.rb +19 -11
  184. data/test/server/master.rb +33 -4
  185. data/test/server/server.rb +2 -7
  186. data/test/types/basic.rb +5 -7
  187. data/test/types/component.rb +22 -18
  188. data/test/types/cron.rb +111 -44
  189. data/test/types/exec.rb +116 -59
  190. data/test/types/file.rb +262 -137
  191. data/test/types/filebucket.rb +13 -15
  192. data/test/types/fileignoresource.rb +12 -16
  193. data/test/types/filesources.rb +73 -48
  194. data/test/types/filetype.rb +13 -15
  195. data/test/types/group.rb +15 -13
  196. data/test/types/host.rb +146 -0
  197. data/test/types/package.rb +74 -63
  198. data/test/types/port.rb +139 -0
  199. data/test/types/query.rb +8 -8
  200. data/test/types/schedule.rb +335 -0
  201. data/test/types/service.rb +137 -21
  202. data/test/types/sshkey.rb +140 -0
  203. data/test/types/symlink.rb +3 -5
  204. data/test/types/tidy.rb +5 -14
  205. data/test/types/type.rb +67 -11
  206. data/test/types/user.rb +25 -23
  207. metadata +186 -122
  208. data/lib/puppet/type/pfile/create.rb +0 -108
  209. data/lib/puppet/type/pprocess.rb +0 -97
  210. data/lib/puppet/type/typegen.rb +0 -149
  211. data/lib/puppet/type/typegen/filerecord.rb +0 -243
  212. data/lib/puppet/type/typegen/filetype.rb +0 -316
  213. data/test/other/state.rb +0 -106
@@ -1,154 +1,22 @@
1
1
  # the available clients
2
2
 
3
3
  require 'puppet'
4
- require 'puppet/sslcertificates'
5
- require 'puppet/type'
6
- require 'facter'
7
- require 'openssl'
8
- require 'puppet/transaction'
9
- require 'puppet/transportable'
10
- require 'puppet/metric'
11
- require 'puppet/daemon'
12
- require 'puppet/server'
13
- require 'puppet/base64'
14
-
15
- $noclientnetworking = false
16
- begin
17
- require 'webrick'
18
- require 'cgi'
19
- require 'xmlrpc/client'
20
- require 'xmlrpc/server'
21
- rescue LoadError => detail
22
- $noclientnetworking = detail
23
- end
4
+ require 'puppet/networkclient'
24
5
 
25
6
  module Puppet
26
- class NetworkClientError < RuntimeError; end
27
- class ClientError < RuntimeError; end
28
- #---------------------------------------------------------------
29
- if $noclientnetworking
30
- Puppet.err "Could not load client network libs: %s" % $noclientnetworking
31
- else
32
- class NetworkClient < XMLRPC::Client
33
- #include Puppet::Daemon
34
-
35
- # add the methods associated with each namespace
36
- Puppet::Server::Handler.each { |handler|
37
- interface = handler.interface
38
- namespace = interface.prefix
39
-
40
- interface.methods.each { |ary|
41
- method = ary[0]
42
- Puppet.info "Defining %s.%s" % [namespace, method]
43
- self.send(:define_method,method) { |*args|
44
- #Puppet.info "Calling %s" % method
45
- #Puppet.info "peer cert is %s" % @http.peer_cert
46
- #Puppet.info "cert is %s" % @http.cert
47
- begin
48
- call("%s.%s" % [namespace, method.to_s],*args)
49
- rescue OpenSSL::SSL::SSLError => detail
50
- #Puppet.err "Could not call %s.%s: Untrusted certificates" %
51
- # [namespace, method]
52
- raise NetworkClientError,
53
- "Certificates were not trusted"
54
- rescue XMLRPC::FaultException => detail
55
- #Puppet.err "Could not call %s.%s: %s" %
56
- # [namespace, method, detail.faultString]
57
- #raise NetworkClientError,
58
- # "XMLRPC Error: %s" % detail.faultString
59
- raise NetworkClientError, detail.faultString
60
- rescue Errno::ECONNREFUSED => detail
61
- msg = "Could not connect to %s on port %s" % [@host, @port]
62
- #Puppet.err msg
63
- raise NetworkClientError, msg
64
- rescue SocketError => detail
65
- Puppet.err "Could not find server %s" % @puppetserver
66
- exit(12)
67
- rescue => detail
68
- Puppet.err "Could not call %s.%s: %s" %
69
- [namespace, method, detail.inspect]
70
- #raise NetworkClientError.new(detail.to_s)
71
- raise
72
- end
73
- }
74
- }
75
- }
76
-
77
- def ca_file=(cafile)
78
- @http.ca_file = cafile
79
- store = OpenSSL::X509::Store.new
80
- cacert = OpenSSL::X509::Certificate.new(
81
- File.read(cafile)
82
- )
83
- store.add_cert(cacert)
84
- store.purpose = OpenSSL::X509::PURPOSE_SSL_CLIENT
85
- @http.cert_store = store
86
- end
87
-
88
- def cert=(cert)
89
- #Puppet.debug "Adding certificate"
90
- @http.cert = cert
91
- @http.verify_mode = OpenSSL::SSL::VERIFY_PEER
92
- end
93
-
94
- def key=(key)
95
- @http.key = key
96
- end
97
-
98
- def initialize(hash)
99
- hash[:Path] ||= "/RPC2"
100
- hash[:Server] ||= "localhost"
101
- hash[:Port] ||= Puppet[:masterport]
102
- Puppet.debug "Creating client for %s" % hash[:Server]
103
-
104
- @puppetserver = hash[:Server]
105
-
106
- super(
107
- hash[:Server],
108
- hash[:Path],
109
- hash[:Port],
110
- nil, # proxy_host
111
- nil, # proxy_port
112
- nil, # user
113
- nil, # password
114
- true # use_ssl
115
- )
116
-
117
- if hash[:Certificate]
118
- self.cert = hash[:Certificate]
119
- else
120
- Puppet.err "No certificate; running with reduced functionality."
121
- end
122
-
123
- if hash[:Key]
124
- self.key = hash[:Key]
125
- end
126
-
127
- if hash[:CAFile]
128
- self.ca_file = hash[:CAFile]
129
- end
130
-
131
- # from here, i need to add the key, cert, and ca cert
132
- # and reorgize how i start the client
133
- end
134
-
135
- def local
136
- false
137
- end
138
- end
139
- end
140
-
141
7
  # FIXME this still isn't a good design, because none of the handlers overlap
142
8
  # so i could just as easily include them all in the main module
143
9
  # but at least it's better organized for now
144
10
  class Client
145
11
  include Puppet
12
+ include SignalObserver
146
13
 
147
14
  # FIXME the cert stuff should only come up with networking, so it
148
15
  # should be in the network client, not the normal client
149
16
  # but if i do that, it's hard to tell whether the certs have been initialized
150
17
  include Puppet::Daemon
151
18
  attr_reader :local, :secureinit
19
+ attr_accessor :schedule, :lastrun
152
20
 
153
21
  class << self
154
22
  attr_reader :drivername
@@ -215,305 +83,72 @@ module Puppet
215
83
  end
216
84
  end
217
85
 
218
- def setcerts
219
- @driver.cert = @cert
220
- @driver.key = @key
221
- @driver.ca_file = @cacertfile
222
- end
223
-
224
- class MasterClient < Puppet::Client
225
- @drivername = :Master
226
-
227
- def self.facts
228
- facts = {}
229
- Facter.each { |name,fact|
230
- facts[name] = fact.downcase
231
- }
232
-
233
- facts
234
- end
235
-
236
- # this method is how the client receives the tree of Transportable
237
- # objects
238
- # for now, just descend into the tree and perform and necessary
239
- # manipulations
240
- def apply
241
- unless defined? @objects
242
- raise Puppet::Error, "Cannot apply; objects not defined"
243
- end
244
-
245
- begin
246
- Puppet::Storage.init
247
- Puppet::Storage.load
248
- rescue => detail
249
- Puppet.err "Corrupt state file %s" % Puppet[:checksumfile]
250
- begin
251
- File.unlink(Puppet[:checksumfile])
252
- retry
253
- rescue => detail
254
- raise Puppet::Error.new("Cannot remove %s: %s" %
255
- [Puppet[statefile], detail])
256
- end
257
- end
258
-
259
- # FIXME this should be in getconfig, not apply
260
- container = @objects.to_type
261
- #if @local
262
- # container = @objects.to_type
263
- #else
264
- # container = Marshal::load(@objects).to_type
265
- #end
266
-
267
- # this is a gross hack... but i don't see a good way around it
268
- # set all of the variables to empty
269
- Puppet::Transaction.init
270
-
271
- # for now we just evaluate the top-level container, but eventually
272
- # there will be schedules and such associated with each object,
273
- # and probably with the container itself
274
- transaction = container.evaluate
275
- #transaction = Puppet::Transaction.new(objects)
276
- transaction.toplevel = true
277
- begin
278
- transaction.evaluate
279
- rescue Puppet::Error => detail
280
- Puppet.err "Could not apply complete configuration: %s" %
281
- detail
282
- rescue => detail
283
- Puppet.err "Found a bug: %s" % detail
284
- end
285
- Puppet::Metric.gather
286
- Puppet::Metric.tally
287
- if Puppet[:rrdgraph] == true
288
- Metric.store
289
- Metric.graph
290
- end
291
- Puppet::Storage.store
292
-
293
- return transaction
294
- end
295
-
296
- def getconfig
297
- #client.loadproperty('files/sslclient.properties')
298
- Puppet.debug("getting config")
299
-
300
- facts = self.class.facts
301
-
302
- unless facts.length > 0
303
- raise Puppet::ClientError.new(
304
- "Could not retrieve any facts"
305
- )
306
- end
307
-
308
- objects = nil
309
- if @local
310
- objects = @driver.getconfig(facts)
311
-
312
- if objects == ""
313
- raise Puppet::Error, "Could not retrieve configuration"
314
- end
315
- else
316
- textfacts = CGI.escape(Marshal::dump(facts))
317
-
318
- # error handling for this is done in the network client
319
- textobjects = @driver.getconfig(textfacts)
320
-
321
- unless textobjects == ""
322
- begin
323
- textobjects = CGI.unescape(textobjects)
324
- rescue => detail
325
- raise Puppet::Error, "Could not CGI.unescape configuration"
326
- end
327
- end
328
-
329
- if @cache
330
- if textobjects == ""
331
- if FileTest.exists?(Puppet[:localconfig])
332
- textobjects = File.read(Puppet[:localconfig])
333
- else
334
- raise Puppet::Error.new(
335
- "Cannot connect to server and there is no cached configuration"
336
- )
337
- end
338
- else
339
- # we store the config so that if we can't connect next time, we
340
- # can just run against the most recently acquired copy
341
- confdir = File.dirname(Puppet[:localconfig])
342
- unless FileTest.exists?(confdir)
343
- Puppet.recmkdir(confdir, 0770)
344
- end
345
- File.open(Puppet[:localconfig], "w", 0660) { |f|
346
- f.print textobjects
347
- }
348
- end
349
- elsif textobjects == ""
350
- raise Puppet::Error, "Could not retrieve configuration"
351
- end
352
-
353
- begin
354
- objects = Marshal::load(textobjects)
355
- rescue => detail
356
- raise Puppet::Error.new("Could not understand configuration")
357
- end
358
- end
359
- if objects.is_a?(Puppet::TransBucket)
360
- @objects = objects
361
- else
362
- raise NetworkClientError,
363
- "Invalid returned objects of type %s" % objects.class
364
- end
86
+ # A wrapper method to run and then store the last run time
87
+ def runnow
88
+ begin
89
+ self.run
90
+ self.lastrun = Time.now.to_i
91
+ rescue => detail
92
+ Puppet.err "Could not run %s: %s" % [self.class, detail]
365
93
  end
366
94
  end
367
95
 
368
- class Dipper < Puppet::Client
369
- @drivername = :Bucket
370
-
371
- def initialize(hash = {})
372
- if hash.include?(:Path)
373
- bucket = Puppet::Server::FileBucket.new(
374
- :Bucket => hash[:Path]
375
- )
376
- hash.delete(:Path)
377
- hash[:Bucket] = bucket
378
- end
379
-
380
- super(hash)
381
- end
382
-
383
- def backup(file)
384
- unless FileTest.exists?(file)
385
- raise(BucketError, "File %s does not exist" % file, caller)
386
- end
387
- contents = File.open(file) { |of| of.read }
388
-
389
- string = Base64.encode64(contents)
390
- #puts "string is created"
391
-
392
- sum = @driver.addfile(string,file)
393
- #puts "file %s is added" % file
394
- return sum
395
- end
396
-
397
- def restore(file,sum)
398
- restore = true
399
- if FileTest.exists?(file)
400
- contents = File.open(file) { |of| of.read }
401
-
402
- cursum = Digest::MD5.hexdigest(contents)
403
-
404
- # if the checksum has changed...
405
- # this might be extra effort
406
- if cursum == sum
407
- restore = false
408
- end
409
- end
410
-
411
- if restore
412
- #puts "Restoring %s" % file
413
- if tmp = @driver.getfile(sum)
414
- newcontents = Base64.decode64(tmp)
415
- newsum = Digest::MD5.hexdigest(newcontents)
416
- File.open(file,File::WRONLY|File::TRUNC) { |of|
417
- of.print(newcontents)
418
- }
419
- else
420
- Puppet.err "Could not find file with checksum %s" % sum
421
- return nil
422
- end
423
- #puts "Done"
424
- return newsum
425
- else
426
- return nil
427
- end
428
-
429
- end
96
+ def run
97
+ raise Puppet::DevError, "Client type %s did not override run" %
98
+ self.class
430
99
  end
431
100
 
432
- # unlike the other client classes (again, this design sucks) this class
433
- # is basically just a proxy class -- it calls its methods on the driver
434
- # and that's about it
435
- class ProxyClient < Puppet::Client
436
- def self.mkmethods
437
- interface = @handler.interface
438
- namespace = interface.prefix
439
-
440
- interface.methods.each { |ary|
441
- method = ary[0]
442
- Puppet.debug "%s: defining %s.%s" % [self, namespace, method]
443
- self.send(:define_method,method) { |*args|
444
- begin
445
- @driver.send(method, *args)
446
- rescue XMLRPC::FaultException => detail
447
- #Puppet.err "Could not call %s.%s: %s" %
448
- # [namespace, method, detail.faultString]
449
- #raise NetworkClientError,
450
- # "XMLRPC Error: %s" % detail.faultString
451
- raise NetworkClientError, detail.faultString
452
- end
453
- }
454
- }
101
+ def scheduled?
102
+ if sched = self.schedule
103
+ return sched.match?(self.lastrun)
104
+ else
105
+ return true
455
106
  end
456
107
  end
457
108
 
458
- class FileClient < Puppet::Client::ProxyClient
459
- @drivername = :FileServer
460
-
461
- # set up the appropriate interface methods
462
- @handler = Puppet::Server::FileServer
463
-
464
- self.mkmethods
465
-
466
- def initialize(hash = {})
467
- if hash.include?(:FileServer)
468
- unless hash[:FileServer].is_a?(Puppet::Server::FileServer)
469
- raise Puppet::DevError, "Must pass an actual FS object"
470
- end
471
- end
472
-
473
- super(hash)
474
- end
109
+ def setcerts
110
+ @driver.cert = @cert
111
+ @driver.key = @key
112
+ @driver.ca_file = @cacertfile
475
113
  end
476
114
 
477
- class CAClient < Puppet::Client::ProxyClient
478
- @drivername = :CA
479
-
480
- # set up the appropriate interface methods
481
- @handler = Puppet::Server::CA
482
- self.mkmethods
483
-
484
- def initialize(hash = {})
485
- if hash.include?(:CA)
486
- hash[:CA] = Puppet::Server::CA.new()
487
- end
488
-
489
- super(hash)
490
- end
115
+ def shutdown
116
+ Puppet::Storage.store
117
+ exit
491
118
  end
492
119
 
493
- class LogClient < Puppet::Client::ProxyClient
494
- @drivername = :Logger
120
+ # Start listening for events. We're pretty much just listening for
121
+ # timer events here.
122
+ def start
123
+ # Create our timer
124
+ timer = EventLoop::Timer.new(
125
+ :interval => Puppet[:runinterval],
126
+ :tolerance => 1,
127
+ :start? => true
128
+ )
495
129
 
496
- # set up the appropriate interface methods
497
- @handler = Puppet::Server::Logger
498
- self.mkmethods
130
+ # Stick it in the loop
131
+ EventLoop.current.monitor_timer timer
499
132
 
500
- def initialize(hash = {})
501
- if hash.include?(:Logger)
502
- hash[:Logger] = Puppet::Server::Logger.new()
503
- end
133
+ # Run once before we start following the timer
134
+ self.runnow
504
135
 
505
- super(hash)
136
+ # And run indefinitely
137
+ observe_signal timer, :alarm do
138
+ if self.scheduled?
139
+ self.runnow
140
+ end
506
141
  end
507
142
  end
508
143
 
509
- class StatusClient < Puppet::Client::ProxyClient
510
- # set up the appropriate interface methods
511
- @handler = Puppet::Server::ServerStatus
512
- self.mkmethods
513
- end
514
-
144
+ require 'puppet/client/proxy'
145
+ require 'puppet/client/ca'
146
+ require 'puppet/client/dipper'
147
+ require 'puppet/client/file'
148
+ require 'puppet/client/log'
149
+ require 'puppet/client/master'
150
+ require 'puppet/client/status'
515
151
  end
516
- #---------------------------------------------------------------
517
152
  end
518
153
 
519
- # $Id: client.rb 740 2005-11-01 20:22:19Z luke $
154
+ # $Id: client.rb 849 2006-01-24 06:37:00Z luke $