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::ALNUM, Util::ALPHA, Util::AbsolutePathPosix, Util::AbsolutePathWindows, Util::DEFAULT_POSIX_MODE, Util::DEFAULT_WINDOWS_MODE, Util::ESCAPED, Util::HEX, Util::HttpProxy, Util::PUPPET_STACK_INSERTION_FRAME, Util::RESERVED, Util::RFC_3986_URI_REGEX, Util::UNRESERVED, Util::UNSAFE
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
-
.callback ⇒ Object
Returns the value of attribute callback.
-
.direction ⇒ Object
Returns the value of attribute direction.
-
.events ⇒ Object
Returns the value of attribute events.
-
.subclasses ⇒ Object
Returns the value of attribute subclasses.
Attributes inherited from Parameter
#name, #parent, #resource, #sensitive
Attributes included from Util::Docs
Class Method Summary collapse
Instance Method Summary collapse
-
#munge(references) ⇒ Array<Puppet::Resource>
Turns attribute values 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, format_value_for_display, #initialize, initvars, isnamevar, isnamevar?, #isnamevar?, isrequired, #line, #log, #metaparam?, munge, newvalues, nodefault, #noop, #path, #pathbuilder, #provider, proxymethods, #remove, #required?, required?, sensitive, #tags, #to_s, unmunge, #unmunge, #unsafe_munge, #unsafe_unmunge, #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?, benchmark, chuser, clear_environment, create_erb, default_env, deterministic_rand, deterministic_rand_int, exit_on_fail, format_backtrace_array, format_puppetstack_frame, get_env, get_environment, logmethods, merge_environment, path_to_uri, pretty_backtrace, replace_file, resolve_stackframe, rfc2396_escape, safe_posix_fork, set_env, skip_external_facts, symbolizehash, thinmark, uri_encode, uri_query_encode, uri_to_path, uri_unescape, which, withenv, withumask
Methods included from Util::POSIX
#get_posix_field, #gid, groups_of, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Methods included from Util::SymbolicFileMode
#display_mode, #normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?
Methods included from Util::Logging
#clear_deprecation_warnings, #debug, #deprecation_warning, #format_backtrace, #format_exception, #get_deprecation_offender, #log_and_raise, #log_deprecations_to_file, #log_exception, #puppet_deprecation_warning, #send_log, setup_facter_logging!, #warn_once
Methods included from Util::Errors
#adderrorcontext, #devfail, #error_context, error_location, error_location_with_space, error_location_with_unknowns, #exceptwrap, #fail
Constructor Details
This class inherits a constructor from Puppet::Parameter
Class Attribute Details
.callback ⇒ Object
Returns the value of attribute callback.
1468 1469 1470 |
# File 'lib/puppet/type.rb', line 1468 def callback @callback end |
.direction ⇒ Object
Returns the value of attribute direction.
1468 1469 1470 |
# File 'lib/puppet/type.rb', line 1468 def direction @direction end |
.events ⇒ Object
Returns the value of attribute events.
1468 1469 1470 |
# File 'lib/puppet/type.rb', line 1468 def events @events end |
.subclasses ⇒ Object
Returns the value of attribute subclasses.
1468 1469 1470 |
# File 'lib/puppet/type.rb', line 1468 def subclasses @subclasses end |
Class Method Details
.inherited(sub) ⇒ Object
1473 1474 1475 |
# File 'lib/puppet/type.rb', line 1473 def self.inherited(sub) @subclasses << sub end |
Instance Method Details
#munge(references) ⇒ Array<Puppet::Resource>
Returns turns attribute values into list of resources.
1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 |
# File 'lib/puppet/type.rb', line 1478 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.
1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 |
# File 'lib/puppet/type.rb', line 1516 def to_edges @value.collect do |reference| reference.catalog = resource.catalog # Either of the two retrieval attempts could have returned # nil. = reference.resolve unless self.fail "Could not retrieve dependency '#{reference}' of #{@resource.ref}" end # Are we requiring them, or vice versa? See the method docs # for further info on this. if self.class.direction == :in source = target = @resource else source = @resource target = end method = self.class.callback if method = { :event => self.class.events, :callback => method } else # If there's no callback, there's no point in even adding # a label. = nil end ## Corrected syntax of debug statement to reflect the way this was called. # i.e. before, after, subscribe, notify debug do relation = case self.class.name when "subscribe" "subscribes" when "notify" "notifies" else self.class.name end "#{relation} to #{.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.
1493 1494 1495 1496 1497 1498 1499 1500 1501 |
# File 'lib/puppet/type.rb', line 1493 def validate_relationship @value.each do |ref| next if @resource.catalog.resource(ref.to_s) description = self.class.direction == :in ? "dependency" : "dependent" fail ResourceError, _("Could not find %{description} %{ref} for %{resource}") % { description: description, ref: ref, resource: resource.ref } end end |