diff options
author | Luke Kanies <luke@madstop.com> | 2005-06-27 21:47:06 +0000 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2005-06-27 21:47:06 +0000 |
commit | 60783f0777eb5dd89d44a8dfd2ced49f06a32d8f (patch) | |
tree | d1cf67771de26cd49d98fff28d2e7aa89cbf63e0 /lib | |
parent | 8f95084cd854aef4e3493854e58cefd352cdc68d (diff) | |
download | puppet-60783f0777eb5dd89d44a8dfd2ced49f06a32d8f.tar.gz puppet-60783f0777eb5dd89d44a8dfd2ced49f06a32d8f.tar.xz puppet-60783f0777eb5dd89d44a8dfd2ced49f06a32d8f.zip |
renaming blink to puppet
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@305 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet.rb | 32 | ||||
-rw-r--r-- | lib/puppet/client.rb | 44 | ||||
-rw-r--r-- | lib/puppet/element.rb | 6 | ||||
-rw-r--r-- | lib/puppet/event.rb | 38 | ||||
-rw-r--r-- | lib/puppet/fact.rb | 10 | ||||
-rw-r--r-- | lib/puppet/function.rb | 18 | ||||
-rw-r--r-- | lib/puppet/message.rb | 6 | ||||
-rw-r--r-- | lib/puppet/selector.rb | 6 | ||||
-rw-r--r-- | lib/puppet/statechange.rb | 16 | ||||
-rw-r--r-- | lib/puppet/storage.rb | 10 | ||||
-rw-r--r-- | lib/puppet/transaction.rb | 30 | ||||
-rw-r--r-- | lib/puppet/transportable.rb | 32 | ||||
-rw-r--r-- | lib/puppet/type.rb | 100 | ||||
-rw-r--r-- | lib/puppet/type/component.rb | 20 | ||||
-rw-r--r-- | lib/puppet/type/file.rb | 84 | ||||
-rw-r--r-- | lib/puppet/type/package.rb | 50 | ||||
-rw-r--r-- | lib/puppet/type/process.rb | 16 | ||||
-rw-r--r-- | lib/puppet/type/service.rb | 36 | ||||
-rw-r--r-- | lib/puppet/type/state.rb | 22 | ||||
-rw-r--r-- | lib/puppet/type/symlink.rb | 28 | ||||
-rw-r--r-- | lib/puppet/type/typegen.rb | 18 | ||||
-rw-r--r-- | lib/puppet/type/typegen/filerecord.rb | 16 | ||||
-rw-r--r-- | lib/puppet/type/typegen/filetype.rb | 32 |
23 files changed, 335 insertions, 335 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb index 17d3a8d6c..5daa2b1a6 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -21,14 +21,14 @@ RESET="[0m" # preferences for things like debugging # # it's also a place to find top-level commands like 'debug' -module Blink +module Puppet # the hash that determines how our system behaves @@config = Hash.new(false) - @@config[:blinkroot] = "/var/blink" - @@config[:logdir] = "/var/blink/log" - @@config[:logfile] = "/var/blink/log/blink.log" - @@config[:statefile] = "/var/blink/log/state" + @@config[:puppetroot] = "/var/puppet" + @@config[:logdir] = "/var/puppet/log" + @@config[:logfile] = "/var/puppet/log/puppet.log" + @@config[:statefile] = "/var/puppet/log/state" loglevels = [:debug,:verbose,:notice,:warning,:error] @@ -38,27 +38,27 @@ module Blink # pick one, and it and all above it will be logged loglevels.each { |level| define_method(level,proc { |args| - Blink.message(level,args) + Puppet.message(level,args) }) module_function level # default to enabling all notice levels except debug @@config[level] = true unless level == :debug } - def Blink.message(level,*ary) + def Puppet.message(level,*ary) msg = ary.join(" ") if @@config[level] - Blink::Message.new( + Puppet::Message.new( :level => level, - :source => "Blink", + :source => "Puppet", :message => msg ) end end # set up our configuration - def Blink.init(args) + def Puppet.init(args) args.each {|p,v| @@config[p] = v } @@ -66,22 +66,22 @@ module Blink # just print any messages we get # we should later behave differently depending on the message - def Blink.newmessage(msg) + def Puppet.newmessage(msg) puts msg end # configuration parameter access and stuff - def Blink.[](param) + def Puppet.[](param) return @@config[param] end # configuration parameter access and stuff - def Blink.[]=(param,value) + def Puppet.[]=(param,value) @@config[param] = value end end -require 'blink/storage' -require 'blink/message' -require 'blink/type' +require 'puppet/storage' +require 'puppet/message' +require 'puppet/type' diff --git a/lib/puppet/client.rb b/lib/puppet/client.rb index f266d2dfb..f1140ea4d 100644 --- a/lib/puppet/client.rb +++ b/lib/puppet/client.rb @@ -4,19 +4,19 @@ # the available clients -require 'blink' -require 'blink/function' -require 'blink/type' -require 'blink/fact' -require 'blink/transaction' -require 'blink/transportable' +require 'puppet' +require 'puppet/function' +require 'puppet/type' +require 'puppet/fact' +require 'puppet/transaction' +require 'puppet/transportable' require 'http-access2' require 'soap/rpc/driver' require 'soap/rpc/httpserver' #require 'webrick/https' require 'logger' -module Blink +module Puppet class ClientError < RuntimeError; end #--------------------------------------------------------------- class Client < SOAP::RPC::HTTPServer @@ -26,19 +26,19 @@ module Blink @nil = nil @url = hash[:Server] if hash.include?(:Listen) and hash[:Listen] == false - Blink.notice "We're a local client" + Puppet.notice "We're a local client" @localonly = true @driver = @url else - Blink.notice "We're a networked client" + Puppet.notice "We're a networked client" @localonly = false - @driver = SOAP::RPC::Driver.new(@url, 'urn:blink-server') + @driver = SOAP::RPC::Driver.new(@url, 'urn:puppet-server') @driver.add_method("getconfig", "name") end unless @localonly hash.delete(:Server) - Blink.notice "Server is %s" % @url + Puppet.notice "Server is %s" % @url hash[:BindAddress] ||= "0.0.0.0" hash[:Port] ||= 17444 @@ -50,14 +50,14 @@ module Blink end def getconfig - Blink.debug "server is %s" % @url + Puppet.debug "server is %s" % @url #client.loadproperty('files/sslclient.properties') - Blink.notice("getting config") + Puppet.notice("getting config") objects = nil if @localonly objects = @driver.getconfig(self) else - objects = @driver.getconfig(Blink::Fact["hostname"]) + objects = @driver.getconfig(Puppet::Fact["hostname"]) end self.config(objects) end @@ -67,28 +67,28 @@ module Blink # for now, just descend into the tree and perform and necessary # manipulations def config(tree) - Blink.notice("Calling config") + Puppet.notice("Calling config") container = Marshal::load(tree).to_type # this is a gross hack... but i don't see a good way around it # set all of the variables to empty - Blink::Transaction.init + Puppet::Transaction.init # for now we just evaluate the top-level container, but eventually # there will be schedules and such associated with each object, # and probably with the container itself transaction = container.evaluate - #transaction = Blink::Transaction.new(objects) + #transaction = Puppet::Transaction.new(objects) transaction.toplevel = true transaction.evaluate self.shutdown end def callfunc(name,args) - Blink.notice("Calling callfunc on %s" % name) - if function = Blink::Function[name] - #Blink.debug("calling function %s" % function) + Puppet.notice("Calling callfunc on %s" % name) + if function = Puppet::Function[name] + #Puppet.debug("calling function %s" % function) value = function.call(args) - #Blink.debug("from %s got %s" % [name,value]) + #Puppet.debug("from %s got %s" % [name,value]) return value else raise "Function '%s' not found" % name @@ -98,7 +98,7 @@ module Blink private def on_init - @default_namespace = 'urn:blink-client' + @default_namespace = 'urn:puppet-client' add_method(self, 'config', 'config') add_method(self, 'callfunc', 'name', 'arguments') end diff --git a/lib/puppet/element.rb b/lib/puppet/element.rb index dd187977a..9e09ae4e7 100644 --- a/lib/puppet/element.rb +++ b/lib/puppet/element.rb @@ -3,14 +3,14 @@ # $Id$ # included so we can test object types -require 'blink' +require 'puppet' #--------------------------------------------------------------- # the base class for both types and states # very little functionality; basically just defines the interface # and provides a few simple across-the-board functions like 'noop' -class Blink::Element +class Puppet::Element attr_writer :noop #--------------------------------------------------------------- @@ -33,7 +33,7 @@ class Blink::Element unless defined? @noop @noop = false end - return @noop || Blink[:noop] || false + return @noop || Puppet[:noop] || false end #--------------------------------------------------------------- diff --git a/lib/puppet/event.rb b/lib/puppet/event.rb index 2cdda9976..51f97e06e 100644 --- a/lib/puppet/event.rb +++ b/lib/puppet/event.rb @@ -3,10 +3,10 @@ # $Id$ # included so we can test object types -require 'blink' -require 'blink/type' +require 'puppet' +require 'puppet/type' -module Blink +module Puppet # events are transient packets of information; they result in one or more (or none) # subscriptions getting triggered, and then they get cleared # eventually, these will be passed on to some central event system @@ -24,7 +24,7 @@ module Blink # this is probably wicked-slow self.send(method.to_s + "=",value) } - Blink.warning "New Subscription: '%s' => '%s'" % + Puppet.warning "New Subscription: '%s' => '%s'" % [@source,@event] end @@ -38,22 +38,22 @@ module Blink # to the "old" object rather than "new" # but we're pretty far from that being a problem if transaction.triggercount(self) > 0 - Blink.verbose "%s has already run" % self + Puppet.verbose "%s has already run" % self else - Blink.verbose "'%s' matched '%s'; triggering '%s' on '%s'" % + Puppet.verbose "'%s' matched '%s'; triggering '%s' on '%s'" % [@source,@event,@method,@target] begin if @target.respond_to?(@method) @target.send(@method) else - Blink.verbose "'%s' of type '%s' does not respond to '%s'" % + Puppet.verbose "'%s' of type '%s' does not respond to '%s'" % [@target,@target.class,@method.inspect] end rescue => detail # um, what the heck do i do when an object fails to refresh? # shouldn't that result in the transaction rolling back? # XXX yeah, it should - Blink.error "'%s' failed to %s: '%s'" % + Puppet.error "'%s' failed to %s: '%s'" % [@target,@method,detail] raise #raise "We need to roll '%s' transaction back" % @@ -71,16 +71,16 @@ module Blink @@subscriptions = [] def Event.process - Blink.warning "Processing events" + Puppet.warning "Processing events" @@events.each { |event| @@subscriptions.find_all { |sub| - #Blink.warning "Sub source: '%s'; event object: '%s'" % + #Puppet.warning "Sub source: '%s'; event object: '%s'" % # [sub.source.inspect,event.object.inspect] sub.source == event.object and (sub.event == event.event or sub.event == :ALL_EVENTS) }.each { |sub| - Blink.notice "Found sub" + Puppet.notice "Found sub" sub.trigger(event.transaction) } } @@ -107,7 +107,7 @@ module Blink @object = args[:object] @transaction = args[:transaction] - Blink.warning "New Event: '%s' => '%s'" % + Puppet.warning "New Event: '%s' => '%s'" % [@object,@event] # initially, just stuff all instances into a central bucket @@ -122,7 +122,7 @@ end # here i'm separating out the methods dealing with handling events # currently not in use, so... -class Blink::NotUsed +class Puppet::NotUsed #--------------------------------------------------------------- # return action array # these are actions to use for responding to events @@ -144,9 +144,9 @@ class Blink::NotUsed # event handling should probably be taking place in a central process, # but.... def event(event,obj) - Blink.debug "#{self} got event #{event} from #{obj}" + Puppet.debug "#{self} got event #{event} from #{obj}" if @actions.key?(event) - Blink.debug "calling it" + Puppet.debug "calling it" @actions[event].call(self,obj,event) else p @actions @@ -170,7 +170,7 @@ class Blink::NotUsed @notify[event] = Array.new end unless @notify[event].include?(obj) - Blink.debug "pushing event '%s' for object '%s'" % [event,obj] + Puppet.debug "pushing event '%s' for object '%s'" % [event,obj] @notify[event].push(obj) end # } @@ -189,13 +189,13 @@ class Blink::NotUsed if (@notify.include?(event) and (! @notify[event].empty?) ) @notify[event].each { |obj| subscribers.push(obj) } end - Blink.debug "triggering #{event}" + Puppet.debug "triggering #{event}" subscribers.each { |obj| - Blink.debug "calling #{event} on #{obj}" + Puppet.debug "calling #{event} on #{obj}" obj.event(event,self) } end #--------------------------------------------------------------- #--------------------------------------------------------------- -end # Blink::Type +end # Puppet::Type diff --git a/lib/puppet/fact.rb b/lib/puppet/fact.rb index 2b46aabd8..0a90d4e50 100644 --- a/lib/puppet/fact.rb +++ b/lib/puppet/fact.rb @@ -9,17 +9,17 @@ # currently a very thin veneer on 'facter' require 'facter' -require 'blink' -require 'blink/type' +require 'puppet' +require 'puppet/type' -module Blink +module Puppet class Fact def Fact.[](name) fact = Facter[name] if fact.value.nil? raise "Could not retrieve fact %s" % name end - Blink.debug("fact: got %s from %s for %s" % [fact.value,fact,name]) + Puppet.debug("fact: got %s from %s for %s" % [fact.value,fact,name]) return fact.value end @@ -39,7 +39,7 @@ module Blink return :name end - #Blink::Type.newtype(self) + #Puppet::Type.newtype(self) # we're adding a new resolution mechanism here; this is just how # types work diff --git a/lib/puppet/function.rb b/lib/puppet/function.rb index d5cc11107..3a46ace72 100644 --- a/lib/puppet/function.rb +++ b/lib/puppet/function.rb @@ -2,10 +2,10 @@ # $Id$ -require 'blink' -require 'blink/fact' +require 'puppet' +require 'puppet/fact' -module Blink +module Puppet class Function @@functions = Hash.new(nil) @@ -34,16 +34,16 @@ module Blink end Function.new("fact", proc { |fact| - require 'blink/fact' + require 'puppet/fact' value = Fact[fact] - Blink.debug("retrieved %s as %s" % [fact,value]) + Puppet.debug("retrieved %s as %s" % [fact,value]) value }) Function.new("addfact", proc { |args| - require 'blink/fact' - #Blink.debug("running addfact") + require 'puppet/fact' + #Puppet.debug("running addfact") hash = nil if args.is_a?(Array) @@ -59,7 +59,7 @@ module Blink else raise "Functions must have names" end - #Blink.debug("adding fact %s" % name) + #Puppet.debug("adding fact %s" % name) newfact = Fact.add(name) { |fact| hash.each { |key,value| method = key + "=" @@ -67,6 +67,6 @@ module Blink } } - #Blink.debug("got fact %s" % newfact) + #Puppet.debug("got fact %s" % newfact) }) end diff --git a/lib/puppet/message.rb b/lib/puppet/message.rb index 31d5fa503..866ac16c4 100644 --- a/lib/puppet/message.rb +++ b/lib/puppet/message.rb @@ -1,6 +1,6 @@ # $Id$ -module Blink +module Puppet #------------------------------------------------------------ # provide feedback of various types to the user # modeled after syslog messages @@ -25,7 +25,7 @@ module Blink def initialize(args) unless args.include?(:level) && args.include?(:message) && args.include?(:source) - raise "Blink::Message called incorrectly" + raise "Puppet::Message called incorrectly" end if args[:level].class == String @@ -45,7 +45,7 @@ module Blink end @@messages.push(self) - Blink.newmessage(self) + Puppet.newmessage(self) end def to_s diff --git a/lib/puppet/selector.rb b/lib/puppet/selector.rb index 51e82b09d..6bfa1e2dd 100644 --- a/lib/puppet/selector.rb +++ b/lib/puppet/selector.rb @@ -2,10 +2,10 @@ # $Id$ -require 'blink' -require 'blink/fact' +require 'puppet' +require 'puppet/fact' -module Blink +module Puppet #--------------------------------------------------------------- # this class will provide something like a 'select' statement, but it will # return a value diff --git a/lib/puppet/statechange.rb b/lib/puppet/statechange.rb index f88108d8a..17f5c80f9 100644 --- a/lib/puppet/statechange.rb +++ b/lib/puppet/statechange.rb @@ -6,7 +6,7 @@ # enables no-op and logging/rollback -module Blink +module Puppet class StateChange attr_accessor :is, :should, :type, :path, :state, :transaction, :run @@ -25,7 +25,7 @@ module Blink #--------------------------------------------------------------- def go if @state.noop - #Blink.notice "%s is noop" % @state + #Puppet.notice "%s is noop" % @state return nil end @@ -37,7 +37,7 @@ module Blink if event.nil? event = @state.parent.class.name.id2name + "_changed" elsif ! event.is_a?(Symbol) - Blink.notice "State '%s' returned invalid event '%s'; resetting to default" % + Puppet.notice "State '%s' returned invalid event '%s'; resetting to default" % [@state.class,event] event = @state.parent.class.name.id2name + "_changed" @@ -45,14 +45,14 @@ module Blink # i should maybe include object type, but the event type # should basically point to that, right? - return Blink::Event.new( + return Puppet::Event.new( :event => event, :object => @state.parent, :transaction => @transaction, :message => self.to_s ) rescue => detail - Blink.error "%s failed: %s" % [self.to_s,detail] + Puppet.error "%s failed: %s" % [self.to_s,detail] raise # there should be a way to ask the state what type of event # it would have generated, but... @@ -60,7 +60,7 @@ module Blink #if pname.is_a?(Symbol) # pname = pname.id2name #end - return Blink::Event.new( + return Puppet::Event.new( :event => pname + "_failed", :object => @state.parent, :transaction => @transaction, @@ -72,7 +72,7 @@ module Blink #--------------------------------------------------------------- def forward - #Blink.notice "moving change forward" + #Puppet.notice "moving change forward" unless defined? @transaction raise "StateChange '%s' tried to be executed outside of transaction" % @@ -88,7 +88,7 @@ module Blink @state.should = @is @state.retrieve - Blink.notice "Rolling %s backward" % self + Puppet.notice "Rolling %s backward" % self return self.go #raise "Moving statechanges backward is currently unsupported" diff --git a/lib/puppet/storage.rb b/lib/puppet/storage.rb index 9fc21d38b..53b3b5a6e 100644 --- a/lib/puppet/storage.rb +++ b/lib/puppet/storage.rb @@ -1,6 +1,6 @@ # $Id$ -module Blink +module Puppet # a class for storing state class Storage include Singleton @@ -15,9 +15,9 @@ module Blink def Storage.load # XXX I should probably use a better default state dir - Blink[:statefile] ||= "/var/tmp/blinkstate" - return unless File.exists?(Blink[:statefile]) - File.open(Blink[:statefile]) { |file| + Puppet[:statefile] ||= "/var/tmp/puppetstate" + return unless File.exists?(Puppet[:statefile]) + File.open(Puppet[:statefile]) { |file| file.gets { |line| myclass, key, value = line.split(@@splitchar) @@ -35,7 +35,7 @@ module Blink end def Storage.store - File.open(Blink[:statefile], File::CREAT|File::WRONLY, 0600) { |file| + File.open(Puppet[:statefile], File::CREAT|File::WRONLY, 0600) { |file| @@state.each { |klass, thash| thash.each { |key,value| mvalue = Marshal::dump(value) diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index 87b2f950c..e1b42aedd 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -9,11 +9,11 @@ # - first we recurse down the tree and collect changes # - then we walk back up the tree through 'refresh' after the changes -require 'blink' -require 'blink/statechange' +require 'puppet' +require 'puppet/statechange' #--------------------------------------------------------------- -module Blink +module Puppet class Transaction attr_accessor :toplevel, :component @@ -41,17 +41,17 @@ class Transaction # thus, an object gets defined, then mentioned as a dependency, and the objects # are synced in that order automatically def evaluate - Blink.notice "executing %s changes or transactions" % @changes.length + Puppet.notice "executing %s changes or transactions" % @changes.length return @changes.collect { |change| - if change.is_a?(Blink::StateChange) + if change.is_a?(Puppet::StateChange) change.transaction = self events = nil begin events = [change.forward].flatten #@@changed.push change.state.parent rescue => detail - Blink.error("%s failed: %s" % [change,detail]) + Puppet.error("%s failed: %s" % [change,detail]) raise # at this point, we would normally do error handling # but i haven't decided what to do for that yet @@ -62,7 +62,7 @@ class Transaction end if events.nil? - Blink.verbose "No events returned?" + Puppet.verbose "No events returned?" else # first handle the subscriptions on individual objects events.each { |event| @@ -72,7 +72,7 @@ class Transaction } end events - elsif change.is_a?(Blink::Transaction) + elsif change.is_a?(Puppet::Transaction) change.evaluate else raise "Transactions cannot handle objects of type %s" % child.class @@ -90,7 +90,7 @@ class Transaction #--------------------------------------------------------------- #--------------------------------------------------------------- - # this should only be called by a Blink::Container object now + # this should only be called by a Puppet::Container object now # and it should only receive an array def initialize(tree) @tree = tree @@ -106,7 +106,7 @@ class Transaction # change collection is in-band, and message generation is out-of-band # of course, exception raising is also out-of-band @changes = @tree.collect { |child| - # these children are all Blink::Type instances + # these children are all Puppet::Type instances # not all of the children will return a change, and Containers # return transactions child.evaluate @@ -119,14 +119,14 @@ class Transaction #--------------------------------------------------------------- def rollback @changes.each { |change| - if change.is_a?(Blink::StateChange) + if change.is_a?(Puppet::StateChange) next unless change.run #change.transaction = self begin change.backward #@@changed.push change.state.parent rescue => detail - Blink.error("%s rollback failed: %s" % [change,detail]) + Puppet.error("%s rollback failed: %s" % [change,detail]) # at this point, we would normally do error handling # but i haven't decided what to do for that yet # so just record that a sync failed for a given object @@ -134,7 +134,7 @@ class Transaction # this still could get hairy; what if file contents changed, # but a chmod failed? how would i handle that error? dern end - elsif change.is_a?(Blink::Transaction) + elsif change.is_a?(Puppet::Transaction) # yay, recursion change.rollback else @@ -146,7 +146,7 @@ class Transaction #--------------------------------------------------------------- def triggercount(sub) - Blink.notice "Triggercount on %s is %s" % [sub,@triggered[sub]] + Puppet.notice "Triggercount on %s is %s" % [sub,@triggered[sub]] return @triggered[sub] end #--------------------------------------------------------------- @@ -154,7 +154,7 @@ class Transaction #--------------------------------------------------------------- def triggered(sub) @triggered[sub] += 1 - Blink.notice "%s was triggered; count is %s" % [sub,@triggered[sub]] + Puppet.notice "%s was triggered; count is %s" % [sub,@triggered[sub]] end #--------------------------------------------------------------- end diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb index 522a34d7c..1f25e2e97 100644 --- a/lib/puppet/transportable.rb +++ b/lib/puppet/transportable.rb @@ -2,9 +2,9 @@ # $Id$ -require 'blink' +require 'puppet' -module Blink +module Puppet #------------------------------------------------------------ class TransObject < Hash attr_accessor :type @@ -50,13 +50,13 @@ module Blink def to_type retobj = nil - if type = Blink::Type.type(self.type) + if type = Puppet::Type.type(self.type) #begin # this will fail if the type already exists # which may or may not be a good thing... retobj = type.new(self) #rescue => detail - # Blink.error "Failed to create %s: %s" % [type.name,detail] + # Puppet.error "Failed to create %s: %s" % [type.name,detail] # puts self.class # puts self.inspect # exit @@ -80,7 +80,7 @@ module Blink def evaluate @evalcount += 0 - if type = Blink::Type.type(self.type) + if type = Puppet::Type.type(self.type) # call the settings name = self.name unless name.is_a?(Symbol) @@ -89,7 +89,7 @@ module Blink if type.allowedmethod(name) type.send(self.name,self.args) else - Blink.error("%s does not respond to %s" % [self.type,self.name]) + Puppet.error("%s does not respond to %s" % [self.type,self.name]) end else raise "Could not find object type %s" % setting.type @@ -106,7 +106,7 @@ module Blink def push(*args) args.each { |arg| case arg - when Blink::TransBucket, Blink::TransObject, Blink::TransSetting + when Puppet::TransBucket, Puppet::TransObject, Puppet::TransSetting # nada else raise "TransBuckets cannot handle objects of type %s" % @@ -119,12 +119,12 @@ module Blink def to_type # this container will contain the equivalent of all objects at # this level - #container = Blink::Component.new(:name => @name, :type => @type) + #container = Puppet::Component.new(:name => @name, :type => @type) unless defined? @name raise "TransBuckets must have names" end unless defined? @type - Blink.verbose "TransBucket '%s' has no type" % @name + Puppet.verbose "TransBucket '%s' has no type" % @name end hash = { :name => @name, @@ -132,27 +132,27 @@ module Blink } if defined? @parameters @parameters.each { |param,value| - Blink.warning "Defining %s on %s of type %s" % + Puppet.warning "Defining %s on %s of type %s" % [param,@name,@type] hash[param] = value } else - Blink.warning "%s has no parameters" % @name + Puppet.warning "%s has no parameters" % @name end - container = Blink::Component.new(hash) + container = Puppet::Component.new(hash) nametable = {} self.each { |child| # the fact that we descend here means that we are # always going to execute depth-first # which is _probably_ a good thing, but one never knows... - if child.is_a?(Blink::TransBucket) + if child.is_a?(Puppet::TransBucket) # just perform the same operation on any children container.push(child.to_type) - elsif child.is_a?(Blink::TransSetting) + elsif child.is_a?(Puppet::TransSetting) # XXX this is wrong, but for now just evaluate the settings child.evaluate - elsif child.is_a?(Blink::TransObject) + elsif child.is_a?(Puppet::TransObject) # do a simple little naming hack to see if the object already # exists in our scope # this assumes that type/name combinations are globally @@ -165,7 +165,7 @@ module Blink # don't rename; this shouldn't be possible anyway next if var == :name - Blink.notice "Adding %s to %s" % [var,name] + Puppet.notice "Adding %s to %s" % [var,name] # override any existing values object[var] = value } diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 51cd904e7..02661f64a 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -3,10 +3,10 @@ # $Id$ # included so we can test object types -require 'blink' -require 'blink/element' -require 'blink/event' -require 'blink/type/state' +require 'puppet' +require 'puppet/element' +require 'puppet/event' +require 'puppet/type/state' # XXX see the bottom of the file for the rest of the inclusions @@ -22,24 +22,24 @@ require 'blink/type/state' # all of our first-class objects (objects, states, and components) will # respond to these methods -# although states don't inherit from Blink::Type -# although maybe Blink::State should... +# although states don't inherit from Puppet::Type +# although maybe Puppet::State should... # the default behaviour that this class provides is to just call a given # method on each contained object, e.g., in calling 'sync', we just run: # object.each { |subobj| subobj.sync() } -# to use this interface, just define an 'each' method and 'include Blink::Type' +# to use this interface, just define an 'each' method and 'include Puppet::Type' -module Blink -class Type < Blink::Element +module Puppet +class Type < Puppet::Element attr_accessor :children, :parameters, :parent include Enumerable @@allobjects = Array.new # an array for all objects @abstract = true - @name = :blink # a little fakery, since Blink itself isn't a type + @name = :puppet # a little fakery, since Puppet itself isn't a type @namevar = :notused @states = [] @@ -104,7 +104,7 @@ class Type < Blink::Element #--------------------------------------------------------------- def Type.statefile(file) - Blink[:statefile] = file + Puppet[:statefile] = file end #--------------------------------------------------------------- @@ -112,13 +112,13 @@ class Type < Blink::Element # ill thought-out # this needs to return @noop #def noop(ary) - # Blink[:noop] = ary.shift + # Puppet[:noop] = ary.shift #end #--------------------------------------------------------------- #--------------------------------------------------------------- #def debug(ary) - # Blink[:debug] = ary.shift + # Puppet[:debug] = ary.shift #end #--------------------------------------------------------------- @@ -129,7 +129,7 @@ class Type < Blink::Element @@typeary.each { |otype| if @@typehash.include?(otype.name) if @@typehash[otype.name] != otype - Blink.warning("Object type %s is already defined (%s vs %s)" % + Puppet.warning("Object type %s is already defined (%s vs %s)" % [otype.name,@@typehash[otype.name],otype]) end else @@ -151,7 +151,7 @@ class Type < Blink::Element def Type.inherited(sub) sub.initvars - #Blink.notice("subtype %s(%s) just created" % [sub,sub.superclass]) + #Puppet.notice("subtype %s(%s) just created" % [sub,sub.superclass]) # add it to the master list # unfortunately we can't yet call sub.name, because the #inherited # method gets called before any commands in the class definition @@ -166,7 +166,7 @@ class Type < Blink::Element def Type.initvars @objects = Hash.new @actions = Hash.new - #Blink.verbose "initing validstates for %s" % self + #Puppet.verbose "initing validstates for %s" % self @validstates = {} @validparameters = {} @@ -187,7 +187,7 @@ class Type < Blink::Element #--------------------------------------------------------------- #--------------------------------------------------------------- - # this is used for mapping object types (e.g., Blink::Type::File) + # this is used for mapping object types (e.g., Puppet::Type::File) # to names (e.g., "file") def Type.name return @name @@ -199,7 +199,7 @@ class Type < Blink::Element raise "Type.newtype called, but I don't know why" @@typeary.push(type) if @@typehash.has_key?(type.name) - Blink.notice("Redefining object type %s" % type.name) + Puppet.notice("Redefining object type %s" % type.name) end @@typehash[type.name] = type end @@ -235,10 +235,10 @@ class Type < Blink::Element #--------------------------------------------------------------- def Type.[]=(name,object) newobj = nil - if object.is_a?(Blink::Type) + if object.is_a?(Puppet::Type) newobj = object else - raise "must pass a Blink::Type object" + raise "must pass a Puppet::Type object" end if @objects.has_key?(newobj.name) @@ -246,7 +246,7 @@ class Type < Blink::Element [newobj.name,newobj.class.name, @objects[newobj.name].object_id,newobj.object_id] else - #Blink.debug("adding %s of type %s to class list" % + #Puppet.debug("adding %s of type %s to class list" % # [object.name,object.class]) @objects[newobj.name] = newobj end @@ -257,7 +257,7 @@ class Type < Blink::Element # remove all type instances def Type.allclear @@typeary.each { |subtype| - Blink.notice "Clearing %s of objects" % subtype + Puppet.notice "Clearing %s of objects" % subtype subtype.clear } end @@ -276,7 +276,7 @@ class Type < Blink::Element # all objects total def Type.push(object) @@allobjects.push object - #Blink.debug("adding %s of type %s to master list" % + #Puppet.debug("adding %s of type %s to master list" % # [object.name,object.class]) end #--------------------------------------------------------------- @@ -334,7 +334,7 @@ class Type < Blink::Element #--------------------------------------------------------------- # this is probably only used by FileRecord objects def Type.parameters=(params) - Blink.notice "setting parameters to [%s]" % params.join(" ") + Puppet.notice "setting parameters to [%s]" % params.join(" ") @parameters = params.collect { |param| if param.class == Symbol param @@ -418,12 +418,12 @@ class Type < Blink::Element mname = name.intern end - if Blink::Type.metaparam(mname) + if Puppet::Type.metaparam(mname) # call the metaparam method self.send(("meta" + mname.id2name),value) elsif stateklass = self.class.validstate(mname) - if value.is_a?(Blink::State) - Blink.debug "'%s' got handed a state for '%s'" % [self,mname] + if value.is_a?(Puppet::State) + Puppet.debug "'%s' got handed a state for '%s'" % [self,mname] @states[mname] = value else if @states.include?(mname) @@ -433,7 +433,7 @@ class Type < Blink::Element :parent => self, :should => value ) - #Blink.notice "Adding parent to %s" % mname + #Puppet.notice "Adding parent to %s" % mname #@states[mname].parent = self end end @@ -540,17 +540,17 @@ class Type < Blink::Element end hash.each { |param,value| - #Blink.debug("adding param '%s' with value '%s'" % + #Puppet.debug("adding param '%s' with value '%s'" % # [param,value]) self[param] = value } # add this object to the specific class's list of objects - #Blink.notice("Adding [%s] to %s" % [self.name,self.class]) + #Puppet.notice("Adding [%s] to %s" % [self.name,self.class]) self.class[self.name] = self # and then add it to the master list - Blink::Type.push(self) + Puppet::Type.push(self) end #--------------------------------------------------------------- @@ -603,7 +603,7 @@ class Type < Blink::Element #--------------------------------------------------------------- def states - Blink.debug "%s has %s states" % [self,@states.length] + Puppet.debug "%s has %s states" % [self,@states.length] tmpstates = [] self.class.states.each { |state| if @states.include?(state.name) @@ -670,7 +670,7 @@ class Type < Blink::Element # rather than 'each' def evaluate unless defined? @evalcount - Blink.error "No evalcount defined on '%s' of type '%s'" % + Puppet.error "No evalcount defined on '%s' of type '%s'" % [self.name,self.class] end # if we're a metaclass and we've already evaluated once... @@ -689,7 +689,7 @@ class Type < Blink::Element changes << self.states.find_all { |state| ! state.insync? }.collect { |state| - Blink::StateChange.new(state) + Puppet::StateChange.new(state) } end # collect changes and return them @@ -708,12 +708,12 @@ class Type < Blink::Element self.states.each { |state| unless state.insync? - Blink.debug("%s is not in sync" % state) + Puppet.debug("%s is not in sync" % state) insync = false end } - Blink.debug("%s sync status is %s" % [self,insync]) + Puppet.debug("%s sync status is %s" % [self,insync]) return insync end #--------------------------------------------------------------- @@ -773,7 +773,7 @@ class Type < Blink::Element end hash[:source] = self - sub = Blink::Event::Subscription.new(hash) + sub = Puppet::Event::Subscription.new(hash) # add to the correct area @subscriptions.push sub @@ -804,7 +804,7 @@ class Type < Blink::Element type = nil object = nil tname = rname[0] - unless type = Blink::Type.type(tname) + unless type = Puppet::Type.type(tname) raise "Could not find type %s" % tname end name = rname[1] @@ -812,7 +812,7 @@ class Type < Blink::Element raise "Could not retrieve object '%s' of type '%s'" % [name,type] end - Blink.debug("%s requires %s" % [self.name,object]) + Puppet.debug("%s requires %s" % [self.name,object]) # for now, we only support this one method, 'refresh' object.subscribe( @@ -827,7 +827,7 @@ class Type < Blink::Element #--------------------------------------------------------------- def metaonerror(response) - Blink.debug("Would have called metaonerror") + Puppet.debug("Would have called metaonerror") @onerror = response end #--------------------------------------------------------------- @@ -837,15 +837,15 @@ class Type < Blink::Element @schedule = schedule end #--------------------------------------------------------------- -end # Blink::Type +end # Puppet::Type end -require 'blink/type/service' -require 'blink/type/file' -require 'blink/type/symlink' -require 'blink/type/package' -require 'blink/type/component' -require 'blink/statechange' -#require 'blink/type/typegen' -#require 'blink/type/typegen/filetype' -#require 'blink/type/typegen/filerecord' +require 'puppet/type/service' +require 'puppet/type/file' +require 'puppet/type/symlink' +require 'puppet/type/package' +require 'puppet/type/component' +require 'puppet/statechange' +#require 'puppet/type/typegen' +#require 'puppet/type/typegen/filetype' +#require 'puppet/type/typegen/filerecord' diff --git a/lib/puppet/type/component.rb b/lib/puppet/type/component.rb index 38bf3326d..f6d127d48 100644 --- a/lib/puppet/type/component.rb +++ b/lib/puppet/type/component.rb @@ -5,12 +5,12 @@ # the object allowing us to build complex structures # this thing contains everything else, including itself -require 'blink' -require 'blink/type' -require 'blink/transaction' +require 'puppet' +require 'puppet/type' +require 'puppet/transaction' -module Blink - class Component < Blink::Type +module Puppet + class Component < Puppet::Type include Enumerable @name = :component @@ -26,7 +26,7 @@ module Blink def initialize(args) @children = [] super(args) - Blink.verbose "Made component with name %s" % self.name + Puppet.verbose "Made component with name %s" % self.name end # now we decide whether a transaction is dumb, and just accepts @@ -34,16 +34,16 @@ module Blink # for now, because i've already got this implemented, let transactions # collect the changes themselves def evaluate - transaction = Blink::Transaction.new(@children) + transaction = Puppet::Transaction.new(@children) transaction.component = self return transaction end def push(*ary) ary.each { |child| - unless child.is_a?(Blink::Element) - Blink.notice "Got object of type %s" % child.class - raise "Containers can only contain Blink::Elements" + unless child.is_a?(Puppet::Element) + Puppet.notice "Got object of type %s" % child.class + raise "Containers can only contain Puppet::Elements" end @children.push child } diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 9d0f98c61..2330d2622 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -4,14 +4,14 @@ require 'digest/md5' require 'etc' -require 'blink/type/state' +require 'puppet/type/state' -module Blink +module Puppet # we first define all of the state that our file will use # because the objects must be defined for us to use them in our # definition of the file object class State - class FileCreate < Blink::State + class FileCreate < Puppet::State require 'etc' attr_accessor :file @name = :create @@ -30,7 +30,7 @@ module Blink stat = nil self.is = FileTest.exist?(self.parent[:path]) - Blink.debug "'exists' state is %s" % self.is + Puppet.debug "'exists' state is %s" % self.is end @@ -45,23 +45,23 @@ module Blink end end - class FileChecksum < Blink::State + class FileChecksum < Puppet::State @name = :checksum @event = :file_modified def should=(value) @checktype = value - state = Blink::Storage.state(self) + state = Puppet::Storage.state(self) if hash = state[self.parent[:path]] if hash.include?(@checktype) @should = hash[@checktype] else - Blink.verbose "Found checksum for %s but not of type %s" % + Puppet.verbose "Found checksum for %s but not of type %s" % [self.parent[:path],@checktype] @should = nil end else - Blink.debug "No checksum for %s" % self.parent[:path] + Puppet.debug "No checksum for %s" % self.parent[:path] end end @@ -88,7 +88,7 @@ module Blink self.is = sum - Blink.debug "checksum state is %s" % self.is + Puppet.debug "checksum state is %s" % self.is end @@ -103,17 +103,17 @@ module Blink end def updatesum - state = Blink::Storage.state(self) + state = Puppet::Storage.state(self) unless state.include?(self.parent[:path]) state[self.parent[:path]] = Hash.new end # if we're replacing, vs. updating if state[self.parent[:path]].include?(@checktype) - Blink.debug "Replacing checksum %s with %s" % + Puppet.debug "Replacing checksum %s with %s" % [state[self.parent[:path]][@checktype],@is] result = true else - Blink.verbose "Creating checksum %s for %s of type %s" % + Puppet.verbose "Creating checksum %s for %s of type %s" % [@is,self.parent[:path],@checktype] result = false end @@ -122,7 +122,7 @@ module Blink end end - class FileUID < Blink::State + class FileUID < Puppet::State require 'etc' attr_accessor :file @name = :owner @@ -139,7 +139,7 @@ module Blink if user.gid == "" raise "Could not retrieve uid for '%s'" % self.parent end - Blink.debug "converting %s to integer '%d'" % + Puppet.debug "converting %s to integer '%d'" % [@should,user.uid] @should = user.uid rescue @@ -148,18 +148,18 @@ module Blink end end - Blink.debug "chown state is %d" % self.is + Puppet.debug "chown state is %d" % self.is end def sync if @is == -1 self.parent.stat(true) self.retrieve - Blink.notice "%s: after refresh, is '%s'" % [self.class.name,@is] + Puppet.notice "%s: after refresh, is '%s'" % [self.class.name,@is] end unless self.parent.stat - Blink.error "File '%s' does not exist; cannot chown" % + Puppet.error "File '%s' does not exist; cannot chown" % self.parent[:path] end @@ -177,7 +177,7 @@ module Blink # this state should actually somehow turn into many states, # one for each bit in the mode # I think MetaStates are the answer, but I'm not quite sure - class FileMode < Blink::State + class FileMode < Puppet::State require 'etc' @name = :mode @@ -199,18 +199,18 @@ module Blink stat = self.parent.stat(true) self.is = stat.mode & 007777 - Blink.debug "chmod state is %o" % self.is + Puppet.debug "chmod state is %o" % self.is end def sync if @is == -1 self.parent.stat(true) self.retrieve - Blink.notice "%s: after refresh, is '%s'" % [self.class.name,@is] + Puppet.notice "%s: after refresh, is '%s'" % [self.class.name,@is] end unless self.parent.stat - Blink.error "File '%s' does not exist; cannot chmod" % + Puppet.error "File '%s' does not exist; cannot chmod" % self.parent[:path] return end @@ -226,10 +226,10 @@ module Blink # not used until I can figure out how to solve the problem with # metastates - class FileSetUID < Blink::State + class FileSetUID < Puppet::State require 'etc' - @parent = Blink::State::FileMode + @parent = Puppet::State::FileMode @name = :setuid @event = :inode_changed @@ -243,7 +243,7 @@ module Blink unless defined? @is or @is == -1 self.parent.stat(true) self.retrieve - Blink.notice "%s: should is '%s'" % [self.class.name,self.should] + Puppet.notice "%s: should is '%s'" % [self.class.name,self.should] end tmp = 0 if self.is == true @@ -254,7 +254,7 @@ module Blink end end - class FileGroup < Blink::State + class FileGroup < Puppet::State require 'etc' @name = :group @@ -271,10 +271,10 @@ module Blink if defined? @should unless self.should.is_a?(Integer) begin - require 'blink/fact' + require 'puppet/fact' group = Etc.getgrnam(self.should) # apparently os x is six shades of weird - os = Blink::Fact["Operatingsystem"] + os = Puppet::Fact["Operatingsystem"] gid = "" case os @@ -286,7 +286,7 @@ module Blink if gid == "" raise "Could not retrieve gid for %s" % self.parent end - Blink.debug "converting %s to integer %d" % + Puppet.debug "converting %s to integer %d" % [self.should,gid] self.should = gid rescue @@ -295,19 +295,19 @@ module Blink end end end - Blink.debug "chgrp state is %d" % self.is + Puppet.debug "chgrp state is %d" % self.is end def sync - Blink.debug "setting chgrp state to %s" % self.should + Puppet.debug "setting chgrp state to %s" % self.should if @is == -1 self.parent.stat(true) self.retrieve - Blink.notice "%s: after refresh, is '%s'" % [self.class.name,@is] + Puppet.notice "%s: after refresh, is '%s'" % [self.class.name,@is] end unless self.parent.stat - Blink.error "File '%s' does not exist; cannot chgrp" % + Puppet.error "File '%s' does not exist; cannot chgrp" % self.parent[:path] return end @@ -328,12 +328,12 @@ module Blink attr_reader :params # class instance variable @states = [ - Blink::State::FileCreate, - Blink::State::FileUID, - Blink::State::FileGroup, - Blink::State::FileMode, - Blink::State::FileChecksum, - Blink::State::FileSetUID + Puppet::State::FileCreate, + Puppet::State::FileUID, + Puppet::State::FileGroup, + Puppet::State::FileMode, + Puppet::State::FileChecksum, + Puppet::State::FileSetUID ] @parameters = [ @@ -347,7 +347,7 @@ module Blink # a wrapper method to make sure the file exists before doing anything def retrieve unless stat = self.stat(true) - Blink.verbose "File %s does not exist" % self[:path] + Puppet.verbose "File %s does not exist" % self[:path] @states.each { |name,state| state.is = -1 } @@ -361,7 +361,7 @@ module Blink begin @stat = ::File.stat(self[:path]) rescue => error - Blink.debug "Failed to stat %s: %s" % + Puppet.debug "Failed to stat %s: %s" % [self[:path],error] @stat = nil end @@ -421,8 +421,8 @@ module Blink end end end - end # Blink::Type::File - end # Blink::Type + end # Puppet::Type::File + end # Puppet::Type class FileSource attr_accessor :name diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb index 77bcd76b2..b2b0f8832 100644 --- a/lib/puppet/type/package.rb +++ b/lib/puppet/type/package.rb @@ -2,20 +2,20 @@ # $Id$ -require 'blink/type/state' -require 'blink/fact' +require 'puppet/type/state' +require 'puppet/fact' -module Blink +module Puppet class State - class PackageInstalled < Blink::State + class PackageInstalled < Puppet::State @name = :install def retrieve - #self.is = Blink::PackageTyping[@object.format][@object.name] + #self.is = Puppet::PackageTyping[@object.format][@object.name] unless @parent.class.listed @parent.class.getpkglist end - Blink.debug "package install state is %s" % self.is + Puppet.debug "package install state is %s" % self.is end def sync @@ -37,7 +37,7 @@ module Blink class Package < Type attr_reader :version, :format @states = [ - Blink::State::PackageInstalled + Puppet::State::PackageInstalled ] @parameters = [ :format, @@ -72,26 +72,26 @@ module Blink array = [array] end @@types = array - Blink.warning "Types are %s" % array.join(" ") + Puppet.warning "Types are %s" % array.join(" ") end def Package.getpkglist if @@types.nil? - case Blink::Fact["operatingsystem"] + case Puppet::Fact["operatingsystem"] when "SunOS": @@types = ["sunpkg"] when "Linux": - case Blink::Fact["distro"] + case Puppet::Fact["distro"] when "Debian": @@types = ["dpkg"] else - raise "No default type for " + Blink::Fact["distro"] + raise "No default type for " + Puppet::Fact["distro"] end else - raise "No default type for " + Blink::Fact["operatingsystem"] + raise "No default type for " + Puppet::Fact["operatingsystem"] end end list = @@types.collect { |type| - if typeobj = Blink::PackagingType[type] + if typeobj = Puppet::PackagingType[type] # pull all of the objects typeobj.list else @@ -110,17 +110,17 @@ module Blink if object = Package[name] states = {} object.states.each { |state| - Blink.warning "Adding %s" % state.name.inspect + Puppet.warning "Adding %s" % state.name.inspect states[state.name] = state } hash.each { |var,value| if states.include?(var) - Blink.verbose "%s is a set state" % var.inspect + Puppet.verbose "%s is a set state" % var.inspect states[var].is = value else - Blink.verbose "%s is not a set state" % var.inspect + Puppet.verbose "%s is not a set state" % var.inspect if object[var] and object[var] != value - Blink.warning "Overriding %s => %s on %s with %s" % + Puppet.warning "Overriding %s => %s on %s with %s" % [var,object[var],name,value] end @@ -128,12 +128,12 @@ module Blink # swap the values if we're a state if states.include?(var) - Blink.verbose "Swapping %s because it's a state" % var + Puppet.verbose "Swapping %s because it's a state" % var states[var].is = value states[var].should = nil else - Blink.verbose "%s is not a state" % var.inspect - Blink.verbose "States are %s" % states.keys.collect { |st| + Puppet.verbose "%s is not a state" % var.inspect + Puppet.verbose "States are %s" % states.keys.collect { |st| st.inspect }.join(" ") end @@ -153,7 +153,7 @@ module Blink super end - end # Blink::Type::Package + end # Puppet::Type::Package end class PackagingType @@ -165,8 +165,8 @@ module Blink if @@types.include?(name) return @@types[name] else - Blink.warning name.inspect - Blink.warning @@types.keys.collect { |key| + Puppet.warning name.inspect + Puppet.warning @@types.keys.collect { |key| key.inspect }.join(" ") return nil @@ -233,7 +233,7 @@ module Blink fields.zip(match.captures) { |field,value| hash[field] = value } - packages.push Blink::Type::Package.installedpkg(hash) + packages.push Puppet::Type::Package.installedpkg(hash) else raise "failed to match dpkg line %s" % line end @@ -287,7 +287,7 @@ module Blink process.each { |line| case line when /^$/ then - packages.push Blink::Type::Package.installedpkg(hash) + packages.push Puppet::Type::Package.installedpkg(hash) hash.clear when /\s*(\w+):\s+(.+)/ name = $1 diff --git a/lib/puppet/type/process.rb b/lib/puppet/type/process.rb index b42f75f26..5ee12a9e2 100644 --- a/lib/puppet/type/process.rb +++ b/lib/puppet/type/process.rb @@ -3,7 +3,7 @@ # DISABLED # I'm only working on services, not processes, right now -module Blink +module Puppet class State class ProcessRunning < State def retrieve @@ -19,7 +19,7 @@ module Blink } rescue # this isn't correct, but what the hell - Blink::Message.new( + Puppet::Message.new( :level => :error, :source => self.parent, :message => "Failed to run ps" @@ -27,7 +27,7 @@ module Blink end self.state = running - Blink.debug "there are #{running} #{self.parent} processes for start" + Puppet.debug "there are #{running} #{self.parent} processes for start" end def <=>(other) @@ -47,7 +47,7 @@ module Blink Process.uid = uid Process.euid = uid string = @params[:binary] + (@params[:arguments] || "") - Blink::Message.new( + Puppet::Message.new( :level => :notice, :source => self.parent, :message => "starting" @@ -65,19 +65,19 @@ module Blink @namevar = :pattern - Blink::Relation.new(self, Blink::Operation::Start, { + Puppet::Relation.new(self, Puppet::Operation::Start, { :user => :user, :pattern => :pattern, :binary => :binary, :arguments => :arguments }) - Blink::Relation.new(self, Blink::Operation::Stop, { + Puppet::Relation.new(self, Puppet::Operation::Stop, { :user => :user, :pattern => :pattern }) - end # Blink::Type::BProcess - end # Blink::Type + end # Puppet::Type::BProcess + end # Puppet::Type end diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb index f17f17e3f..98004ca58 100644 --- a/lib/puppet/type/service.rb +++ b/lib/puppet/type/service.rb @@ -8,7 +8,7 @@ # can only be managed through the interface of an init script # which is why they have a search path for initscripts and such -module Blink +module Puppet class State class ServiceRunning < State @name = :running @@ -23,7 +23,7 @@ module Blink when true,1,"1": should = 1 else - Blink.warning "%s: interpreting '%s' as false" % + Puppet.warning "%s: interpreting '%s' as false" % [self.class,should] should = 0 end @@ -32,7 +32,7 @@ module Blink def retrieve self.is = self.running() - Blink.debug "Running value for '%s' is '%s'" % + Puppet.debug "Running value for '%s' is '%s'" % [self.parent.name,self.is] end @@ -40,7 +40,7 @@ module Blink def running begin status = self.parent.initcmd("status") - Blink.debug "initcmd status for '%s' is '%s'" % + Puppet.debug "initcmd status for '%s' is '%s'" % [self.parent.name,status] if status # the command succeeded @@ -60,33 +60,33 @@ module Blink else status = 0 end - Blink.debug "'%s' status is '%s' and should be '%s'" % + Puppet.debug "'%s' status is '%s' and should be '%s'" % [self,status,should] event = nil if self.should > 0 if status < 1 - Blink.debug "Starting '%s'" % self + Puppet.debug "Starting '%s'" % self if self.parent.initcmd("start") event = :service_started else raise "Failed to start '%s'" % self.parent.name end else - Blink.debug "'%s' is already running, yo" % self - #Blink.debug "Starting '%s'" % self + Puppet.debug "'%s' is already running, yo" % self + #Puppet.debug "Starting '%s'" % self #unless self.parent.initcmd("start") # raise "Failed to start %s" % self.name #end end elsif status > 0 - Blink.debug "Stopping '%s'" % self + Puppet.debug "Stopping '%s'" % self if self.parent.initcmd("stop") event = :service_stopped else raise "Failed to stop %s" % self.name end else - Blink.debug "Not running '%s' and shouldn't be running" % self + Puppet.debug "Not running '%s' and shouldn't be running" % self end return event @@ -97,7 +97,7 @@ module Blink class Service < Type attr_reader :stat @states = [ - Blink::State::ServiceRunning + Puppet::State::ServiceRunning ] @parameters = [ :name, @@ -116,13 +116,13 @@ module Blink def Service.search(name) @searchpaths.each { |path| - # must specify that we want the top-level File, not Blink::...::File + # must specify that we want the top-level File, not Puppet::...::File fqname = ::File.join(path,name) begin stat = ::File.stat(fqname) rescue # should probably rescue specific errors... - Blink.debug("Could not find %s in %s" % [name,path]) + Puppet.debug("Could not find %s in %s" % [name,path]) next end @@ -140,7 +140,7 @@ module Blink begin retvalue = ::File.stat(dir).directory? rescue => detail - Blink.verbose("Directory %s does not exist: %s" % [dir,detail]) + Puppet.verbose("Directory %s does not exist: %s" % [dir,detail]) # just ignore it end # disallow relative paths @@ -157,13 +157,13 @@ module Blink def initcmd(cmd) script = self.initscript - Blink.debug "Executing '%s %s' as initcmd for '%s'" % + Puppet.debug "Executing '%s %s' as initcmd for '%s'" % [script,cmd,self] rvalue = Kernel.system("%s %s" % [script,cmd]) - Blink.debug "'%s' ran with exit status '%s'" % + Puppet.debug "'%s' ran with exit status '%s'" % [cmd,rvalue] @@ -181,6 +181,6 @@ module Blink def refresh self.initcmd("restart") end - end # Blink::Type::Service - end # Blink::Type + end # Puppet::Type::Service + end # Puppet::Type end diff --git a/lib/puppet/type/state.rb b/lib/puppet/type/state.rb index 4706b04b7..0ec91d4c1 100644 --- a/lib/puppet/type/state.rb +++ b/lib/puppet/type/state.rb @@ -2,9 +2,9 @@ # $Id$ -require 'blink' -require 'blink/element' -require 'blink/statechange' +require 'puppet' +require 'puppet/element' +require 'puppet/statechange' #--------------------------------------------------------------- # this is a virtual base class for states @@ -14,8 +14,8 @@ require 'blink/statechange' # against the real state of the system. For instance, you could verify that # a file's owner is what you want, but you could not create two file objects # and use these methods to verify that they have the same owner -module Blink -class State < Blink::Element +module Puppet +class State < Puppet::Element attr_accessor :is, :should, :parent @virtual = true @@ -41,13 +41,13 @@ class State < Blink::Element # if we're not in sync, return a statechange capable of putting us # in sync def evaluate - Blink.verbose "evaluating %s" % self + Puppet.verbose "evaluating %s" % self self.retrieve if self.insync? - Blink.verbose "%s is in sync" % self + Puppet.verbose "%s is in sync" % self return nil else - return Blink::StateChange.new(self) + return Puppet::StateChange.new(self) end end #--------------------------------------------------------------- @@ -63,7 +63,7 @@ class State < Blink::Element # we aren't actually comparing the states themselves, we're only # comparing the "should" value with the "is" value def insync? - Blink.debug "%s value is '%s', should be '%s'" % + Puppet.debug "%s value is '%s', should be '%s'" % [self,self.is.inspect,self.should.inspect] self.is == self.should end @@ -92,8 +92,8 @@ class State < Blink::Element unless defined? @noop @noop = false end - tmp = @noop || self.parent.noop || Blink[:noop] || false - Blink.notice "noop is %s" % tmp + tmp = @noop || self.parent.noop || Puppet[:noop] || false + Puppet.notice "noop is %s" % tmp return tmp end #--------------------------------------------------------------- diff --git a/lib/puppet/type/symlink.rb b/lib/puppet/type/symlink.rb index 772b5a831..b33e81dba 100644 --- a/lib/puppet/type/symlink.rb +++ b/lib/puppet/type/symlink.rb @@ -3,14 +3,14 @@ # $Id$ require 'etc' -require 'blink/type/state' -require 'blink/type/file' +require 'puppet/type/state' +require 'puppet/type/file' -module Blink +module Puppet # okay, how do we deal with parameters that don't have operations # associated with them? class State - class SymlinkTarget < Blink::State + class SymlinkTarget < Puppet::State require 'etc' attr_accessor :file @@ -18,7 +18,7 @@ module Blink def create begin - Blink.debug("Creating symlink '%s' to '%s'" % + Puppet.debug("Creating symlink '%s' to '%s'" % [self.parent[:path],self.should]) unless File.symlink(self.should,self.parent[:path]) raise TypeError.new("Could not create symlink '%s'" % @@ -32,7 +32,7 @@ module Blink def remove if FileTest.symlink?(self.parent[:path]) - Blink.debug("Removing symlink '%s'" % self.parent[:path]) + Puppet.debug("Removing symlink '%s'" % self.parent[:path]) begin File.unlink(self.parent[:path]) rescue @@ -43,7 +43,7 @@ module Blink raise TypeError.new("Cannot remove normal file '%s'" % self.parent[:path]) else - Blink.debug("Symlink '%s' does not exist" % + Puppet.debug("Symlink '%s' does not exist" % self.parent[:path]) end end @@ -53,7 +53,7 @@ module Blink if FileTest.symlink?(self.parent[:path]) self.is = File.readlink(self.parent[:path]) - Blink.debug("link value is '%s'" % self.is) + Puppet.debug("link value is '%s'" % self.is) return else self.is = nil @@ -91,10 +91,10 @@ module Blink attr_reader :stat, :path, :params # class instance variable @states = [ - Blink::State::FileUID, - Blink::State::FileGroup, - Blink::State::FileMode, - Blink::State::SymlinkTarget + Puppet::State::FileUID, + Puppet::State::FileGroup, + Puppet::State::FileMode, + Puppet::State::SymlinkTarget ] @parameters = [ @@ -103,7 +103,7 @@ module Blink @name = :symlink @namevar = :path - end # Blink::Type::Symlink - end # Blink::Type + end # Puppet::Type::Symlink + end # Puppet::Type end diff --git a/lib/puppet/type/typegen.rb b/lib/puppet/type/typegen.rb index 85f04912c..204678272 100644 --- a/lib/puppet/type/typegen.rb +++ b/lib/puppet/type/typegen.rb @@ -5,11 +5,11 @@ # parse and write configuration files using objects with minimal parsing abilities require 'etc' -require 'blink/type' +require 'puppet/type' -module Blink +module Puppet class Type -class TypeGenerator < Blink::Type +class TypeGenerator < Puppet::Type include Enumerable @namevar = :name @@ -61,7 +61,7 @@ class TypeGenerator < Blink::Type #--------------------------------------------------------------- def TypeGenerator.namevar=(namevar) - Blink.debug "Setting namevar for %s to %s" % [self,namevar] + Puppet.debug "Setting namevar for %s to %s" % [self,namevar] unless namevar.is_a? Symbol namevar = namevar.intern end @@ -105,7 +105,7 @@ class TypeGenerator < Blink::Type klassname = arghash[:name].capitalize # create the file type - Blink::Type.module_eval " + Puppet::Type.module_eval " class %s < %s end" % [klassname,self] klass = eval(klassname) @@ -116,10 +116,10 @@ class TypeGenerator < Blink::Type arghash.each { |option,value| method = option.id2name + "=" if klass.respond_to?(method) - #Blink.debug "Setting %s on %s to '%s'" % [option,klass,arghash[option]] + #Puppet.debug "Setting %s on %s to '%s'" % [option,klass,arghash[option]] klass.send(method,arghash[option]) else - Blink.debug "%s does not respond to %s" % [klass,method] + Puppet.debug "%s does not respond to %s" % [klass,method] end } @@ -135,8 +135,8 @@ class TypeGenerator < Blink::Type # klass.send(writer,hash[option]) #} - #Blink::Type.inherited(klass) - Blink::Type.buildtypehash + #Puppet::Type.inherited(klass) + Puppet::Type.buildtypehash return klass end #--------------------------------------------------------------- diff --git a/lib/puppet/type/typegen/filerecord.rb b/lib/puppet/type/typegen/filerecord.rb index fb9030c12..833f10fd0 100644 --- a/lib/puppet/type/typegen/filerecord.rb +++ b/lib/puppet/type/typegen/filerecord.rb @@ -5,11 +5,11 @@ # parse and write configuration files using objects with minimal parsing abilities require 'etc' -require 'blink/type' -require 'blink/type/typegen' +require 'puppet/type' +require 'puppet/type/typegen' #--------------------------------------------------------------- -class Blink::Type::FileRecord < Blink::Type::TypeGenerator +class Puppet::Type::FileRecord < Puppet::Type::TypeGenerator attr_accessor :fields, :namevar, :splitchar, :object @parameters = [:name, :splitchar, :fields, :namevar, :filetype, :regex, :joinchar] @@ -55,8 +55,8 @@ class Blink::Type::FileRecord < Blink::Type::TypeGenerator #--------------------------------------------------------------- def FileRecord.filetype=(filetype) if filetype.is_a?(String) - @filetype = Blink::Type::FileType[filetype] - elsif filetype.is_a?(Blink::Type::FileType) + @filetype = Puppet::Type::FileType[filetype] + elsif filetype.is_a?(Puppet::Type::FileType) @filetype = filetype else raise "Cannot use objects of type %s as filetypes" % filetype @@ -121,7 +121,7 @@ class Blink::Type::FileRecord < Blink::Type::TypeGenerator rescue RegexpError => detail raise "Could not create splitregex from %s" % @splitchar end - Blink.debug("Created regexp %s" % @regex) + Puppet.debug("Created regexp %s" % @regex) end elsif @regex.is_a?(String) begin @@ -170,7 +170,7 @@ class Blink::Type::FileRecord < Blink::Type::TypeGenerator end @parameters.keys { |field| unless self[field] == other[field] - Blink.debug("%s -> %s has changed" % [self.name, field]) + Puppet.debug("%s -> %s has changed" % [self.name, field]) return false end } @@ -180,7 +180,7 @@ class Blink::Type::FileRecord < Blink::Type::TypeGenerator #--------------------------------------------------------------- def initialize(hash) - if self.class == Blink::Type::FileRecord + if self.class == Puppet::Type::FileRecord self.class.newtype(hash) return end diff --git a/lib/puppet/type/typegen/filetype.rb b/lib/puppet/type/typegen/filetype.rb index 4b3b89db8..59ff0978d 100644 --- a/lib/puppet/type/typegen/filetype.rb +++ b/lib/puppet/type/typegen/filetype.rb @@ -4,10 +4,10 @@ # parse and write configuration files using objects with minimal parsing abilities -require 'blink/type' -require 'blink/type/typegen' +require 'puppet/type' +require 'puppet/type/typegen' -class Blink::Type::FileType < Blink::Type::TypeGenerator +class Puppet::Type::FileType < Puppet::Type::TypeGenerator attr_accessor :childtype @parameters = [:name, :linesplit, :escapednewlines] @@ -26,14 +26,14 @@ class Blink::Type::FileType < Blink::Type::TypeGenerator end # i don't think there's any reason to 'super' this - #klass = Blink::Type::TypeGenerator.newtype(hash) + #klass = Puppet::Type::TypeGenerator.newtype(hash) klass = super(hash) klass.escapednewlines = true klass.namevar = :name klass.parameters = [:name, :path, :complete] - #klass.childtype = Blink::Type::FileRecord.newtype( + #klass.childtype = Puppet::Type::FileRecord.newtype( # :name => hash[:name] + "_record", # :splitchar => hash[:recordsplit], # :fields => hash[:fields], @@ -63,7 +63,7 @@ class Blink::Type::FileType < Blink::Type::TypeGenerator hash[:namevar] = hash[:fields][0] end - recordtype = Blink::Type::FileRecord.newtype(hash) + recordtype = Puppet::Type::FileRecord.newtype(hash) @records[recordtype.name] = recordtype end #--------------------------------------------------------------- @@ -140,14 +140,14 @@ class Blink::Type::FileType < Blink::Type::TypeGenerator # so i'm sticking with 'equals' until those make sense def ==(other) unless self.children.length == other.children.length - Blink.debug("file has %s records instead of %s" % + Puppet.debug("file has %s records instead of %s" % [self.children.length, other.children.length]) return self.children.length == other.children.length end equal = true self.zip(other.children) { |schild,ochild| unless schild == ochild - Blink.debug("%s has changed in %s" % + Puppet.debug("%s has changed in %s" % [schild.name,self.name]) equal = false break @@ -162,7 +162,7 @@ class Blink::Type::FileType < Blink::Type::TypeGenerator # create a new record with a block def add(type,&block) obj = self.class.records[type].new(self,&block) - Blink.debug("adding %s" % obj.name) + Puppet.debug("adding %s" % obj.name) @childary.push(obj) @childhash[obj.name] = obj @@ -204,13 +204,13 @@ class Blink::Type::FileType < Blink::Type::TypeGenerator # if we are the FileType object itself, we create a new type # otherwise, we create an instance of an existing type # yes, this should be more straightforward - if self.class == Blink::Type::FileType + if self.class == Puppet::Type::FileType self.class.newtype(hash) return end - Blink.debug "Creating new '%s' file with path '%s' and name '%s'" % + Puppet.debug "Creating new '%s' file with path '%s' and name '%s'" % [self.class.name,hash["path"],hash[:name]] - Blink.debug hash.inspect + Puppet.debug hash.inspect @file = hash["path"] @childary = [] @@ -261,15 +261,15 @@ class Blink::Type::FileType < Blink::Type::TypeGenerator end } if childobj.nil? - Blink.warning("%s: could not match %s" % [self.name,line]) - #Blink.warning("could not match %s" % line) + Puppet.warning("%s: could not match %s" % [self.name,line]) + #Puppet.warning("could not match %s" % line) next end begin - Blink.debug("got child: %s(%s)" % [childobj.class,childobj.to_s]) + Puppet.debug("got child: %s(%s)" % [childobj.class,childobj.to_s]) rescue NoMethodError - Blink.warning "Failed: %s" % childobj + Puppet.warning "Failed: %s" % childobj end childobj }.reject { |child| |