puppet 0.16.0 → 0.18.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +98 -0
- data/Rakefile +5 -1
- data/bin/puppet +1 -1
- data/bin/puppetca +25 -11
- data/bin/puppetd +189 -66
- data/bin/puppetdoc +79 -62
- data/bin/puppetmasterd +93 -49
- data/bin/puppetrun +385 -0
- data/conf/redhat/client.init +5 -2
- data/conf/redhat/fileserver.conf +1 -1
- data/conf/redhat/lsb-config.patch +51 -0
- data/conf/redhat/puppet.spec +45 -18
- data/conf/redhat/puppetd.conf +32 -4
- data/conf/redhat/server.init +5 -2
- data/conf/solaris/pkginfo +7 -0
- data/conf/solaris/smf/puppetd.xml +77 -0
- data/conf/solaris/smf/puppetmasterd.xml +77 -0
- data/conf/solaris/smf/svc-puppetd +66 -0
- data/conf/solaris/smf/svc-puppetmasterd +62 -0
- data/examples/code/failers/noobjectrvalue +1 -0
- data/examples/code/snippets/deepclassheirarchy.pp +23 -0
- data/examples/code/snippets/defineoverrides.pp +17 -0
- data/examples/code/snippets/emptyexec.pp +3 -0
- data/examples/code/snippets/selectorvalues.pp +6 -1
- data/examples/code/snippets/tagged.pp +35 -0
- data/ext/ldap/puppet.schema +2 -2
- data/install.rb +4 -2
- data/lib/puppet.rb +206 -15
- data/lib/puppet/client.rb +30 -20
- data/lib/puppet/client/ca.rb +2 -2
- data/lib/puppet/client/dipper.rb +5 -9
- data/lib/puppet/client/master.rb +224 -44
- data/lib/puppet/client/pelement.rb +54 -9
- data/lib/puppet/client/proxy.rb +3 -2
- data/lib/puppet/client/reporter.rb +34 -0
- data/lib/puppet/client/runner.rb +17 -0
- data/lib/puppet/config.rb +136 -55
- data/lib/puppet/daemon.rb +59 -37
- data/lib/puppet/element.rb +2 -1
- data/lib/puppet/event.rb +14 -3
- data/lib/puppet/filetype.rb +28 -19
- data/lib/puppet/log.rb +297 -132
- data/lib/puppet/metric.rb +31 -131
- data/lib/puppet/networkclient.rb +73 -46
- data/lib/puppet/parameter.rb +49 -1
- data/lib/puppet/parsedfile.rb +32 -12
- data/lib/puppet/parser/ast.rb +6 -1
- data/lib/puppet/parser/ast/astarray.rb +32 -6
- data/lib/puppet/parser/ast/collection.rb +91 -0
- data/lib/puppet/parser/ast/compdef.rb +2 -2
- data/lib/puppet/parser/ast/component.rb +24 -11
- data/lib/puppet/parser/ast/function.rb +50 -0
- data/lib/puppet/parser/ast/hostclass.rb +70 -22
- data/lib/puppet/parser/ast/node.rb +17 -8
- data/lib/puppet/parser/ast/nodedef.rb +1 -1
- data/lib/puppet/parser/ast/objectdef.rb +28 -10
- data/lib/puppet/parser/ast/selector.rb +4 -1
- data/lib/puppet/parser/functions.rb +145 -0
- data/lib/puppet/parser/interpreter.rb +243 -86
- data/lib/puppet/parser/lexer.rb +5 -4
- data/lib/puppet/parser/parser.rb +586 -505
- data/lib/puppet/parser/scope.rb +337 -187
- data/lib/puppet/rails.rb +115 -0
- data/lib/puppet/rails/database.rb +40 -0
- data/lib/puppet/rails/host.rb +83 -0
- data/lib/puppet/rails/rails_object.rb +42 -0
- data/lib/puppet/rails/rails_parameter.rb +5 -0
- data/lib/puppet/reports/rrdgraph.rb +20 -0
- data/lib/puppet/reports/tagmail.rb +94 -0
- data/lib/puppet/server.rb +20 -4
- data/lib/puppet/server/authconfig.rb +14 -3
- data/lib/puppet/server/authstore.rb +2 -2
- data/lib/puppet/server/ca.rb +23 -11
- data/lib/puppet/server/filebucket.rb +10 -10
- data/lib/puppet/server/fileserver.rb +4 -8
- data/lib/puppet/server/master.rb +19 -22
- data/lib/puppet/server/pelement.rb +28 -16
- data/lib/puppet/server/report.rb +184 -0
- data/lib/puppet/server/runner.rb +62 -0
- data/lib/puppet/server/servlet.rb +23 -9
- data/lib/puppet/sslcertificates/ca.rb +25 -1
- data/lib/puppet/statechange.rb +34 -53
- data/lib/puppet/storage.rb +1 -2
- data/lib/puppet/transaction.rb +305 -133
- data/lib/puppet/transaction/report.rb +42 -0
- data/lib/puppet/transportable.rb +57 -33
- data/lib/puppet/type.rb +260 -127
- data/lib/puppet/type/component.rb +9 -21
- data/lib/puppet/type/cron.rb +367 -116
- data/lib/puppet/type/exec.rb +15 -16
- data/lib/puppet/type/group.rb +9 -1
- data/lib/puppet/type/nameservice.rb +2 -5
- data/lib/puppet/type/nameservice/netinfo.rb +3 -0
- data/lib/puppet/type/nameservice/objectadd.rb +23 -10
- data/lib/puppet/type/nameservice/pw.rb +16 -3
- data/lib/puppet/type/package.rb +25 -75
- data/lib/puppet/type/package/apple.rb +15 -1
- data/lib/puppet/type/package/apt.rb +37 -2
- data/lib/puppet/type/package/blastwave.rb +136 -0
- data/lib/puppet/type/package/dpkg.rb +4 -4
- data/lib/puppet/type/package/gem.rb +119 -0
- data/lib/puppet/type/package/openbsd.rb +7 -6
- data/lib/puppet/type/package/ports.rb +7 -2
- data/lib/puppet/type/package/rpm.rb +1 -1
- data/lib/puppet/type/package/sun.rb +23 -9
- data/lib/puppet/type/package/sunfreeware.rb +7 -0
- data/lib/puppet/type/package/yum.rb +16 -9
- data/lib/puppet/type/parsedtype.rb +7 -5
- data/lib/puppet/type/parsedtype/mount.rb +55 -34
- data/lib/puppet/type/parsedtype/port.rb +7 -1
- data/lib/puppet/type/parsedtype/sshkey.rb +6 -16
- data/lib/puppet/type/pfile.rb +115 -23
- data/lib/puppet/type/pfile/checksum.rb +18 -5
- data/lib/puppet/type/pfile/content.rb +2 -2
- data/lib/puppet/type/pfile/ensure.rb +3 -3
- data/lib/puppet/type/pfile/group.rb +2 -2
- data/lib/puppet/type/pfile/source.rb +28 -17
- data/lib/puppet/type/pfile/target.rb +25 -17
- data/lib/puppet/type/pfilebucket.rb +25 -6
- data/lib/puppet/type/schedule.rb +6 -6
- data/lib/puppet/type/service.rb +24 -14
- data/lib/puppet/type/service/debian.rb +1 -1
- data/lib/puppet/type/service/redhat.rb +13 -10
- data/lib/puppet/type/service/smf.rb +3 -3
- data/lib/puppet/type/state.rb +1 -2
- data/lib/puppet/type/symlink.rb +3 -4
- data/lib/puppet/type/user.rb +22 -10
- data/lib/puppet/type/yumrepo.rb +6 -1
- data/lib/puppet/type/zone.rb +595 -0
- data/lib/puppet/util.rb +58 -12
- data/test/client/client.rb +2 -2
- data/test/client/master.rb +92 -3
- data/test/client/pelement.rb +99 -0
- data/test/executables/puppetbin.rb +3 -4
- data/test/executables/puppetca.rb +3 -3
- data/test/executables/puppetd.rb +3 -3
- data/test/executables/puppetmasterd.rb +1 -5
- data/test/executables/puppetmodule.rb +2 -2
- data/test/language/ast.rb +200 -11
- data/test/language/functions.rb +245 -0
- data/test/language/interpreter.rb +155 -6
- data/test/language/lexer.rb +35 -2
- data/test/language/node.rb +48 -1
- data/test/language/parser.rb +250 -1
- data/test/language/rails.rb +105 -0
- data/test/language/scope.rb +304 -10
- data/test/language/snippets.rb +54 -5
- data/test/language/transportable.rb +60 -28
- data/test/other/config.rb +214 -1
- data/test/other/events.rb +67 -9
- data/test/other/log.rb +31 -5
- data/test/other/metrics.rb +23 -21
- data/test/other/parsedfile.rb +29 -2
- data/test/other/puppet.rb +79 -0
- data/test/other/report.rb +106 -0
- data/test/other/storage.rb +2 -2
- data/test/other/transactions.rb +128 -2
- data/test/puppet/utiltest.rb +10 -5
- data/test/puppettest.rb +193 -21
- data/test/server/authstore.rb +13 -4
- data/test/server/bucket.rb +33 -8
- data/test/server/ca.rb +44 -6
- data/test/server/master.rb +6 -7
- data/test/server/pelement.rb +15 -5
- data/test/server/report.rb +93 -0
- data/test/server/runner.rb +107 -0
- data/test/server/server.rb +28 -1
- data/test/types/cron.rb +339 -31
- data/test/types/file.rb +256 -24
- data/test/types/filebucket.rb +6 -2
- data/test/types/filesources.rb +41 -92
- data/test/types/group.rb +31 -1
- data/test/types/host.rb +2 -1
- data/test/types/mount.rb +18 -1
- data/test/types/package.rb +200 -18
- data/test/types/service.rb +5 -1
- data/test/types/sshkey.rb +2 -1
- data/test/types/symlink.rb +3 -2
- data/test/types/type.rb +180 -1
- data/test/types/user.rb +65 -27
- data/test/types/yumrepo.rb +15 -0
- data/test/types/zone.rb +437 -0
- metadata +43 -4
- data/bin/cf2puppet +0 -186
- data/conf/redhat/puppetmasterd.conf +0 -5
data/lib/puppet/metric.rb
CHANGED
@@ -4,133 +4,28 @@ require 'puppet'
|
|
4
4
|
module Puppet
|
5
5
|
# A class for handling metrics. This is currently ridiculously hackish.
|
6
6
|
class Metric
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
Metric.init
|
19
|
-
end
|
20
|
-
|
21
|
-
def Metric.gather
|
22
|
-
Metric.init
|
23
|
-
|
24
|
-
# first gather stats about all of the types
|
25
|
-
Puppet::Type.eachtype { |type|
|
26
|
-
type.each { |instance|
|
27
|
-
hash = @@typemetrics[type]
|
28
|
-
hash[:total] += 1
|
29
|
-
if instance.managed?
|
30
|
-
hash[:managed] += 1
|
31
|
-
end
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
# the rest of the metrics are injected directly by type.rb
|
36
|
-
end
|
37
|
-
|
38
|
-
def Metric.add(type,instance,metric,count)
|
39
|
-
return unless defined? @@typemetrics
|
40
|
-
case metric
|
41
|
-
when :outofsync:
|
42
|
-
@@typemetrics[type][metric] += count
|
43
|
-
when :changes:
|
44
|
-
@@typemetrics[type][:changed] += 1
|
45
|
-
@@typemetrics[type][:totalchanges] += count
|
46
|
-
else
|
47
|
-
raise Puppet::DevError, "Unknown metric %s" % metric
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# we're currently throwing away the type and instance information
|
52
|
-
def Metric.addevents(type,instance,events)
|
53
|
-
return unless defined? @@eventmetrics
|
54
|
-
events.each { |event|
|
55
|
-
@@eventmetrics[event] += 1
|
56
|
-
}
|
57
|
-
end
|
58
|
-
|
59
|
-
# Iterate across all of the metrics
|
60
|
-
def Metric.each
|
61
|
-
@@metrics.each { |name,metric|
|
62
|
-
yield metric
|
63
|
-
}
|
64
|
-
end
|
65
|
-
|
66
|
-
# I'm nearly positive this method is used only for testing
|
67
|
-
def Metric.load(ary)
|
68
|
-
@@typemetrics = ary[0]
|
69
|
-
@@eventmetrics = ary[1]
|
70
|
-
end
|
71
|
-
|
72
|
-
def Metric.graph(range = nil)
|
73
|
-
@@metrics.each { |name,metric|
|
74
|
-
metric.graph(range)
|
75
|
-
}
|
76
|
-
end
|
77
|
-
|
78
|
-
def Metric.store(time = nil)
|
7
|
+
Puppet.config.setdefaults("metrics",
|
8
|
+
:rrddir => {:default => "$vardir/rrd",
|
9
|
+
:owner => "$user",
|
10
|
+
:group => "$group",
|
11
|
+
:desc => "The directory where RRD database files are stored."
|
12
|
+
},
|
13
|
+
:rrdgraph => [false, "Whether RRD information should be graphed."]
|
14
|
+
)
|
15
|
+
|
16
|
+
@@haverrd = false
|
17
|
+
begin
|
79
18
|
require 'RRD'
|
80
|
-
|
81
|
-
|
82
|
-
end
|
83
|
-
@@metrics.each { |name,metric|
|
84
|
-
metric.store(time)
|
85
|
-
}
|
19
|
+
@@haverrd = true
|
20
|
+
rescue LoadError
|
86
21
|
end
|
87
22
|
|
88
|
-
def
|
89
|
-
|
90
|
-
type.newvalue("Number",@@typemetrics.length)
|
91
|
-
|
92
|
-
metrics = {
|
93
|
-
:total => "Instances",
|
94
|
-
:managed => "Managed Instances",
|
95
|
-
:outofsync => "Out of Sync Instances",
|
96
|
-
:changed => "Changed Instances",
|
97
|
-
:totalchanges => "Total Number of Changes",
|
98
|
-
}
|
99
|
-
total = Hash.new(0)
|
100
|
-
@@typemetrics.each { |type,instancehash|
|
101
|
-
name = type.name.to_s
|
102
|
-
instmet = Metric.new("type-" + name,name.capitalize)
|
103
|
-
metrics.each { |symbol,label|
|
104
|
-
instmet.newvalue(symbol.to_s,instancehash[symbol],label)
|
105
|
-
total[symbol] += instancehash[symbol]
|
106
|
-
}
|
107
|
-
}
|
108
|
-
|
109
|
-
totalmet = Metric.new("typetotals","Type Totals")
|
110
|
-
metrics.each { |symbol,label|
|
111
|
-
totalmet.newvalue(symbol.to_s,total[symbol],label)
|
112
|
-
}
|
113
|
-
|
114
|
-
eventmet = Metric.new("events")
|
115
|
-
total = 0
|
116
|
-
@@eventmetrics.each { |event,count|
|
117
|
-
event = event.to_s
|
118
|
-
# add the specific event as a value, with the label being a
|
119
|
-
# capitalized version with s/_/ /g
|
120
|
-
eventmet.newvalue(
|
121
|
-
event,
|
122
|
-
count,
|
123
|
-
event.capitalize.gsub(/_/,' ')
|
124
|
-
)
|
125
|
-
|
126
|
-
total += count
|
127
|
-
}
|
128
|
-
eventmet.newvalue("total",total,"Event Total")
|
23
|
+
def self.haverrd?
|
24
|
+
@@haverrd
|
129
25
|
end
|
130
26
|
|
131
27
|
attr_accessor :type, :name, :value, :label
|
132
28
|
|
133
|
-
|
134
29
|
def create
|
135
30
|
Puppet.config.use(:metrics)
|
136
31
|
|
@@ -154,24 +49,20 @@ module Puppet
|
|
154
49
|
end
|
155
50
|
|
156
51
|
def initialize(name,label = nil)
|
157
|
-
@name = name
|
52
|
+
@name = name.to_s
|
53
|
+
|
158
54
|
if label
|
159
55
|
@label = label
|
160
56
|
else
|
161
|
-
@label = name.capitalize
|
57
|
+
@label = name.to_s.capitalize.gsub("_", " ")
|
162
58
|
end
|
163
59
|
|
164
60
|
@values = []
|
165
|
-
if @@metrics.include?(self.name)
|
166
|
-
raise "Somehow created two metrics with name %s" % self.name
|
167
|
-
else
|
168
|
-
@@metrics[self.name] = self
|
169
|
-
end
|
170
61
|
end
|
171
62
|
|
172
63
|
def newvalue(name,value,label = nil)
|
173
64
|
unless label
|
174
|
-
label = name.capitalize
|
65
|
+
label = name.to_s.capitalize.gsub("_", " ")
|
175
66
|
end
|
176
67
|
@values.push [name,label,value]
|
177
68
|
end
|
@@ -181,11 +72,16 @@ module Puppet
|
|
181
72
|
end
|
182
73
|
|
183
74
|
def graph(range = nil)
|
75
|
+
unless @@haverrd
|
76
|
+
Puppet.warning "RRD library is missing; cannot graph metrics"
|
77
|
+
return
|
78
|
+
end
|
184
79
|
args = [self.path.sub(/rrd$/,"png")]
|
80
|
+
|
185
81
|
args.push("--title",self.label)
|
186
82
|
args.push("--imgformat","PNG")
|
187
83
|
args.push("--interlace")
|
188
|
-
colorstack = %w{#ff0000 #00ff00 #0000ff #099000 #000990 #f00990}
|
84
|
+
colorstack = %w{#ff0000 #00ff00 #0000ff #099000 #000990 #f00990 #0f0f0f}
|
189
85
|
i = 0
|
190
86
|
defs = []
|
191
87
|
lines = []
|
@@ -210,7 +106,11 @@ module Puppet
|
|
210
106
|
end
|
211
107
|
|
212
108
|
def store(time)
|
213
|
-
unless
|
109
|
+
unless @@haverrd
|
110
|
+
Puppet.warning "RRD library is missing; cannot store metrics"
|
111
|
+
return
|
112
|
+
end
|
113
|
+
unless FileTest.exists?(self.path)
|
214
114
|
self.create
|
215
115
|
end
|
216
116
|
|
@@ -229,4 +129,4 @@ module Puppet
|
|
229
129
|
end
|
230
130
|
end
|
231
131
|
|
232
|
-
# $Id: metric.rb
|
132
|
+
# $Id: metric.rb 1358 2006-07-04 16:07:47Z luke $
|
data/lib/puppet/networkclient.rb
CHANGED
@@ -30,52 +30,75 @@ module Puppet
|
|
30
30
|
Puppet.err "Could not load client network libs: %s" % $noclientnetworking
|
31
31
|
else
|
32
32
|
class NetworkClient < XMLRPC::Client
|
33
|
-
|
34
|
-
|
35
|
-
#
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
-
if Puppet[:debug]
|
72
|
-
puts detail.backtrace
|
73
|
-
end
|
74
|
-
raise
|
33
|
+
@clients = {}
|
34
|
+
|
35
|
+
# Create a netclient for each handler
|
36
|
+
def self.mkclients
|
37
|
+
# add the methods associated with each namespace
|
38
|
+
Puppet::Server::Handler.each { |handler|
|
39
|
+
interface = handler.interface
|
40
|
+
namespace = interface.prefix
|
41
|
+
|
42
|
+
# Create a subclass for every client type. This is
|
43
|
+
# so that all of the methods are on their own class,
|
44
|
+
# so that they namespaces can define the same methods if
|
45
|
+
# they want.
|
46
|
+
newclient = Class.new(self)
|
47
|
+
|
48
|
+
#name = "Puppet::NetworkClient::" + handler.to_s.sub(/^.+::/, '')
|
49
|
+
name = handler.to_s.sub(/^.+::/, '')
|
50
|
+
const_set(name, newclient)
|
51
|
+
@clients[namespace] = newclient
|
52
|
+
|
53
|
+
interface.methods.each { |ary|
|
54
|
+
method = ary[0]
|
55
|
+
if public_method_defined?(method)
|
56
|
+
raise Puppet::DevError, "Method %s is already defined" %
|
57
|
+
method
|
75
58
|
end
|
59
|
+
newclient.send(:define_method,method) { |*args|
|
60
|
+
Puppet.debug "Calling %s.%s" % [namespace, method]
|
61
|
+
#Puppet.info "peer cert is %s" % @http.peer_cert
|
62
|
+
#Puppet.info "cert is %s" % @http.cert
|
63
|
+
begin
|
64
|
+
call("%s.%s" % [namespace, method.to_s],*args)
|
65
|
+
rescue OpenSSL::SSL::SSLError => detail
|
66
|
+
raise NetworkClientError,
|
67
|
+
"Certificates were not trusted: %s" % detail
|
68
|
+
rescue XMLRPC::FaultException => detail
|
69
|
+
#Puppet.err "Could not call %s.%s: %s" %
|
70
|
+
# [namespace, method, detail.faultString]
|
71
|
+
#raise NetworkClientError,
|
72
|
+
# "XMLRPC Error: %s" % detail.faultString
|
73
|
+
raise NetworkClientError, detail.faultString
|
74
|
+
rescue Errno::ECONNREFUSED => detail
|
75
|
+
msg = "Could not connect to %s on port %s" %
|
76
|
+
[@host, @port]
|
77
|
+
raise NetworkClientError, msg
|
78
|
+
rescue SocketError => detail
|
79
|
+
Puppet.err "Could not find server %s" % @puppetserver
|
80
|
+
exit(12)
|
81
|
+
rescue => detail
|
82
|
+
Puppet.err "Could not call %s.%s: %s" %
|
83
|
+
[namespace, method, detail.inspect]
|
84
|
+
#raise NetworkClientError.new(detail.to_s)
|
85
|
+
if Puppet[:debug]
|
86
|
+
puts detail.backtrace
|
87
|
+
end
|
88
|
+
raise
|
89
|
+
end
|
90
|
+
}
|
76
91
|
}
|
77
92
|
}
|
78
|
-
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.netclient(namespace)
|
96
|
+
if @clients.empty?
|
97
|
+
self.mkclients()
|
98
|
+
end
|
99
|
+
|
100
|
+
@clients[namespace]
|
101
|
+
end
|
79
102
|
|
80
103
|
def ca_file=(cafile)
|
81
104
|
@http.ca_file = cafile
|
@@ -113,13 +136,17 @@ module Puppet
|
|
113
136
|
nil, # proxy_port
|
114
137
|
nil, # user
|
115
138
|
nil, # password
|
116
|
-
true # use_ssl
|
139
|
+
true, # use_ssl
|
140
|
+
120 # a two minute timeout, instead of 30 seconds
|
117
141
|
)
|
118
142
|
|
119
143
|
if hash[:Certificate]
|
120
144
|
self.cert = hash[:Certificate]
|
121
145
|
else
|
122
|
-
|
146
|
+
unless defined? $nocertwarned
|
147
|
+
Puppet.err "No certificate; running with reduced functionality."
|
148
|
+
$nocertwarned = true
|
149
|
+
end
|
123
150
|
end
|
124
151
|
|
125
152
|
if hash[:Key]
|
@@ -145,4 +172,4 @@ module Puppet
|
|
145
172
|
end
|
146
173
|
end
|
147
174
|
|
148
|
-
# $Id: networkclient.rb
|
175
|
+
# $Id: networkclient.rb 1385 2006-07-11 17:36:32Z luke $
|
data/lib/puppet/parameter.rb
CHANGED
@@ -19,6 +19,48 @@ module Puppet
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
# Return a documentation string. If there are valid values,
|
23
|
+
# then tack them onto the string.
|
24
|
+
def doc
|
25
|
+
@doc ||= ""
|
26
|
+
|
27
|
+
unless defined? @addeddocvals
|
28
|
+
unless values.empty?
|
29
|
+
if @aliasvalues.empty?
|
30
|
+
@doc += " Valid values are ``" +
|
31
|
+
values.join("``, ``") + "``."
|
32
|
+
else
|
33
|
+
@doc += " Valid values are "
|
34
|
+
|
35
|
+
@doc += values.collect do |value|
|
36
|
+
ary = @aliasvalues.find do |name, val|
|
37
|
+
val == value
|
38
|
+
end
|
39
|
+
if ary
|
40
|
+
"``%s`` (also called ``%s``)" % [value, ary[0]]
|
41
|
+
else
|
42
|
+
"``#{value}``"
|
43
|
+
end
|
44
|
+
end.join(", ") + "."
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
if defined? @parameterregexes and ! @parameterregexes.empty?
|
49
|
+
regs = @parameterregexes
|
50
|
+
if @parameterregexes.is_a? Hash
|
51
|
+
regs = @parameterregexes.keys
|
52
|
+
end
|
53
|
+
unless regs.empty?
|
54
|
+
@doc += " Values can also match ``" +
|
55
|
+
regs.join("``, ``") + "``."
|
56
|
+
end
|
57
|
+
end
|
58
|
+
@addeddocvals = true
|
59
|
+
end
|
60
|
+
|
61
|
+
@doc
|
62
|
+
end
|
63
|
+
|
22
64
|
def nodefault
|
23
65
|
if public_method_defined? :default
|
24
66
|
undef_method :default
|
@@ -187,7 +229,9 @@ module Puppet
|
|
187
229
|
# Just a simple method to proxy instance methods to class methods
|
188
230
|
def self.proxymethods(*values)
|
189
231
|
values.each { |val|
|
190
|
-
|
232
|
+
define_method(val) do
|
233
|
+
self.class.send(val)
|
234
|
+
end
|
191
235
|
}
|
192
236
|
end
|
193
237
|
|
@@ -324,6 +368,10 @@ module Puppet
|
|
324
368
|
end
|
325
369
|
end
|
326
370
|
|
371
|
+
def remove
|
372
|
+
@parent = nil
|
373
|
+
end
|
374
|
+
|
327
375
|
# This should only be called for parameters, but go ahead and make
|
328
376
|
# it possible to call for states, too.
|
329
377
|
def value
|
data/lib/puppet/parsedfile.rb
CHANGED
@@ -4,35 +4,55 @@
|
|
4
4
|
require 'puppet'
|
5
5
|
|
6
6
|
module Puppet
|
7
|
+
class NoSuchFile < Puppet::Error; end
|
7
8
|
class ParsedFile
|
8
9
|
attr_reader :file
|
9
10
|
|
11
|
+
# Provide a hook for setting the timestamp during testing, so we don't
|
12
|
+
# have to depend on the granularity of the filesystem.
|
13
|
+
attr_writer :tstamp
|
14
|
+
|
15
|
+
Puppet.config.setdefaults(:puppet,
|
16
|
+
:filetimeout => [ 15,
|
17
|
+
"The minimum time to wait between checking for updates in
|
18
|
+
configuration files."
|
19
|
+
]
|
20
|
+
)
|
21
|
+
|
10
22
|
# Determine whether the file has changed and thus whether it should
|
11
23
|
# be reparsed
|
12
24
|
def changed?
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
retval = true
|
17
|
-
@stamp = tmp
|
18
|
-
end
|
19
|
-
@statted = Time.now
|
25
|
+
# Don't actually stat the file more often than filetimeout.
|
26
|
+
if Time.now - @statted >= Puppet[:filetimeout]
|
27
|
+
tmp = stamp()
|
20
28
|
|
21
|
-
|
29
|
+
if tmp == @tstamp
|
30
|
+
return false
|
31
|
+
else
|
32
|
+
@tstamp = tmp
|
33
|
+
return true
|
34
|
+
end
|
35
|
+
else
|
36
|
+
return false
|
37
|
+
end
|
22
38
|
end
|
23
39
|
|
24
40
|
# Create the file. Must be passed the file path.
|
25
41
|
def initialize(file)
|
26
42
|
@file = file
|
27
43
|
unless FileTest.exists?(@file)
|
28
|
-
raise Puppet::
|
44
|
+
raise Puppet::NoSuchFile, "Can not use a non-existent file for parsing"
|
29
45
|
end
|
30
|
-
@
|
31
|
-
@statted = Time.now
|
46
|
+
@tstamp = stamp()
|
32
47
|
end
|
33
48
|
|
49
|
+
private
|
50
|
+
|
34
51
|
def stamp
|
35
|
-
|
52
|
+
@statted = Time.now
|
53
|
+
return File.stat(@file).ctime
|
36
54
|
end
|
37
55
|
end
|
38
56
|
end
|
57
|
+
|
58
|
+
# $Id: parsedfile.rb 1422 2006-07-22 03:32:56Z luke $
|