Class: Puppet::Type::RelationshipMetaparam
- Defined in:
- lib/puppet/type.rb
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
Attributes included from Util::Docs
Attributes included from Util::Cacher::Expirer
Class Method Summary collapse
Instance Method Summary collapse
- #munge(references) ⇒ Object
-
#to_edges ⇒ Object
Create edges from each of our relationships.
- #validate_relationship ⇒ Object
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
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
Methods included from Util::LogPaths
Methods included from Util::Errors
#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail
Constructor Details
This class inherits a constructor from Puppet::Parameter
Class Attribute Details
.callback ⇒ Object
Returns the value of attribute callback.
1125 1126 1127 |
# File 'lib/puppet/type.rb', line 1125 def callback @callback end |
.direction ⇒ Object
Returns the value of attribute direction.
1125 1126 1127 |
# File 'lib/puppet/type.rb', line 1125 def direction @direction end |
.events ⇒ Object
Returns the value of attribute events.
1125 1126 1127 |
# File 'lib/puppet/type.rb', line 1125 def events @events end |
.subclasses ⇒ Object
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_edges ⇒ Object
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 = 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 #{.ref}") else # If there's no callback, there's no point in even adding # a label. = nil self.debug("requires #{.ref}") end rel = Puppet::Relationship.new(source, target, ) end end |
#validate_relationship ⇒ Object
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 |