diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-09-12 20:33:14 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-09-12 20:33:14 +0000 |
commit | f9df5236aa75aa2978c7d9ce826aa6b9bf06a711 (patch) | |
tree | fe2f6fac3fe0721c919a98e313d537e0a42de815 | |
parent | 4dd1dd8cfb7842c463cac11f785b56739b09e93b (diff) | |
download | puppet-f9df5236aa75aa2978c7d9ce826aa6b9bf06a711.tar.gz puppet-f9df5236aa75aa2978c7d9ce826aa6b9bf06a711.tar.xz puppet-f9df5236aa75aa2978c7d9ce826aa6b9bf06a711.zip |
intermediate commit so cron is not loaded
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@648 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet/transaction.rb | 7 | ||||
-rw-r--r-- | lib/puppet/transportable.rb | 54 | ||||
-rw-r--r-- | lib/puppet/type.rb | 47 | ||||
-rwxr-xr-x | lib/puppet/type/exec.rb | 7 |
4 files changed, 82 insertions, 33 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index 63a6ebbd7..1efd21de5 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -75,10 +75,13 @@ class Transaction event.nil? } + @triggerevents = [] events.each { |event| object = event.source object.propagate(event) } + + events += @triggerevents end #--------------------------------------------------------------- @@ -139,16 +142,20 @@ class Transaction end }.flatten.reject { |e| e.nil? } + @triggerevents = [] events.each { |event| object = event.source object.propagate(event) } + + events += @triggerevents end #--------------------------------------------------------------- #--------------------------------------------------------------- def triggered(object, method) @triggered[object][method] += 1 + @triggerevents << ("%s_%sed" % [object.class.name.to_s, method.to_s]).intern end #--------------------------------------------------------------- diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb index 1adaeafe1..f3a701130 100644 --- a/lib/puppet/transportable.rb +++ b/lib/puppet/transportable.rb @@ -52,7 +52,27 @@ module Puppet def to_type retobj = nil if type = Puppet::Type.type(self.type) - retobj = type.new(self) + begin + retobj = type.new(self) + rescue => detail + # FIXME TransObject should be handling what happens when there's an error + if Puppet[:debug] + puts self.inspect + if detail.respond_to?(:stack) + puts detail.stack + end + end + if retobj + Puppet.err "Destroying %s" % self[:name] + retobj.destroy() + else + if obj = type[self[:name]] + Puppet.err "Destroying retrieved %s" % self[:name] + obj.destroy() + end + end + return nil + end retobj.file = @file retobj.line = @line else @@ -72,7 +92,7 @@ module Puppet def push(*args) args.each { |arg| case arg - when Puppet::TransBucket, Puppet::TransObject, Puppet::TransSetting + when Puppet::TransBucket, Puppet::TransObject # nada else raise "TransBuckets cannot handle objects of type %s" % @@ -121,7 +141,7 @@ module Puppet # this assumes that type/name combinations are globally # unique - # XXX this still might be wrong, because it doesn't search + # FIXME this still might be wrong, because it doesn't search # up scopes # either that, or it's redundant name = [child[:name],child.type].join("--") @@ -139,29 +159,13 @@ module Puppet object.parent = self else # the object does not exist yet in our scope # now we have the object instantiated, in our scope - begin - object = child.to_type - rescue Puppet::Error => except - Puppet.err "Failed to create %s %s: %s" % - [child.type,child.name,except.message] - if Puppet[:debug] - puts child.inspect - puts except.stack - end - next - rescue => except - Puppet.err "Failed to create %s %s: %s" % - [child.type,child.name,except.message] - if Puppet[:debug] - puts child.inspect - puts caller - end - next - end - nametable[name] = object + if object = child.to_type + # the object will be nil if it failed + nametable[name] = object - # this sets the order of the object - container.push object + # this sets the order of the object + container.push object + end end else raise "TransBucket#to_type cannot handle objects of type %s" % diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index bb6c68574..befaaa4cd 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -251,6 +251,9 @@ class Type < Puppet::Element # [object.name,object.class]) @objects[newobj.name] = newobj end + + # and then add it to the master list + Puppet::Type.push(object) end #--------------------------------------------------------------- @@ -274,6 +277,19 @@ class Type < Puppet::Element #--------------------------------------------------------------- #--------------------------------------------------------------- + # remove a specified object + def self.delete(object) + if @@allobjects.include?(object) + @@allobjects.delete(object) + end + return unless defined? @objects + if @objects.include?(object.name) + @objects.delete(object.name) + end + end + #--------------------------------------------------------------- + + #--------------------------------------------------------------- # iterate across each of the type's instances def self.each return unless defined? @objects @@ -496,6 +512,18 @@ class Type < Puppet::Element #--------------------------------------------------------------- #--------------------------------------------------------------- + # remove a state from the object; useful in testing or in cleanup + # when an error has been encountered + def destroy + self.class.delete(self) + + @dependencies.each { |dep| + dep.unsubscribe(self) + } + end + #--------------------------------------------------------------- + + #--------------------------------------------------------------- # iterate across all children, and then iterate across states # we do children first so we're sure that all dependent objects # are checked first @@ -719,9 +747,6 @@ class Type < Puppet::Element # add this object to the specific class's list of objects #puts caller self.class[self.name] = self - - # and then add it to the master list - Puppet::Type.push(self) end #--------------------------------------------------------------- @@ -1155,6 +1180,20 @@ class Type < Puppet::Element #--------------------------------------------------------------- #--------------------------------------------------------------- + def unsubscribe(object, event = nil) + @subscriptions.find_all { |sub| + if event + sub.target == object and sub.event = event + else + sub.target == object + end + }.each { |sub| + @subscriptions.delete(sub) + } + end + #--------------------------------------------------------------- + + #--------------------------------------------------------------- # return all of the subscriptions to a given event def subscribers?(event) @subscriptions.find_all { |sub| @@ -1213,7 +1252,7 @@ end require 'puppet/statechange' require 'puppet/type/component' -require 'puppet/type/cron' +#require 'puppet/type/cron' require 'puppet/type/exec' require 'puppet/type/group' require 'puppet/type/package' diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index c5326ca33..e58c25f24 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -152,7 +152,7 @@ module Puppet hash["returns"] = hash["returns"].to_s end elsif hash.include?(:returns) - if hash["returns"].is_a?(Fixnum) + if hash[:returns].is_a?(Fixnum) hash[:returns] = hash[:returns].to_s end else @@ -169,11 +169,10 @@ module Puppet # if we're not fully qualified, require a path if self[:command] !~ /^\// if self[:path].nil? - error = TypeError.new( + puts caller + raise TypeError, "'%s' is both unqualifed and specified no search path" % self[:command] - ) - raise error end end end |