Class: Puppet::Resource::Catalog

Inherits:
Graph::SimpleGraph
  • Object
show all
Defined in:
lib/puppet/resource/catalog.rb

Overview

This class models a node catalog. It is the thing meant to be passed from server to client, and it contains all of the information in the catalog, including the resources and the relationships between them.

Constant Summary

Instance Method Summary collapse

Instance Method Details

#apply(options = {}) {|transaction| ... } ⇒ Puppet::Transaction

Apply our catalog to the local host.

Options Hash (options):

  • :report (Puppet::Transaction::Report)

    The report object to log this transaction to. This is optional, and the resulting transaction will create a report if not supplied.

  • :tags (Array[String])

    Tags used to filter the transaction. If supplied then only resources tagged with any of these tags will be evaluated.

  • :ignoreschedules (Boolean)

    Ignore schedules when evaluating resources

  • :for_network_device (Boolean)

    Whether this catalog is for a network device

Yields:

  • (transaction)


162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/puppet/resource/catalog.rb', line 162

def apply(options = {})
  Puppet::Util::Storage.load if host_config?

  transaction = create_transaction(options)

  begin
    transaction.report.as_logging_destination do
      transaction.evaluate
    end
  rescue Puppet::Error => detail
    Puppet.log_exception(detail, "Could not apply complete catalog: #{detail}")
  rescue => detail
    Puppet.log_exception(detail, "Got an uncaught exception of type #{detail.class}: #{detail}")
  ensure
    # Don't try to store state unless we're a host config
    # too recursive.
    Puppet::Util::Storage.store if host_config?
  end

  yield transaction if block_given?

  transaction
end

#container_of(resource) ⇒ A Resource?

Returns the resource that contains the given resource



79
80
81
# File 'lib/puppet/resource/catalog.rb', line 79

def container_of(resource)
  adjacent(resource, :direction => :in)[0]
end

#relationship_graph(given_prioritizer = nil) ⇒ Puppet::Graph::RelationshipGraph

The relationship_graph form of the catalog. This contains all of the dependency edges that are used for determining order.



194
195
196
197
198
199
200
# File 'lib/puppet/resource/catalog.rb', line 194

def relationship_graph(given_prioritizer = nil)
  if @relationship_graph.nil?
    @relationship_graph = Puppet::Graph::RelationshipGraph.new(given_prioritizer || prioritizer)
    @relationship_graph.populate_from(self)
  end
  @relationship_graph
end