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/parser/ast.rb
CHANGED
@@ -79,6 +79,9 @@ module Puppet
|
|
79
79
|
error.line ||= @line
|
80
80
|
error.file ||= @file
|
81
81
|
error.backtrace = detail.backtrace
|
82
|
+
if Puppet[:debug]
|
83
|
+
puts detail.backtrace
|
84
|
+
end
|
82
85
|
raise error
|
83
86
|
end
|
84
87
|
end
|
@@ -131,6 +134,7 @@ end
|
|
131
134
|
|
132
135
|
require 'puppet/parser/ast/astarray'
|
133
136
|
require 'puppet/parser/ast/branch'
|
137
|
+
require 'puppet/parser/ast/collection'
|
134
138
|
require 'puppet/parser/ast/caseopt'
|
135
139
|
require 'puppet/parser/ast/casestatement'
|
136
140
|
require 'puppet/parser/ast/classdef'
|
@@ -147,5 +151,6 @@ require 'puppet/parser/ast/selector'
|
|
147
151
|
require 'puppet/parser/ast/typedefaults'
|
148
152
|
require 'puppet/parser/ast/vardef'
|
149
153
|
require 'puppet/parser/ast/tag'
|
154
|
+
require 'puppet/parser/ast/function'
|
150
155
|
|
151
|
-
# $Id: ast.rb
|
156
|
+
# $Id: ast.rb 1250 2006-06-09 21:22:25Z luke $
|
@@ -22,20 +22,46 @@ class Puppet::Parser::AST
|
|
22
22
|
# do we need to evaluate the settor-like statements first. This
|
23
23
|
# is basically variable and type-default declarations.
|
24
24
|
if scope.declarative?
|
25
|
-
|
26
|
-
|
25
|
+
# This is such a stupid hack. I've no real idea how to make a
|
26
|
+
# "real" declarative language, so I hack it so it looks like
|
27
|
+
# one, yay.
|
28
|
+
definelist = [
|
29
|
+
AST::CompDef, AST::NodeDef, AST::ClassDef
|
30
|
+
]
|
31
|
+
setlist = [
|
32
|
+
AST::VarDef, AST::TypeDefaults, AST::Function
|
27
33
|
]
|
28
34
|
|
35
|
+
definers = []
|
29
36
|
settors = []
|
30
37
|
others = []
|
38
|
+
|
39
|
+
# Make a new array, so we don't have to deal with the details of
|
40
|
+
# flattening and such
|
41
|
+
items = []
|
42
|
+
|
43
|
+
# First clean out any AST::ASTArrays
|
31
44
|
@children.each { |child|
|
32
|
-
if
|
33
|
-
|
45
|
+
if child.instance_of?(AST::ASTArray)
|
46
|
+
child.each do |ac|
|
47
|
+
items << ac
|
48
|
+
end
|
49
|
+
else
|
50
|
+
items << child
|
51
|
+
end
|
52
|
+
}
|
53
|
+
|
54
|
+
# Now sort them all according to the type of action
|
55
|
+
items.each { |child|
|
56
|
+
if definelist.include?(child.class)
|
57
|
+
definers << child
|
58
|
+
elsif setlist.include?(child.class)
|
59
|
+
settors << child
|
34
60
|
else
|
35
|
-
others
|
61
|
+
others << child
|
36
62
|
end
|
37
63
|
}
|
38
|
-
rets = [settors,others].flatten.collect { |child|
|
64
|
+
rets = [definers, settors, others].flatten.collect { |child|
|
39
65
|
child.safeevaluate(:scope => scope)
|
40
66
|
}
|
41
67
|
else
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'puppet/rails'
|
2
|
+
|
3
|
+
class Puppet::Parser::AST
|
4
|
+
# An object that collects stored objects from the central cache and returns
|
5
|
+
# them to the current host, yo.
|
6
|
+
class Collection < AST::Branch
|
7
|
+
attr_accessor :type
|
8
|
+
|
9
|
+
# We cannot evaluate directly here; instead we need to store a
|
10
|
+
# CollectType object, which will do the collection. This is
|
11
|
+
# the only way to find certain exported types in the current
|
12
|
+
# configuration.
|
13
|
+
def evaluate(hash)
|
14
|
+
scope = hash[:scope]
|
15
|
+
|
16
|
+
@convertedtype = @type.safeevaluate(:scope => scope)
|
17
|
+
|
18
|
+
scope.newcollection(self)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Now perform the actual collection, yo.
|
22
|
+
def perform(scope)
|
23
|
+
# First get everything from the export table.
|
24
|
+
|
25
|
+
# FIXME This will only find objects that are before us in the tree,
|
26
|
+
# which is a problem.
|
27
|
+
objects = scope.exported(@convertedtype)
|
28
|
+
|
29
|
+
# We want to return all of these objects, and then whichever objects
|
30
|
+
# we find in the db.
|
31
|
+
array = objects.values
|
32
|
+
|
33
|
+
# Mark all of these objects as collected, so that they also get
|
34
|
+
# returned to the client. We don't store them in our scope
|
35
|
+
# or anything, which is a little odd, but eh.
|
36
|
+
array.each do |obj|
|
37
|
+
obj.collected = true
|
38
|
+
end
|
39
|
+
|
40
|
+
count = array.length
|
41
|
+
|
42
|
+
# Now we also have to see if there are any exported objects
|
43
|
+
# in our own scope.
|
44
|
+
scope.lookupexported(@convertedtype).each do |obj|
|
45
|
+
objects[obj.name] = obj
|
46
|
+
obj.collected = true
|
47
|
+
end
|
48
|
+
|
49
|
+
bucket = Puppet::TransBucket.new
|
50
|
+
|
51
|
+
Puppet::Rails::RailsObject.find_all_by_collectable(true).each do |obj|
|
52
|
+
# FIXME This should check that the source of the object is the
|
53
|
+
# host we're running on, else it's a bad conflict.
|
54
|
+
if objects.include?(obj.name)
|
55
|
+
scope.debug("%s[%s] is already exported" % [@convertedtype, obj.name])
|
56
|
+
next
|
57
|
+
end
|
58
|
+
count += 1
|
59
|
+
trans = obj.to_trans
|
60
|
+
bucket.push(trans)
|
61
|
+
|
62
|
+
args = {
|
63
|
+
:name => trans.name,
|
64
|
+
:type => trans.type,
|
65
|
+
}
|
66
|
+
|
67
|
+
[:file, :line].each do |param|
|
68
|
+
if val = trans.send(param)
|
69
|
+
args[param] = val
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
args[:arguments] = {}
|
74
|
+
trans.each do |p,v| args[:arguments][p] = v end
|
75
|
+
|
76
|
+
|
77
|
+
# XXX Because the scopes don't expect objects to return values,
|
78
|
+
# we have to manually add our objects to the scope. This is
|
79
|
+
# uber-lame.
|
80
|
+
scope.setobject(args)
|
81
|
+
end
|
82
|
+
|
83
|
+
scope.debug("Collected %s objects of type %s" %
|
84
|
+
[count, @convertedtype])
|
85
|
+
|
86
|
+
return bucket
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# $Id: collection.rb 1193 2006-05-15 18:02:16Z luke $
|
@@ -9,7 +9,7 @@ class Puppet::Parser::AST
|
|
9
9
|
# encounter an error if the component is instantiated more than
|
10
10
|
# once.
|
11
11
|
class CompDef < AST::Branch
|
12
|
-
attr_accessor :type, :args, :code, :keyword
|
12
|
+
attr_accessor :type, :args, :code, :keyword, :scope
|
13
13
|
|
14
14
|
def each
|
15
15
|
[@type,@args,@code].each { |child| yield child }
|
@@ -72,4 +72,4 @@ class Puppet::Parser::AST
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
# $Id: compdef.rb
|
75
|
+
# $Id: compdef.rb 1186 2006-05-13 02:14:35Z luke $
|
@@ -10,39 +10,47 @@ class Puppet::Parser::AST
|
|
10
10
|
# The class name
|
11
11
|
@name = :component
|
12
12
|
|
13
|
-
attr_accessor :type, :args, :code, :scope, :keyword
|
13
|
+
attr_accessor :type, :args, :code, :scope, :keyword, :collectable
|
14
14
|
|
15
15
|
#def evaluate(scope,hash,objtype,objname)
|
16
16
|
def evaluate(hash)
|
17
|
-
|
17
|
+
origscope = hash[:scope]
|
18
18
|
objtype = hash[:type]
|
19
19
|
objname = hash[:name]
|
20
20
|
arguments = hash[:arguments] || {}
|
21
21
|
|
22
|
-
|
22
|
+
@collectable = hash[:collectable]
|
23
|
+
|
24
|
+
pscope = origscope
|
25
|
+
#pscope = if ! Puppet[:lexical] or hash[:asparent] == false
|
26
|
+
# origscope
|
27
|
+
#else
|
28
|
+
# @scope
|
29
|
+
#end
|
30
|
+
scope = pscope.newscope(
|
23
31
|
:type => @type,
|
24
32
|
:name => objname,
|
25
33
|
:keyword => self.keyword
|
26
34
|
)
|
27
35
|
newcontext = hash[:newcontext]
|
28
36
|
|
37
|
+
if @collectable or origscope.collectable
|
38
|
+
scope.collectable = true
|
39
|
+
end
|
40
|
+
|
29
41
|
unless self.is_a? AST::HostClass and ! newcontext
|
30
42
|
#scope.warning "Setting context to %s" % self.object_id
|
31
43
|
scope.context = self.object_id
|
32
44
|
end
|
33
45
|
@scope = scope
|
34
46
|
|
35
|
-
|
36
47
|
# Additionally, add a tag for whatever kind of class
|
37
48
|
# we are
|
38
49
|
scope.tag(@type)
|
39
50
|
|
40
51
|
unless objname.nil?
|
41
|
-
#Puppet.info "tagging with %s" % objname.inspect
|
42
52
|
scope.tag(objname)
|
43
53
|
end
|
44
|
-
#scope.base = self.class.name
|
45
|
-
|
46
54
|
|
47
55
|
# define all of the arguments in our local scope
|
48
56
|
if self.args
|
@@ -95,9 +103,14 @@ class Puppet::Parser::AST
|
|
95
103
|
# Now just evaluate the code with our new bindings.
|
96
104
|
self.code.safeevaluate(:scope => scope)
|
97
105
|
|
98
|
-
#
|
99
|
-
#
|
100
|
-
return
|
106
|
+
# If we're being evaluated as a parent class, we want to return the
|
107
|
+
# scope, so it can be overridden and such, but if not, we want to
|
108
|
+
# return a TransBucket of our objects.
|
109
|
+
if hash.include?(:asparent)
|
110
|
+
return scope
|
111
|
+
else
|
112
|
+
return scope.to_trans
|
113
|
+
end
|
101
114
|
end
|
102
115
|
|
103
116
|
# Check whether a given argument is valid. Searches up through
|
@@ -136,4 +149,4 @@ class Puppet::Parser::AST
|
|
136
149
|
end
|
137
150
|
end
|
138
151
|
|
139
|
-
# $Id: component.rb
|
152
|
+
# $Id: component.rb 1192 2006-05-14 02:42:21Z luke $
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class Puppet::Parser::AST
|
2
|
+
# An AST object to call a function.
|
3
|
+
class Function < AST::Branch
|
4
|
+
attr_accessor :name, :arguments
|
5
|
+
|
6
|
+
def evaluate(hash)
|
7
|
+
# We don't need to evaluate the name, because it's plaintext
|
8
|
+
|
9
|
+
# Just evaluate the arguments
|
10
|
+
scope = hash[:scope]
|
11
|
+
|
12
|
+
args = @arguments.safeevaluate(:scope => scope)
|
13
|
+
|
14
|
+
return scope.send("function_" + @name, args)
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(hash)
|
18
|
+
@ftype = hash[:ftype] || :rvalue
|
19
|
+
hash.delete(:ftype) if hash.include? :ftype
|
20
|
+
|
21
|
+
super(hash)
|
22
|
+
|
23
|
+
# Make sure it's a defined function
|
24
|
+
unless @fname = Puppet::Parser::Functions.function(@name)
|
25
|
+
raise Puppet::ParseError, "Unknown function %s" % @name
|
26
|
+
end
|
27
|
+
|
28
|
+
# Now check that it's been used correctly
|
29
|
+
case @ftype
|
30
|
+
when :rvalue:
|
31
|
+
unless Puppet::Parser::Functions.rvalue?(@name)
|
32
|
+
raise Puppet::ParseError, "Function '%s' does not return a value" %
|
33
|
+
@name
|
34
|
+
end
|
35
|
+
when :statement:
|
36
|
+
if Puppet::Parser::Functions.rvalue?(@name)
|
37
|
+
raise Puppet::ParseError,
|
38
|
+
"Function '%s' must be the value of a statement" %
|
39
|
+
@name
|
40
|
+
end
|
41
|
+
else
|
42
|
+
raise Puppet::DevError, "Invalid function type %s" % @ftype.inspect
|
43
|
+
end
|
44
|
+
|
45
|
+
# Lastly, check the arity
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# $Id: function.rb 1190 2006-05-13 20:01:12Z luke $
|
@@ -9,47 +9,92 @@ class Puppet::Parser::AST
|
|
9
9
|
#def evaluate(scope,hash,objtype,objname)
|
10
10
|
def evaluate(hash)
|
11
11
|
scope = hash[:scope]
|
12
|
-
objtype = hash[:type]
|
13
12
|
objname = hash[:name]
|
14
|
-
|
13
|
+
args = hash[:arguments]
|
15
14
|
# Verify that we haven't already been evaluated
|
16
15
|
# FIXME The second subclass won't evaluate the parent class
|
17
16
|
# code at all, and any overrides will throw an error.
|
18
|
-
if scope.lookupclass(self.object_id)
|
17
|
+
if myscope = scope.lookupclass(self.object_id)
|
19
18
|
Puppet.debug "%s class already evaluated" % @type
|
19
|
+
|
20
|
+
# Not used, but will eventually be used to fix #140.
|
21
|
+
if myscope.is_a? Puppet::Parser::Scope
|
22
|
+
unless scope.object_id == myscope.object_id
|
23
|
+
#scope.parent = myscope
|
24
|
+
end
|
25
|
+
end
|
20
26
|
return nil
|
21
27
|
end
|
22
28
|
|
29
|
+
# Set the class before we do anything else, so that it's set
|
30
|
+
# during the evaluation and can be inspected.
|
31
|
+
scope.setclass(self.object_id, @type)
|
32
|
+
|
33
|
+
origscope = scope
|
34
|
+
|
23
35
|
# Default to creating a new context
|
24
36
|
newcontext = true
|
25
|
-
|
26
|
-
|
37
|
+
|
38
|
+
# If we've got a parent, then we pass it the original scope we
|
39
|
+
# received. It will get passed all the way up to the top class,
|
40
|
+
# which will create a subscope and pass that subscope to its
|
41
|
+
# subclass.
|
42
|
+
if @parentscope = self.evalparent(
|
43
|
+
:scope => scope, :arguments => args, :name => objname
|
27
44
|
)
|
45
|
+
if @parentscope.is_a? Puppet::TransBucket
|
46
|
+
raise Puppet::DevError, "Got a bucket instead of a scope"
|
47
|
+
end
|
48
|
+
|
28
49
|
# Override our scope binding with the parent scope
|
29
|
-
# binding.
|
30
|
-
|
31
|
-
# our parent scopes.
|
32
|
-
scope = parentscope
|
50
|
+
# binding.
|
51
|
+
scope = @parentscope
|
33
52
|
|
34
53
|
# But don't create a new context if our parent created one
|
35
54
|
newcontext = false
|
36
55
|
end
|
37
56
|
|
38
|
-
#
|
39
|
-
# to our own type
|
40
|
-
|
41
|
-
retval = super(
|
57
|
+
# Just use the Component evaluate method, but change the type
|
58
|
+
# to our own type.
|
59
|
+
result = super(
|
42
60
|
:scope => scope,
|
43
|
-
:arguments =>
|
61
|
+
:arguments => args,
|
44
62
|
:type => @type,
|
45
|
-
:name => objname,
|
46
|
-
:newcontext => newcontext
|
63
|
+
:name => objname, # might be nil
|
64
|
+
:newcontext => newcontext,
|
65
|
+
:asparent => hash[:asparent] || false # might be nil
|
47
66
|
)
|
48
67
|
|
49
|
-
#
|
50
|
-
#
|
51
|
-
|
52
|
-
|
68
|
+
# Now set the class again, this time using the scope. This way
|
69
|
+
# we can look up the parent scope of this class later, so we
|
70
|
+
# can hook the children together.
|
71
|
+
scope.setscope(self.object_id, result)
|
72
|
+
|
73
|
+
# This is important but painfully difficult. If we're the top-level
|
74
|
+
# class, that is, we have no parent classes, then the transscope
|
75
|
+
# is our own scope, but if there are parent classes, then the topmost
|
76
|
+
# parent's scope is the transscope, since it contains its code and
|
77
|
+
# all of the subclass's code.
|
78
|
+
transscope ||= result
|
79
|
+
|
80
|
+
if hash[:asparent]
|
81
|
+
# If we're a parent class, then return the scope object itself.
|
82
|
+
return result
|
83
|
+
else
|
84
|
+
transscope = nil
|
85
|
+
if @parentscope
|
86
|
+
transscope = @parentscope
|
87
|
+
until transscope.parent.object_id == origscope.object_id
|
88
|
+
transscope = transscope.parent
|
89
|
+
end
|
90
|
+
else
|
91
|
+
transscope = result
|
92
|
+
end
|
93
|
+
|
94
|
+
# But if we're the final subclass, translate the whole scope tree
|
95
|
+
# into TransObjects and TransBuckets.
|
96
|
+
return transscope.to_trans
|
97
|
+
end
|
53
98
|
end
|
54
99
|
|
55
100
|
# Evaluate our parent class. Parent classes are evaluated in the
|
@@ -97,11 +142,14 @@ class Puppet::Parser::AST
|
|
97
142
|
raise error
|
98
143
|
end
|
99
144
|
# We don't need to pass the type, because the parent will just
|
100
|
-
# use its own type
|
145
|
+
# use its own type. Specify that it's being evaluated as a parent,
|
146
|
+
# so that it returns the scope, not a transbucket.
|
101
147
|
return parentobj.safeevaluate(
|
102
148
|
:scope => scope,
|
103
149
|
:arguments => args,
|
104
|
-
:name => name
|
150
|
+
:name => name,
|
151
|
+
:asparent => true,
|
152
|
+
:collectable => self.collectable
|
105
153
|
)
|
106
154
|
else
|
107
155
|
return false
|
@@ -7,13 +7,21 @@ class Puppet::Parser::AST
|
|
7
7
|
|
8
8
|
#def evaluate(scope, facts = {})
|
9
9
|
def evaluate(hash)
|
10
|
-
|
10
|
+
origscope = hash[:scope]
|
11
11
|
facts = hash[:facts] || {}
|
12
|
-
|
12
|
+
|
13
13
|
# nodes are never instantiated like a normal object,
|
14
14
|
# but we need the type to be the name users would use for
|
15
15
|
# instantiation, otherwise tags don't work out
|
16
|
-
|
16
|
+
|
17
|
+
pscope = origscope
|
18
|
+
#pscope = if ! Puppet[:lexical] or hash[:asparent]
|
19
|
+
# @scope
|
20
|
+
#else
|
21
|
+
# origscope
|
22
|
+
#end
|
23
|
+
|
24
|
+
scope = pscope.newscope(
|
17
25
|
:type => self.type,
|
18
26
|
:keyword => @keyword
|
19
27
|
)
|
@@ -36,13 +44,14 @@ class Puppet::Parser::AST
|
|
36
44
|
# already been defined at this top-level scope.
|
37
45
|
#super(scope, facts, @name, @name)
|
38
46
|
|
39
|
-
# And then evaluate our code.
|
40
|
-
@code.safeevaluate(:scope => scope)
|
41
|
-
|
42
47
|
# Mark our node name as a class, too, but strip it of the domain
|
43
|
-
# name.
|
48
|
+
# name. Make the mark before we evaluate the code, so that it is
|
49
|
+
# marked within the code itself.
|
44
50
|
scope.setclass(self.object_id, @type.sub(/\..+/, ''))
|
45
51
|
|
52
|
+
# And then evaluate our code.
|
53
|
+
@code.safeevaluate(:scope => scope)
|
54
|
+
|
46
55
|
return scope
|
47
56
|
end
|
48
57
|
|
@@ -77,7 +86,7 @@ class Puppet::Parser::AST
|
|
77
86
|
|
78
87
|
begin
|
79
88
|
code = node.code
|
80
|
-
code.safeevaluate(:scope => scope)
|
89
|
+
code.safeevaluate(:scope => scope, :asparent => true)
|
81
90
|
rescue Puppet::ParseError => except
|
82
91
|
except.line = self.line
|
83
92
|
except.file = self.file
|