summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-09-23 22:32:29 -0500
committerLuke Kanies <luke@madstop.com>2008-09-23 22:32:29 -0500
commite31df2f7f5e98c524b68cd724cfaa3e308e7b9a1 (patch)
tree9779e515d976b16b011f24b4f403c64c5db2102b /lib
parent4aeabbbb2163684ff7064198c653cd60d46e5717 (diff)
downloadpuppet-e31df2f7f5e98c524b68cd724cfaa3e308e7b9a1.tar.gz
puppet-e31df2f7f5e98c524b68cd724cfaa3e308e7b9a1.tar.xz
puppet-e31df2f7f5e98c524b68cd724cfaa3e308e7b9a1.zip
Removing files that git wasn't smart enough to remote during a merge.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/metatype/container.rb47
-rw-r--r--lib/puppet/metatype/instances.rb280
-rw-r--r--lib/puppet/metatype/metaparams.rb422
-rw-r--r--lib/puppet/metatype/relationships.rb118
-rw-r--r--lib/puppet/metatype/schedules.rb37
5 files changed, 0 insertions, 904 deletions
diff --git a/lib/puppet/metatype/container.rb b/lib/puppet/metatype/container.rb
deleted file mode 100644
index 0e06e71d2..000000000
--- a/lib/puppet/metatype/container.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-class Puppet::Type
-
- def self.depthfirst?
- if defined? @depthfirst
- return @depthfirst
- else
- return false
- end
- end
-
- def depthfirst?
- self.class.depthfirst?
- end
-
- # Add a hook for testing for recursion.
- def parentof?(child)
- if (self == child)
- debug "parent is equal to child"
- return true
- elsif defined? @parent and @parent.parentof?(child)
- debug "My parent is parent of child"
- return true
- else
- return false
- end
- end
-
- # Remove an object. The argument determines whether the object's
- # subscriptions get eliminated, too.
- def remove(rmdeps = true)
- # This is hackish (mmm, cut and paste), but it works for now, and it's
- # better than warnings.
- @parameters.each do |name, obj|
- obj.remove
- end
- @parameters.clear
-
- @parent = nil
-
- # Remove the reference to the provider.
- if self.provider
- @provider.clear
- @provider = nil
- end
- end
-end
-
diff --git a/lib/puppet/metatype/instances.rb b/lib/puppet/metatype/instances.rb
deleted file mode 100644
index 34d542c5d..000000000
--- a/lib/puppet/metatype/instances.rb
+++ /dev/null
@@ -1,280 +0,0 @@
-require 'puppet/transportable'
-
-class Puppet::Type
- # Make 'new' private, so people have to use create instead.
- class << self
- private :new
- end
-
- # retrieve a named instance of the current type
- def self.[](name)
- raise "Global resource access is deprecated"
- @objects[name] || @aliases[name]
- end
-
- # add an instance by name to the class list of instances
- def self.[]=(name,object)
- raise "Global resource storage is deprecated"
- newobj = nil
- if object.is_a?(Puppet::Type)
- newobj = object
- else
- raise Puppet::DevError, "must pass a Puppet::Type object"
- end
-
- if exobj = @objects[name] and self.isomorphic?
- msg = "Object '%s[%s]' already exists" %
- [newobj.class.name, name]
-
- if exobj.file and exobj.line
- msg += ("in file %s at line %s" %
- [object.file, object.line])
- end
- if object.file and object.line
- msg += ("and cannot be redefined in file %s at line %s" %
- [object.file, object.line])
- end
- error = Puppet::Error.new(msg)
- raise error
- else
- #Puppet.info("adding %s of type %s to class list" %
- # [name,object.class])
- @objects[name] = newobj
- end
- end
-
- # Create an alias. We keep these in a separate hash so that we don't encounter
- # the objects multiple times when iterating over them.
- def self.alias(name, obj)
- raise "Global resource aliasing is deprecated"
- if @objects.include?(name)
- unless @objects[name] == obj
- raise Puppet::Error.new(
- "Cannot create alias %s: object already exists" %
- [name]
- )
- end
- end
-
- if @aliases.include?(name)
- unless @aliases[name] == obj
- raise Puppet::Error.new(
- "Object %s already has alias %s" %
- [@aliases[name].name, name]
- )
- end
- end
-
- @aliases[name] = obj
- end
-
- # remove all of the instances of a single type
- def self.clear
- raise "Global resource removal is deprecated"
- if defined? @objects
- @objects.each do |name, obj|
- obj.remove(true)
- end
- @objects.clear
- end
- if defined? @aliases
- @aliases.clear
- end
- end
-
- # Force users to call this, so that we can merge objects if
- # necessary.
- def self.create(args)
- # Don't modify the original hash; instead, create a duplicate and modify it.
- # We have to dup and use the ! so that it stays a TransObject if it is
- # one.
- hash = args.dup
- symbolizehash!(hash)
-
- # If we're the base class, then pass the info on appropriately
- if self == Puppet::Type
- type = nil
- if hash.is_a? Puppet::TransObject
- type = hash.type
- else
- # If we're using the type to determine object type, then delete it
- if type = hash[:type]
- hash.delete(:type)
- end
- end
-
- # If they've specified a type and called on the base, then
- # delegate to the subclass.
- if type
- if typeklass = self.type(type)
- return typeklass.create(hash)
- else
- raise Puppet::Error, "Unknown type %s" % type
- end
- else
- raise Puppet::Error, "No type found for %s" % hash.inspect
- end
- end
-
- # Handle this new object being implicit
- implicit = hash[:implicit] || false
- if hash.include?(:implicit)
- hash.delete(:implicit)
- end
-
- name = nil
- unless hash.is_a? Puppet::TransObject
- hash = self.hash2trans(hash)
- end
-
- # XXX This will have to change when transobjects change to using titles
- title = hash.name
-
- # create it anew
- # if there's a failure, destroy the object if it got that far, but raise
- # the error.
- begin
- obj = new(hash)
- rescue => detail
- Puppet.err "Could not create %s: %s" % [title, detail.to_s]
- if obj
- obj.remove(true)
- end
- raise
- end
-
- if implicit
- obj.implicit = true
- end
-
- return obj
- end
-
- # remove a specified object
- def self.delete(resource)
- raise "Global resource removal is deprecated"
- return unless defined? @objects
- if @objects.include?(resource.title)
- @objects.delete(resource.title)
- end
- if @aliases.include?(resource.title)
- @aliases.delete(resource.title)
- end
- if @aliases.has_value?(resource)
- names = []
- @aliases.each do |name, otherres|
- if otherres == resource
- names << name
- end
- end
- names.each { |name| @aliases.delete(name) }
- end
- end
-
- # iterate across each of the type's instances
- def self.each
- raise "Global resource iteration is deprecated"
- return unless defined? @objects
- @objects.each { |name,instance|
- yield instance
- }
- end
-
- # does the type have an object with the given name?
- def self.has_key?(name)
- raise "Global resource access is deprecated"
- return @objects.has_key?(name)
- end
-
- # Convert a hash to a TransObject.
- def self.hash2trans(hash)
- title = nil
- if hash.include? :title
- title = hash[:title]
- hash.delete(:title)
- elsif hash.include? self.namevar
- title = hash[self.namevar]
- hash.delete(self.namevar)
-
- if hash.include? :name
- raise ArgumentError, "Cannot provide both name and %s to %s" %
- [self.namevar, self.name]
- end
- elsif hash[:name]
- title = hash[:name]
- hash.delete :name
- end
-
- if catalog = hash[:catalog]
- hash.delete(:catalog)
- end
-
- raise(Puppet::Error, "You must specify a title for objects of type %s" % self.to_s) unless title
-
- if hash.include? :type
- unless self.validattr? :type
- hash.delete :type
- end
- end
-
- # okay, now make a transobject out of hash
- begin
- trans = Puppet::TransObject.new(title, self.name.to_s)
- trans.catalog = catalog if catalog
- hash.each { |param, value|
- trans[param] = value
- }
- rescue => detail
- raise Puppet::Error, "Could not create %s: %s" %
- [name, detail]
- end
-
- return trans
- end
-
- # Retrieve all known instances. Either requires providers or must be overridden.
- def self.instances
- unless defined?(@providers) and ! @providers.empty?
- raise Puppet::DevError, "%s has no providers and has not overridden 'instances'" % self.name
- end
-
- # Put the default provider first, then the rest of the suitable providers.
- provider_instances = {}
- providers_by_source.collect do |provider|
- provider.instances.collect do |instance|
- # We always want to use the "first" provider instance we find, unless the resource
- # is already managed and has a different provider set
- if other = provider_instances[instance.name]
- Puppet.warning "%s %s found in both %s and %s; skipping the %s version" %
- [self.name.to_s.capitalize, instance.name, other.class.name, instance.class.name, instance.class.name]
- next
- end
- provider_instances[instance.name] = instance
-
- create(:name => instance.name, :provider => instance, :check => :all)
- end
- end.flatten.compact
- end
-
- # Return a list of one suitable provider per source, with the default provider first.
- def self.providers_by_source
- # Put the default provider first, then the rest of the suitable providers.
- sources = []
- [defaultprovider, suitableprovider].flatten.uniq.collect do |provider|
- next if sources.include?(provider.source)
-
- sources << provider.source
- provider
- end.compact
- end
-
- # Create the path for logging and such.
- def pathbuilder
- if p = parent
- [p.pathbuilder, self.ref].flatten
- else
- [self.ref]
- end
- end
-end
-
diff --git a/lib/puppet/metatype/metaparams.rb b/lib/puppet/metatype/metaparams.rb
deleted file mode 100644
index 9ba786ee2..000000000
--- a/lib/puppet/metatype/metaparams.rb
+++ /dev/null
@@ -1,422 +0,0 @@
-require 'puppet'
-require 'puppet/type'
-
-class Puppet::Type
- # Add all of the meta parameters.
- #newmetaparam(:onerror) do
- # desc "How to handle errors -- roll back innermost
- # transaction, roll back entire transaction, ignore, etc. Currently
- # non-functional."
- #end
-
- newmetaparam(:noop) do
- desc "Boolean flag indicating whether work should actually
- be done."
-
- newvalues(:true, :false)
- munge do |value|
- case value
- when true, :true, "true": @resource.noop = true
- when false, :false, "false": @resource.noop = false
- end
- end
- end
-
- newmetaparam(:schedule) do
- desc "On what schedule the object should be managed. You must create a
- schedule object, and then reference the name of that object to use
- that for your schedule::
-
- schedule { daily:
- period => daily,
- range => \"2-4\"
- }
-
- exec { \"/usr/bin/apt-get update\":
- schedule => daily
- }
-
- The creation of the schedule object does not need to appear in the
- configuration before objects that use it."
- end
-
- newmetaparam(:check) do
- desc "Propertys which should have their values retrieved
- but which should not actually be modified. This is currently used
- internally, but will eventually be used for querying, so that you
- could specify that you wanted to check the install state of all
- packages, and then query the Puppet client daemon to get reports
- on all packages."
-
- munge do |args|
- # If they've specified all, collect all known properties
- if args == :all
- args = @resource.class.properties.find_all do |property|
- # Only get properties supported by our provider
- if @resource.provider
- @resource.provider.class.supports_parameter?(property)
- else
- true
- end
- end.collect do |property|
- property.name
- end
- end
-
- unless args.is_a?(Array)
- args = [args]
- end
-
- unless defined? @resource
- self.devfail "No parent for %s, %s?" %
- [self.class, self.name]
- end
-
- args.each { |property|
- unless property.is_a?(Symbol)
- property = property.intern
- end
- next if @resource.propertydefined?(property)
-
- unless propertyklass = @resource.class.validproperty?(property)
- if @resource.class.validattr?(property)
- next
- else
- raise Puppet::Error, "%s is not a valid attribute for %s" %
- [property, self.class.name]
- end
- end
- next unless propertyklass.checkable?
- @resource.newattr(property)
- }
- end
- end
-
- # We've got four relationship metaparameters, so this method is used
- # to reduce code duplication between them.
- def munge_relationship(param, values)
- # We need to support values passed in as an array or as a
- # resource reference.
- result = []
-
- # 'values' could be an array or a reference. If it's an array,
- # it could be an array of references or an array of arrays.
- if values.is_a?(Puppet::Type)
- result << [values.class.name, values.title]
- else
- unless values.is_a?(Array)
- devfail "Relationships must be resource references"
- end
- if values[0].is_a?(String) or values[0].is_a?(Symbol)
- # we're a type/title array reference
- values[0] = symbolize(values[0])
- result << values
- else
- # we're an array of stuff
- values.each do |value|
- if value.is_a?(Puppet::Type)
- result << [value.class.name, value.title]
- elsif value.is_a?(Array)
- value[0] = symbolize(value[0])
- result << value
- else
- devfail "Invalid relationship %s" % value.inspect
- end
- end
- end
- end
-
- if existing = self[param]
- result = existing + result
- end
-
- result
- end
-
- newmetaparam(:loglevel) do
- desc "Sets the level that information will be logged.
- The log levels have the biggest impact when logs are sent to
- syslog (which is currently the default)."
- defaultto :notice
-
- newvalues(*Puppet::Util::Log.levels)
- newvalues(:verbose)
-
- munge do |loglevel|
- val = super(loglevel)
- if val == :verbose
- val = :info
- end
- val
- end
- end
-
- newmetaparam(:alias) do
- desc "Creates an alias for the object. Puppet uses this internally when you
- provide a symbolic name::
-
- file { sshdconfig:
- path => $operatingsystem ? {
- solaris => \"/usr/local/etc/ssh/sshd_config\",
- default => \"/etc/ssh/sshd_config\"
- },
- source => \"...\"
- }
-
- service { sshd:
- subscribe => file[sshdconfig]
- }
-
- When you use this feature, the parser sets ``sshdconfig`` as the name,
- and the library sets that as an alias for the file so the dependency
- lookup for ``sshd`` works. You can use this parameter yourself,
- but note that only the library can use these aliases; for instance,
- the following code will not work::
-
- file { \"/etc/ssh/sshd_config\":
- owner => root,
- group => root,
- alias => sshdconfig
- }
-
- file { sshdconfig:
- mode => 644
- }
-
- There's no way here for the Puppet parser to know that these two stanzas
- should be affecting the same file.
-
- See the `LanguageTutorial language tutorial`:trac: for more information.
-
- "
-
- munge do |aliases|
- unless aliases.is_a?(Array)
- aliases = [aliases]
- end
-
- raise(ArgumentError, "Cannot add aliases without a catalog") unless @resource.catalog
-
- @resource.info "Adding aliases %s" % aliases.collect { |a| a.inspect }.join(", ")
-
- aliases.each do |other|
- if obj = @resource.catalog.resource(@resource.class.name, other)
- unless obj.object_id == @resource.object_id
- self.fail("%s can not create alias %s: object already exists" % [@resource.title, other])
- end
- next
- end
-
- # Newschool, add it to the catalog.
- @resource.catalog.alias(@resource, other)
- end
- end
- end
-
- newmetaparam(:tag) do
- desc "Add the specified tags to the associated resource. While all resources
- are automatically tagged with as much information as possible
- (e.g., each class and definition containing the resource), it can
- be useful to add your own tags to a given resource.
-
- Tags are currently useful for things like applying a subset of a
- host's configuration::
-
- puppetd --test --tags mytag
-
- This way, when you're testing a configuration you can run just the
- portion you're testing."
-
- munge do |tags|
- tags = [tags] unless tags.is_a? Array
-
- tags.each do |tag|
- @resource.tag(tag)
- end
- end
- end
-
- class RelationshipMetaparam < Puppet::Parameter
- class << self
- attr_accessor :direction, :events, :callback, :subclasses
- end
-
- @subclasses = []
-
- def self.inherited(sub)
- @subclasses << sub
- end
-
- def munge(rels)
- @resource.munge_relationship(self.class.name, rels)
- end
-
- def validate_relationship
- @value.each do |value|
- unless @resource.catalog.resource(*value)
- description = self.class.direction == :in ? "dependency" : "dependent"
- fail Puppet::Error, "Could not find %s %s[%s] for %s" %
- [description, value[0].to_s.capitalize, value[1], resource.ref]
- end
- end
- end
-
- # 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.
- def to_edges
- @value.collect do |value|
- # we just have a name and a type, and we need to convert it
- # to an object...
- tname, name = value
- reference = Puppet::ResourceReference.new(tname, name)
- reference.catalog = resource.catalog
-
- # Either of the two retrieval attempts could have returned
- # nil.
- unless object = reference.resolve
- self.fail "Could not retrieve dependency '%s' of %s" % [reference, @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 = object
- target = @resource
- else
- source = @resource
- target = object
- end
-
- if method = self.class.callback
- subargs = {
- :event => self.class.events,
- :callback => method
- }
- self.debug("subscribes to %s" % [object.ref])
- else
- # If there's no callback, there's no point in even adding
- # a label.
- subargs = nil
- self.debug("requires %s" % [object.ref])
- end
-
- rel = Puppet::Relationship.new(source, target, subargs)
- end
- end
- end
-
- def self.relationship_params
- RelationshipMetaparam.subclasses
- end
-
-
- # Note that the order in which the relationships params is defined
- # matters. The labelled params (notify and subcribe) must be later,
- # so that if both params are used, those ones win. It's a hackish
- # solution, but it works.
-
- newmetaparam(:require, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do
- desc "One or more objects that this object depends on.
- This is used purely for guaranteeing that changes to required objects
- happen before the dependent object. For instance::
-
- # Create the destination directory before you copy things down
- file { \"/usr/local/scripts\":
- ensure => directory
- }
-
- file { \"/usr/local/scripts/myscript\":
- source => \"puppet://server/module/myscript\",
- mode => 755,
- require => File[\"/usr/local/scripts\"]
- }
-
- Multiple dependencies can be specified by providing a comma-seperated list
- of resources, enclosed in square brackets::
-
- require => [ File[\"/usr/local\"], File[\"/usr/local/scripts\"] ]
-
- Note that Puppet will autorequire everything that it can, and
- there are hooks in place so that it's easy for resources to add new
- ways to autorequire objects, so if you think Puppet could be
- smarter here, let us know.
-
- In fact, the above code was redundant -- Puppet will autorequire
- any parent directories that are being managed; it will
- automatically realize that the parent directory should be created
- before the script is pulled down.
-
- Currently, exec resources will autorequire their CWD (if it is
- specified) plus any fully qualified paths that appear in the
- command. For instance, if you had an ``exec`` command that ran
- the ``myscript`` mentioned above, the above code that pulls the
- file down would be automatically listed as a requirement to the
- ``exec`` code, so that you would always be running againts the
- most recent version.
- "
- end
-
- newmetaparam(:subscribe, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :ALL_EVENTS, :callback => :refresh}) do
- desc "One or more objects that this object depends on. Changes in the
- subscribed to objects result in the dependent objects being
- refreshed (e.g., a service will get restarted). For instance::
-
- class nagios {
- file { \"/etc/nagios/nagios.conf\":
- source => \"puppet://server/module/nagios.conf\",
- alias => nagconf # just to make things easier for me
- }
- service { nagios:
- running => true,
- subscribe => File[nagconf]
- }
- }
-
- Currently the ``exec``, ``mount`` and ``service`` type support
- refreshing.
- "
- end
-
- newmetaparam(:before, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do
- desc %{This parameter is the opposite of **require** -- it guarantees
- that the specified object is applied later than the specifying
- object::
-
- file { "/var/nagios/configuration":
- source => "...",
- recurse => true,
- before => Exec["nagios-rebuid"]
- }
-
- exec { "nagios-rebuild":
- command => "/usr/bin/make",
- cwd => "/var/nagios/configuration"
- }
-
- This will make sure all of the files are up to date before the
- make command is run.}
- end
-
- newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do
- desc %{This parameter is the opposite of **subscribe** -- it sends events
- to the specified object::
-
- file { "/etc/sshd_config":
- source => "....",
- notify => Service[sshd]
- }
-
- service { sshd:
- ensure => running
- }
-
- This will restart the sshd service if the sshd config file changes.}
- end
-end # Puppet::Type
-
diff --git a/lib/puppet/metatype/relationships.rb b/lib/puppet/metatype/relationships.rb
deleted file mode 100644
index 0070c6efb..000000000
--- a/lib/puppet/metatype/relationships.rb
+++ /dev/null
@@ -1,118 +0,0 @@
-class Puppet::Type
- # Specify a block for generating a list of objects to autorequire. This
- # makes it so that you don't have to manually specify things that you clearly
- # require.
- def self.autorequire(name, &block)
- @autorequires ||= {}
- @autorequires[name] = block
- end
-
- # Yield each of those autorequires in turn, yo.
- def self.eachautorequire
- @autorequires ||= {}
- @autorequires.each { |type, block|
- yield(type, block)
- }
- end
-
- # Figure out of there are any objects we can automatically add as
- # dependencies.
- def autorequire(rel_catalog = nil)
- rel_catalog ||= catalog
- raise(Puppet::DevError, "You cannot add relationships without a catalog") unless rel_catalog
-
- reqs = []
- self.class.eachautorequire { |type, block|
- # Ignore any types we can't find, although that would be a bit odd.
- next unless typeobj = Puppet.type(type)
-
- # Retrieve the list of names from the block.
- next unless list = self.instance_eval(&block)
- unless list.is_a?(Array)
- list = [list]
- end
-
- # Collect the current prereqs
- list.each { |dep|
- obj = nil
- # Support them passing objects directly, to save some effort.
- unless dep.is_a? Puppet::Type
- # Skip autorequires that we aren't managing
- unless dep = rel_catalog.resource(type, dep)
- next
- end
- end
-
- reqs << Puppet::Relationship.new(dep, self)
- }
- }
-
- return reqs
- end
-
- # Build the dependencies associated with an individual object.
- def builddepends
- # Handle the requires
- self.class.relationship_params.collect do |klass|
- if param = @parameters[klass.name]
- param.to_edges
- end
- end.flatten.reject { |r| r.nil? }
- end
-
- # Does this resource have a relationship with the other? We have to
- # check each object for both directions of relationship.
- def requires?(other)
- them = [other.class.name, other.title]
- me = [self.class.name, self.title]
- self.class.relationship_params.each do |param|
- case param.direction
- when :in: return true if v = self[param.name] and v.include?(them)
- when :out: return true if v = other[param.name] and v.include?(me)
- end
- end
- return false
- end
-
- # we've received an event
- # we only support local events right now, so we can pass actual
- # objects around, including the transaction object
- # the assumption here is that container objects will pass received
- # methods on to contained objects
- # i.e., we don't trigger our children, our refresh() method calls
- # refresh() on our children
- def trigger(event, source)
- trans = event.transaction
- if @callbacks.include?(source)
- [:ALL_EVENTS, event.event].each { |eventname|
- if method = @callbacks[source][eventname]
- if trans.triggered?(self, method) > 0
- next
- end
- if self.respond_to?(method)
- self.send(method)
- end
-
- trans.triggered(self, method)
- end
- }
- end
- end
-
- # Unsubscribe from a given object, possibly with a specific event.
- def unsubscribe(object, event = nil)
- # First look through our own relationship params
- [:require, :subscribe].each do |param|
- if values = self[param]
- newvals = values.reject { |d|
- d == [object.class.name, object.title]
- }
- if newvals.length != values.length
- self.delete(param)
- self[param] = newvals
- end
- end
- end
- end
-end
-
diff --git a/lib/puppet/metatype/schedules.rb b/lib/puppet/metatype/schedules.rb
deleted file mode 100644
index b4782f852..000000000
--- a/lib/puppet/metatype/schedules.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-class Puppet::Type
- # Look up the schedule and set it appropriately. This is done after
- # the instantiation phase, so that the schedule can be anywhere in the
- # file.
- def schedule
- unless catalog
- warning "Cannot schedule without a schedule-containing catalog"
- return nil
- end
- unless defined? @schedule
- if name = self[:schedule]
- if sched = catalog.resource(:schedule, name)
- @schedule = sched
- else
- self.fail "Could not find schedule %s" % name
- end
- else
- @schedule = nil
- end
- end
- @schedule
- end
-
- # Check whether we are scheduled to run right now or not.
- def scheduled?
- return true if Puppet[:ignoreschedules]
- return true unless schedule = self.schedule
-
- # We use 'checked' here instead of 'synced' because otherwise we'll
- # end up checking most resources most times, because they will generally
- # have been synced a long time ago (e.g., a file only gets updated
- # once a month on the server and its schedule is daily; the last sync time
- # will have been a month ago, so we'd end up checking every run).
- return schedule.match?(self.cached(:checked).to_i)
- end
-end
-