~bkerensa/ubuntu/raring/puppet/new-upstream-release

« back to all changes in this revision

Viewing changes to lib/puppet/parser/compiler.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-07-25 01:00:37 UTC
  • mfrom: (1.1.24 upstream) (3.1.25 sid)
  • Revision ID: james.westby@ubuntu.com-20110725010037-875vuxs10eboqgw3
Tags: 2.7.1-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - debian/puppetmaster-passenger.postinst: Use cacrl instead of hostcrl to
    set the location of the CRL in apache2 configuration. Fix apache2
    configuration on upgrade as well (LP: #641001)
  - move all puppet dependencies to puppet-common since all the code
    actually located in puppet-common.
  - move libagueas from a recommend to a dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
  include Puppet::Resource::TypeCollectionHelper
16
16
 
17
17
  def self.compile(node)
 
18
    # We get these from the environment and only cache them in a thread
 
19
    # variable for the duration of the compilation.  If nothing else is using
 
20
    # the thread, though, we can leave 'em hanging round with no ill effects,
 
21
    # and this is safer than cleaning them at the end and assuming that will
 
22
    # stick until the next entry to this function.
 
23
    Thread.current[:known_resource_types] = nil
 
24
    Thread.current[:env_module_directories] = nil
 
25
 
 
26
    # ...and we actually do the compile now we have caching ready.
18
27
    new(node).compile.to_resource
19
28
  rescue => detail
20
29
    puts detail.backtrace if Puppet[:trace]
21
30
    raise Puppet::Error, "#{detail} on node #{node.name}"
22
 
  ensure
23
 
    # We get these from the environment and only cache them in a thread 
24
 
    # variable for the duration of the compilation.
25
 
    Thread.current[:known_resource_types] = nil
26
 
    Thread.current[:env_module_directories] = nil
27
31
 end
28
32
 
29
33
  attr_reader :node, :facts, :collections, :catalog, :node_scope, :resources, :relationships
133
137
  end
134
138
 
135
139
  # Evaluate each specified class in turn.  If there are any classes we can't
136
 
  # find, just tag the catalog and move on.  This method really just
137
 
  # creates resource objects that point back to the classes, and then the
138
 
  # resources are themselves evaluated later in the process.
 
140
  # find, raise an error.  This method really just creates resource objects
 
141
  # that point back to the classes, and then the resources are themselves
 
142
  # evaluated later in the process.
139
143
  def evaluate_classes(classes, scope, lazy_evaluate = true)
140
144
    raise Puppet::DevError, "No source for scope passed to evaluate_classes" unless scope.source
141
 
    found = []
142
145
    param_classes = nil
143
146
    # if we are a param class, save the classes hash
144
147
    # and transform classes to be the keys
153
156
        if param_classes
154
157
          resource = klass.ensure_in_catalog(scope, param_classes[name] || {})
155
158
        else
156
 
          found << name and next if scope.class_scope(klass)
 
159
          next if scope.class_scope(klass)
157
160
          resource = klass.ensure_in_catalog(scope)
158
161
        end
159
162
 
160
163
        # If they've disabled lazy evaluation (which the :include function does),
161
164
        # then evaluate our resource immediately.
162
165
        resource.evaluate unless lazy_evaluate
163
 
        found << name
164
166
      else
165
 
        Puppet.warning "Could not find class #{name} for #{node.name}"
166
 
        @catalog.tag(name)
 
167
        raise Puppet::Error, "Could not find class #{name} for #{node.name}"
167
168
      end
168
169
    end
169
 
    found
170
170
  end
171
171
 
172
172
  def evaluate_relationships