Class: Puppet::Resource::Catalog::Compiler

Inherits:
Indirector::Code show all
Includes:
Util
Defined in:
lib/vendor/puppet/indirector/catalog/compiler.rb

Constant Summary

Constants included from Util

Util::AbsolutePathPosix, Util::AbsolutePathWindows

Constants included from Util::Docs

Util::Docs::HEADER_LEVELS

Instance Attribute Summary collapse

Attributes included from Util::Docs

#doc, #nodoc

Instance Method Summary collapse

Methods included from Util

absolute_path?, activerecord_version, benchmark, binread, chuser, classproxy, #execfail, #execpipe, execute, execute_posix, execute_windows, logmethods, memory, path_to_uri, proxy, replace_file, safe_posix_fork, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, uri_to_path, wait_for_output, which, withumask

Methods included from Util::POSIX

#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid

Methods inherited from Indirector::Terminus

abstract_terminus?, const2name, #indirection, indirection_name, inherited, mark_as_abstract_terminus, #model, model, #name, name2const, register_terminus_class, terminus_class, terminus_classes, #terminus_type

Methods included from Util::InstanceLoader

#instance_docs, #instance_hash, #instance_load, #instance_loader, #instance_loading?, #loaded_instance, #loaded_instances

Methods included from Util::Docs

#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub

Constructor Details

#initializeCompiler

Returns a new instance of Compiler.



50
51
52
# File 'lib/vendor/puppet/indirector/catalog/compiler.rb', line 50

def initialize
  set_server_facts
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



12
13
14
# File 'lib/vendor/puppet/indirector/catalog/compiler.rb', line 12

def code
  @code
end

Instance Method Details

#extract_facts_from_request(request) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vendor/puppet/indirector/catalog/compiler.rb', line 14

def extract_facts_from_request(request)
  return unless text_facts = request.options[:facts]
  raise ArgumentError, "Facts but no fact format provided for #{request.name}" unless format = request.options[:facts_format]

  # If the facts were encoded as yaml, then the param reconstitution system
  # in Network::HTTP::Handler will automagically deserialize the value.
  if text_facts.is_a?(Puppet::Node::Facts)
    facts = text_facts
  else
    facts = Puppet::Node::Facts.convert_from(format, text_facts)
  end
  facts.add_timestamp
  Puppet::Node::Facts.indirection.save(facts)
end

#filter(catalog) ⇒ Object

filter-out a catalog to remove exported resources



45
46
47
48
# File 'lib/vendor/puppet/indirector/catalog/compiler.rb', line 45

def filter(catalog)
  return catalog.filter { |r| r.virtual? } if catalog.respond_to?(:filter)
  catalog
end

#find(request) ⇒ Object

Compile a node’s catalog.



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/vendor/puppet/indirector/catalog/compiler.rb', line 30

def find(request)
  extract_facts_from_request(request)

  node = node_from_request(request)

  if catalog = compile(node)
    return catalog
  else
    # This shouldn't actually happen; we should either return
    # a config or raise an exception.
    return nil
  end
end

#networked?Boolean

Is our compiler part of a network, or are we just local?

Returns:

  • (Boolean)


55
56
57
# File 'lib/vendor/puppet/indirector/catalog/compiler.rb', line 55

def networked?
  Puppet.run_mode.master?
end