summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-26 04:44:25 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-26 04:44:25 +0000
commit0ae5e3392597452acf6a2e9f0d4ac976b8ec9846 (patch)
treee2307bce0ffacb9bf8ed54b0ebe84632b51fd9b8 /lib
parent0d3db7984fd40769cbb29cde76e081cb06204710 (diff)
downloadpuppet-0ae5e3392597452acf6a2e9f0d4ac976b8ec9846.tar.gz
puppet-0ae5e3392597452acf6a2e9f0d4ac976b8ec9846.tar.xz
puppet-0ae5e3392597452acf6a2e9f0d4ac976b8ec9846.zip
Adding logging methods to all Puppet::Element instances, and converting all instance log statements to use those methods. Additionally modified logging to take advantage of this by including the path of the logging object in the output. Logs will still need some cleanup to avoid duplicate information.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@731 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet.rb9
-rw-r--r--lib/puppet/element.rb14
-rw-r--r--lib/puppet/log.rb30
-rw-r--r--lib/puppet/statechange.rb20
-rw-r--r--lib/puppet/storage.rb6
-rw-r--r--lib/puppet/transportable.rb1
-rw-r--r--lib/puppet/type.rb36
-rw-r--r--lib/puppet/type/component.rb4
-rwxr-xr-xlib/puppet/type/cron.rb4
-rwxr-xr-xlib/puppet/type/exec.rb5
-rwxr-xr-xlib/puppet/type/group.rb2
-rw-r--r--lib/puppet/type/nameservice/netinfo.rb2
-rw-r--r--lib/puppet/type/nameservice/posix.rb4
-rw-r--r--lib/puppet/type/package.rb16
-rwxr-xr-xlib/puppet/type/package/apt.rb8
-rwxr-xr-xlib/puppet/type/package/sun.rb2
-rwxr-xr-xlib/puppet/type/package/yum.rb6
-rw-r--r--lib/puppet/type/pfile.rb36
-rwxr-xr-xlib/puppet/type/pfile/checksum.rb31
-rwxr-xr-xlib/puppet/type/pfile/create.rb2
-rwxr-xr-xlib/puppet/type/pfile/group.rb4
-rwxr-xr-xlib/puppet/type/pfile/mode.rb8
-rwxr-xr-xlib/puppet/type/pfile/source.rb16
-rwxr-xr-xlib/puppet/type/pfile/uid.rb6
-rw-r--r--lib/puppet/type/service.rb14
-rwxr-xr-xlib/puppet/type/service/init.rb10
-rw-r--r--lib/puppet/type/state.rb6
-rwxr-xr-xlib/puppet/type/symlink.rb4
-rwxr-xr-xlib/puppet/type/tidy.rb6
-rwxr-xr-xlib/puppet/type/user.rb2
30 files changed, 173 insertions, 141 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb
index 8033c007e..1f4b18d44 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -55,7 +55,14 @@ module Puppet
# define helper messages for each of the message levels
Puppet::Log.levels.each { |level|
define_method(level,proc { |args|
- Puppet::Log.create(level,args)
+ if args.is_a?(Array)
+ args = args.join(" ")
+ end
+ Puppet::Log.create(
+ :level => level,
+ :source => "Puppet",
+ :message => args
+ )
})
module_function level
}
diff --git a/lib/puppet/element.rb b/lib/puppet/element.rb
index eb43d4013..2dcabfbc4 100644
--- a/lib/puppet/element.rb
+++ b/lib/puppet/element.rb
@@ -32,6 +32,20 @@ class Puppet::Element
}
#---------------------------------------------------------------
+ # create instance methods for each of the log levels, too
+ Puppet::Log.levels.each { |level|
+ define_method(level,proc { |args|
+ if args.is_a?(Array)
+ args = args.join(" ")
+ end
+ Puppet::Log.create(
+ :level => level,
+ :source => self,
+ :message => args
+ )
+ })
+ }
+
#---------------------------------------------------------------
# for testing whether we should actually do anything
def noop
diff --git a/lib/puppet/log.rb b/lib/puppet/log.rb
index 36759e2b4..885260f2e 100644
--- a/lib/puppet/log.rb
+++ b/lib/puppet/log.rb
@@ -50,15 +50,9 @@ module Puppet
end
end
- def Log.create(level,*ary)
- msg = ary.join(" ")
-
- if @@levels.index(level) >= @@loglevel
- return Puppet::Log.new(
- :level => level,
- :source => "Puppet",
- :message => msg
- )
+ def Log.create(hash)
+ if @@levels.index(hash[:level]) >= @@loglevel
+ return Puppet::Log.new(hash)
else
return nil
end
@@ -185,7 +179,6 @@ module Puppet
"Level is not a string or symbol: #{args[:level].class}"
end
@message = args[:message]
- @source = args[:source] || "Puppet"
@time = Time.now
# this should include the host name, and probly lots of other
# stuff, at some point
@@ -201,6 +194,23 @@ module Puppet
@path = args[:path]
end
+ if args.include?(:source)
+ @source = args[:source]
+ unless defined? @tags and @tags
+ if @source.respond_to?(:tags)
+ @tags = @source.tags
+ end
+ end
+
+ unless defined? @path and @path
+ if @source.respond_to?(:path)
+ @path = @source.path
+ end
+ end
+ else
+ @source = "Puppet"
+ end
+
Log.newmessage(self)
end
diff --git a/lib/puppet/statechange.rb b/lib/puppet/statechange.rb
index 902f2ee04..2221088b0 100644
--- a/lib/puppet/statechange.rb
+++ b/lib/puppet/statechange.rb
@@ -1,7 +1,3 @@
-#!/usr/local/bin/ruby -w
-
-# $Id$
-
# the class responsible for actually doing any work
# enables no-op and logging/rollback
@@ -30,7 +26,7 @@ module Puppet
#---------------------------------------------------------------
def go
if @state.is == @state.should
- Puppet.info "%s.%s is already in sync" %
+ @state.info "%s.%s is already in sync" %
[@state.parent.name, @state.name]
return nil
end
@@ -38,7 +34,7 @@ module Puppet
if @state.noop
@state.parent.log "%s is %s, should be %s" %
[@state, state.is_to_s, state.should_to_s]
- #Puppet.debug "%s is noop" % @state
+ #@state.debug "%s is noop" % @state
return nil
end
@@ -59,7 +55,7 @@ module Puppet
return events.collect { |event|
# default to a simple event type
if ! event.is_a?(Symbol)
- Puppet.warning("State '%s' returned invalid event '%s'; resetting to default" %
+ @state.warning("State '%s' returned invalid event '%s'; resetting to default" %
[@state.class,event])
event = @state.parent.class.name.id2name + "_changed"
@@ -80,7 +76,7 @@ module Puppet
)
}
rescue => detail
- #Puppet.err "%s failed: %s" % [self.to_s,detail]
+ #@state.err "%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...
@@ -103,7 +99,7 @@ module Puppet
#---------------------------------------------------------------
def forward
- #Puppet.debug "moving change forward"
+ #@state.debug "moving change forward"
unless defined? @transaction
raise Puppet::Error,
@@ -126,10 +122,10 @@ module Puppet
self
end
unless @state.insync?
- Puppet.info "Backing %s" % self
+ @state.info "Backing %s" % self
return self.go
else
- Puppet.debug "rollback is already in sync: %s vs. %s" %
+ @state.debug "rollback is already in sync: %s vs. %s" %
[@state.is.inspect, @state.should.inspect]
return nil
end
@@ -152,3 +148,5 @@ module Puppet
end
end
end
+
+# $Id$
diff --git a/lib/puppet/storage.rb b/lib/puppet/storage.rb
index c7c4a7ae1..24a6b6920 100644
--- a/lib/puppet/storage.rb
+++ b/lib/puppet/storage.rb
@@ -1,5 +1,3 @@
-# $Id$
-
module Puppet
# a class for storing state
class Storage
@@ -26,7 +24,7 @@ module Puppet
def self.load
if Puppet[:checksumfile].nil?
- raise "Somehow the statefile is nil"
+ raise Puppet::DevError, "Somehow the statefile is nil"
end
unless File.exists?(Puppet[:checksumfile])
@@ -89,3 +87,5 @@ module Puppet
end
end
end
+
+# $Id$
diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb
index 23bfecee3..9cd0c237c 100644
--- a/lib/puppet/transportable.rb
+++ b/lib/puppet/transportable.rb
@@ -44,6 +44,7 @@ module Puppet
if defined? @tags and @tags
Puppet.debug "%s(%s) tags: %s" % [@type, @name, @tags.join(" ")]
+ retobj.tags = @tags
end
return retobj
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 20c4d3a01..403c5dd15 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -14,7 +14,7 @@ require 'puppet/type/state'
module Puppet
class Type < Puppet::Element
attr_accessor :children, :parameters, :parent
- attr_accessor :file, :line
+ attr_accessor :file, :line, :tags
attr_writer :implicit
def implicit?
@@ -421,7 +421,7 @@ class Type < Puppet::Element
self.send(("meta" + name.id2name + "="),value)
elsif stateklass = self.class.validstate?(name)
if value.is_a?(Puppet::State)
- Puppet.debug "'%s' got handed a state for '%s'" % [self,name]
+ self.debug "'%s' got handed a state for '%s'" % [self,name]
@states[name] = value
else
if @states.include?(name)
@@ -506,7 +506,11 @@ class Type < Puppet::Element
# create a log at specified level
def log(msg)
- Puppet::Log.create(@metaparams[:loglevel],msg)
+ Puppet::Log.create(
+ :level => @metaparams[:loglevel],
+ :message => msg,
+ :source => self
+ )
end
# is the instance a managed instance? A 'yes' here means that
@@ -544,15 +548,15 @@ class Type < Puppet::Element
@states[name] = newstate
rescue Puppet::Error => detail
# the state failed, so just ignore it
- Puppet.warning "State %s failed: %s" %
+ self.warning "State %s failed: %s" %
[name, detail]
rescue Puppet::DevError => detail
# the state failed, so just ignore it
- Puppet.err "State %s failed: %s" %
+ self.err "State %s failed: %s" %
[name, detail]
rescue => detail
# the state failed, so just ignore it
- Puppet.err "State %s failed: %s (%s)" %
+ self.err "State %s failed: %s (%s)" %
[name, detail, detail.class]
end
end
@@ -790,7 +794,7 @@ class Type < Puppet::Element
}
if hash.length > 0
- Puppet.debug hash.inspect
+ self.debug hash.inspect
raise Puppet::Error.new("Class %s does not accept argument(s) %s" %
[self.class.name, hash.keys.join(" ")])
end
@@ -823,7 +827,7 @@ class Type < Puppet::Element
raise Puppet::Error, "No common values for %s on %s(%s)" %
[param, self.class.name, self.name]
else
- Puppet.debug "Reduced old values %s and new values %s to %s" %
+ self.debug "Reduced old values %s and new values %s to %s" %
[oldvals.inspect, value.inspect, newvals.inspect]
self.should = newvals
end
@@ -954,7 +958,7 @@ class Type < Puppet::Element
def evaluate
#Puppet.err "Evaluating %s" % self.path.join(":")
unless defined? @evalcount
- Puppet.err "No evalcount defined on '%s' of type '%s'" %
+ self.err "No evalcount defined on '%s' of type '%s'" %
[self.name,self.class]
@evalcount = 0
end
@@ -1025,10 +1029,10 @@ class Type < Puppet::Element
# now record how many changes we've resulted in
Puppet::Metric.add(self.class,self,:changes,changes.length)
if changes.length > 0
- Puppet.info "%s: %s change(s)" %
- [self.name, changes.length]
+ self.info "%s change(s)" %
+ [changes.length]
#changes.each { |change|
- # Puppet.debug "change: %s" % change.state.name
+ # self.debug "change: %s" % change.state.name
#}
end
return changes.flatten
@@ -1042,13 +1046,13 @@ class Type < Puppet::Element
states.each { |state|
unless state.insync?
- Puppet.debug("%s is not in sync: %s vs %s" %
+ self.debug("%s is not in sync: %s vs %s" %
[state, state.is, state.should])
insync = false
end
}
- #Puppet.debug("%s sync status is %s" % [self,insync])
+ #self.debug("%s sync status is %s" % [self,insync])
return insync
end
@@ -1111,7 +1115,7 @@ class Type < Puppet::Element
end
def metaonerror=(response)
- Puppet.debug("Would have called metaonerror")
+ self.debug("Would have called metaonerror")
@onerror = response
end
@@ -1173,7 +1177,7 @@ class Type < Puppet::Element
raise Puppet::Error, "Could not retrieve object '%s' of type '%s'" %
[name,type]
end
- Puppet.debug("%s subscribes to %s" % [self.name,object])
+ self.debug("%s subscribes to %s" % [self.name,object])
#unless @dependencies.include?(object)
# @dependencies << object
diff --git a/lib/puppet/type/component.rb b/lib/puppet/type/component.rb
index 22b5490b8..c9b97f71f 100644
--- a/lib/puppet/type/component.rb
+++ b/lib/puppet/type/component.rb
@@ -82,7 +82,7 @@ module Puppet
args[:type] = "component"
end
super(args)
- #Puppet.debug "Made component with name %s and type %s" %
+ #self.debug "Made component with name %s and type %s" %
# [self.name, self[:type]]
end
@@ -105,7 +105,7 @@ module Puppet
def push(*ary)
ary.each { |child|
unless child.is_a?(Puppet::Element)
- Puppet.debug "Got object of type %s" % child.class
+ self.debug "Got object of type %s" % child.class
raise Puppet::DevError.new(
"Containers can only contain Puppet::Elements, not %s" %
child.class
diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb
index c19404cbb..f237ecd7d 100755
--- a/lib/puppet/type/cron.rb
+++ b/lib/puppet/type/cron.rb
@@ -126,11 +126,11 @@ module Puppet
@parent.remove(true)
event = :cron_deleted
elsif self.should == @is
- Puppet.err "Uh, they're both %s" % self.should
+ self.err "Uh, they're both %s" % self.should
return nil
else
#@is = @should
- Puppet.err "@is is %s" % @is
+ self.err "@is is %s" % @is
event = :cron_changed
end
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb
index 0463a133c..30480efa3 100755
--- a/lib/puppet/type/exec.rb
+++ b/lib/puppet/type/exec.rb
@@ -102,9 +102,7 @@ module Puppet
# and log
@output.split(/\n/).each { |line|
- Puppet.send(loglevel,
- "%s: %s" % [self.parent[:command],line]
- )
+ Puppet.send(loglevel, line)
}
}
rescue Errno::ENOENT => detail
@@ -169,7 +167,6 @@ module Puppet
hash[:returns] = hash[:returns].to_s
end
else
- debug("setting return to 0")
hash[:returns] = "0"
end
diff --git a/lib/puppet/type/group.rb b/lib/puppet/type/group.rb
index be838d70e..0f057b869 100755
--- a/lib/puppet/type/group.rb
+++ b/lib/puppet/type/group.rb
@@ -57,7 +57,7 @@ module Puppet
end
end
- Puppet.info "Setting gid to %s" % gid
+ self.info "Setting gid to %s" % gid
return gid
end
diff --git a/lib/puppet/type/nameservice/netinfo.rb b/lib/puppet/type/nameservice/netinfo.rb
index 16148ffbf..006164879 100644
--- a/lib/puppet/type/nameservice/netinfo.rb
+++ b/lib/puppet/type/nameservice/netinfo.rb
@@ -78,7 +78,7 @@ module Puppet
"Could not find netinfokey for state %s" %
self.class.name
end
- Puppet.debug "Executing %s" % cmd.join(" ").inspect
+ self.debug "Executing %s" % cmd.join(" ").inspect
output = %x{#{cmd.join(" ")} 2>&1}.split("\n").each { |line|
if line =~ /^(\w+)\s+(.+)$/
diff --git a/lib/puppet/type/nameservice/posix.rb b/lib/puppet/type/nameservice/posix.rb
index 8b764ba71..1f7a427cd 100644
--- a/lib/puppet/type/nameservice/posix.rb
+++ b/lib/puppet/type/nameservice/posix.rb
@@ -130,7 +130,7 @@ module Puppet
# or its parent class
cmd = self.modifycmd
- Puppet.debug "Executing %s" % cmd.inspect
+ self.debug "Executing %s" % cmd.inspect
output = %x{#{cmd} 2>&1}
@@ -172,7 +172,7 @@ module Puppet
cmd = self.addcmd
type = "create"
end
- Puppet.debug "Executing %s" % cmd.inspect
+ self.debug "Executing %s" % cmd.inspect
output = %x{#{cmd} 2>&1}
diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb
index e74e95b8c..45032c206 100644
--- a/lib/puppet/type/package.rb
+++ b/lib/puppet/type/package.rb
@@ -37,7 +37,7 @@ module Puppet
if @is == latest
return true
else
- Puppet.debug "latest %s is %s" % [@parent.name, latest]
+ self.debug "latest %s is %s" % [@parent.name, latest]
end
when :notinstalled
if @is == :notinstalled
@@ -63,7 +63,7 @@ module Puppet
case value
when "latest":
unless @parent.respond_to?(:latest)
- Puppet.err @parent.inspect
+ self.err @parent.inspect
raise Puppet::Error,
"Package type %s does not support querying versions" %
@parent[:type]
@@ -101,7 +101,7 @@ module Puppet
end
else
unless ! @parent.respond_to?(:versionable?) or @parent.versionable?
- Puppet.warning value
+ self.warning value
raise Puppet::Error,
"Package type %s does not support specifying versions" %
@parent[:type]
@@ -113,9 +113,9 @@ module Puppet
if @parent.respond_to?(method)
begin
- @parent.send(method)
+ @parent.send(method)
rescue => detail
- Puppet.err "Could not run %s: %s" % [method, detail.to_s]
+ self.err "Could not run %s: %s" % [method, detail.to_s]
raise
end
else
@@ -330,8 +330,10 @@ module Puppet
super
+ self.debug "Extending to package type %s" % [@type]
+
unless @states.include?(:install)
- Puppet.debug "Defaulting to installing a package"
+ self.debug "Defaulting to installing a package"
self[:install] = true
end
@@ -361,7 +363,7 @@ module Puppet
# Extend the package with the appropriate package type.
def type2module(typename)
if type = self.class.pkgtype(typename)
- Puppet.debug "Extending to package type %s" % [type]
+ @type = type
self.extend(type)
else
raise Puppet::Error, "Invalid package type %s" % typename
diff --git a/lib/puppet/type/package/apt.rb b/lib/puppet/type/package/apt.rb
index 4dd93fed7..dbc764df5 100755
--- a/lib/puppet/type/package/apt.rb
+++ b/lib/puppet/type/package/apt.rb
@@ -21,7 +21,7 @@ module Puppet
end
cmd = "apt-get -q -y install %s" % str
- Puppet.info "Executing %s" % cmd.inspect
+ self.info "Executing %s" % cmd.inspect
output = %x{#{cmd} 2>&1}
unless $? == 0
@@ -44,13 +44,13 @@ module Puppet
if version =~ /^([^\(]+)\(/
$1
else
- Puppet.warning "Could not match version '%s'" % version
+ self.warning "Could not match version '%s'" % version
nil
end
}.reject { |vers| vers.nil? }.sort[-1]
unless version
- Puppet.debug "No latest version"
+ self.debug "No latest version"
if Puppet[:debug]
print output
end
@@ -58,7 +58,7 @@ module Puppet
return version
else
- Puppet.err "Could not match string"
+ self.err "Could not match string"
end
end
diff --git a/lib/puppet/type/package/sun.rb b/lib/puppet/type/package/sun.rb
index c3190995b..65da29a31 100755
--- a/lib/puppet/type/package/sun.rb
+++ b/lib/puppet/type/package/sun.rb
@@ -36,7 +36,7 @@ module Puppet
hash[names[name]] = value
end
else
- Puppet.err "'pkginfo' returned invalid name %s" %
+ self.err "'pkginfo' returned invalid name %s" %
name
end
when /\s+\d+.+/:
diff --git a/lib/puppet/type/package/yum.rb b/lib/puppet/type/package/yum.rb
index 581f3f326..beb356f89 100755
--- a/lib/puppet/type/package/yum.rb
+++ b/lib/puppet/type/package/yum.rb
@@ -10,7 +10,7 @@ module Puppet
def install
cmd = "yum -y install %s" % self.name
- Puppet.info "Executing %s" % cmd.inspect
+ self.info "Executing %s" % cmd.inspect
output = %x{#{cmd} 2>&1}
unless $? == 0
@@ -30,7 +30,7 @@ module Puppet
if output =~ /#{self.name}\S+\s+(\S+)\s/
return $1
else
- Puppet.debug "No version"
+ self.debug "No version"
if Puppet[:debug]
print output
end
@@ -42,7 +42,7 @@ module Puppet
def update
cmd = "yum -y update %s" % self.name
- Puppet.info "Executing %s" % cmd.inspect
+ self.info "Executing %s" % cmd.inspect
output = %x{#{cmd} 2>&1}
unless $? == 0
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index 5c78c4517..e5ec383f9 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -103,7 +103,7 @@ module Puppet
case backup
when Puppet::Client::Dipper:
sum = backup.backup(file)
- Puppet.info "Filebucketed %s with sum %s" %
+ self.info "Filebucketed %s with sum %s" %
[file, sum]
return true
when String:
@@ -112,7 +112,7 @@ module Puppet
begin
File.unlink(newfile)
rescue => detail
- Puppet.err "Could not remove old backup: %s" %
+ self.err "Could not remove old backup: %s" %
detail
return false
end
@@ -128,11 +128,11 @@ module Puppet
[file, detail.message])
end
else
- Puppet.err "Invalid backup type %s" % backup
+ self.err "Invalid backup type %s" % backup
return false
end
else
- Puppet.notice "Cannot backup files of type %s" %
+ self.notice "Cannot backup files of type %s" %
File.stat(file).ftype
return false
end
@@ -238,7 +238,7 @@ module Puppet
unless hash.include?(:recurse)
if args.include?(:recurse)
if args[:recurse].is_a?(Integer)
- Puppet.notice "Decrementing recurse on %s" % path
+ self.notice "Decrementing recurse on %s" % path
args[:recurse] -= 1 # reduce the level of recursion
end
end
@@ -255,7 +255,7 @@ module Puppet
! FileTest.directory?(args[:source])
klass = Puppet::Type::Symlink
- Puppet.debug "%s is a link" % path
+ self.debug "%s is a link" % path
# clean up the args a lot for links
old = args.dup
args = {
@@ -272,7 +272,7 @@ module Puppet
# than this last bit, so it doesn't really make sense.
if child = klass[path]
unless @children.include?(child)
- Puppet.notice "Not managing more explicit file %s" %
+ self.notice "Not managing more explicit file %s" %
path
return nil
end
@@ -296,18 +296,18 @@ module Puppet
child.parent = self
@children << child
rescue Puppet::Error => detail
- Puppet.notice(
+ self.notice(
"Cannot manage %s: %s" %
[path,detail.message]
)
- Puppet.debug args.inspect
+ self.debug args.inspect
child = nil
rescue => detail
- Puppet.notice(
+ self.notice(
"Cannot manage %s: %s" %
[path,detail]
)
- Puppet.debug args.inspect
+ self.debug args.inspect
child = nil
end
end
@@ -330,7 +330,7 @@ module Puppet
# are we at the end of the recursion?
if recurse == 0
- Puppet.info "finished recursing"
+ self.info "finished recursing"
return
end
@@ -346,7 +346,7 @@ module Puppet
def localrecurse(recurse)
unless FileTest.exist?(self.name) and self.stat.directory?
- #Puppet.info "%s is not a directory; not recursing" %
+ #self.info "%s is not a directory; not recursing" %
# self.name
return
end
@@ -357,7 +357,7 @@ module Puppet
)
end
unless FileTest.readable? self.name
- Puppet.notice "Cannot manage %s: permission denied" % self.name
+ self.notice "Cannot manage %s: permission denied" % self.name
return
end
@@ -412,14 +412,14 @@ module Puppet
ignore = @parameters[:ignore]
- #Puppet.warning "Listing path %s" % path.inspect
+ #self.warning "Listing path %s" % path.inspect
desc = server.list(path, r, ignore)
desc.split("\n").each { |line|
file, type = line.split("\t")
next if file == "/"
name = file.sub(/^\//, '')
- #Puppet.warning "child name is %s" % name
+ #self.warning "child name is %s" % name
args = {:source => source + file}
if type == file
args[:recurse] = nil
@@ -446,7 +446,7 @@ module Puppet
end
unless stat = self.stat(true)
- Puppet.debug "File %s does not exist" % self.name
+ self.debug "File does not exist" % self.name
@states.each { |name,state|
# We've already retreived the source, and we don't
# want to overwrite whatever it did. This is a bit
@@ -467,7 +467,7 @@ module Puppet
rescue Errno::ENOENT => error
@stat = nil
rescue => error
- Puppet.debug "Failed to stat %s: %s" %
+ self.debug "Failed to stat %s: %s" %
[self.name,error]
@stat = nil
end
diff --git a/lib/puppet/type/pfile/checksum.rb b/lib/puppet/type/pfile/checksum.rb
index addad4b50..33687c517 100755
--- a/lib/puppet/type/pfile/checksum.rb
+++ b/lib/puppet/type/pfile/checksum.rb
@@ -27,7 +27,7 @@ module Puppet
case checktype
when "md5", "md5lite":
unless FileTest.file?(@parent[:path])
- #Puppet.info "Cannot MD5 sum directory %s" %
+ #@parent.info "Cannot MD5 sum directory %s" %
# @parent[:path]
# because we cannot sum directories, just delete ourselves
@@ -44,7 +44,7 @@ module Puppet
text = file.read(512)
end
if text.nil?
- Puppet.info "Not checksumming empty file %s" %
+ self.info "Not checksumming empty file %s" %
@parent.name
sum = 0
else
@@ -52,11 +52,11 @@ module Puppet
end
}
rescue Errno::EACCES => detail
- Puppet.notice "Cannot checksum %s: permission denied" %
+ self.notice "Cannot checksum %s: permission denied" %
@parent.name
@parent.delete(self.class.name)
rescue => detail
- Puppet.notice "Cannot checksum %s: %s" %
+ self.notice "Cannot checksum %s: %s" %
detail
@parent.delete(self.class.name)
end
@@ -86,10 +86,10 @@ module Puppet
if hash = state[@parent[:path]]
if hash.include?(value)
return hash[value]
- #Puppet.debug "Found checksum %s for %s" %
+ #@parent.debug "Found checksum %s for %s" %
# [self.should,@parent[:path]]
else
- #Puppet.debug "Found checksum for %s but not of type %s" %
+ #@parent.debug "Found checksum for %s but not of type %s" %
# [@parent[:path],@checktype]
return :nosum
end
@@ -126,7 +126,7 @@ module Puppet
self.updatesum
end
- #Puppet.debug "checksum state is %s" % self.is
+ #@parent.debug "checksum state is %s" % self.is
end
@@ -143,10 +143,10 @@ module Puppet
self.retrieve
if self.insync?
- Puppet.debug "Checksum is already in sync"
+ self.debug "Checksum is already in sync"
return nil
end
- #Puppet.debug "%s(%s): after refresh, is '%s'" %
+ #@parent.debug "%s(%s): after refresh, is '%s'" %
# [self.class.name,@parent.name,@is]
# If we still can't retrieve a checksum, it means that
@@ -155,7 +155,7 @@ module Puppet
# if they're copying, then we won't worry about the file
# not existing yet
unless @parent.state(:source)
- Puppet.warning(
+ self.warning(
"File %s does not exist -- cannot checksum" %
@parent.name
)
@@ -177,8 +177,7 @@ module Puppet
result = false
state = Puppet::Storage.state(self)
unless state.include?(@parent.name)
- Puppet.debug "Initializing state hash for %s" %
- @parent.name
+ self.debug "Initializing state hash"
state[@parent.name] = Hash.new
end
@@ -201,13 +200,13 @@ module Puppet
"found a checksum") % @parent[:path]
)
end
- Puppet.debug "Replacing %s checksum %s with %s" %
+ self.debug "Replacing %s checksum %s with %s" %
[@parent.name, state[@parent.name][@checktypes[0]],@is]
- #Puppet.debug "@is: %s; @should: %s" % [@is,@should]
+ #@parent.debug "@is: %s; @should: %s" % [@is,@should]
result = true
else
- Puppet.debug "Creating checksum %s for %s of type %s" %
- [self.is,@parent.name,@checktypes[0]]
+ @parent.debug "Creating checksum %s of type %s" %
+ [@is,@checktypes[0]]
result = false
end
state[@parent.name][@checktypes[0]] = @is
diff --git a/lib/puppet/type/pfile/create.rb b/lib/puppet/type/pfile/create.rb
index 9ed9b19af..d4c593018 100755
--- a/lib/puppet/type/pfile/create.rb
+++ b/lib/puppet/type/pfile/create.rb
@@ -31,7 +31,7 @@ module Puppet
@is = :notfound
end
- #Puppet.debug "'exists' state is %s" % self.is
+ #self.debug "'exists' state is %s" % self.is
end
diff --git a/lib/puppet/type/pfile/group.rb b/lib/puppet/type/pfile/group.rb
index 65acb3d00..63098b892 100755
--- a/lib/puppet/type/pfile/group.rb
+++ b/lib/puppet/type/pfile/group.rb
@@ -79,7 +79,7 @@ module Puppet
#unless Process.uid == 0
# groups = %x{groups}.chomp.split(/\s/)
# unless groups.include?(gname)
- # Puppet.notice "Cannot chgrp: not in group %s" % gname
+ # self.notice "Cannot chgrp: not in group %s" % gname
# raise Puppet::Error.new(
# "Cannot chgrp: not in group %s" % gname)
# end
@@ -102,7 +102,7 @@ module Puppet
self.retrieve
if @is == :notfound
- Puppet.err "File '%s' does not exist; cannot chgrp" %
+ self.err "File '%s' does not exist; cannot chgrp" %
@parent[:path]
return nil
end
diff --git a/lib/puppet/type/pfile/mode.rb b/lib/puppet/type/pfile/mode.rb
index bbfe9b2ae..b49e3ff53 100755
--- a/lib/puppet/type/pfile/mode.rb
+++ b/lib/puppet/type/pfile/mode.rb
@@ -38,7 +38,7 @@ module Puppet
value = Integer(value)
end
- #Puppet.warning "Should is %o from %s" % [value, should]
+ #self.warning "Should is %o from %s" % [value, should]
return value
end
@@ -73,16 +73,16 @@ module Puppet
self.is = :notfound
end
- #Puppet.debug "chmod state is %o" % self.is
+ #self.debug "chmod state is %o" % self.is
end
def sync
if @is == :notfound
@parent.stat(true)
self.retrieve
- #Puppet.debug "%s: after refresh, is '%s'" % [self.class.name,@is]
+ #self.debug "%s: after refresh, is '%s'" % [self.class.name,@is]
if @is == :notfound
- Puppet.info "%s does not exist; cannot set mode" %
+ self.info "File does not exist; cannot set mode" %
@parent.name
return nil
end
diff --git a/lib/puppet/type/pfile/source.rb b/lib/puppet/type/pfile/source.rb
index d6678a705..625458b23 100755
--- a/lib/puppet/type/pfile/source.rb
+++ b/lib/puppet/type/pfile/source.rb
@@ -17,7 +17,7 @@ module Puppet
begin
desc = server.describe(path)
rescue NetworkClientError => detail
- Puppet.err "Could not describe %s: %s" %
+ self.err "Could not describe %s: %s" %
[path, detail]
return nil
end
@@ -99,7 +99,7 @@ module Puppet
@is = :notfound
end
else
- Puppet.info "File does not have checksum"
+ self.info "File does not have checksum"
@is = :notfound
end
@@ -107,7 +107,7 @@ module Puppet
if state = @parent.state(:create)
unless state.should == "file"
- Puppet.notice(
+ self.notice(
"File %s had both create and source enabled" %
@parent.name
)
@@ -130,7 +130,7 @@ module Puppet
@is = true
# FIXME We should at least support symlinks, I would think...
else
- Puppet.err "Cannot use files of type %s as sources" %
+ self.err "Cannot use files of type %s as sources" %
@stats[:type]
@should = nil
@is = true
@@ -189,7 +189,7 @@ module Puppet
begin
contents = sourceobj.server.retrieve(path)
rescue NetworkClientError => detail
- Puppet.err "Could not retrieve %s: %s" %
+ self.err "Could not retrieve %s: %s" %
[path, detail]
return nil
end
@@ -201,7 +201,7 @@ module Puppet
end
if contents == ""
- Puppet.notice "Could not retrieve contents for %s" %
+ self.notice "Could not retrieve contents for %s" %
@source
end
@@ -237,7 +237,7 @@ module Puppet
begin
File.unlink(@parent.name)
rescue => detail
- Puppet.err "Could not remove %s for replacing: %s" %
+ self.err "Could not remove %s for replacing: %s" %
[@parent.name, detail]
end
end
@@ -245,7 +245,7 @@ module Puppet
begin
File.rename(@parent.name + ".puppettmp", @parent.name)
rescue => detail
- Puppet.err "Could not rename tmp %s for replacing: %s" %
+ self.err "Could not rename tmp %s for replacing: %s" %
[@parent.name, detail]
end
diff --git a/lib/puppet/type/pfile/uid.rb b/lib/puppet/type/pfile/uid.rb
index 41538dfe7..298be997a 100755
--- a/lib/puppet/type/pfile/uid.rb
+++ b/lib/puppet/type/pfile/uid.rb
@@ -86,7 +86,7 @@ module Puppet
def sync
unless Process.uid == 0
unless defined? @@notifieduid
- Puppet.notice "Cannot manage ownership unless running as root"
+ self.notice "Cannot manage ownership unless running as root"
#@parent.delete(self.name)
@@notifieduid = true
end
@@ -101,14 +101,14 @@ module Puppet
@parent.stat(true)
self.retrieve
if @is == :notfound
- Puppet.info "File '%s' does not exist; cannot chown" %
+ self.info "File does not exist; cannot set owner" %
@parent[:path]
return nil
end
if self.insync?
return nil
end
- #Puppet.debug "%s: after refresh, is '%s'" % [self.class.name,@is]
+ #self.debug "%s: after refresh, is '%s'" % [self.class.name,@is]
end
begin
diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb
index 49da3ce00..04c1bc904 100644
--- a/lib/puppet/type/service.rb
+++ b/lib/puppet/type/service.rb
@@ -63,17 +63,17 @@ module Puppet
when true,1,"1", :running, "running":
should = :running
else
- Puppet.warning "%s: interpreting '%s' as false" %
+ self.warning "%s: interpreting '%s' as false" %
[self.class,should]
should = 0
end
- Puppet.debug "Service should is %s" % should
+ self.debug "Service should is %s" % should
return should
end
def retrieve
self.is = @parent.status
- Puppet.debug "Running value for '%s' is '%s'" %
+ self.debug "Running value is '%s'" %
[self.parent.name,self.is]
end
@@ -87,7 +87,7 @@ module Puppet
@parent.stop
event = :service_stopped
else
- Puppet.debug "Not running '%s' and shouldn't be running" %
+ self.debug "Not running '%s' and shouldn't be running" %
self
end
end
@@ -174,7 +174,7 @@ module Puppet
end
unless @defsvctype
- Puppet.notice "Defaulting to base service type"
+ self.notice "Defaulting to base service type"
@defsvctype = Puppet::ServiceTypes::BaseSvc
end
end
@@ -287,7 +287,7 @@ module Puppet
)
cmd = self[:status] || self.statuscmd
output = %x(#{cmd} 2>&1)
- Puppet.debug "%s status returned %s" %
+ self.debug "%s status returned %s" %
[self.name, output]
if $? == 0
return :running
@@ -320,7 +320,7 @@ module Puppet
else
pid = getpid
unless pid
- Puppet.info "%s is not running" % self.name
+ self.info "%s is not running" % self.name
return false
end
output = %x("kill #{pid} 2>&1")
diff --git a/lib/puppet/type/service/init.rb b/lib/puppet/type/service/init.rb
index 49702161c..27e0d779b 100755
--- a/lib/puppet/type/service/init.rb
+++ b/lib/puppet/type/service/init.rb
@@ -9,10 +9,10 @@ module Puppet
end
unless @searchpaths.length > 0
if init = self.defaultinit
- Puppet.notice "Adding default init"
+ self.notice "Adding default init"
@searchpaths << init
else
- Puppet.notice "No default init for %s" %
+ self.notice "No default init for %s" %
Facter["operatingsystem"].value
raise Puppet::Error.new(
@@ -55,13 +55,13 @@ module Puppet
def initcmd(cmd)
script = self.initscript
- Puppet.debug "Executing '%s %s' as initcmd for '%s'" %
+ self.debug "Executing '%s %s' as initcmd for '%s'" %
[script,cmd,self]
rvalue = Kernel.system("%s %s" %
[script,cmd])
- Puppet.debug "'%s' ran with exit status '%s'" %
+ self.debug "'%s' ran with exit status '%s'" %
[cmd,rvalue]
@@ -110,7 +110,7 @@ module Puppet
stat = File.stat(fqname)
rescue
# should probably rescue specific errors...
- Puppet.debug("Could not find %s in %s" % [name,path])
+ self.debug("Could not find %s in %s" % [name,path])
next
end
diff --git a/lib/puppet/type/state.rb b/lib/puppet/type/state.rb
index 357c66d0d..5af4e38d1 100644
--- a/lib/puppet/type/state.rb
+++ b/lib/puppet/type/state.rb
@@ -100,7 +100,7 @@ class State < Puppet::Element
def should
if defined? @should
unless @should.is_a?(Array)
- Puppet.warning @should.inspect
+ self.warning @should.inspect
raise Puppet::DevError, "should for %s on %s is not an array" %
[self.class.name, @parent.name]
end
@@ -137,8 +137,8 @@ class State < Puppet::Element
return "%s: undefined %s from '%s'" %
[self.parent, self.name, self.is_to_s]
else
- return "%s: %s changed '%s' to '%s'" %
- [self.parent, self.name, self.is_to_s, self.should_to_s]
+ return "%s changed '%s' to '%s'" %
+ [self.name, self.is_to_s, self.should_to_s]
end
end
diff --git a/lib/puppet/type/symlink.rb b/lib/puppet/type/symlink.rb
index 79780e869..eb8250e79 100755
--- a/lib/puppet/type/symlink.rb
+++ b/lib/puppet/type/symlink.rb
@@ -127,7 +127,7 @@ module Puppet
if FileTest.exist?(@target)
@stat = File.stat(@target)
else
- Puppet.info "Target %s must exist for recursive links" %
+ self.info "Target %s must exist for recursive links" %
@target
return
end
@@ -169,7 +169,7 @@ module Puppet
dir = Puppet::Type::PFile.implicitcreate(args)
dir.parent = self
- Puppet.debug "Got dir %s" % dir.name
+ self.debug "Got dir %s" % dir.name
self.push dir
#Dir.foreach(@target) { |file|
# next if file =~ /^\.\.?$/ # skip . and ..
diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb
index 833f4444b..5c324944c 100755
--- a/lib/puppet/type/tidy.rb
+++ b/lib/puppet/type/tidy.rb
@@ -54,14 +54,14 @@ module Puppet
d == "." or d == ".."
}.length
if subs > 0
- Puppet.info "%s has %s children; not tidying" %
+ self.info "%s has %s children; not tidying" %
[@parent[:path], subs]
- Puppet.info Dir.entries(@parent[:path]).inspect
+ self.info Dir.entries(@parent[:path]).inspect
else
Dir.rmdir(@parent[:path])
end
else
- Puppet.debug "Not tidying directories"
+ self.debug "Not tidying directories"
return nil
end
when "file":
diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb
index 715ea4ed5..183b6bb98 100755
--- a/lib/puppet/type/user.rb
+++ b/lib/puppet/type/user.rb
@@ -88,7 +88,7 @@ module Puppet
[gid, detail]
end
- Puppet.notice "setting gid to %s" % ginfo.gid.inspect
+ self.notice "setting gid to %s" % ginfo.gid.inspect
return ginfo.gid
end
end