lib/puppet/transaction.rb
# This method does all the actual work of running a transaction.  It
# collects all of the changes, executes them, and responds to any
# necessary events.
This method does all the actual work of running a transaction.  It
collects all of the changes, executes them, and responds to any
necessary events.
This method does all the actual work of running a transaction . It collects all of the changes executes them and responds to any necessary events .
def evaluate(&block)
    block ||= method(:eval_resource)
    generator = AdditionalResourceGenerator.new(@catalog, relationship_graph, @prioritizer)
    @catalog.vertices.each { |resource| generator.generate_additional_resources(resource) }
    perform_pre_run_checks
    Puppet.info "Applying configuration version '#{catalog.version}'" if catalog.version
    continue_while = lambda { !stop_processing? }
    post_evalable_providers = Set.new
    pre_process = lambda do |resource|
      prov_class = resource.provider.class
      post_evalable_providers << prov_class if prov_class.respond_to?(:post_resource_eval)
      prefetch_if_necessary(resource)
      relationship_graph.clear_blockers if generator.eval_generate(resource)
    end
    providerless_types = []
    overly_deferred_resource_handler = lambda do |resource|
      return if missing_tags?(resource)
      if resource.provider
        resource.err "Provider #{resource.provider.class.name} is not functional on this host"
      else
        providerless_types << resource.type
      end
      resource_status(resource).failed = true
    end
    canceled_resource_handler = lambda do |resource|
      resource_status(resource).skipped = true
      resource.debug "Transaction canceled, skipping"
    end
    teardown = lambda do
      providerless_types.uniq.each do |type|
        Puppet.err "Could not find a suitable provider for #{type}"
      end
      post_evalable_providers.each do |provider|
        begin
          provider.post_resource_eval
        rescue => detail
          Puppet.log_exception(detail, "post_resource_eval failed for provider #{provider}")
        end
      end
    end
    relationship_graph.traverse(:while => continue_while,
                                :pre_process => pre_process,
                                :overly_deferred_resource_handler => overly_deferred_resource_handler,
                                :canceled_resource_handler => canceled_resource_handler,
                                :teardown => teardown) do |resource|
      if resource.is_a?(Puppet::Type::Component)
        Puppet.warning "Somehow left a component in the relationship graph"
      else
        resource.info "Starting to evaluate the resource" if Puppet[:evaltrace] and @catalog.host_config?
        seconds = thinmark { block.call(resource) }
        resource.info "Evaluated in %0.2f seconds" % seconds if Puppet[:evaltrace] and @catalog.host_config?
      end
    end
    Puppet.debug "Finishing transaction #{object_id}"
  end
def evaluate ( & block ) block ||= method ( :eval_resource ) generator = AdditionalResourceGenerator . new ( @catalog , relationship_graph , @prioritizer ) @catalog . vertices . each { | resource | generator . generate_additional_resources ( resource ) } perform_pre_run_checks Puppet . info "Applying configuration version '#{catalog.version}'" if catalog . version continue_while = lambda { ! stop_processing? } post_evalable_providers = Set . new pre_process = lambda do | resource | prov_class = resource . provider . class post_evalable_providers << prov_class if prov_class . respond_to? ( :post_resource_eval ) prefetch_if_necessary ( resource ) relationship_graph . clear_blockers if generator . eval_generate ( resource ) end providerless_types = [ ] overly_deferred_resource_handler = lambda do | resource | return if missing_tags? ( resource ) if resource . provider resource . err "Provider #{resource.provider.class.name} is not functional on this host" else providerless_types << resource . type end resource_status ( resource ) . failed = true end canceled_resource_handler = lambda do | resource | resource_status ( resource ) . skipped = true resource . debug "Transaction canceled, skipping" end teardown = lambda do providerless_types . uniq . each do | type | Puppet . err "Could not find a suitable provider for #{type}" end post_evalable_providers . each do | provider | begin provider . post_resource_eval rescue => detail Puppet . log_exception ( detail , "post_resource_eval failed for provider #{provider}" ) end end end relationship_graph . traverse ( :while => continue_while , :pre_process => pre_process , :overly_deferred_resource_handler => overly_deferred_resource_handler , :canceled_resource_handler => canceled_resource_handler , :teardown => teardown ) do | resource | if resource . is_a? ( Puppet :: Type :: Component ) Puppet . warning "Somehow left a component in the relationship graph" else resource . info "Starting to evaluate the resource" if Puppet [ :evaltrace ] and @catalog . host_config? seconds = thinmark { block . call ( resource ) } resource . info "Evaluated in %0.2f seconds" % seconds if Puppet [ :evaltrace ] and @catalog . host_config? end end Puppet . debug "Finishing transaction #{object_id}" end
This method does all the actual work of running a transaction.
This method does all the actual work of running a transaction .
# If we generated resources, we don't know what they are now # blocking, so we opt to recompute it, rather than try to track every # change that would affect the number. # We don't automatically assign unsuitable providers, so if there # is one, it must have been selected by the user. # Just once per type. No need to punish the user.
block
<not_specific>