Class: Puppet::Type::RelationshipMetaparam

Inherits:
Parameter show all
Defined in:
lib/vendor/puppet/type.rb

Constant Summary

Constants included from Util::Docs

Util::Docs::HEADER_LEVELS

Constants included from Util

Util::AbsolutePathPosix, Util::AbsolutePathWindows

Class Attribute Summary collapse

Attributes inherited from Parameter

#parent, #resource

Attributes included from Util::Docs

#doc, #nodoc

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Parameter

aliasvalue, defaultto, desc, #devfail, doc, #fail, format_value_for_display, #initialize, initvars, isnamevar, isnamevar?, isrequired, #log, #metaparam?, munge, #name, newvalues, nodefault, #noop, #pathbuilder, #provider, proxymethods, #remove, required?, #tags, #to_s, unmunge, #unmunge, #unsafe_munge, #unsafe_validate, validate, #validate, #value, #value=

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, #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 included from Util::MethodHelper

#requiredopts, #set_options, #symbolize_options

Methods included from Util::Logging

#clear_deprecation_warnings, #deprecation_warning, #send_log

Methods included from Util::LogPaths

#path, #source_descriptors

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail

Constructor Details

This class inherits a constructor from Puppet::Parameter

Class Attribute Details

.callbackObject

Returns the value of attribute callback.



1168
1169
1170
# File 'lib/vendor/puppet/type.rb', line 1168

def callback
  @callback
end

.directionObject

Returns the value of attribute direction.



1168
1169
1170
# File 'lib/vendor/puppet/type.rb', line 1168

def direction
  @direction
end

.eventsObject

Returns the value of attribute events.



1168
1169
1170
# File 'lib/vendor/puppet/type.rb', line 1168

def events
  @events
end

.subclassesObject

Returns the value of attribute subclasses.



1168
1169
1170
# File 'lib/vendor/puppet/type.rb', line 1168

def subclasses
  @subclasses
end

Class Method Details

.inherited(sub) ⇒ Object



1173
1174
1175
# File 'lib/vendor/puppet/type.rb', line 1173

def self.inherited(sub)
  @subclasses << sub
end

Instance Method Details

#munge(references) ⇒ Object



1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
# File 'lib/vendor/puppet/type.rb', line 1177

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_edgesObject

Create edges from each of our relationships. :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 – that is, 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.



1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
# File 'lib/vendor/puppet/type.rb', line 1205

def to_edges
  @value.collect do |reference|
    reference.catalog = resource.catalog

    # Either of the two retrieval attempts could have returned
    # nil.
    unless related_resource = 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 = related_resource
      target = @resource
    else
      source = @resource
      target = related_resource
    end

    if method = self.class.callback
      subargs = {
        :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.
      subargs = nil
      self.debug("requires #{related_resource.ref}")
    end

    rel = Puppet::Relationship.new(source, target, subargs)
  end
end

#validate_relationshipObject



1188
1189
1190
1191
1192
1193
1194
1195
# File 'lib/vendor/puppet/type.rb', line 1188

def validate_relationship
  @value.each do |ref|
    unless @resource.catalog.resource(ref.to_s)
      description = self.class.direction == :in ? "dependency" : "dependent"
      fail "Could not find #{description} #{ref} for #{resource.ref}"
    end
  end
end