Class: Puppet::Type::RelationshipMetaparam
- Defined in:
- lib/puppet/type.rb
Overview
RelationshipMetaparam is an implementation supporting the meta-parameters ‘:require`, `:subscribe`, `:notify`, and `:before`.
Constant Summary
Constants included from Util::Docs
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
Class Attribute Summary collapse
Attributes inherited from Parameter
Attributes included from Util::Docs
Class Method Summary collapse
Instance Method Summary collapse
-
#munge(references) ⇒ Array<Puppet::Resource>
Turns attribute value(s) into list of resources.
-
#to_edges ⇒ Array<Puppet::Relationship>
Creates edges for all relationships.
-
#validate_relationship ⇒ void
Checks each reference to assert that what it references exists in the catalog.
Methods inherited from Parameter
aliasvalue, defaultto, desc, doc, #file, format_value_for_display, #initialize, initvars, isnamevar, isnamevar?, #isnamevar?, isrequired, #line, #log, #metaparam?, munge, newvalues, nodefault, #noop, #path, #pathbuilder, #provider, proxymethods, #remove, #required?, required?, #tags, #to_s, unmunge, #unmunge, #unsafe_munge, #unsafe_validate, validate, #validate, #value, #value=, #version
Methods included from Util::Docs
#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub
Methods included from Util
absolute_path?, activerecord_version, benchmark, binread, chuser, classproxy, deterministic_rand, execfail, execpipe, execute, exit_on_fail, logmethods, memory, path_to_uri, pretty_backtrace, proxy, 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 included from Util::MethodHelper
#requiredopts, #set_options, #symbolize_options
Methods included from Util::Logging
#clear_deprecation_warnings, #deprecation_warning, #format_exception, #get_deprecation_offender, #log_and_raise, #log_deprecations_to_file, #log_exception, #puppet_deprecation_warning, #send_log
Methods included from Util::Errors
#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail
Constructor Details
This class inherits a constructor from Puppet::Parameter
Class Attribute Details
.direction ⇒ Object
1449 1450 1451 |
# File 'lib/puppet/type.rb', line 1449 def direction @direction end |
.subclasses ⇒ Object
1449 1450 1451 |
# File 'lib/puppet/type.rb', line 1449 def subclasses @subclasses end |
Class Method Details
.inherited(sub) ⇒ Object
1454 1455 1456 |
# File 'lib/puppet/type.rb', line 1454 def self.inherited(sub) @subclasses << sub end |
Instance Method Details
#munge(references) ⇒ Array<Puppet::Resource>
Returns turns attribute value(s) into list of resources.
1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 |
# File 'lib/puppet/type.rb', line 1459 def munge(references) references = [references] unless references.is_a?(Array) references.collect do |ref| if ref.is_a?(Puppet::Resource) ref else Puppet::Resource.new(ref) end end end |
#to_edges ⇒ Array<Puppet::Relationship>
references to “event-receivers” and “event generator” means in this context - are those just the resources at the two ends of the relationship?
Creates edges for all relationships. The ‘:in` relationships are specified by the event-receivers, and `:out` relationships are specified by the event generator. This way ’source’ and ‘target’ are consistent terms in both edges and events, i.e. an event targets edges whose source matches the event’s source. The direction of the relationship determines which resource is applied first and which resource is considered to be the event generator.
1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 |
# File 'lib/puppet/type.rb', line 1496 def to_edges @value.collect do |reference| reference.catalog = resource.catalog # Either of the two retrieval attempts could have returned # nil. unless = reference.resolve self.fail "Could not retrieve dependency '#{reference}' of #{@resource.ref}" end # Are we requiring them, or vice versa? See the method docs # for futher info on this. if self.class.direction == :in source = target = @resource else source = @resource target = end if method = self.class.callback = { :event => self.class.events, :callback => method } self.debug("subscribes to #{related_resource.ref}") else # If there's no callback, there's no point in even adding # a label. = nil self.debug("requires #{related_resource.ref}") end Puppet::Relationship.new(source, target, ) end end |
#validate_relationship ⇒ void
This method returns an undefined value.
Checks each reference to assert that what it references exists in the catalog.
1474 1475 1476 1477 1478 1479 1480 1481 |
# File 'lib/puppet/type.rb', line 1474 def validate_relationship @value.each do |ref| unless @resource.catalog.resource(ref.to_s) description = self.class.direction == :in ? "dependency" : "dependent" fail ResourceError, "Could not find #{description} #{ref} for #{resource.ref}" end end end |