Class: Puppet::Resource::Catalog::Compiler
- Inherits:
-
Indirector::Code
- Object
- Indirector::Terminus
- Indirector::Code
- Puppet::Resource::Catalog::Compiler
- Includes:
- Util
- Defined in:
- lib/puppet/indirector/catalog/compiler.rb
Direct Known Subclasses
Constant Summary
Constants included from Util
Util::AbsolutePathPosix, Util::AbsolutePathWindows, Util::DEFAULT_POSIX_MODE, Util::DEFAULT_WINDOWS_MODE
Constants included from Util::POSIX
Util::POSIX::LOCALE_ENV_VARS, Util::POSIX::USER_ENV_VARS
Constants included from Util::SymbolicFileMode
Util::SymbolicFileMode::SetGIDBit, Util::SymbolicFileMode::SetUIDBit, Util::SymbolicFileMode::StickyBit, Util::SymbolicFileMode::SymbolicMode, Util::SymbolicFileMode::SymbolicSpecialToBit
Constants included from Util::Docs
Instance Attribute Summary collapse
Attributes included from Util::Docs
Instance Method Summary collapse
- #extract_facts_from_request(request) ⇒ Object
-
#filter(catalog) ⇒ Object
filter-out a catalog to remove exported resources.
-
#find(request) ⇒ Object
Compile a node’s catalog.
-
#initialize ⇒ Compiler
constructor
A new instance of Compiler.
-
#networked? ⇒ Boolean
Is our compiler part of a network, or are we just local?.
Methods included from Util
absolute_path?, benchmark, chuser, deterministic_rand, deterministic_rand_int, exit_on_fail, logmethods, path_to_uri, pretty_backtrace, replace_file, safe_posix_fork, symbolizehash, thinmark, uri_to_path, which, withenv, withumask
Methods included from Util::POSIX
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Methods included from Util::SymbolicFileMode
#normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?
Methods inherited from Indirector::Terminus
abstract_terminus?, #allow_remote_requests?, const2name, #indirection, indirection_name, inherited, mark_as_abstract_terminus, #model, model, #name, name2const, register_terminus_class, terminus_class, terminus_classes, #terminus_type, #validate, #validate_key, #validate_model
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
#initialize ⇒ Compiler
Returns a new instance of Compiler.
65 66 67 68 69 |
# File 'lib/puppet/indirector/catalog/compiler.rb', line 65 def initialize Puppet::Util::Profiler.profile("Setup server facts for compiling", [:compiler, :init_server_facts]) do set_server_facts end end |
Instance Attribute Details
#code ⇒ Object
12 13 14 |
# File 'lib/puppet/indirector/catalog/compiler.rb', line 12 def code @code end |
Instance Method Details
#extract_facts_from_request(request) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/puppet/indirector/catalog/compiler.rb', line 14 def extract_facts_from_request(request) return unless text_facts = request.[:facts] unless format = request.[:facts_format] raise ArgumentError, "Facts but no fact format provided for #{request.key}" end Puppet::Util::Profiler.profile("Found facts", [:compiler, :find_facts]) do # 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 # We unescape here because the corresponding code in Puppet::Configurer::FactHandler escapes facts = Puppet::Node::Facts.convert_from(format, CGI.unescape(text_facts)) end unless facts.name == request.key raise Puppet::Error, "Catalog for #{request.key.inspect} was requested with fact definition for the wrong node (#{facts.name.inspect})." end = { :environment => request.environment, :transaction_uuid => request.[:transaction_uuid], } Puppet::Node::Facts.indirection.save(facts, nil, ) end end |
#filter(catalog) ⇒ Object
filter-out a catalog to remove exported resources
60 61 62 63 |
# File 'lib/puppet/indirector/catalog/compiler.rb', line 60 def filter(catalog) return catalog.filter { |r| r.virtual? } if catalog.respond_to?(:filter) catalog end |
#find(request) ⇒ Object
Compile a node’s catalog.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/puppet/indirector/catalog/compiler.rb', line 44 def find(request) extract_facts_from_request(request) node = node_from_request(request) node.trusted_data = Puppet.lookup(:trusted_information) { Puppet::Context::TrustedInformation.local(node) }.to_h if catalog = compile(node, request.[:code_id]) 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?
72 73 74 |
# File 'lib/puppet/indirector/catalog/compiler.rb', line 72 def networked? Puppet.run_mode.master? end |