Class: Puppet::Type::RelationshipMetaparam

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

Class Attribute Summary collapse

Attributes inherited from Parameter

#parent, #resource

Attributes included from Util::Docs

#doc, #nodoc

Attributes included from Util::Cacher::Expirer

#timestamp

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Parameter

aliasvalue, defaultto, desc, #devfail, doc, #expirer, #fail, #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, #nodoc?, #pad, scrub

Methods included from Util

activerecord_version, benchmark, chuser, classproxy, #execfail, #execpipe, execute, logmethods, memory, proxy, recmkdir, secure_open, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, which, withumask

Methods included from Util::POSIX

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

Methods included from Util::Cacher

extended, included

Methods included from Util::Cacher::Expirer

#dependent_data_expired?, #expire

Methods included from Util::MethodHelper

#requiredopts, #set_options, #symbolize_options

Methods included from Util::Logging

#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.



1125
1126
1127
# File 'lib/puppet/type.rb', line 1125

def callback
  @callback
end

.directionObject

Returns the value of attribute direction.



1125
1126
1127
# File 'lib/puppet/type.rb', line 1125

def direction
  @direction
end

.eventsObject

Returns the value of attribute events.



1125
1126
1127
# File 'lib/puppet/type.rb', line 1125

def events
  @events
end

.subclassesObject

Returns the value of attribute subclasses.



1125
1126
1127
# File 'lib/puppet/type.rb', line 1125

def subclasses
  @subclasses
end

Class Method Details

.inherited(sub) ⇒ Object



1130
1131
1132
# File 'lib/puppet/type.rb', line 1130

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

Instance Method Details

#munge(references) ⇒ Object



1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
# File 'lib/puppet/type.rb', line 1134

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.



1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
# File 'lib/puppet/type.rb', line 1162

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



1145
1146
1147
1148
1149
1150
1151
1152
# File 'lib/puppet/type.rb', line 1145

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