summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/puppet8
-rwxr-xr-xbin/puppetca4
-rwxr-xr-xbin/puppetd22
-rwxr-xr-xbin/puppetmasterd14
-rwxr-xr-xbin/puppetrun6
-rw-r--r--lib/puppet.rb30
-rw-r--r--lib/puppet/client.rb2
-rw-r--r--lib/puppet/client/master.rb8
-rw-r--r--lib/puppet/configuration.rb2
-rwxr-xr-xlib/puppet/daemon.rb8
-rw-r--r--lib/puppet/dsl.rb4
-rwxr-xr-xlib/puppet/filetype.rb302
-rw-r--r--lib/puppet/inifile.rb212
-rw-r--r--lib/puppet/log.rb550
-rw-r--r--lib/puppet/metatype/manager.rb4
-rw-r--r--lib/puppet/metatype/metaparams.rb2
-rw-r--r--lib/puppet/metric.rb160
-rw-r--r--lib/puppet/networkclient.rb1
-rw-r--r--lib/puppet/parameter.rb2
-rw-r--r--lib/puppet/parser/ast.rb4
-rw-r--r--lib/puppet/parser/functions.rb6
-rw-r--r--lib/puppet/parser/grammar.ra2
-rw-r--r--lib/puppet/parser/interpreter.rb4
-rw-r--r--lib/puppet/parser/parser.rb8
-rwxr-xr-xlib/puppet/provider/parsedfile.rb8
-rw-r--r--lib/puppet/reports/log.rb2
-rw-r--r--lib/puppet/reports/rrdgraph.rb2
-rw-r--r--lib/puppet/reports/store.rb2
-rw-r--r--lib/puppet/server/authconfig.rb4
-rwxr-xr-xlib/puppet/server/fileserver.rb2
-rwxr-xr-xlib/puppet/server/logger.rb2
-rwxr-xr-xlib/puppet/server/report.rb2
-rw-r--r--lib/puppet/sslcertificates/ca.rb2
-rw-r--r--lib/puppet/storage.rb106
-rw-r--r--lib/puppet/suidmanager.rb88
-rw-r--r--lib/puppet/transaction.rb4
-rw-r--r--lib/puppet/transaction/report.rb2
-rw-r--r--lib/puppet/type.rb12
-rwxr-xr-xlib/puppet/type/cron.rb6
-rwxr-xr-xlib/puppet/type/exec.rb17
-rwxr-xr-xlib/puppet/type/parsedtype.rb2
-rw-r--r--lib/puppet/type/pfile.rb4
-rwxr-xr-xlib/puppet/type/pfile/owner.rb2
-rwxr-xr-xlib/puppet/type/pfile/source.rb2
-rw-r--r--lib/puppet/type/pfile/target.rb2
-rw-r--r--lib/puppet/type/property.rb2
-rw-r--r--lib/puppet/type/yumrepo.rb12
-rw-r--r--lib/puppet/util.rb24
-rw-r--r--lib/puppet/util/autoload.rb (renamed from lib/puppet/autoload.rb)2
-rw-r--r--lib/puppet/util/config.rb (renamed from lib/puppet/config.rb)22
-rw-r--r--lib/puppet/util/feature.rb (renamed from lib/puppet/feature.rb)4
-rwxr-xr-xlib/puppet/util/filetype.rb300
-rw-r--r--lib/puppet/util/inifile.rb209
-rwxr-xr-xlib/puppet/util/loadedfile.rb (renamed from lib/puppet/loadedfile.rb)2
-rw-r--r--lib/puppet/util/log.rb548
-rw-r--r--lib/puppet/util/logging.rb6
-rw-r--r--lib/puppet/util/metric.rb158
-rw-r--r--lib/puppet/util/storage.rb103
-rw-r--r--lib/puppet/util/suidmanager.rb86
-rwxr-xr-xtest/client/master.rb6
-rw-r--r--test/data/types/sshkey/11
-rwxr-xr-xtest/executables/puppetca.rb2
-rwxr-xr-xtest/language/interpreter.rb2
-rwxr-xr-xtest/lib/puppettest.rb20
-rw-r--r--test/lib/puppettest/exetest.rb4
-rw-r--r--test/lib/puppettest/support/assertions.rb6
-rw-r--r--test/lib/puppettest/support/helpers.rb4
-rwxr-xr-xtest/other/autoload.rb8
-rwxr-xr-xtest/other/config.rb18
-rwxr-xr-xtest/other/dsl.rb2
-rwxr-xr-xtest/other/features.rb4
-rwxr-xr-xtest/other/filetype.rb6
-rwxr-xr-xtest/other/inifile.rb4
-rwxr-xr-xtest/other/loadedfile.rb10
-rwxr-xr-xtest/other/log.rb74
-rwxr-xr-xtest/other/metrics.rb2
-rwxr-xr-xtest/other/propertychange.rb6
-rwxr-xr-xtest/other/report.rb8
-rwxr-xr-xtest/other/storage.rb34
-rwxr-xr-xtest/other/transactions.rb40
-rwxr-xr-xtest/puppet/conffiles.rb5
-rwxr-xr-xtest/puppet/defaults.rb2
-rwxr-xr-xtest/puppet/tc_suidmanager.rb24
-rwxr-xr-xtest/ral/providers/group.rb2
-rwxr-xr-xtest/ral/providers/host/parsed.rb4
-rwxr-xr-xtest/ral/providers/mount/parsed.rb6
-rwxr-xr-xtest/ral/providers/parsedfile.rb8
-rwxr-xr-xtest/ral/providers/parsedport.rb2
-rwxr-xr-xtest/ral/providers/parsedsshkey.rb2
-rwxr-xr-xtest/ral/providers/user.rb2
-rwxr-xr-xtest/ral/types/cron.rb10
-rwxr-xr-xtest/ral/types/exec.rb63
-rwxr-xr-xtest/ral/types/file.rb12
-rwxr-xr-xtest/ral/types/filebucket.rb8
-rwxr-xr-xtest/ral/types/fileignoresource.rb8
-rwxr-xr-xtest/ral/types/filesources.rb6
-rwxr-xr-xtest/ral/types/service.rb2
-rwxr-xr-xtest/ral/types/user.rb2
-rwxr-xr-xtest/ral/types/zone.rb2
-rwxr-xr-xtest/server/logger.rb20
-rwxr-xr-xtest/util/posixtest.rb8
-rwxr-xr-xtest/util/utiltest.rb18
102 files changed, 1785 insertions, 1808 deletions
diff --git a/bin/puppet b/bin/puppet
index 8ded2304c..609a6e2e4 100755
--- a/bin/puppet
+++ b/bin/puppet
@@ -118,7 +118,7 @@ begin
loadclasses = true
when "--logdest"
begin
- Puppet::Log.newdestination(arg)
+ Puppet::Util::Log.newdestination(arg)
logset = true
rescue => detail
$stderr.puts detail.to_s
@@ -133,7 +133,7 @@ rescue GetoptLong::InvalidOption => detail
end
unless logset
- Puppet::Log.newdestination(:console)
+ Puppet::Util::Log.newdestination(:console)
end
client = nil
@@ -142,9 +142,9 @@ server = nil
Puppet.settraps
if debug
- Puppet::Log.level = :debug
+ Puppet::Util::Log.level = :debug
elsif verbose
- Puppet::Log.level = :info
+ Puppet::Util::Log.level = :info
end
# Now parse the config
diff --git a/bin/puppetca b/bin/puppetca
index 30dfcf8ef..e37f48d7f 100755
--- a/bin/puppetca
+++ b/bin/puppetca
@@ -116,7 +116,7 @@ begin
when "--clean"
mode = :clean
when "--debug"
- Puppet::Log.level = :debug
+ Puppet::Util::Log.level = :debug
when "--generate"
generate = arg
mode = :generate
@@ -134,7 +134,7 @@ begin
when "--sign"
mode = :sign
when "--verbose"
- Puppet::Log.level = :info
+ Puppet::Util::Log.level = :info
else
Puppet.config.handlearg(opt, arg)
end
diff --git a/bin/puppetd b/bin/puppetd
index ddcaadfd6..62973260b 100755
--- a/bin/puppetd
+++ b/bin/puppetd
@@ -214,10 +214,10 @@ begin
# Enable all of the most common test options.
Puppet.config.handlearg("--no-usecacheonfailure")
options[:onetime] = true
- unless Puppet::Log.level == :debug
- Puppet::Log.level = :info
+ unless Puppet::Util::Log.level == :debug
+ Puppet::Util::Log.level = :info
end
- Puppet::Log.newdestination(:console)
+ Puppet::Util::Log.newdestination(:console)
when "--centrallogging"
options[:centrallogs] = true
when "--help"
@@ -231,11 +231,11 @@ begin
puts "%s" % Puppet.version
exit
when "--verbose"
- Puppet::Log.level = :info
- Puppet::Log.newdestination(:console)
+ Puppet::Util::Log.level = :info
+ Puppet::Util::Log.newdestination(:console)
when "--debug"
- Puppet::Log.level = :debug
- Puppet::Log.newdestination(:console)
+ Puppet::Util::Log.level = :debug
+ Puppet::Util::Log.newdestination(:console)
when "--fqdn"
options[:fqdn] = arg
when "--no-client"
@@ -246,7 +246,7 @@ begin
args[:Port] = arg
when "--logdest"
begin
- Puppet::Log.newdestination(arg)
+ Puppet::Util::Log.newdestination(arg)
options[:setdest] = true
rescue => detail
$stderr.puts detail.to_s
@@ -274,7 +274,7 @@ Puppet.genmanifest
# Default to daemonizing, but if verbose or debug is specified,
# default to staying in the foreground.
unless options.include?(:daemonize)
- if Puppet::Log.level == :debug or Puppet::Log.level == :info
+ if Puppet::Util::Log.level == :debug or Puppet::Util::Log.level == :info
options[:daemonize] = false
else
options[:daemonize] = true
@@ -282,7 +282,7 @@ unless options.include?(:daemonize)
end
unless options[:setdest]
- Puppet::Log.newdestination(:syslog)
+ Puppet::Util::Log.newdestination(:syslog)
end
args[:Server] = Puppet[:server]
@@ -296,7 +296,7 @@ if options[:centrallogs]
if args.include?(:Port)
logdest += ":" + args[:Port]
end
- Puppet::Log.newdestination(logdest)
+ Puppet::Util::Log.newdestination(logdest)
end
if options[:onetime]
diff --git a/bin/puppetmasterd b/bin/puppetmasterd
index 2fd27ac46..ecacf480a 100755
--- a/bin/puppetmasterd
+++ b/bin/puppetmasterd
@@ -97,7 +97,7 @@ options = [
[ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
[ "--version", "-V", GetoptLong::NO_ARGUMENT ]
]
-#Puppet::Log.newdestination(:syslog)
+#Puppet::Util::Log.newdestination(:syslog)
# Add all of the config parameters as valid options.
Puppet.config.addargs(options)
@@ -147,7 +147,7 @@ begin
master[:UseNodes] = false
when "--logdest"
begin
- Puppet::Log.newdestination(arg)
+ Puppet::Util::Log.newdestination(arg)
options[:setdest] = true
rescue => detail
if Puppet[:debug]
@@ -173,19 +173,19 @@ end
# Handle the logging settings.
if options[:debug] or options[:verbose]
if options[:debug]
- Puppet::Log.level = :debug
+ Puppet::Util::Log.level = :debug
else
- Puppet::Log.level = :info
+ Puppet::Util::Log.level = :info
end
unless options[:daemonize]
- Puppet::Log.newdestination(:console)
+ Puppet::Util::Log.newdestination(:console)
options[:setdest] = true
end
end
unless options[:setdest]
- Puppet::Log.newdestination(:syslog)
+ Puppet::Util::Log.newdestination(:syslog)
end
# Now parse the config
@@ -201,7 +201,7 @@ require 'etc'
# Default to daemonizing, but if verbose or debug is specified,
# default to staying in the foreground.
unless options.include?(:daemonize)
- if Puppet::Log.level == :debug or Puppet::Log.level == :info
+ if Puppet::Util::Log.level == :debug or Puppet::Util::Log.level == :info
options[:daemonize] = false
else
options[:daemonize] = true
diff --git a/bin/puppetrun b/bin/puppetrun
index da6926569..8df673eea 100755
--- a/bin/puppetrun
+++ b/bin/puppetrun
@@ -216,7 +216,7 @@ hosts = []
classes = []
tags = []
-Puppet::Log.newdestination(:console)
+Puppet::Util::Log.newdestination(:console)
begin
result.each { |opt,arg|
@@ -266,9 +266,9 @@ rescue GetoptLong::InvalidOption => detail
end
if options[:debug]
- Puppet::Log.level = :debug
+ Puppet::Util::Log.level = :debug
else
- Puppet::Log.level = :info
+ Puppet::Util::Log.level = :info
end
# Now parse the config
diff --git a/lib/puppet.rb b/lib/puppet.rb
index 739113fc9..f12645357 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -4,11 +4,11 @@ require 'facter'
require 'puppet/error'
require 'puppet/external/event-loop'
require 'puppet/util'
-require 'puppet/log'
-require 'puppet/autoload'
-require 'puppet/config'
-require 'puppet/feature'
-require 'puppet/suidmanager'
+require 'puppet/util/log'
+require 'puppet/util/autoload'
+require 'puppet/util/config'
+require 'puppet/util/feature'
+require 'puppet/util/suidmanager'
#------------------------------------------------------------
# the top-level module
@@ -47,18 +47,18 @@ module Puppet
end
# the hash that determines how our system behaves
- @@config = Puppet::Config.new
+ @@config = Puppet::Util::Config.new
# The services running in this process.
@services ||= []
# define helper messages for each of the message levels
- Puppet::Log.eachlevel { |level|
+ Puppet::Util::Log.eachlevel { |level|
define_method(level,proc { |args|
if args.is_a?(Array)
args = args.join(" ")
end
- Puppet::Log.create(
+ Puppet::Util::Log.create(
:level => level,
:message => args
)
@@ -71,7 +71,7 @@ module Puppet
alias :error :err
# The feature collection
- @features = Puppet::Feature.new('puppet/feature')
+ @features = Puppet::Util::Feature.new('puppet/feature')
# Store a new default value.
def self.setdefaults(section, hash)
@@ -85,7 +85,7 @@ module Puppet
def self.[](param)
case param
when :debug:
- if Puppet::Log.level == :debug
+ if Puppet::Util::Log.level == :debug
return true
else
return false
@@ -106,9 +106,9 @@ module Puppet
def self.debug=(value)
if value
- Puppet::Log.level=(:debug)
+ Puppet::Util::Log.level=(:debug)
else
- Puppet::Log.level=(:notice)
+ Puppet::Util::Log.level=(:notice)
end
end
@@ -194,7 +194,7 @@ module Puppet
command = $0 + " " + self.args.join(" ")
Puppet.notice "Restarting with '%s'" % command
Puppet.shutdown(false)
- Puppet::Log.reopen
+ Puppet::Util::Log.reopen
exec(command)
end
@@ -245,7 +245,7 @@ module Puppet
end
trap(:USR2) do
- Puppet::Log.reopen
+ Puppet::Util::Log.reopen
end
end
@@ -389,7 +389,7 @@ end
require 'puppet/server'
require 'puppet/type'
-require 'puppet/storage'
+require 'puppet/util/storage'
if Puppet[:storeconfigs]
require 'puppet/rails'
end
diff --git a/lib/puppet/client.rb b/lib/puppet/client.rb
index de3b3eaec..e668aa27a 100644
--- a/lib/puppet/client.rb
+++ b/lib/puppet/client.rb
@@ -153,7 +153,7 @@ module Puppet
else
self.stopping = true
if self.respond_to? :running? and self.running?
- Puppet::Storage.store
+ Puppet::Util::Storage.store
end
rmpidfile()
end
diff --git a/lib/puppet/client/master.rb b/lib/puppet/client/master.rb
index b59d710c9..046e0c5aa 100644
--- a/lib/puppet/client/master.rb
+++ b/lib/puppet/client/master.rb
@@ -137,7 +137,7 @@ class Puppet::Client::MasterClient < Puppet::Client
puts detail.backtrace
end
ensure
- Puppet::Storage.store
+ Puppet::Util::Storage.store
end
if Puppet[:report]
@@ -177,8 +177,8 @@ class Puppet::Client::MasterClient < Puppet::Client
# Initialize and load storage
def dostorage
begin
- Puppet::Storage.load
- @compile_time ||= Puppet::Storage.cache(:configuration)[:compile_time]
+ Puppet::Util::Storage.load
+ @compile_time ||= Puppet::Util::Storage.cache(:configuration)[:compile_time]
rescue => detail
if Puppet[:trace]
puts detail.backtrace
@@ -626,7 +626,7 @@ class Puppet::Client::MasterClient < Puppet::Client
fromcache = true
else
@compile_time = Time.now
- Puppet::Storage.cache(:configuration)[:compile_time] = @compile_time
+ Puppet::Util::Storage.cache(:configuration)[:compile_time] = @compile_time
end
begin
diff --git a/lib/puppet/configuration.rb b/lib/puppet/configuration.rb
index 952a54397..5b2d90af8 100644
--- a/lib/puppet/configuration.rb
+++ b/lib/puppet/configuration.rb
@@ -4,7 +4,7 @@ module Puppet
# use basedirs that are in the user's home directory.
conf = nil
var = nil
- if self.name != "puppetmasterd" and Puppet::SUIDManager.uid != 0
+ if self.name != "puppetmasterd" and Puppet::Util::SUIDManager.uid != 0
conf = File.expand_path("~/.puppet")
var = File.expand_path("~/.puppet/var")
else
diff --git a/lib/puppet/daemon.rb b/lib/puppet/daemon.rb
index bd02a9dc3..9fdb33bcf 100755
--- a/lib/puppet/daemon.rb
+++ b/lib/puppet/daemon.rb
@@ -29,7 +29,7 @@ module Puppet
end
# Get rid of console logging
- Puppet::Log.close(:console)
+ Puppet::Util::Log.close(:console)
Process.setsid
Dir.chdir("/")
@@ -37,7 +37,7 @@ module Puppet
$stdin.reopen "/dev/null"
$stdout.reopen "/dev/null", "a"
$stderr.reopen $stdout
- Puppet::Log.reopen
+ Puppet::Util::Log.reopen
rescue => detail
File.open("/tmp/daemonout", "w") { |f|
f.puts "Could not start %s: %s" % [Puppet.name, detail]
@@ -264,8 +264,8 @@ module Puppet
rmpidfile()
# And close all logs except the console.
- Puppet::Log.destinations.reject { |d| d == :console }.each do |dest|
- Puppet::Log.close(dest)
+ Puppet::Util::Log.destinations.reject { |d| d == :console }.each do |dest|
+ Puppet::Util::Log.close(dest)
end
super
diff --git a/lib/puppet/dsl.rb b/lib/puppet/dsl.rb
index 071a3f6dd..44c03e8a9 100644
--- a/lib/puppet/dsl.rb
+++ b/lib/puppet/dsl.rb
@@ -95,8 +95,8 @@ module Puppet
end
Puppet[:user] = Process.uid
Puppet[:group] = Process.gid
- Puppet::Log.newdestination(:console)
- Puppet::Log.level = :info
+ Puppet::Util::Log.newdestination(:console)
+ Puppet::Util::Log.level = :info
end
private
diff --git a/lib/puppet/filetype.rb b/lib/puppet/filetype.rb
deleted file mode 100755
index d05c1469d..000000000
--- a/lib/puppet/filetype.rb
+++ /dev/null
@@ -1,302 +0,0 @@
-module Puppet
- # Basic classes for reading, writing, and emptying files. Not much
- # to see here.
- class FileType
- attr_accessor :loaded, :path, :synced
-
- class << self
- attr_accessor :name
- include Puppet::Util::ClassGen
- end
-
- # Create a new filetype.
- def self.newfiletype(name, &block)
- @filetypes ||= {}
-
- klass = genclass(name,
- :block => block,
- :prefix => "FileType",
- :hash => @filetypes
- )
-
- # Rename the read and write methods, so that we're sure they
- # maintain the stats.
- klass.class_eval do
- # Rename the read method
- define_method(:real_read, instance_method(:read))
- define_method(:read) do
- begin
- val = real_read()
- @loaded = Time.now
- if val
- return val.gsub(/# HEADER.*\n/,'')
- else
- return ""
- end
- rescue Puppet::Error => detail
- raise
- rescue => detail
- if Puppet[:trace]
- puts detail.backtrace
- end
- raise Puppet::Error, "%s could not read %s: %s" %
- [self.class, @path, detail]
- end
- end
-
- # And then the write method
- define_method(:real_write, instance_method(:write))
- define_method(:write) do |text|
- begin
- val = real_write(text)
- @synced = Time.now
- return val
- rescue Puppet::Error => detail
- raise
- rescue => detail
- if Puppet[:debug]
- puts detail.backtrace
- end
- raise Puppet::Error, "%s could not write %s: %s" %
- [self.class, @path, detail]
- end
- end
- end
- end
-
- def self.filetype(type)
- @filetypes[type]
- end
-
- def initialize(path)
- @path = path
- end
-
- # Operate on plain files.
- newfiletype(:flat) do
- # Read the file.
- def read
- if File.exists?(@path)
- File.read(@path)
- else
- return nil
- end
- end
-
- # Remove the file.
- def remove
- if File.exists?(@path)
- File.unlink(@path)
- end
- end
-
- # Overwrite the file.
- def write(text)
- File.open(@path, "w") { |f| f.print text; f.flush }
- end
- end
-
- # Operate on plain files.
- newfiletype(:ram) do
- @@tabs = {}
-
- def self.clear
- @@tabs.clear
- end
-
- def initialize(path)
- super
- @@tabs[@path] ||= ""
- end
-
- # Read the file.
- def read
- Puppet.info "Reading %s from RAM" % @path
- @@tabs[@path]
- end
-
- # Remove the file.
- def remove
- Puppet.info "Removing %s from RAM" % @path
- @@tabs[@path] = ""
- end
-
- # Overwrite the file.
- def write(text)
- Puppet.info "Writing %s to RAM" % @path
- @@tabs[@path] = text
- end
- end
-
- # Handle Linux-style cron tabs.
- newfiletype(:crontab) do
- def initialize(user)
- self.path = user
- end
-
- def path=(user)
- begin
- @uid = Puppet::Util.uid(user)
- rescue Puppet::Error => detail
- raise Puppet::Error, "Could not retrieve user %s" % user
- end
-
- # XXX We have to have the user name, not the uid, because some
- # systems *cough*linux*cough* require it that way
- @path = user
- end
-
- # Read a specific @path's cron tab.
- def read
- %x{#{cmdbase()} -l 2>/dev/null}
- end
-
- # Remove a specific @path's cron tab.
- def remove
- if Facter.value("operatingsystem") == "FreeBSD"
- %x{/bin/echo yes | #{cmdbase()} -r 2>/dev/null}
- else
- %x{#{cmdbase()} -r 2>/dev/null}
- end
- end
-
- # Overwrite a specific @path's cron tab; must be passed the @path name
- # and the text with which to create the cron tab.
- def write(text)
- IO.popen("#{cmdbase()} -", "w") { |p|
- p.print text
- }
- end
-
- private
-
- # Only add the -u flag when the @path is different. Fedora apparently
- # does not think I should be allowed to set the @path to my own user name
- def cmdbase
- cmd = nil
- if @uid == Puppet::SUIDManager.uid
- return "crontab"
- else
- return "crontab -u #{@path}"
- end
- end
- end
-
- # SunOS has completely different cron commands; this class implements
- # its versions.
- newfiletype(:suntab) do
- # Read a specific @path's cron tab.
- def read
- Puppet::SUIDManager.asuser(@path) {
- %x{crontab -l 2>/dev/null}
- }
- end
-
- # Remove a specific @path's cron tab.
- def remove
- Puppet::SUIDManager.asuser(@path) {
- %x{crontab -r 2>/dev/null}
- }
- end
-
- # Overwrite a specific @path's cron tab; must be passed the @path name
- # and the text with which to create the cron tab.
- def write(text)
- Puppet::SUIDManager.asuser(@path) {
- IO.popen("crontab", "w") { |p|
- p.print text
- }
- }
- end
- end
-
- # Treat netinfo tables as a single file, just for simplicity of certain
- # types
- newfiletype(:netinfo) do
- class << self
- attr_accessor :format
- end
- def read
- %x{nidump -r /#{@path} /}
- end
-
- # This really only makes sense for cron tabs.
- def remove
- %x{nireport / /#{@path} name}.split("\n").each do |name|
- newname = name.gsub(/\//, '\/').sub(/\s+$/, '')
- output = %x{niutil -destroy / '/#{@path}/#{newname}'}
-
- unless $? == 0
- raise Puppet::Error, "Could not remove %s from %s" %
- [name, @path]
- end
- end
- end
-
- # Convert our table to an array of hashes. This only works for
- # handling one table at a time.
- def to_array(text = nil)
- unless text
- text = read
- end
-
- hash = nil
-
- # Initialize it with the first record
- records = []
- text.split("\n").each do |line|
- next if line =~ /^[{}]$/ # Skip the wrapping lines
- next if line =~ /"name" = \( "#{@path}" \)/ # Skip the table name
- next if line =~ /CHILDREN = \(/ # Skip this header
- next if line =~ /^ \)/ # and its closer
-
- # Now we should have nothing but records, wrapped in braces
-
- case line
- when /^\s+\{/: hash = {}
- when /^\s+\}/: records << hash
- when /\s+"(\w+)" = \( (.+) \)/
- field = $1
- values = $2
-
- # Always use an array
- hash[field] = []
-
- values.split(/, /).each do |value|
- if value =~ /^"(.*)"$/
- hash[field] << $1
- else
- raise ArgumentError, "Could not match value %s" % value
- end
- end
- else
- raise ArgumentError, "Could not match line %s" % line
- end
- end
-
- records
- end
-
- def write(text)
- text.gsub!(/^#.*\n/,'')
- text.gsub!(/^$/,'')
- if text == "" or text == "\n"
- self.remove
- return
- end
- unless format = self.class.format
- raise Puppe::DevError, "You must define the NetInfo format to inport"
- end
- IO.popen("niload -d #{format} . 1>/dev/null 2>/dev/null", "w") { |p|
- p.print text
- }
-
- unless $? == 0
- raise ArgumentError, "Failed to write %s" % @path
- end
- end
- end
- end
-end
-
-# $Id$
diff --git a/lib/puppet/inifile.rb b/lib/puppet/inifile.rb
deleted file mode 100644
index 3ffd6d137..000000000
--- a/lib/puppet/inifile.rb
+++ /dev/null
@@ -1,212 +0,0 @@
-# Module Puppet::IniConfig
-# A generic way to parse .ini style files and manipulate them in memory
-# One 'file' can be made up of several physical files. Changes to sections
-# on the file are tracked so that only the physical files in which
-# something has changed are written back to disk
-# Great care is taken to preserve comments and blank lines from the original
-# files
-#
-# The parsing tries to stay close to python's ConfigParser
-
-require 'puppet/filetype'
-
-module Puppet
- module IniConfig
-
- # A section in a .ini file
- class Section
- attr_reader :name, :file
-
- def initialize(name, file)
- @name = name
- @file = file
- @dirty = false
- @entries = []
- end
-
- # Has this section been modified since it's been read in
- # or written back to disk
- def dirty?
- @dirty
- end
-
- # Should only be used internally
- def mark_clean
- @dirty = false
- end
-
- # Add a line of text (e.g., a comment) Such lines
- # will be written back out in exactly the same
- # place they were read in
- def add_line(line)
- @entries << line
- end
-
- # Set the entry 'key=value'. If no entry with the
- # given key exists, one is appended to teh end of the section
- def []=(key, value)
- entry = find_entry(key)
- @dirty = true
- if entry.nil?
- @entries << [key, value]
- else
- entry[1] = value
- end
- end
-
- # Return the value associated with KEY. If no such entry
- # exists, return nil
- def [](key)
- entry = find_entry(key)
- if entry.nil?
- return nil
- end
- return entry[1]
- end
-
- # Format the section as text in the way it should be
- # written to file
- def format
- text = "[#{name}]\n"
- @entries.each do |entry|
- if entry.is_a?(Array)
- key, value = entry
- unless value.nil?
- text << "#{key}=#{value}\n"
- end
- else
- text << entry
- end
- end
- return text
- end
-
- private
- def find_entry(key)
- @entries.each do |entry|
- if entry.is_a?(Array) && entry[0] == key
- return entry
- end
- end
- return nil
- end
-
- end
-
- # A logical .ini-file that can be spread across several physical
- # files. For each physical file, call #read with the filename
- class File
- def initialize
- @files = {}
- end
-
- # Add the contents of the file with name FILE to the
- # already existing sections
- def read(file)
- text = Puppet::FileType.filetype(:flat).new(file).read
- if text.nil?
- raise "Could not find #{file}"
- end
-
- section = nil # The name of the current section
- optname = nil # The name of the last option in section
- line = 0
- @files[file] = []
- text.each_line do |l|
- line += 1
- if l.strip.empty? || "#;".include?(l[0,1]) ||
- (l.split(nil, 2)[0].downcase == "rem" &&
- l[0,1].downcase == "r")
- # Whitespace or comment
- if section.nil?
- @files[file] << l
- else
- section.add_line(l)
- end
- elsif " \t\r\n\f".include?(l[0,1]) && section && optname
- # continuation line
- section[optname] += "\n" + l.chomp
- elsif l =~ /^\[([^\]]+)\]/
- # section heading
- section.mark_clean unless section.nil?
- section = add_section($1, file)
- optname = nil
- elsif l =~ /^\s*([^\s=]+)\s*\=(.+)$/
- # We allow space around the keys, but not the values
- # For the values, we don't know if space is significant
- if section.nil?
- raise "#{file}:#{line}:Key/value pair outside of a section for key #{$1}"
- else
- section[$1] = $2
- optname = $1
- end
- else
- raise "#{file}:#{line}: Can't parse '#{l.chomp}'"
- end
- end
- section.mark_clean unless section.nil?
- end
-
- # Store all modifications made to sections in this file back
- # to the physical files. If no modifications were made to
- # a physical file, nothing is written
- def store
- @files.each do |file, lines|
- text = ""
- dirty = false
- lines.each do |l|
- if l.is_a?(Section)
- dirty ||= l.dirty?
- text << l.format
- l.mark_clean
- else
- text << l
- end
- end
- if dirty
- Puppet::FileType.filetype(:flat).new(file).write(text)
- end
- end
- end
-
- # Execute BLOCK, passing each section in this file
- # as an argument
- def each_section(&block)
- @files.each do |file, list|
- list.each do |entry|
- if entry.is_a?(Section)
- yield(entry)
- end
- end
- end
- end
-
- # Return the Section with the given name or nil
- def [](name)
- name = name.to_s
- each_section do |section|
- return section if section.name == name
- end
- return nil
- end
-
- # Return true if the file contains a section with name NAME
- def include?(name)
- return ! self[name].nil?
- end
-
- # Add a section to be stored in FILE when store is called
- def add_section(name, file)
- if include?(name)
- raise "A section with name #{name} already exists"
- end
- result = Section.new(name, file)
- @files[file] ||= []
- @files[file] << result
- return result
- end
- end
-
-
- end
-end
diff --git a/lib/puppet/log.rb b/lib/puppet/log.rb
deleted file mode 100644
index 44b4352ce..000000000
--- a/lib/puppet/log.rb
+++ /dev/null
@@ -1,550 +0,0 @@
-require 'syslog'
-
-module Puppet
- # Pass feedback to the user. Log levels are modeled after syslog's, and it is
- # expected that that will be the most common log destination. Supports
- # multiple destinations, one of which is a remote server.
- class Log
- include Puppet::Util
-
- @levels = [:debug,:info,:notice,:warning,:err,:alert,:emerg,:crit]
- @loglevel = 2
-
- @desttypes = {}
-
- # A type of log destination.
- class Destination
- class << self
- attr_accessor :name
- end
-
- def self.initvars
- @matches = []
- end
-
- # Mark the things we're supposed to match.
- def self.match(obj)
- @matches ||= []
- @matches << obj
- end
-
- # See whether we match a given thing.
- def self.match?(obj)
- # Convert single-word strings into symbols like :console and :syslog
- if obj.is_a? String and obj =~ /^\w+$/
- obj = obj.downcase.intern
- end
-
- @matches.each do |thing|
- # Search for direct matches or class matches
- return true if thing === obj or thing == obj.class.to_s
- end
- return false
- end
-
- def name
- if defined? @name
- return @name
- else
- return self.class.name
- end
- end
-
- # Set how to handle a message.
- def self.sethandler(&block)
- define_method(:handle, &block)
- end
-
- # Mark how to initialize our object.
- def self.setinit(&block)
- define_method(:initialize, &block)
- end
- end
-
- # Create a new destination type.
- def self.newdesttype(name, options = {}, &block)
- dest = genclass(name, :parent => Destination, :prefix => "Dest",
- :block => block,
- :hash => @desttypes,
- :attributes => options
- )
- dest.match(dest.name)
-
- return dest
- end
-
- @destinations = {}
-
- class << self
- include Puppet::Util
- include Puppet::Util::ClassGen
- end
-
- # Reset all logs to basics. Basically just closes all files and undefs
- # all of the other objects.
- def Log.close(dest = nil)
- if dest
- if @destinations.include?(dest)
- if @destinations.respond_to?(:close)
- @destinations[dest].close
- end
- @destinations.delete(dest)
- end
- else
- @destinations.each { |name, dest|
- if dest.respond_to?(:flush)
- dest.flush
- end
- if dest.respond_to?(:close)
- dest.close
- end
- }
- @destinations = {}
- end
- end
-
- # Flush any log destinations that support such operations.
- def Log.flush
- @destinations.each { |type, dest|
- if dest.respond_to?(:flush)
- dest.flush
- end
- }
- end
-
- # Create a new log message. The primary role of this method is to
- # avoid creating log messages below the loglevel.
- def Log.create(hash)
- unless hash.include?(:level)
- raise Puppet::DevError, "Logs require a level"
- end
- unless @levels.index(hash[:level])
- raise Puppet::DevError, "Invalid log level %s" % hash[:level]
- end
- if @levels.index(hash[:level]) >= @loglevel
- return Puppet::Log.new(hash)
- else
- return nil
- end
- end
-
- def Log.destinations
- return @destinations.keys
- end
-
- # Yield each valid level in turn
- def Log.eachlevel
- @levels.each { |level| yield level }
- end
-
- # Return the current log level.
- def Log.level
- return @levels[@loglevel]
- end
-
- # Set the current log level.
- def Log.level=(level)
- unless level.is_a?(Symbol)
- level = level.intern
- end
-
- unless @levels.include?(level)
- raise Puppet::DevError, "Invalid loglevel %s" % level
- end
-
- @loglevel = @levels.index(level)
- end
-
- def Log.levels
- @levels.dup
- end
-
- newdesttype :syslog do
- def close
- Syslog.close
- end
-
- def initialize
- if Syslog.opened?
- Syslog.close
- end
- name = Puppet.name
- name = "puppet-#{name}" unless name =~ /puppet/
-
- options = Syslog::LOG_PID | Syslog::LOG_NDELAY
-
- # XXX This should really be configurable.
- str = Puppet[:syslogfacility]
- begin
- facility = Syslog.const_get("LOG_#{str.upcase}")
- rescue NameError
- raise Puppet::Error, "Invalid syslog facility %s" % str
- end
-
- @syslog = Syslog.open(name, options, facility)
- end
-
- def handle(msg)
- # XXX Syslog currently has a bug that makes it so you
- # cannot log a message with a '%' in it. So, we get rid
- # of them.
- if msg.source == "Puppet"
- @syslog.send(msg.level, msg.to_s.gsub("%", '%%'))
- else
- @syslog.send(msg.level, "(%s) %s" %
- [msg.source.to_s.gsub("%", ""),
- msg.to_s.gsub("%", '%%')
- ]
- )
- end
- end
- end
-
- newdesttype :file do
- match(/^\//)
-
- def close
- if defined? @file
- @file.close
- @file = nil
- end
- end
-
- def flush
- if defined? @file
- @file.flush
- end
- end
-
- def initialize(path)
- @name = path
- # first make sure the directory exists
- # We can't just use 'Config.use' here, because they've
- # specified a "special" destination.
- unless FileTest.exist?(File.dirname(path))
- Puppet.recmkdir(File.dirname(path))
- Puppet.info "Creating log directory %s" % File.dirname(path)
- end
-
- # create the log file, if it doesn't already exist
- file = File.open(path, File::WRONLY|File::CREAT|File::APPEND)
-
- @file = file
-
- @autoflush = Puppet[:autoflush]
- end
-
- def handle(msg)
- @file.puts("%s %s (%s): %s" %
- [msg.time, msg.source, msg.level, msg.to_s])
-
- @file.flush if @autoflush
- end
- end
-
- newdesttype :console do
-
-
- PINK = {:console => "", :html => "FFA0A0"}
- GREEN = {:console => "", :html => "00CD00"}
- YELLOW = {:console => "", :html => "FFFF60"}
- SLATE = {:console => "", :html => "80A0FF"}
- ORANGE = {:console => "", :html => "FFA500"}
- BLUE = {:console => "", :html => "40FFFF"}
- RESET = {:console => "", :html => ""}
-
- @@colormap = {
- :debug => SLATE,
- :info => GREEN,
- :notice => PINK,
- :warning => ORANGE,
- :err => YELLOW,
- :alert => BLUE,
- :emerg => RESET,
- :crit => RESET
- }
-
- def colorize(level, str)
- case Puppet[:color]
- when false: str
- when true, :ansi, "ansi": console_color(level, str)
- when :html, "html": html_color(level, str)
- end
- end
-
- def console_color(level, str)
- @@colormap[level][:console] + str + RESET[:console]
- end
-
- def html_color(level, str)
- %{<span style="color: %s">%s</span>} % [@@colormap[level][:html], str]
- end
-
- def initialize
- # Flush output immediately.
- $stdout.sync = true
- end
-
- def handle(msg)
- if msg.source == "Puppet"
- puts colorize(msg.level, "%s: %s" % [msg.level, msg.to_s])
- else
- puts colorize(msg.level, "%s: %s: %s" % [msg.level, msg.source, msg.to_s])
- end
- end
- end
-
- newdesttype :host do
- def initialize(host)
- Puppet.info "Treating %s as a hostname" % host
- args = {}
- if host =~ /:(\d+)/
- args[:Port] = $1
- args[:Server] = host.sub(/:\d+/, '')
- else
- args[:Server] = host
- end
-
- @name = host
-
- @driver = Puppet::Client::LogClient.new(args)
- end
-
- def handle(msg)
- unless msg.is_a?(String) or msg.remote
- unless defined? @hostname
- @hostname = Facter["hostname"].value
- end
- unless defined? @domain
- @domain = Facter["domain"].value
- if @domain
- @hostname += "." + @domain
- end
- end
- if msg.source =~ /^\//
- msg.source = @hostname + ":" + msg.source
- elsif msg.source == "Puppet"
- msg.source = @hostname + " " + msg.source
- else
- msg.source = @hostname + " " + msg.source
- end
- begin
- #puts "would have sent %s" % msg
- #puts "would have sent %s" %
- # CGI.escape(YAML.dump(msg))
- begin
- tmp = CGI.escape(YAML.dump(msg))
- rescue => detail
- puts "Could not dump: %s" % detail.to_s
- return
- end
- # Add the hostname to the source
- @driver.addlog(tmp)
- rescue => detail
- if Puppet[:trace]
- puts detail.backtrace
- end
- Puppet.err detail
- Puppet::Log.close(self)
- end
- end
- end
- end
-
- # Log to a transaction report.
- newdesttype :report do
- match "Puppet::Transaction::Report"
-
- def initialize(report)
- @report = report
- end
-
- def handle(msg)
- # Only add messages from objects, since anything else is
- # probably unrelated to this run.
- if msg.objectsource?
- @report.newlog(msg)
- end
- end
- end
-
- # Log to an array, just for testing.
- newdesttype :array do
- match "Array"
-
- def initialize(array)
- @array = array
- end
-
- def handle(msg)
- @array << msg
- end
- end
-
- # Create a new log destination.
- def Log.newdestination(dest)
- # Each destination can only occur once.
- if @destinations.find { |name, obj| obj.name == dest }
- return
- end
-
- name, type = @desttypes.find do |name, klass|
- klass.match?(dest)
- end
-
- unless type
- raise Puppet::DevError, "Unknown destination type %s" % dest
- end
-
- begin
- if type.instance_method(:initialize).arity == 1
- @destinations[dest] = type.new(dest)
- else
- @destinations[dest] = type.new()
- end
- rescue => detail
- if Puppet[:debug]
- puts detail.backtrace
- end
-
- # If this was our only destination, then add the console back in.
- if @destinations.empty? and (dest != :console and dest != "console")
- newdestination(:console)
- end
- end
- end
-
- # Route the actual message. FIXME There are lots of things this method
- # should do, like caching, storing messages when there are not yet
- # destinations, a bit more. It's worth noting that there's a potential
- # for a loop here, if the machine somehow gets the destination set as
- # itself.
- def Log.newmessage(msg)
- if @levels.index(msg.level) < @loglevel
- return
- end
-
- @destinations.each do |name, dest|
- threadlock(dest) do
- dest.handle(msg)
- end
- end
- end
-
- def Log.sendlevel?(level)
- @levels.index(level) >= @loglevel
- end
-
- # Reopen all of our logs.
- def Log.reopen
- Puppet.notice "Reopening log files"
- types = @destinations.keys
- @destinations.each { |type, dest|
- if dest.respond_to?(:close)
- dest.close
- end
- }
- @destinations.clear
- # We need to make sure we always end up with some kind of destination
- begin
- types.each { |type|
- Log.newdestination(type)
- }
- rescue => detail
- if @destinations.empty?
- Log.newdestination(:syslog)
- Puppet.err detail.to_s
- end
- end
- end
-
- # Is the passed level a valid log level?
- def self.validlevel?(level)
- @levels.include?(level)
- end
-
- attr_accessor :level, :message, :time, :tags, :remote
- attr_reader :source
-
- def initialize(args)
- unless args.include?(:level) && args.include?(:message)
- raise Puppet::DevError, "Puppet::Log called incorrectly"
- end
-
- if args[:level].class == String
- @level = args[:level].intern
- elsif args[:level].class == Symbol
- @level = args[:level]
- else
- raise Puppet::DevError,
- "Level is not a string or symbol: #{args[:level].class}"
- end
-
- # Just return unless we're actually at a level we should send
- #return unless self.class.sendlevel?(@level)
-
- @message = args[:message].to_s
- @time = Time.now
- # this should include the host name, and probly lots of other
- # stuff, at some point
- unless self.class.validlevel?(level)
- raise Puppet::DevError, "Invalid message level #{level}"
- end
-
- if args.include?(:tags)
- @tags = args[:tags]
- end
-
- if args.include?(:source)
- self.source = args[:source]
- else
- @source = "Puppet"
- end
-
- Log.newmessage(self)
- end
-
- # Was the source of this log an object?
- def objectsource?
- if defined? @objectsource and @objectsource
- @objectsource
- else
- false
- end
- end
-
- # If they pass a source in to us, we make sure it is a string, and
- # we retrieve any tags we can.
- def source=(source)
- # We can't store the actual source, we just store the path.
- # We can't just check for whether it responds to :path, because
- # plenty of providers respond to that in their normal function.
- if source.is_a?(Puppet::Element) and source.respond_to?(:path)
- @objectsource = true
- @source = source.path
- else
- @objectsource = false
- @source = source.to_s
- end
- unless defined? @tags and @tags
- if source.respond_to?(:tags)
- @tags = source.tags
- end
- end
- end
-
- def tagged?(tag)
- @tags.detect { |t| t.to_s == tag.to_s }
- end
-
- def to_report
- "%s %s (%s): %s" % [self.time, self.source, self.level, self.to_s]
- end
-
- def to_s
- return @message
- end
- end
-end
-
-# $Id$
diff --git a/lib/puppet/metatype/manager.rb b/lib/puppet/metatype/manager.rb
index 1e2d6db97..1c0194c16 100644
--- a/lib/puppet/metatype/manager.rb
+++ b/lib/puppet/metatype/manager.rb
@@ -109,7 +109,7 @@ module Manager
end
# Now set up autoload any providers that might exist for this type.
- klass.providerloader = Puppet::Autoload.new(klass,
+ klass.providerloader = Puppet::Util::Autoload.new(klass,
"puppet/provider/#{klass.name.to_s}"
)
@@ -156,7 +156,7 @@ module Manager
# Create a loader for Puppet types.
def typeloader
unless defined? @typeloader
- @typeloader = Puppet::Autoload.new(self,
+ @typeloader = Puppet::Util::Autoload.new(self,
"puppet/type", :wrap => false
)
end
diff --git a/lib/puppet/metatype/metaparams.rb b/lib/puppet/metatype/metaparams.rb
index ee667bfb3..4c85699ba 100644
--- a/lib/puppet/metatype/metaparams.rb
+++ b/lib/puppet/metatype/metaparams.rb
@@ -136,7 +136,7 @@ class Puppet::Type
syslog (which is currently the default)."
defaultto :notice
- newvalues(*Puppet::Log.levels)
+ newvalues(*Puppet::Util::Log.levels)
newvalues(:verbose)
munge do |loglevel|
diff --git a/lib/puppet/metric.rb b/lib/puppet/metric.rb
deleted file mode 100644
index 3749d257f..000000000
--- a/lib/puppet/metric.rb
+++ /dev/null
@@ -1,160 +0,0 @@
-# included so we can test object types
-require 'puppet'
-
-module Puppet
- # A class for handling metrics. This is currently ridiculously hackish.
- class Metric
- Puppet.config.setdefaults("metrics",
- :rrddir => {:default => "$vardir/rrd",
- :owner => "$user",
- :group => "$group",
- :desc => "The directory where RRD database files are stored.
- Directories for each reporting host will be created under
- this directory."
- },
- :rrdgraph => [false, "Whether RRD information should be graphed."],
- :rrdinterval => ["$runinterval", "How often RRD should expect data.
- This should match how often the hosts report back to the server."]
- )
-
- # Load the library as a feature, so we can test its presence.
- Puppet.features.add :rrd, :libs => 'RRD'
-
- attr_accessor :type, :name, :value, :label
-
- attr_writer :basedir
-
- def basedir
- if defined? @basedir
- @basedir
- else
- Puppet[:rrddir]
- end
- end
-
- def create(start = nil)
- Puppet.config.use(:metrics)
-
- start ||= Time.now.to_i - 5
-
- path = self.path
- args = [
- path,
- "--start", start,
- "--step", Puppet[:rrdinterval]
- ]
-
- values.each { |value|
- # the 7200 is the heartbeat -- this means that any data that isn't
- # more frequently than every two hours gets thrown away
- args.push "DS:%s:GAUGE:7200:U:U" % [value[0]]
- }
- args.push "RRA:AVERAGE:0.5:1:300"
-
- begin
- RRD.create(*args)
- rescue => detail
- raise "Could not create RRD file %s: %s" % [path,detail]
- end
- end
-
- def dump
- puts RRD.info(self.path)
- end
-
- def graph(range = nil)
- unless Puppet.features.rrd?
- Puppet.warning "RRD library is missing; cannot graph metrics"
- return
- end
-
- unit = 60 * 60 * 24
- colorstack = %w{#ff0000 #00ff00 #0000ff #099000 #000990 #f00990 #0f0f0f}
-
- {:daily => unit, :weekly => unit * 7, :monthly => unit * 30, :yearly => unit * 365}.each do |name, time|
- file = self.path.sub(/\.rrd$/, "-%s.png" % name)
- args = [file]
-
- args.push("--title",self.label)
- args.push("--imgformat","PNG")
- args.push("--interlace")
- i = 0
- defs = []
- lines = []
- #p @values.collect { |s,l| s }
- values.zip(colorstack).each { |value,color|
- next if value.nil?
- # this actually uses the data label
- defs.push("DEF:%s=%s:%s:AVERAGE" % [value[0],self.path,value[0]])
- lines.push("LINE2:%s%s:%s" % [value[0],color,value[1]])
- }
- args << defs
- args << lines
- args.flatten!
- if range
- args.push("--start",range[0],"--end",range[1])
- else
- args.push("--start", Time.now.to_i - time, "--end", Time.now.to_i)
- end
-
- begin
- RRD.graph(*args)
- rescue => detail
- Puppet.err "Failed to graph %s: %s" % [self.name,detail]
- end
- end
- end
-
- def initialize(name,label = nil)
- @name = name.to_s
-
- if label
- @label = label
- else
- @label = name.to_s.capitalize.gsub("_", " ")
- end
-
- @values = []
- end
-
- def path
- return File.join(self.basedir, @name + ".rrd")
- end
-
- def newvalue(name,value,label = nil)
- unless label
- label = name.to_s.capitalize.gsub("_", " ")
- end
- @values.push [name,label,value]
- end
-
- def store(time)
- unless Puppet.features.rrd?
- Puppet.warning "RRD library is missing; cannot store metrics"
- return
- end
- unless FileTest.exists?(self.path)
- self.create(time - 5)
- end
-
- # XXX this is not terribly error-resistant
- args = [time]
- values.each { |value|
- args.push value[2]
- }
- arg = args.join(":")
- begin
- RRD.update(self.path,arg)
- #system("rrdtool updatev %s '%s'" % [self.path, arg])
- rescue => detail
- raise Puppet::Error, "Failed to update %s: %s" % [self.name,detail]
- end
- end
-
- def values
- @values.sort { |a, b| a[1] <=> b[1] }
- end
- end
-end
-
-# $Id$
diff --git a/lib/puppet/networkclient.rb b/lib/puppet/networkclient.rb
index 8951c3ccb..f082665c0 100644
--- a/lib/puppet/networkclient.rb
+++ b/lib/puppet/networkclient.rb
@@ -5,7 +5,6 @@ require 'facter'
require 'openssl'
require 'puppet/transaction'
require 'puppet/transportable'
-require 'puppet/metric'
require 'puppet/daemon'
require 'puppet/server'
require 'puppet/external/base64'
diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb
index 35db58815..d34bc7a9e 100644
--- a/lib/puppet/parameter.rb
+++ b/lib/puppet/parameter.rb
@@ -284,7 +284,7 @@ class Puppet::Parameter < Puppet::Element
self.devfail "Parent %s has no loglevel" %
@parent.name
end
- Puppet::Log.create(
+ Puppet::Util::Log.create(
:level => @parent[:loglevel],
:message => msg,
:source => self
diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb
index e8cfcc4dd..d8d421c47 100644
--- a/lib/puppet/parser/ast.rb
+++ b/lib/puppet/parser/ast.rb
@@ -1,7 +1,7 @@
# the parent class for all of our syntactical objects
require 'puppet'
-require 'puppet/autoload'
+require 'puppet/util/autoload'
# The base class for all of the objects that make up the parse trees.
# Handles things like file name, line #, and also does the initialization
@@ -114,7 +114,7 @@ class Puppet::Parser::AST
end
#---------------------------------------------------------------
# Now autoload everything.
- @autoloader = Puppet::Autoload.new(self,
+ @autoloader = Puppet::Util::Autoload.new(self,
"puppet/parser/ast"
)
@autoloader.loadall
diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb
index 9fbec43df..47c5ff110 100644
--- a/lib/puppet/parser/functions.rb
+++ b/lib/puppet/parser/functions.rb
@@ -1,5 +1,5 @@
# Grr
-require 'puppet/autoload'
+require 'puppet/util/autoload'
require 'puppet/parser/scope'
module Puppet::Parser
@@ -13,7 +13,7 @@ module Functions
def self.autoloader
unless defined? @autoloader
- @autoloader = Puppet::Autoload.new(self,
+ @autoloader = Puppet::Util::Autoload.new(self,
"puppet/parser/functions",
:wrap => false
)
@@ -181,7 +181,7 @@ module Functions
end
# Runs a newfunction to create a function for each of the log levels
- Puppet::Log.levels.each do |level|
+ Puppet::Util::Log.levels.each do |level|
newfunction(level, :doc => "Log a message on the server at level
#{level.to_s}.") do |vals|
send(level, vals.join(" "))
diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra
index fe4a08c57..5877439ec 100644
--- a/lib/puppet/parser/grammar.ra
+++ b/lib/puppet/parser/grammar.ra
@@ -615,7 +615,7 @@ endcomma: # nothing
end
---- header ----
require 'puppet'
-require 'puppet/loadedfile'
+require 'puppet/util/loadedfile'
require 'puppet/parser/lexer'
require 'puppet/parser/ast'
#require 'puppet/parser/interpreter'
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index 63b107985..3b268c16c 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -611,8 +611,8 @@ class Puppet::Parser::Interpreter
# reparsed.
def newfile(*files)
files.each do |file|
- unless file.is_a? Puppet::LoadedFile
- file = Puppet::LoadedFile.new(file)
+ unless file.is_a? Puppet::Util::LoadedFile
+ file = Puppet::Util::LoadedFile.new(file)
end
@files << file
end
diff --git a/lib/puppet/parser/parser.rb b/lib/puppet/parser/parser.rb
index 414405302..94d4f7fad 100644
--- a/lib/puppet/parser/parser.rb
+++ b/lib/puppet/parser/parser.rb
@@ -8,7 +8,7 @@ require 'racc/parser'
require 'puppet'
-require 'puppet/loadedfile'
+require 'puppet/util/loadedfile'
require 'puppet/parser/lexer'
require 'puppet/parser/ast'
#require 'puppet/parser/interpreter'
@@ -29,7 +29,7 @@ module Puppet
class Parser < Racc::Parser
-module_eval <<'..end grammar.ra modeval..id0df015d0a0', 'grammar.ra', 633
+module_eval <<'..end grammar.ra modeval..id05c09a2dac', 'grammar.ra', 633
require 'puppet/parser/functions'
attr_reader :file, :interp
@@ -101,7 +101,7 @@ def file=(file)
if @files.detect { |f| f.file == file }
raise Puppet::ImportError.new("Import loop detected")
else
- @files << Puppet::LoadedFile.new(file)
+ @files << Puppet::Util::LoadedFile.new(file)
@lexer.file = file
end
end
@@ -199,7 +199,7 @@ end
# $Id$
-..end grammar.ra modeval..id0df015d0a0
+..end grammar.ra modeval..id05c09a2dac
##### racc 1.4.5 generates ###
diff --git a/lib/puppet/provider/parsedfile.rb b/lib/puppet/provider/parsedfile.rb
index a685c7250..f1b77e56b 100755
--- a/lib/puppet/provider/parsedfile.rb
+++ b/lib/puppet/provider/parsedfile.rb
@@ -1,5 +1,5 @@
require 'puppet'
-require 'puppet/filetype'
+require 'puppet/util/filetype'
require 'puppet/util/fileparsing'
# This provider can be used as the parent class for a provider that
@@ -37,7 +37,7 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
def self.filetype
unless defined? @filetype
- @filetype = Puppet::FileType.filetype(:flat)
+ @filetype = Puppet::Util::FileType.filetype(:flat)
end
return @filetype
end
@@ -45,7 +45,7 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
def self.filetype=(type)
if type.is_a?(Class)
@filetype = type
- elsif klass = Puppet::FileType.filetype(type)
+ elsif klass = Puppet::Util::FileType.filetype(type)
@filetype = klass
else
raise ArgumentError, "Invalid filetype %s" % type
@@ -101,7 +101,7 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
@target = nil
# Default to flat files
- @filetype = Puppet::FileType.filetype(:flat)
+ @filetype = Puppet::Util::FileType.filetype(:flat)
super
end
diff --git a/lib/puppet/reports/log.rb b/lib/puppet/reports/log.rb
index 4df832980..614a07c7a 100644
--- a/lib/puppet/reports/log.rb
+++ b/lib/puppet/reports/log.rb
@@ -5,7 +5,7 @@ Puppet::Server::Report.newreport(:log) do
def process
self.logs.each do |log|
- Puppet::Log.newmessage(log)
+ Puppet::Util::Log.newmessage(log)
end
end
end
diff --git a/lib/puppet/reports/rrdgraph.rb b/lib/puppet/reports/rrdgraph.rb
index 86f54bf5d..ef353a1b9 100644
--- a/lib/puppet/reports/rrdgraph.rb
+++ b/lib/puppet/reports/rrdgraph.rb
@@ -96,7 +96,7 @@ Puppet::Server::Report.newreport(:rrdgraph) do
unless File.directory?(hostdir)
# Some hackishness to create the dir
- config = Puppet::Config.new
+ config = Puppet::Util::Config.new
config.setdefaults(:reports, :hostdir => [hostdir, "eh"])
# This creates the dir.
diff --git a/lib/puppet/reports/store.rb b/lib/puppet/reports/store.rb
index cb0aa0a3c..23bbc037e 100644
--- a/lib/puppet/reports/store.rb
+++ b/lib/puppet/reports/store.rb
@@ -11,7 +11,7 @@ Puppet::Server::Report.newreport(:store, :useyaml => true) do
default report)."
def mkclientdir(client, dir)
- config = Puppet::Config.new
+ config = Puppet::Util::Config.new
config.setdefaults("reportclient-#{client}",
"clientdir-#{client}" => { :default => dir,
:mode => 0750,
diff --git a/lib/puppet/server/authconfig.rb b/lib/puppet/server/authconfig.rb
index 073ff9516..d43371a77 100644
--- a/lib/puppet/server/authconfig.rb
+++ b/lib/puppet/server/authconfig.rb
@@ -1,4 +1,4 @@
-require 'puppet/loadedfile'
+require 'puppet/util/loadedfile'
require 'puppet/server/rights'
module Puppet
@@ -6,7 +6,7 @@ class Server
class ConfigurationError < Puppet::Error; end
-class AuthConfig < Puppet::LoadedFile
+class AuthConfig < Puppet::Util::LoadedFile
Puppet.config.setdefaults(:puppet,
:authconfig => [ "$confdir/namespaceauth.conf",
"The configuration file that defines the rights to the different
diff --git a/lib/puppet/server/fileserver.rb b/lib/puppet/server/fileserver.rb
index b541f2474..3ea44d785 100755
--- a/lib/puppet/server/fileserver.rb
+++ b/lib/puppet/server/fileserver.rb
@@ -75,7 +75,7 @@ class Server
if hash[:Config] == false
@noreadconfig = true
else
- @config = Puppet::LoadedFile.new(
+ @config = Puppet::Util::LoadedFile.new(
hash[:Config] || Puppet[:fileserverconfig]
)
@noreadconfig = false
diff --git a/lib/puppet/server/logger.rb b/lib/puppet/server/logger.rb
index 2170a5772..aa3521573 100755
--- a/lib/puppet/server/logger.rb
+++ b/lib/puppet/server/logger.rb
@@ -42,7 +42,7 @@ class Server
end
end
- Puppet::Log.newmessage(message)
+ Puppet::Util::Log.newmessage(message)
# This is necessary or XMLRPC gets all pukey
return ""
diff --git a/lib/puppet/server/report.rb b/lib/puppet/server/report.rb
index 3c325041d..4298f8ee6 100755
--- a/lib/puppet/server/report.rb
+++ b/lib/puppet/server/report.rb
@@ -39,7 +39,7 @@ class Server
)
@reports = {}
- @reportloader = Puppet::Autoload.new(self, "puppet/reports")
+ @reportloader = Puppet::Util::Autoload.new(self, "puppet/reports")
class << self
attr_reader :hooks
diff --git a/lib/puppet/sslcertificates/ca.rb b/lib/puppet/sslcertificates/ca.rb
index 13b845472..0d5678b7a 100644
--- a/lib/puppet/sslcertificates/ca.rb
+++ b/lib/puppet/sslcertificates/ca.rb
@@ -237,7 +237,7 @@ class Puppet::SSLCertificates::CA
)
# This creates the cakey file
- Puppet::SUIDManager.asuser(Puppet[:user], Puppet[:group]) do
+ Puppet::Util::SUIDManager.asuser(Puppet[:user], Puppet[:group]) do
@cert = cert.mkselfsigned
end
Puppet.config.write(:cacert) do |f|
diff --git a/lib/puppet/storage.rb b/lib/puppet/storage.rb
deleted file mode 100644
index ebebb8ee5..000000000
--- a/lib/puppet/storage.rb
+++ /dev/null
@@ -1,106 +0,0 @@
-require 'yaml'
-require 'sync'
-#require 'puppet/lockfile'
-
-module Puppet
- # a class for storing state
- class Storage
- include Singleton
- include Puppet::Util
-
- def initialize
- self.class.load
- end
-
- # Return a hash that will be stored to disk. It's worth noting
- # here that we use the object's full path, not just the name/type
- # combination. At the least, this is useful for those non-isomorphic
- # types like exec, but it also means that if an object changes locations
- # in the configuration it will lose its cache.
- def self.cache(object)
- if object.is_a? Puppet::Type
- # We used to store things by path, now we store them by ref.
- # In oscar(0.20.0) this changed to using the ref.
- if @@state.include?(object.path)
- @@state[object.ref] = @@state[object.path]
- @@state.delete(object.path)
- end
- name = object.ref
- elsif object.is_a?(Symbol)
- name = object
- else
- raise ArgumentError, "You can only cache information for Types and symbols"
- end
-
- return @@state[name] ||= {}
- end
-
- def self.clear
- @@state.clear
- Storage.init
- end
-
- def self.init
- @@state = {}
- @@splitchar = "\t"
- end
-
- self.init
-
- def self.load
- Puppet.config.use(:puppet)
-
- unless File.exists?(Puppet[:statefile])
- unless defined? @@state and ! @@state.nil?
- self.init
- end
- return
- end
- Puppet::Util.benchmark(:debug, "Loaded state") do
- Puppet::Util.readlock(Puppet[:statefile]) do |file|
- begin
- @@state = YAML.load(file)
- rescue => detail
- Puppet.err "Checksumfile %s is corrupt (%s); replacing" %
- [Puppet[:statefile], detail]
- begin
- File.rename(Puppet[:statefile],
- Puppet[:statefile] + ".bad")
- rescue
- raise Puppet::Error,
- "Could not rename corrupt %s; remove manually" %
- Puppet[:statefile]
- end
- end
- end
- end
-
- unless @@state.is_a?(Hash)
- Puppet.err "State got corrupted"
- self.init
- end
-
- #Puppet.debug "Loaded state is %s" % @@state.inspect
- end
-
- def self.stateinspect
- @@state.inspect
- end
-
- def self.store
- Puppet.debug "Storing state"
-
- unless FileTest.exist?(Puppet[:statefile])
- Puppet.info "Creating state file %s" % Puppet[:statefile]
- end
-
- Puppet::Util.benchmark(:debug, "Stored state") do
- Puppet::Util.writelock(Puppet[:statefile], 0660) do |file|
- file.print YAML.dump(@@state)
- end
- end
- end
- end
-end
-
-# $Id$
diff --git a/lib/puppet/suidmanager.rb b/lib/puppet/suidmanager.rb
deleted file mode 100644
index 659ffaab8..000000000
--- a/lib/puppet/suidmanager.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-require 'facter'
-require 'puppet/util/warnings'
-
-module Puppet
- module SUIDManager
- include Puppet::Util::Warnings
-
- platform = Facter["kernel"].value
- [:uid=, :gid=, :uid, :gid].each do |method|
- define_method(method) do |*args|
- # NOTE: 'method' is closed here.
- newmethod = method
-
- if platform == "Darwin" and (method == :uid= or method == :gid=)
- Puppet::Util::Warnings.warnonce "Cannot change real UID on Darwin"
- newmethod = ("e" + method.to_s).intern
- end
-
- return Process.send(newmethod, *args)
- end
- module_function method
- end
-
- [:euid=, :euid, :egid=, :egid].each do |method|
- define_method(method) do |*args|
- Process.send(method, *args)
- end
- module_function method
- end
-
- def asuser(new_euid=nil, new_egid=nil)
- # Unless we're root, don't do a damn thing.
- unless Process.uid == 0
- return yield
- end
- old_egid = old_euid = nil
- if new_egid
- old_egid = self.egid
- self.egid = convert_xid(:gid, new_egid)
- end
- if new_euid
- old_euid = self.euid
- self.euid = convert_xid(:uid, new_euid)
- end
-
- return yield
- ensure
- self.euid = old_euid if old_euid
- self.egid = old_egid if old_egid
- end
-
- # Make sure the passed argument is a number.
- def convert_xid(type, id)
- map = {:gid => :group, :uid => :user}
- raise ArgumentError, "Invalid id type %s" % type unless map.include?(type)
- ret = Puppet::Util.send(type, id)
- if ret == nil
- raise Puppet::Error, "Invalid %s: %s" % [map[type], id]
- end
- return ret
- end
-
- module_function :asuser, :convert_xid
-
- def run_and_capture(command, new_uid=nil, new_gid=nil)
- output = nil
-
- output = Puppet::Util.execute(command, false, new_uid, new_gid)
-
- [output, $?.dup]
- end
-
- module_function :run_and_capture
-
- def system(command, new_uid=nil, new_gid=nil)
- status = nil
- asuser(new_uid, new_gid) do
- Kernel.system(command)
- status = $?.dup
- end
- status
- end
-
- module_function :system
- end
-end
-
-# $Id$
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index 3c8a3a2e8..43ee135a6 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -292,7 +292,7 @@ class Transaction
graph(@resources, :resources)
# Start logging.
- Puppet::Log.newdestination(@report)
+ Puppet::Util::Log.newdestination(@report)
prepare()
@@ -314,7 +314,7 @@ class Transaction
}.flatten.reject { |e| e.nil? }
ensure
# And then close the transaction log.
- Puppet::Log.close(@report)
+ Puppet::Util::Log.close(@report)
end
Puppet.debug "Finishing transaction %s with %s changes" %
diff --git a/lib/puppet/transaction/report.rb b/lib/puppet/transaction/report.rb
index 769866ef0..e14135140 100644
--- a/lib/puppet/transaction/report.rb
+++ b/lib/puppet/transaction/report.rb
@@ -25,7 +25,7 @@ class Puppet::Transaction::Report
# Create a new metric.
def newmetric(name, hash)
- metric = Puppet::Metric.new(name)
+ metric = Puppet::Util::Metric.new(name)
hash.each do |name, value|
metric.newvalue(name, value)
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index fd4704ae5..023f85ab3 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -1,12 +1,12 @@
require 'puppet'
-require 'puppet/log'
+require 'puppet/util/log'
require 'puppet/element'
require 'puppet/event'
-require 'puppet/metric'
+require 'puppet/util/metric'
require 'puppet/type/property'
require 'puppet/parameter'
require 'puppet/util'
-require 'puppet/autoload'
+require 'puppet/util/autoload'
require 'puppet/metatype/manager'
# see the bottom of the file for the rest of the inclusions
@@ -141,7 +141,7 @@ class Type < Puppet::Element
# create a log at specified level
def log(msg)
- Puppet::Log.create(
+ Puppet::Util::Log.create(
:level => @parameters[:loglevel].value,
:message => msg,
:source => self
@@ -299,13 +299,13 @@ class Type < Puppet::Element
# Return a cached value
def cached(name)
- Puppet::Storage.cache(self)[name]
+ Puppet::Util::Storage.cache(self)[name]
#@cache[name] ||= nil
end
# Cache a value
def cache(name, value)
- Puppet::Storage.cache(self)[name] = value
+ Puppet::Util::Storage.cache(self)[name] = value
#@cache[name] = value
end
diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb
index 9c991886e..a91af13ed 100755
--- a/lib/puppet/type/cron.rb
+++ b/lib/puppet/type/cron.rb
@@ -1,7 +1,7 @@
require 'etc'
require 'facter'
require 'puppet/type/property'
-require 'puppet/filetype'
+require 'puppet/util/filetype'
require 'puppet/type/parsedtype'
module Puppet
@@ -433,9 +433,9 @@ module Puppet
def self.defaulttype
case Facter["operatingsystem"].value
when "Solaris":
- return Puppet::FileType.filetype(:suntab)
+ return Puppet::Util::FileType.filetype(:suntab)
else
- return Puppet::FileType.filetype(:crontab)
+ return Puppet::Util::FileType.filetype(:crontab)
end
end
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb
index 9dfa2b05e..33796b129 100755
--- a/lib/puppet/type/exec.rb
+++ b/lib/puppet/type/exec.rb
@@ -195,7 +195,7 @@ module Puppet
# Most validation is handled by the SUIDManager class.
validate do |user|
- unless Puppet::SUIDManager.uid == 0
+ unless Puppet::Util::SUIDManager.uid == 0
self.fail "Only root can execute commands as other users"
end
end
@@ -235,7 +235,7 @@ module Puppet
values = [:true, :false]
# And all of the log levels
- Puppet::Log.eachlevel { |level| values << level }
+ Puppet::Util::Log.eachlevel { |level| values << level }
newvalues(*values)
end
@@ -473,9 +473,12 @@ module Puppet
self.collect { |i| i }
end
- # Verify that we pass all of the checks.
- def check
+ # Verify that we pass all of the checks. The argument determines whether
+ # we skip the :refreshonly check, which is necessary because we now check
+ # within refresh()
+ def check(refreshing = false)
self.class.checks.each { |check|
+ next if refreshing and check == :refreshonly
if @parameters.include?(check)
val = @parameters[check].value
val = [val] unless val.is_a? Array
@@ -498,9 +501,9 @@ module Puppet
end
end
- # this might be a very, very bad idea...
+ # Run the command, or optionally run a separately-specified command.
def refresh
- if self.check
+ if self.check(true)
if cmd = self[:refresh]
self.run(cmd)
else
@@ -563,7 +566,7 @@ module Puppet
withenv env do
Timeout::timeout(self[:timeout]) do
- output, status = Puppet::SUIDManager.run_and_capture(
+ output, status = Puppet::Util::SUIDManager.run_and_capture(
[command], self[:user], self[:group]
)
end
diff --git a/lib/puppet/type/parsedtype.rb b/lib/puppet/type/parsedtype.rb
index 1232c979e..40a90d5ae 100755
--- a/lib/puppet/type/parsedtype.rb
+++ b/lib/puppet/type/parsedtype.rb
@@ -1,6 +1,6 @@
require 'etc'
require 'facter'
-require 'puppet/filetype'
+require 'puppet/util/filetype'
require 'puppet/type/property'
module Puppet
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index 478978623..89e94d140 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -270,7 +270,7 @@ module Puppet
# Determine the user to write files as.
def asuser
if self.should(:owner) and ! self.should(:owner).is_a?(Symbol)
- writeable = Puppet::SUIDManager.asuser(self.should(:owner)) {
+ writeable = Puppet::Util::SUIDManager.asuser(self.should(:owner)) {
FileTest.writable?(File.dirname(self[:path]))
}
@@ -1058,7 +1058,7 @@ module Puppet
yield
# We're getting different behaviors from different versions of ruby, so...
# asroot = true
- # Puppet::SUIDManager.asuser(asuser(), self.should(:group)) do
+ # Puppet::Util::SUIDManager.asuser(asuser(), self.should(:group)) do
# if FileTest.writable?(dir)
# asroot = false
# yield
diff --git a/lib/puppet/type/pfile/owner.rb b/lib/puppet/type/pfile/owner.rb
index 908f25d0f..07a2b880b 100755
--- a/lib/puppet/type/pfile/owner.rb
+++ b/lib/puppet/type/pfile/owner.rb
@@ -121,7 +121,7 @@ module Puppet
end
def sync
- unless Puppet::SUIDManager.uid == 0
+ unless Puppet::Util::SUIDManager.uid == 0
unless defined? @@notifieduid
self.notice "Cannot manage ownership unless running as root"
#@parent.delete(self.name)
diff --git a/lib/puppet/type/pfile/source.rb b/lib/puppet/type/pfile/source.rb
index 12bb7003e..d06366a79 100755
--- a/lib/puppet/type/pfile/source.rb
+++ b/lib/puppet/type/pfile/source.rb
@@ -105,7 +105,7 @@ module Puppet
}
# we can't manage ownership as root, so don't even try
- unless Puppet::SUIDManager.uid == 0
+ unless Puppet::Util::SUIDManager.uid == 0
args.delete(:owner)
end
diff --git a/lib/puppet/type/pfile/target.rb b/lib/puppet/type/pfile/target.rb
index f6ae0f9c8..3de74bb74 100644
--- a/lib/puppet/type/pfile/target.rb
+++ b/lib/puppet/type/pfile/target.rb
@@ -28,7 +28,7 @@ module Puppet
@parent.remove_existing(target)
Dir.chdir(File.dirname(@parent[:path])) do
- Puppet::SUIDManager.asuser(@parent.asuser()) do
+ Puppet::Util::SUIDManager.asuser(@parent.asuser()) do
mode = @parent.should(:mode)
if mode
Puppet::Util.withumask(000) do
diff --git a/lib/puppet/type/property.rb b/lib/puppet/type/property.rb
index 7279ffee7..b4dcdfae0 100644
--- a/lib/puppet/type/property.rb
+++ b/lib/puppet/type/property.rb
@@ -281,7 +281,7 @@ class Property < Puppet::Parameter
self.devfail "Parent %s has no loglevel" %
@parent.name
end
- Puppet::Log.create(
+ Puppet::Util::Log.create(
:level => @parent[:loglevel],
:message => msg,
:source => self
diff --git a/lib/puppet/type/yumrepo.rb b/lib/puppet/type/yumrepo.rb
index b7a1ff5e7..94ba3ef6c 100644
--- a/lib/puppet/type/yumrepo.rb
+++ b/lib/puppet/type/yumrepo.rb
@@ -1,7 +1,7 @@
# Description of yum repositories
require 'puppet/propertychange'
-require 'puppet/inifile'
+require 'puppet/util/inifile'
require 'puppet/type/parsedtype'
module Puppet
@@ -72,7 +72,7 @@ module Puppet
attr_accessor :yumconf
end
- self.filetype = Puppet::FileType.filetype(:flat)
+ self.filetype = Puppet::Util::FileType.filetype(:flat)
@inifile = nil
@@ -102,7 +102,7 @@ module Puppet
l
end
- # Return the Puppet::IniConfig::File for the whole yum config
+ # Return the Puppet::Util::IniConfig::File for the whole yum config
def self.inifile
if @inifile.nil?
@inifile = read()
@@ -134,7 +134,7 @@ module Puppet
# Non-test code should use self.inifile to get at the
# underlying file
def self.read
- result = Puppet::IniConfig::File.new()
+ result = Puppet::Util::IniConfig::File.new()
result.read(yumconf)
main = result['main']
if main.nil?
@@ -161,7 +161,7 @@ module Puppet
return result
end
- # Return the Puppet::IniConfig::Section with name NAME
+ # Return the Puppet::Util::IniConfig::Section with name NAME
# from the yum config
def self.section(name)
result = inifile[name]
@@ -189,7 +189,7 @@ module Puppet
super
end
- # Return the Puppet::IniConfig::Section for this yumrepo element
+ # Return the Puppet::Util::IniConfig::Section for this yumrepo element
def section
self.class.section(self[:name])
end
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index 2bd3035c6..3bd7d277c 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -33,10 +33,10 @@ module Util
unless group
raise Puppet::Error, "No such group %s" % Puppet[:group]
end
- unless Puppet::SUIDManager.gid == group
+ unless Puppet::Util::SUIDManager.gid == group
begin
- Puppet::SUIDManager.egid = group
- Puppet::SUIDManager.gid = group
+ Puppet::Util::SUIDManager.egid = group
+ Puppet::Util::SUIDManager.gid = group
rescue => detail
Puppet.warning "could not change to group %s: %s" %
[group.inspect, detail]
@@ -54,10 +54,10 @@ module Util
unless user
raise Puppet::Error, "No such user %s" % Puppet[:user]
end
- unless Puppet::SUIDManager.uid == user
+ unless Puppet::Util::SUIDManager.uid == user
begin
- Puppet::SUIDManager.uid = user
- Puppet::SUIDManager.euid = user
+ Puppet::Util::SUIDManager.uid = user
+ Puppet::Util::SUIDManager.euid = user
rescue
$stderr.puts "could not change to user %s" % user
exit(74)
@@ -104,19 +104,19 @@ module Util
# the messages to be a little richer. Most classes will be calling this
# method.
def self.logmethods(klass, useself = true)
- Puppet::Log.eachlevel { |level|
+ Puppet::Util::Log.eachlevel { |level|
klass.send(:define_method, level, proc { |args|
if args.is_a?(Array)
args = args.join(" ")
end
if useself
- Puppet::Log.create(
+ Puppet::Util::Log.create(
:level => level,
:source => self,
:message => args
)
else
- Puppet::Log.create(
+ Puppet::Util::Log.create(
:level => level,
:message => args
)
@@ -206,7 +206,7 @@ module Util
end
# Only benchmark if our log level is high enough
- if level != :none and Puppet::Log.sendlevel?(level)
+ if level != :none and Puppet::Util::Log.sendlevel?(level)
result = nil
seconds = Benchmark.realtime {
yield
@@ -285,10 +285,10 @@ module Util
end
if uid
- uid = Puppet::SUIDManager.convert_xid(:uid, uid)
+ uid = Puppet::Util::SUIDManager.convert_xid(:uid, uid)
end
if gid
- gid = Puppet::SUIDManager.convert_xid(:gid, gid)
+ gid = Puppet::Util::SUIDManager.convert_xid(:gid, gid)
end
@@os ||= Facter.value(:operatingsystem)
diff --git a/lib/puppet/autoload.rb b/lib/puppet/util/autoload.rb
index 862aabbff..f171254af 100644
--- a/lib/puppet/autoload.rb
+++ b/lib/puppet/util/autoload.rb
@@ -1,5 +1,5 @@
# Autoload paths, either based on names or all at once.
-class Puppet::Autoload
+class Puppet::Util::Autoload
include Puppet::Util
@autoloaders = {}
diff --git a/lib/puppet/config.rb b/lib/puppet/util/config.rb
index 77838fec0..097d59b9f 100644
--- a/lib/puppet/config.rb
+++ b/lib/puppet/util/config.rb
@@ -2,9 +2,8 @@ require 'puppet'
require 'sync'
require 'puppet/transportable'
-module Puppet
# The class for handling configuration files.
-class Config
+class Puppet::Util::Config
include Enumerable
include Puppet::Util
@@ -216,7 +215,7 @@ class Config
raise ArgumentError, "Default %s is not a file" % default
end
- Puppet::SUIDManager.asuser(obj.owner, obj.group) do
+ Puppet::Util::SUIDManager.asuser(obj.owner, obj.group) do
mode = obj.mode || 0750
Dir.mkdir(obj.value, mode)
end
@@ -248,10 +247,10 @@ class Config
def parse(file)
text = nil
- if file.is_a? Puppet::LoadedFile
+ if file.is_a? Puppet::Util::LoadedFile
@file = file
else
- @file = Puppet::LoadedFile.new(file)
+ @file = Puppet::Util::LoadedFile.new(file)
end
# Create a timer so that this.
@@ -430,7 +429,7 @@ class Config
newobj[:comment] ||= "%s user" % name
end
else
- newobj = TransObject.new(name, type.to_s)
+ newobj = Puppet::TransObject.new(name, type.to_s)
newobj.tags = ["puppet", "configuration", section]
newobj[:ensure] = "present"
if type == :user
@@ -643,12 +642,12 @@ Generated on #{Time.now}.
end
chown = nil
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
chown = [obj.owner, obj.group]
else
chown = [nil, nil]
end
- Puppet::SUIDManager.asuser(*chown) do
+ Puppet::Util::SUIDManager.asuser(*chown) do
mode = obj.mode || 0640
if args.empty?
@@ -676,13 +675,13 @@ Generated on #{Time.now}.
end
chown = nil
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
chown = [obj.owner, obj.group]
else
chown = [nil, nil]
end
- Puppet::SUIDManager.asuser(*chown) do
+ Puppet::Util::SUIDManager.asuser(*chown) do
mode = obj.mode || 0640
if args.empty?
args << "w"
@@ -906,7 +905,7 @@ Generated on #{Time.now}.
}
# Only chown or chgrp when root
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
[:group, :owner].each { |var|
if value = self.send(var)
obj[var] = value
@@ -956,6 +955,5 @@ Generated on #{Time.now}.
end
end
end
-end
# $Id$
diff --git a/lib/puppet/feature.rb b/lib/puppet/util/feature.rb
index ece8ec86a..30c38e286 100644
--- a/lib/puppet/feature.rb
+++ b/lib/puppet/util/feature.rb
@@ -1,7 +1,7 @@
# Created by Luke Kanies on 2006-11-07.
# Copyright (c) 2006. All rights reserved.
-class Puppet::Feature
+class Puppet::Util::Feature
attr_reader :path
# Create a new feature test. You have to pass the feature name,
@@ -52,7 +52,7 @@ class Puppet::Feature
# Create a new feature collection.
def initialize(path)
@path = path
- @loader = Puppet::Autoload.new(self, @path)
+ @loader = Puppet::Util::Autoload.new(self, @path)
end
def load
diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb
new file mode 100755
index 000000000..8abe0cc00
--- /dev/null
+++ b/lib/puppet/util/filetype.rb
@@ -0,0 +1,300 @@
+# Basic classes for reading, writing, and emptying files. Not much
+# to see here.
+class Puppet::Util::FileType
+ attr_accessor :loaded, :path, :synced
+
+ class << self
+ attr_accessor :name
+ include Puppet::Util::ClassGen
+ end
+
+ # Create a new filetype.
+ def self.newfiletype(name, &block)
+ @filetypes ||= {}
+
+ klass = genclass(name,
+ :block => block,
+ :prefix => "FileType",
+ :hash => @filetypes
+ )
+
+ # Rename the read and write methods, so that we're sure they
+ # maintain the stats.
+ klass.class_eval do
+ # Rename the read method
+ define_method(:real_read, instance_method(:read))
+ define_method(:read) do
+ begin
+ val = real_read()
+ @loaded = Time.now
+ if val
+ return val.gsub(/# HEADER.*\n/,'')
+ else
+ return ""
+ end
+ rescue Puppet::Error => detail
+ raise
+ rescue => detail
+ if Puppet[:trace]
+ puts detail.backtrace
+ end
+ raise Puppet::Error, "%s could not read %s: %s" %
+ [self.class, @path, detail]
+ end
+ end
+
+ # And then the write method
+ define_method(:real_write, instance_method(:write))
+ define_method(:write) do |text|
+ begin
+ val = real_write(text)
+ @synced = Time.now
+ return val
+ rescue Puppet::Error => detail
+ raise
+ rescue => detail
+ if Puppet[:debug]
+ puts detail.backtrace
+ end
+ raise Puppet::Error, "%s could not write %s: %s" %
+ [self.class, @path, detail]
+ end
+ end
+ end
+ end
+
+ def self.filetype(type)
+ @filetypes[type]
+ end
+
+ def initialize(path)
+ @path = path
+ end
+
+ # Operate on plain files.
+ newfiletype(:flat) do
+ # Read the file.
+ def read
+ if File.exists?(@path)
+ File.read(@path)
+ else
+ return nil
+ end
+ end
+
+ # Remove the file.
+ def remove
+ if File.exists?(@path)
+ File.unlink(@path)
+ end
+ end
+
+ # Overwrite the file.
+ def write(text)
+ File.open(@path, "w") { |f| f.print text; f.flush }
+ end
+ end
+
+ # Operate on plain files.
+ newfiletype(:ram) do
+ @@tabs = {}
+
+ def self.clear
+ @@tabs.clear
+ end
+
+ def initialize(path)
+ super
+ @@tabs[@path] ||= ""
+ end
+
+ # Read the file.
+ def read
+ Puppet.info "Reading %s from RAM" % @path
+ @@tabs[@path]
+ end
+
+ # Remove the file.
+ def remove
+ Puppet.info "Removing %s from RAM" % @path
+ @@tabs[@path] = ""
+ end
+
+ # Overwrite the file.
+ def write(text)
+ Puppet.info "Writing %s to RAM" % @path
+ @@tabs[@path] = text
+ end
+ end
+
+ # Handle Linux-style cron tabs.
+ newfiletype(:crontab) do
+ def initialize(user)
+ self.path = user
+ end
+
+ def path=(user)
+ begin
+ @uid = Puppet::Util.uid(user)
+ rescue Puppet::Error => detail
+ raise Puppet::Error, "Could not retrieve user %s" % user
+ end
+
+ # XXX We have to have the user name, not the uid, because some
+ # systems *cough*linux*cough* require it that way
+ @path = user
+ end
+
+ # Read a specific @path's cron tab.
+ def read
+ %x{#{cmdbase()} -l 2>/dev/null}
+ end
+
+ # Remove a specific @path's cron tab.
+ def remove
+ if Facter.value("operatingsystem") == "FreeBSD"
+ %x{/bin/echo yes | #{cmdbase()} -r 2>/dev/null}
+ else
+ %x{#{cmdbase()} -r 2>/dev/null}
+ end
+ end
+
+ # Overwrite a specific @path's cron tab; must be passed the @path name
+ # and the text with which to create the cron tab.
+ def write(text)
+ IO.popen("#{cmdbase()} -", "w") { |p|
+ p.print text
+ }
+ end
+
+ private
+
+ # Only add the -u flag when the @path is different. Fedora apparently
+ # does not think I should be allowed to set the @path to my own user name
+ def cmdbase
+ cmd = nil
+ if @uid == Puppet::Util::SUIDManager.uid
+ return "crontab"
+ else
+ return "crontab -u #{@path}"
+ end
+ end
+ end
+
+ # SunOS has completely different cron commands; this class implements
+ # its versions.
+ newfiletype(:suntab) do
+ # Read a specific @path's cron tab.
+ def read
+ Puppet::Util::SUIDManager.asuser(@path) {
+ %x{crontab -l 2>/dev/null}
+ }
+ end
+
+ # Remove a specific @path's cron tab.
+ def remove
+ Puppet::Util::SUIDManager.asuser(@path) {
+ %x{crontab -r 2>/dev/null}
+ }
+ end
+
+ # Overwrite a specific @path's cron tab; must be passed the @path name
+ # and the text with which to create the cron tab.
+ def write(text)
+ Puppet::Util::SUIDManager.asuser(@path) {
+ IO.popen("crontab", "w") { |p|
+ p.print text
+ }
+ }
+ end
+ end
+
+ # Treat netinfo tables as a single file, just for simplicity of certain
+ # types
+ newfiletype(:netinfo) do
+ class << self
+ attr_accessor :format
+ end
+ def read
+ %x{nidump -r /#{@path} /}
+ end
+
+ # This really only makes sense for cron tabs.
+ def remove
+ %x{nireport / /#{@path} name}.split("\n").each do |name|
+ newname = name.gsub(/\//, '\/').sub(/\s+$/, '')
+ output = %x{niutil -destroy / '/#{@path}/#{newname}'}
+
+ unless $? == 0
+ raise Puppet::Error, "Could not remove %s from %s" %
+ [name, @path]
+ end
+ end
+ end
+
+ # Convert our table to an array of hashes. This only works for
+ # handling one table at a time.
+ def to_array(text = nil)
+ unless text
+ text = read
+ end
+
+ hash = nil
+
+ # Initialize it with the first record
+ records = []
+ text.split("\n").each do |line|
+ next if line =~ /^[{}]$/ # Skip the wrapping lines
+ next if line =~ /"name" = \( "#{@path}" \)/ # Skip the table name
+ next if line =~ /CHILDREN = \(/ # Skip this header
+ next if line =~ /^ \)/ # and its closer
+
+ # Now we should have nothing but records, wrapped in braces
+
+ case line
+ when /^\s+\{/: hash = {}
+ when /^\s+\}/: records << hash
+ when /\s+"(\w+)" = \( (.+) \)/
+ field = $1
+ values = $2
+
+ # Always use an array
+ hash[field] = []
+
+ values.split(/, /).each do |value|
+ if value =~ /^"(.*)"$/
+ hash[field] << $1
+ else
+ raise ArgumentError, "Could not match value %s" % value
+ end
+ end
+ else
+ raise ArgumentError, "Could not match line %s" % line
+ end
+ end
+
+ records
+ end
+
+ def write(text)
+ text.gsub!(/^#.*\n/,'')
+ text.gsub!(/^$/,'')
+ if text == "" or text == "\n"
+ self.remove
+ return
+ end
+ unless format = self.class.format
+ raise Puppe::DevError, "You must define the NetInfo format to inport"
+ end
+ IO.popen("niload -d #{format} . 1>/dev/null 2>/dev/null", "w") { |p|
+ p.print text
+ }
+
+ unless $? == 0
+ raise ArgumentError, "Failed to write %s" % @path
+ end
+ end
+ end
+end
+
+# $Id$
diff --git a/lib/puppet/util/inifile.rb b/lib/puppet/util/inifile.rb
new file mode 100644
index 000000000..d050e6dd1
--- /dev/null
+++ b/lib/puppet/util/inifile.rb
@@ -0,0 +1,209 @@
+# Module Puppet::IniConfig
+# A generic way to parse .ini style files and manipulate them in memory
+# One 'file' can be made up of several physical files. Changes to sections
+# on the file are tracked so that only the physical files in which
+# something has changed are written back to disk
+# Great care is taken to preserve comments and blank lines from the original
+# files
+#
+# The parsing tries to stay close to python's ConfigParser
+
+require 'puppet/util/filetype'
+
+module Puppet::Util::IniConfig
+ # A section in a .ini file
+ class Section
+ attr_reader :name, :file
+
+ def initialize(name, file)
+ @name = name
+ @file = file
+ @dirty = false
+ @entries = []
+ end
+
+ # Has this section been modified since it's been read in
+ # or written back to disk
+ def dirty?
+ @dirty
+ end
+
+ # Should only be used internally
+ def mark_clean
+ @dirty = false
+ end
+
+ # Add a line of text (e.g., a comment) Such lines
+ # will be written back out in exactly the same
+ # place they were read in
+ def add_line(line)
+ @entries << line
+ end
+
+ # Set the entry 'key=value'. If no entry with the
+ # given key exists, one is appended to teh end of the section
+ def []=(key, value)
+ entry = find_entry(key)
+ @dirty = true
+ if entry.nil?
+ @entries << [key, value]
+ else
+ entry[1] = value
+ end
+ end
+
+ # Return the value associated with KEY. If no such entry
+ # exists, return nil
+ def [](key)
+ entry = find_entry(key)
+ if entry.nil?
+ return nil
+ end
+ return entry[1]
+ end
+
+ # Format the section as text in the way it should be
+ # written to file
+ def format
+ text = "[#{name}]\n"
+ @entries.each do |entry|
+ if entry.is_a?(Array)
+ key, value = entry
+ unless value.nil?
+ text << "#{key}=#{value}\n"
+ end
+ else
+ text << entry
+ end
+ end
+ return text
+ end
+
+ private
+ def find_entry(key)
+ @entries.each do |entry|
+ if entry.is_a?(Array) && entry[0] == key
+ return entry
+ end
+ end
+ return nil
+ end
+
+ end
+
+ # A logical .ini-file that can be spread across several physical
+ # files. For each physical file, call #read with the filename
+ class File
+ def initialize
+ @files = {}
+ end
+
+ # Add the contents of the file with name FILE to the
+ # already existing sections
+ def read(file)
+ text = Puppet::Util::FileType.filetype(:flat).new(file).read
+ if text.nil?
+ raise "Could not find #{file}"
+ end
+
+ section = nil # The name of the current section
+ optname = nil # The name of the last option in section
+ line = 0
+ @files[file] = []
+ text.each_line do |l|
+ line += 1
+ if l.strip.empty? || "#;".include?(l[0,1]) ||
+ (l.split(nil, 2)[0].downcase == "rem" &&
+ l[0,1].downcase == "r")
+ # Whitespace or comment
+ if section.nil?
+ @files[file] << l
+ else
+ section.add_line(l)
+ end
+ elsif " \t\r\n\f".include?(l[0,1]) && section && optname
+ # continuation line
+ section[optname] += "\n" + l.chomp
+ elsif l =~ /^\[([^\]]+)\]/
+ # section heading
+ section.mark_clean unless section.nil?
+ section = add_section($1, file)
+ optname = nil
+ elsif l =~ /^\s*([^\s=]+)\s*\=(.+)$/
+ # We allow space around the keys, but not the values
+ # For the values, we don't know if space is significant
+ if section.nil?
+ raise "#{file}:#{line}:Key/value pair outside of a section for key #{$1}"
+ else
+ section[$1] = $2
+ optname = $1
+ end
+ else
+ raise "#{file}:#{line}: Can't parse '#{l.chomp}'"
+ end
+ end
+ section.mark_clean unless section.nil?
+ end
+
+ # Store all modifications made to sections in this file back
+ # to the physical files. If no modifications were made to
+ # a physical file, nothing is written
+ def store
+ @files.each do |file, lines|
+ text = ""
+ dirty = false
+ lines.each do |l|
+ if l.is_a?(Section)
+ dirty ||= l.dirty?
+ text << l.format
+ l.mark_clean
+ else
+ text << l
+ end
+ end
+ if dirty
+ Puppet::Util::FileType.filetype(:flat).new(file).write(text)
+ end
+ end
+ end
+
+ # Execute BLOCK, passing each section in this file
+ # as an argument
+ def each_section(&block)
+ @files.each do |file, list|
+ list.each do |entry|
+ if entry.is_a?(Section)
+ yield(entry)
+ end
+ end
+ end
+ end
+
+ # Return the Section with the given name or nil
+ def [](name)
+ name = name.to_s
+ each_section do |section|
+ return section if section.name == name
+ end
+ return nil
+ end
+
+ # Return true if the file contains a section with name NAME
+ def include?(name)
+ return ! self[name].nil?
+ end
+
+ # Add a section to be stored in FILE when store is called
+ def add_section(name, file)
+ if include?(name)
+ raise "A section with name #{name} already exists"
+ end
+ result = Section.new(name, file)
+ @files[file] ||= []
+ @files[file] << result
+ return result
+ end
+ end
+end
+
+# $Id$
diff --git a/lib/puppet/loadedfile.rb b/lib/puppet/util/loadedfile.rb
index cfd666e36..362b5df09 100755
--- a/lib/puppet/loadedfile.rb
+++ b/lib/puppet/util/loadedfile.rb
@@ -5,7 +5,7 @@ require 'puppet'
module Puppet
class NoSuchFile < Puppet::Error; end
- class LoadedFile
+ class Util::LoadedFile
attr_reader :file, :statted
# Provide a hook for setting the timestamp during testing, so we don't
diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb
new file mode 100644
index 000000000..dd7544dae
--- /dev/null
+++ b/lib/puppet/util/log.rb
@@ -0,0 +1,548 @@
+require 'syslog'
+
+# Pass feedback to the user. Log levels are modeled after syslog's, and it is
+# expected that that will be the most common log destination. Supports
+# multiple destinations, one of which is a remote server.
+class Puppet::Util::Log
+ include Puppet::Util
+
+ @levels = [:debug,:info,:notice,:warning,:err,:alert,:emerg,:crit]
+ @loglevel = 2
+
+ @desttypes = {}
+
+ # A type of log destination.
+ class Destination
+ class << self
+ attr_accessor :name
+ end
+
+ def self.initvars
+ @matches = []
+ end
+
+ # Mark the things we're supposed to match.
+ def self.match(obj)
+ @matches ||= []
+ @matches << obj
+ end
+
+ # See whether we match a given thing.
+ def self.match?(obj)
+ # Convert single-word strings into symbols like :console and :syslog
+ if obj.is_a? String and obj =~ /^\w+$/
+ obj = obj.downcase.intern
+ end
+
+ @matches.each do |thing|
+ # Search for direct matches or class matches
+ return true if thing === obj or thing == obj.class.to_s
+ end
+ return false
+ end
+
+ def name
+ if defined? @name
+ return @name
+ else
+ return self.class.name
+ end
+ end
+
+ # Set how to handle a message.
+ def self.sethandler(&block)
+ define_method(:handle, &block)
+ end
+
+ # Mark how to initialize our object.
+ def self.setinit(&block)
+ define_method(:initialize, &block)
+ end
+ end
+
+ # Create a new destination type.
+ def self.newdesttype(name, options = {}, &block)
+ dest = genclass(name, :parent => Destination, :prefix => "Dest",
+ :block => block,
+ :hash => @desttypes,
+ :attributes => options
+ )
+ dest.match(dest.name)
+
+ return dest
+ end
+
+ @destinations = {}
+
+ class << self
+ include Puppet::Util
+ include Puppet::Util::ClassGen
+ end
+
+ # Reset all logs to basics. Basically just closes all files and undefs
+ # all of the other objects.
+ def Log.close(dest = nil)
+ if dest
+ if @destinations.include?(dest)
+ if @destinations.respond_to?(:close)
+ @destinations[dest].close
+ end
+ @destinations.delete(dest)
+ end
+ else
+ @destinations.each { |name, dest|
+ if dest.respond_to?(:flush)
+ dest.flush
+ end
+ if dest.respond_to?(:close)
+ dest.close
+ end
+ }
+ @destinations = {}
+ end
+ end
+
+ # Flush any log destinations that support such operations.
+ def Log.flush
+ @destinations.each { |type, dest|
+ if dest.respond_to?(:flush)
+ dest.flush
+ end
+ }
+ end
+
+ # Create a new log message. The primary role of this method is to
+ # avoid creating log messages below the loglevel.
+ def Log.create(hash)
+ unless hash.include?(:level)
+ raise Puppet::DevError, "Logs require a level"
+ end
+ unless @levels.index(hash[:level])
+ raise Puppet::DevError, "Invalid log level %s" % hash[:level]
+ end
+ if @levels.index(hash[:level]) >= @loglevel
+ return Puppet::Util::Log.new(hash)
+ else
+ return nil
+ end
+ end
+
+ def Log.destinations
+ return @destinations.keys
+ end
+
+ # Yield each valid level in turn
+ def Log.eachlevel
+ @levels.each { |level| yield level }
+ end
+
+ # Return the current log level.
+ def Log.level
+ return @levels[@loglevel]
+ end
+
+ # Set the current log level.
+ def Log.level=(level)
+ unless level.is_a?(Symbol)
+ level = level.intern
+ end
+
+ unless @levels.include?(level)
+ raise Puppet::DevError, "Invalid loglevel %s" % level
+ end
+
+ @loglevel = @levels.index(level)
+ end
+
+ def Log.levels
+ @levels.dup
+ end
+
+ newdesttype :syslog do
+ def close
+ Syslog.close
+ end
+
+ def initialize
+ if Syslog.opened?
+ Syslog.close
+ end
+ name = Puppet.name
+ name = "puppet-#{name}" unless name =~ /puppet/
+
+ options = Syslog::LOG_PID | Syslog::LOG_NDELAY
+
+ # XXX This should really be configurable.
+ str = Puppet[:syslogfacility]
+ begin
+ facility = Syslog.const_get("LOG_#{str.upcase}")
+ rescue NameError
+ raise Puppet::Error, "Invalid syslog facility %s" % str
+ end
+
+ @syslog = Syslog.open(name, options, facility)
+ end
+
+ def handle(msg)
+ # XXX Syslog currently has a bug that makes it so you
+ # cannot log a message with a '%' in it. So, we get rid
+ # of them.
+ if msg.source == "Puppet"
+ @syslog.send(msg.level, msg.to_s.gsub("%", '%%'))
+ else
+ @syslog.send(msg.level, "(%s) %s" %
+ [msg.source.to_s.gsub("%", ""),
+ msg.to_s.gsub("%", '%%')
+ ]
+ )
+ end
+ end
+ end
+
+ newdesttype :file do
+ match(/^\//)
+
+ def close
+ if defined? @file
+ @file.close
+ @file = nil
+ end
+ end
+
+ def flush
+ if defined? @file
+ @file.flush
+ end
+ end
+
+ def initialize(path)
+ @name = path
+ # first make sure the directory exists
+ # We can't just use 'Config.use' here, because they've
+ # specified a "special" destination.
+ unless FileTest.exist?(File.dirname(path))
+ Puppet.recmkdir(File.dirname(path))
+ Puppet.info "Creating log directory %s" % File.dirname(path)
+ end
+
+ # create the log file, if it doesn't already exist
+ file = File.open(path, File::WRONLY|File::CREAT|File::APPEND)
+
+ @file = file
+
+ @autoflush = Puppet[:autoflush]
+ end
+
+ def handle(msg)
+ @file.puts("%s %s (%s): %s" %
+ [msg.time, msg.source, msg.level, msg.to_s])
+
+ @file.flush if @autoflush
+ end
+ end
+
+ newdesttype :console do
+
+
+ PINK = {:console => "", :html => "FFA0A0"}
+ GREEN = {:console => "", :html => "00CD00"}
+ YELLOW = {:console => "", :html => "FFFF60"}
+ SLATE = {:console => "", :html => "80A0FF"}
+ ORANGE = {:console => "", :html => "FFA500"}
+ BLUE = {:console => "", :html => "40FFFF"}
+ RESET = {:console => "", :html => ""}
+
+ @@colormap = {
+ :debug => SLATE,
+ :info => GREEN,
+ :notice => PINK,
+ :warning => ORANGE,
+ :err => YELLOW,
+ :alert => BLUE,
+ :emerg => RESET,
+ :crit => RESET
+ }
+
+ def colorize(level, str)
+ case Puppet[:color]
+ when false: str
+ when true, :ansi, "ansi": console_color(level, str)
+ when :html, "html": html_color(level, str)
+ end
+ end
+
+ def console_color(level, str)
+ @@colormap[level][:console] + str + RESET[:console]
+ end
+
+ def html_color(level, str)
+ %{<span style="color: %s">%s</span>} % [@@colormap[level][:html], str]
+ end
+
+ def initialize
+ # Flush output immediately.
+ $stdout.sync = true
+ end
+
+ def handle(msg)
+ if msg.source == "Puppet"
+ puts colorize(msg.level, "%s: %s" % [msg.level, msg.to_s])
+ else
+ puts colorize(msg.level, "%s: %s: %s" % [msg.level, msg.source, msg.to_s])
+ end
+ end
+ end
+
+ newdesttype :host do
+ def initialize(host)
+ Puppet.info "Treating %s as a hostname" % host
+ args = {}
+ if host =~ /:(\d+)/
+ args[:Port] = $1
+ args[:Server] = host.sub(/:\d+/, '')
+ else
+ args[:Server] = host
+ end
+
+ @name = host
+
+ @driver = Puppet::Client::LogClient.new(args)
+ end
+
+ def handle(msg)
+ unless msg.is_a?(String) or msg.remote
+ unless defined? @hostname
+ @hostname = Facter["hostname"].value
+ end
+ unless defined? @domain
+ @domain = Facter["domain"].value
+ if @domain
+ @hostname += "." + @domain
+ end
+ end
+ if msg.source =~ /^\//
+ msg.source = @hostname + ":" + msg.source
+ elsif msg.source == "Puppet"
+ msg.source = @hostname + " " + msg.source
+ else
+ msg.source = @hostname + " " + msg.source
+ end
+ begin
+ #puts "would have sent %s" % msg
+ #puts "would have sent %s" %
+ # CGI.escape(YAML.dump(msg))
+ begin
+ tmp = CGI.escape(YAML.dump(msg))
+ rescue => detail
+ puts "Could not dump: %s" % detail.to_s
+ return
+ end
+ # Add the hostname to the source
+ @driver.addlog(tmp)
+ rescue => detail
+ if Puppet[:trace]
+ puts detail.backtrace
+ end
+ Puppet.err detail
+ Puppet::Util::Log.close(self)
+ end
+ end
+ end
+ end
+
+ # Log to a transaction report.
+ newdesttype :report do
+ match "Puppet::Transaction::Report"
+
+ def initialize(report)
+ @report = report
+ end
+
+ def handle(msg)
+ # Only add messages from objects, since anything else is
+ # probably unrelated to this run.
+ if msg.objectsource?
+ @report.newlog(msg)
+ end
+ end
+ end
+
+ # Log to an array, just for testing.
+ newdesttype :array do
+ match "Array"
+
+ def initialize(array)
+ @array = array
+ end
+
+ def handle(msg)
+ @array << msg
+ end
+ end
+
+ # Create a new log destination.
+ def Log.newdestination(dest)
+ # Each destination can only occur once.
+ if @destinations.find { |name, obj| obj.name == dest }
+ return
+ end
+
+ name, type = @desttypes.find do |name, klass|
+ klass.match?(dest)
+ end
+
+ unless type
+ raise Puppet::DevError, "Unknown destination type %s" % dest
+ end
+
+ begin
+ if type.instance_method(:initialize).arity == 1
+ @destinations[dest] = type.new(dest)
+ else
+ @destinations[dest] = type.new()
+ end
+ rescue => detail
+ if Puppet[:debug]
+ puts detail.backtrace
+ end
+
+ # If this was our only destination, then add the console back in.
+ if @destinations.empty? and (dest != :console and dest != "console")
+ newdestination(:console)
+ end
+ end
+ end
+
+ # Route the actual message. FIXME There are lots of things this method
+ # should do, like caching, storing messages when there are not yet
+ # destinations, a bit more. It's worth noting that there's a potential
+ # for a loop here, if the machine somehow gets the destination set as
+ # itself.
+ def Log.newmessage(msg)
+ if @levels.index(msg.level) < @loglevel
+ return
+ end
+
+ @destinations.each do |name, dest|
+ threadlock(dest) do
+ dest.handle(msg)
+ end
+ end
+ end
+
+ def Log.sendlevel?(level)
+ @levels.index(level) >= @loglevel
+ end
+
+ # Reopen all of our logs.
+ def Log.reopen
+ Puppet.notice "Reopening log files"
+ types = @destinations.keys
+ @destinations.each { |type, dest|
+ if dest.respond_to?(:close)
+ dest.close
+ end
+ }
+ @destinations.clear
+ # We need to make sure we always end up with some kind of destination
+ begin
+ types.each { |type|
+ Log.newdestination(type)
+ }
+ rescue => detail
+ if @destinations.empty?
+ Log.newdestination(:syslog)
+ Puppet.err detail.to_s
+ end
+ end
+ end
+
+ # Is the passed level a valid log level?
+ def self.validlevel?(level)
+ @levels.include?(level)
+ end
+
+ attr_accessor :level, :message, :time, :tags, :remote
+ attr_reader :source
+
+ def initialize(args)
+ unless args.include?(:level) && args.include?(:message)
+ raise Puppet::DevError, "Puppet::Util::Log called incorrectly"
+ end
+
+ if args[:level].class == String
+ @level = args[:level].intern
+ elsif args[:level].class == Symbol
+ @level = args[:level]
+ else
+ raise Puppet::DevError,
+ "Level is not a string or symbol: #{args[:level].class}"
+ end
+
+ # Just return unless we're actually at a level we should send
+ #return unless self.class.sendlevel?(@level)
+
+ @message = args[:message].to_s
+ @time = Time.now
+ # this should include the host name, and probly lots of other
+ # stuff, at some point
+ unless self.class.validlevel?(level)
+ raise Puppet::DevError, "Invalid message level #{level}"
+ end
+
+ if args.include?(:tags)
+ @tags = args[:tags]
+ end
+
+ if args.include?(:source)
+ self.source = args[:source]
+ else
+ @source = "Puppet"
+ end
+
+ Log.newmessage(self)
+ end
+
+ # Was the source of this log an object?
+ def objectsource?
+ if defined? @objectsource and @objectsource
+ @objectsource
+ else
+ false
+ end
+ end
+
+ # If they pass a source in to us, we make sure it is a string, and
+ # we retrieve any tags we can.
+ def source=(source)
+ # We can't store the actual source, we just store the path.
+ # We can't just check for whether it responds to :path, because
+ # plenty of providers respond to that in their normal function.
+ if source.is_a?(Puppet::Element) and source.respond_to?(:path)
+ @objectsource = true
+ @source = source.path
+ else
+ @objectsource = false
+ @source = source.to_s
+ end
+ unless defined? @tags and @tags
+ if source.respond_to?(:tags)
+ @tags = source.tags
+ end
+ end
+ end
+
+ def tagged?(tag)
+ @tags.detect { |t| t.to_s == tag.to_s }
+ end
+
+ def to_report
+ "%s %s (%s): %s" % [self.time, self.source, self.level, self.to_s]
+ end
+
+ def to_s
+ return @message
+ end
+end
+
+# $Id$
diff --git a/lib/puppet/util/logging.rb b/lib/puppet/util/logging.rb
index 1245e24de..298df93ba 100644
--- a/lib/puppet/util/logging.rb
+++ b/lib/puppet/util/logging.rb
@@ -1,14 +1,14 @@
# A module to make logging a bit easier.
-require 'puppet/log'
+require 'puppet/util/log'
module Puppet::Util::Logging
# Create a method for each log level.
- Puppet::Log.eachlevel do |level|
+ Puppet::Util::Log.eachlevel do |level|
define_method(level) do |args|
if args.is_a?(Array)
args = args.join(" ")
end
- Puppet::Log.create(
+ Puppet::Util::Log.create(
:level => level,
:source => self,
:message => args
diff --git a/lib/puppet/util/metric.rb b/lib/puppet/util/metric.rb
new file mode 100644
index 000000000..4c62df315
--- /dev/null
+++ b/lib/puppet/util/metric.rb
@@ -0,0 +1,158 @@
+# included so we can test object types
+require 'puppet'
+
+# A class for handling metrics. This is currently ridiculously hackish.
+class Puppet::Util::Metric
+ Puppet.config.setdefaults("metrics",
+ :rrddir => {:default => "$vardir/rrd",
+ :owner => "$user",
+ :group => "$group",
+ :desc => "The directory where RRD database files are stored.
+ Directories for each reporting host will be created under
+ this directory."
+ },
+ :rrdgraph => [false, "Whether RRD information should be graphed."],
+ :rrdinterval => ["$runinterval", "How often RRD should expect data.
+ This should match how often the hosts report back to the server."]
+ )
+
+ # Load the library as a feature, so we can test its presence.
+ Puppet.features.add :rrd, :libs => 'RRD'
+
+ attr_accessor :type, :name, :value, :label
+
+ attr_writer :basedir
+
+ def basedir
+ if defined? @basedir
+ @basedir
+ else
+ Puppet[:rrddir]
+ end
+ end
+
+ def create(start = nil)
+ Puppet.config.use(:metrics)
+
+ start ||= Time.now.to_i - 5
+
+ path = self.path
+ args = [
+ path,
+ "--start", start,
+ "--step", Puppet[:rrdinterval]
+ ]
+
+ values.each { |value|
+ # the 7200 is the heartbeat -- this means that any data that isn't
+ # more frequently than every two hours gets thrown away
+ args.push "DS:%s:GAUGE:7200:U:U" % [value[0]]
+ }
+ args.push "RRA:AVERAGE:0.5:1:300"
+
+ begin
+ RRD.create(*args)
+ rescue => detail
+ raise "Could not create RRD file %s: %s" % [path,detail]
+ end
+ end
+
+ def dump
+ puts RRD.info(self.path)
+ end
+
+ def graph(range = nil)
+ unless Puppet.features.rrd?
+ Puppet.warning "RRD library is missing; cannot graph metrics"
+ return
+ end
+
+ unit = 60 * 60 * 24
+ colorstack = %w{#ff0000 #00ff00 #0000ff #099000 #000990 #f00990 #0f0f0f}
+
+ {:daily => unit, :weekly => unit * 7, :monthly => unit * 30, :yearly => unit * 365}.each do |name, time|
+ file = self.path.sub(/\.rrd$/, "-%s.png" % name)
+ args = [file]
+
+ args.push("--title",self.label)
+ args.push("--imgformat","PNG")
+ args.push("--interlace")
+ i = 0
+ defs = []
+ lines = []
+ #p @values.collect { |s,l| s }
+ values.zip(colorstack).each { |value,color|
+ next if value.nil?
+ # this actually uses the data label
+ defs.push("DEF:%s=%s:%s:AVERAGE" % [value[0],self.path,value[0]])
+ lines.push("LINE2:%s%s:%s" % [value[0],color,value[1]])
+ }
+ args << defs
+ args << lines
+ args.flatten!
+ if range
+ args.push("--start",range[0],"--end",range[1])
+ else
+ args.push("--start", Time.now.to_i - time, "--end", Time.now.to_i)
+ end
+
+ begin
+ RRD.graph(*args)
+ rescue => detail
+ Puppet.err "Failed to graph %s: %s" % [self.name,detail]
+ end
+ end
+ end
+
+ def initialize(name,label = nil)
+ @name = name.to_s
+
+ if label
+ @label = label
+ else
+ @label = name.to_s.capitalize.gsub("_", " ")
+ end
+
+ @values = []
+ end
+
+ def path
+ return File.join(self.basedir, @name + ".rrd")
+ end
+
+ def newvalue(name,value,label = nil)
+ unless label
+ label = name.to_s.capitalize.gsub("_", " ")
+ end
+ @values.push [name,label,value]
+ end
+
+ def store(time)
+ unless Puppet.features.rrd?
+ Puppet.warning "RRD library is missing; cannot store metrics"
+ return
+ end
+ unless FileTest.exists?(self.path)
+ self.create(time - 5)
+ end
+
+ # XXX this is not terribly error-resistant
+ args = [time]
+ values.each { |value|
+ args.push value[2]
+ }
+ arg = args.join(":")
+ begin
+ RRD.update(self.path,arg)
+ #system("rrdtool updatev %s '%s'" % [self.path, arg])
+ rescue => detail
+ raise Puppet::Error, "Failed to update %s: %s" % [self.name,detail]
+ end
+ end
+
+ def values
+ @values.sort { |a, b| a[1] <=> b[1] }
+ end
+end
+
+# $Id$
diff --git a/lib/puppet/util/storage.rb b/lib/puppet/util/storage.rb
new file mode 100644
index 000000000..d76c67433
--- /dev/null
+++ b/lib/puppet/util/storage.rb
@@ -0,0 +1,103 @@
+require 'yaml'
+require 'sync'
+
+# a class for storing state
+class Puppet::Util::Storage
+ include Singleton
+ include Puppet::Util
+
+ def initialize
+ self.class.load
+ end
+
+ # Return a hash that will be stored to disk. It's worth noting
+ # here that we use the object's full path, not just the name/type
+ # combination. At the least, this is useful for those non-isomorphic
+ # types like exec, but it also means that if an object changes locations
+ # in the configuration it will lose its cache.
+ def self.cache(object)
+ if object.is_a? Puppet::Type
+ # We used to store things by path, now we store them by ref.
+ # In oscar(0.20.0) this changed to using the ref.
+ if @@state.include?(object.path)
+ @@state[object.ref] = @@state[object.path]
+ @@state.delete(object.path)
+ end
+ name = object.ref
+ elsif object.is_a?(Symbol)
+ name = object
+ else
+ raise ArgumentError, "You can only cache information for Types and symbols"
+ end
+
+ return @@state[name] ||= {}
+ end
+
+ def self.clear
+ @@state.clear
+ Storage.init
+ end
+
+ def self.init
+ @@state = {}
+ @@splitchar = "\t"
+ end
+
+ self.init
+
+ def self.load
+ Puppet.config.use(:puppet)
+
+ unless File.exists?(Puppet[:statefile])
+ unless defined? @@state and ! @@state.nil?
+ self.init
+ end
+ return
+ end
+ Puppet::Util.benchmark(:debug, "Loaded state") do
+ Puppet::Util.readlock(Puppet[:statefile]) do |file|
+ begin
+ @@state = YAML.load(file)
+ rescue => detail
+ Puppet.err "Checksumfile %s is corrupt (%s); replacing" %
+ [Puppet[:statefile], detail]
+ begin
+ File.rename(Puppet[:statefile],
+ Puppet[:statefile] + ".bad")
+ rescue
+ raise Puppet::Error,
+ "Could not rename corrupt %s; remove manually" %
+ Puppet[:statefile]
+ end
+ end
+ end
+ end
+
+ unless @@state.is_a?(Hash)
+ Puppet.err "State got corrupted"
+ self.init
+ end
+
+ #Puppet.debug "Loaded state is %s" % @@state.inspect
+ end
+
+ def self.stateinspect
+ @@state.inspect
+ end
+
+ def self.store
+ Puppet.debug "Storing state"
+
+ unless FileTest.exist?(Puppet[:statefile])
+ Puppet.info "Creating state file %s" % Puppet[:statefile]
+ end
+
+ Puppet::Util.benchmark(:debug, "Stored state") do
+ Puppet::Util.writelock(Puppet[:statefile], 0660) do |file|
+ file.print YAML.dump(@@state)
+ end
+ end
+ end
+end
+
+# $Id$
diff --git a/lib/puppet/util/suidmanager.rb b/lib/puppet/util/suidmanager.rb
new file mode 100644
index 000000000..7a0c3ae2c
--- /dev/null
+++ b/lib/puppet/util/suidmanager.rb
@@ -0,0 +1,86 @@
+require 'facter'
+require 'puppet/util/warnings'
+
+module Puppet::Util::SUIDManager
+ include Puppet::Util::Warnings
+
+ platform = Facter["kernel"].value
+ [:uid=, :gid=, :uid, :gid].each do |method|
+ define_method(method) do |*args|
+ # NOTE: 'method' is closed here.
+ newmethod = method
+
+ if platform == "Darwin" and (method == :uid= or method == :gid=)
+ Puppet::Util::Warnings.warnonce "Cannot change real UID on Darwin"
+ newmethod = ("e" + method.to_s).intern
+ end
+
+ return Process.send(newmethod, *args)
+ end
+ module_function method
+ end
+
+ [:euid=, :euid, :egid=, :egid].each do |method|
+ define_method(method) do |*args|
+ Process.send(method, *args)
+ end
+ module_function method
+ end
+
+ def asuser(new_euid=nil, new_egid=nil)
+ # Unless we're root, don't do a damn thing.
+ unless Process.uid == 0
+ return yield
+ end
+ old_egid = old_euid = nil
+ if new_egid
+ old_egid = self.egid
+ self.egid = convert_xid(:gid, new_egid)
+ end
+ if new_euid
+ old_euid = self.euid
+ self.euid = convert_xid(:uid, new_euid)
+ end
+
+ return yield
+ ensure
+ self.euid = old_euid if old_euid
+ self.egid = old_egid if old_egid
+ end
+
+ # Make sure the passed argument is a number.
+ def convert_xid(type, id)
+ map = {:gid => :group, :uid => :user}
+ raise ArgumentError, "Invalid id type %s" % type unless map.include?(type)
+ ret = Puppet::Util.send(type, id)
+ if ret == nil
+ raise Puppet::Error, "Invalid %s: %s" % [map[type], id]
+ end
+ return ret
+ end
+
+ module_function :asuser, :convert_xid
+
+ def run_and_capture(command, new_uid=nil, new_gid=nil)
+ output = nil
+
+ output = Puppet::Util.execute(command, false, new_uid, new_gid)
+
+ [output, $?.dup]
+ end
+
+ module_function :run_and_capture
+
+ def system(command, new_uid=nil, new_gid=nil)
+ status = nil
+ asuser(new_uid, new_gid) do
+ Kernel.system(command)
+ status = $?.dup
+ end
+ status
+ end
+
+ module_function :system
+end
+
+# $Id$
diff --git a/test/client/master.rb b/test/client/master.rb
index 8a7bf4f8b..ccd808bbd 100755
--- a/test/client/master.rb
+++ b/test/client/master.rb
@@ -482,14 +482,14 @@ end
# Now make sure the config time is cached
assert(master.compile_time, "No stored config time")
- assert_equal(master.compile_time, Puppet::Storage.cache(:configuration)[:compile_time], "times did not match")
+ assert_equal(master.compile_time, Puppet::Util::Storage.cache(:configuration)[:compile_time], "times did not match")
time = master.compile_time
master.clear
File.unlink(file)
- Puppet::Storage.store
+ Puppet::Util::Storage.store
# Now make a new master
- Puppet::Storage.clear
+ Puppet::Util::Storage.clear
master = mkclient(driver)
master.run
assert_equal(time, master.compile_time, "time was not retrieved from cache")
diff --git a/test/data/types/sshkey/1 b/test/data/types/sshkey/1
index e0da86ee8..840ed19df 100644
--- a/test/data/types/sshkey/1
+++ b/test/data/types/sshkey/1
@@ -18,3 +18,4 @@ config.sage.org,131.106.3.205 ssh-dss AAAAB3NzaC1kc3MAAACBAL2akEcIfQsfm3zCd2hD6P
rh3b,192.168.0.56 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAufcvE7s1eRwhUwMBfZ6uFNxkdSdzjSDEn3vjByOjG/eraNhnYAW3rxV7WIf2pEa6JSOMrE1mqsEL75xEtpXlzC949Ysz4+1OSHY52KonoFm/a+FbmbFp81TVuVPYaLoeWN27STiJh+puC5spkIZe0laqT1GU13M4gj6B+j3NLhU=
centos1,192.168.0.57 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEA0DXqYF+3Lf68GkWBAjjKBb6UITNnzm4wiDi/AGjv5+DoVXqDcqHvZ8rZFAMgUe1dVob4pWT2ZWLHW0gicoJCdr4UQbPXlWz1F62z8fo2PRRPlG6KN1wmF7pnyml8jr0wBX8lQZJsMqi4InGozf7wFHLH/7DNGRK3MD6tSp3Z4is=
doorstop.cafes.net,205.241.238.186 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEApJKeB9/bN5t55zLETHs0MVo/vEkfQ3EzY7178GKLI/yiOFmcn+NvUvUtCQK/xKpod813LBHCODxZPG1Kb0SjlaC/EkFEenb74LNu0o1qXa1GWh3wfaIm0JRNjXqPqxAWTlMs43O2HXwOwmLVhl7SSP3xtTw6h9gREbVKmfBaRdsRfzD0etfz1NCnmGh/1Sh9+j4eeS+IBtwoR5JVhZVhuofHCqs5HZ8gLDgfn8HXP7pMbLkx54cf1R/tmFmn9JGLdTPtEGcSIiu7414XSbfChSC83rGZCDPKHq7ZodiE8GpbWLBnyPXi2AYxTPM7aZMqitIHv3MWf5suV0q0WLGdnQ==
+host.domain.com,host1.domain.com,192.168.0.1 dss thisismykey1
diff --git a/test/executables/puppetca.rb b/test/executables/puppetca.rb
index 2eafb7f6c..92633c01b 100755
--- a/test/executables/puppetca.rb
+++ b/test/executables/puppetca.rb
@@ -75,7 +75,7 @@ class TestPuppetCA < Test::Unit::TestCase
uid = Puppet::Util.uid(Puppet[:user])
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
assert(! FileTest.owned?(signedfile), "cert is owned by root")
end
assert_nothing_raised {
diff --git a/test/language/interpreter.rb b/test/language/interpreter.rb
index 0b7703a67..ab3b97210 100755
--- a/test/language/interpreter.rb
+++ b/test/language/interpreter.rb
@@ -198,7 +198,7 @@ class TestInterpreter < Test::Unit::TestCase
end
end
- if Puppet::SUIDManager.uid == 0 and Facter["hostname"].value == "culain"
+ if Puppet::Util::SUIDManager.uid == 0 and Facter["hostname"].value == "culain"
def test_ldapreconnect
Puppet[:ldapbase] = "ou=hosts, dc=madstop, dc=com"
Puppet[:ldapnodes] = true
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index 2354722a9..6d19ba983 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -35,8 +35,8 @@ module PuppetTest
dir, method = arg.split(",")
when "--debug"
$puppet_debug = true
- Puppet::Log.level = :debug
- Puppet::Log.newdestination(:console)
+ Puppet::Util::Log.level = :debug
+ Puppet::Util::Log.newdestination(:console)
when "--help"
puts usage
exit
@@ -106,9 +106,9 @@ module PuppetTest
def logcollector
collector = []
- Puppet::Log.newdestination(collector)
+ Puppet::Util::Log.newdestination(collector)
cleanup do
- Puppet::Log.close(collector)
+ Puppet::Util::Log.close(collector)
end
collector
end
@@ -156,14 +156,14 @@ module PuppetTest
if textmate?
Puppet[:color] = false
end
- Puppet::Log.newdestination :console
- Puppet::Log.level = :debug
+ Puppet::Util::Log.newdestination :console
+ Puppet::Util::Log.level = :debug
#$VERBOSE = 1
Puppet.info @method_name
Puppet[:trace] = true
else
- Puppet::Log.close
- Puppet::Log.newdestination tempfile()
+ Puppet::Util::Log.close
+ Puppet::Util::Log.newdestination tempfile()
Puppet[:httplog] = tempfile()
end
@@ -238,7 +238,7 @@ module PuppetTest
@@tmppids.clear
Puppet::Type.allclear
- Puppet::Storage.clear
+ Puppet::Util::Storage.clear
Puppet.clear
@memoryatend = Puppet::Util.memory
@@ -250,7 +250,7 @@ module PuppetTest
end
# reset all of the logs
- Puppet::Log.close
+ Puppet::Util::Log.close
# Just in case there are processes waiting to die...
require 'timeout'
diff --git a/test/lib/puppettest/exetest.rb b/test/lib/puppettest/exetest.rb
index c6beaf5ba..d0a85956a 100644
--- a/test/lib/puppettest/exetest.rb
+++ b/test/lib/puppettest/exetest.rb
@@ -48,8 +48,8 @@ module PuppetTest::ExeTest
args += " --rundir %s" % File.join(Puppet[:vardir], "run")
args += " --vardir %s" % Puppet[:vardir]
args += " --masterport %s" % @@port
- args += " --user %s" % Puppet::SUIDManager.uid
- args += " --group %s" % Puppet::SUIDManager.gid
+ args += " --user %s" % Puppet::Util::SUIDManager.uid
+ args += " --group %s" % Puppet::Util::SUIDManager.gid
args += " --nonodes"
args += " --autosign true"
diff --git a/test/lib/puppettest/support/assertions.rb b/test/lib/puppettest/support/assertions.rb
index 75056b0db..46e4350fa 100644
--- a/test/lib/puppettest/support/assertions.rb
+++ b/test/lib/puppettest/support/assertions.rb
@@ -7,12 +7,12 @@ module PuppetTest
flunk "Must be uid 0 to run these tests" unless Process.uid == 0
fork do
- Puppet::SUIDManager.gid = gid
- Puppet::SUIDManager.uid = uid
+ Puppet::Util::SUIDManager.gid = gid
+ Puppet::Util::SUIDManager.uid = uid
# FIXME: use the tempfile method from puppettest.rb
system("mkfifo "+filename)
f = File.open(filename, "w")
- f << "#{Puppet::SUIDManager.uid}\n#{Puppet::SUIDManager.gid}\n"
+ f << "#{Puppet::Util::SUIDManager.uid}\n#{Puppet::Util::SUIDManager.gid}\n"
yield if block_given?
end
diff --git a/test/lib/puppettest/support/helpers.rb b/test/lib/puppettest/support/helpers.rb
index bd5356d53..dc01fa3b8 100644
--- a/test/lib/puppettest/support/helpers.rb
+++ b/test/lib/puppettest/support/helpers.rb
@@ -5,7 +5,7 @@ module PuppetTest
# UID of nobody.
def nonrootuser
Etc.passwd { |user|
- if user.uid != Puppet::SUIDManager.uid and user.uid > 0 and user.uid < 255
+ if user.uid != Puppet::Util::SUIDManager.uid and user.uid > 0 and user.uid < 255
return user
end
}
@@ -13,7 +13,7 @@ module PuppetTest
def nonrootgroup
Etc.group { |group|
- if group.gid != Puppet::SUIDManager.gid and group.gid > 0 and group.gid < 255
+ if group.gid != Puppet::Util::SUIDManager.gid and group.gid > 0 and group.gid < 255
return group
end
}
diff --git a/test/other/autoload.rb b/test/other/autoload.rb
index 86ba639aa..34f40df24 100755
--- a/test/other/autoload.rb
+++ b/test/other/autoload.rb
@@ -3,7 +3,7 @@
$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
require 'puppet'
-require 'puppet/autoload'
+require 'puppet/util/autoload'
require 'puppettest'
class TestAutoload < Test::Unit::TestCase
@@ -53,10 +53,10 @@ TestAutoload.newthing(:#{name.to_s})
loader = nil
assert_nothing_raised {
- loader = Puppet::Autoload.new(klass, :yayness)
+ loader = Puppet::Util::Autoload.new(klass, :yayness)
}
- assert_equal(loader.object_id, Puppet::Autoload[klass].object_id,
+ assert_equal(loader.object_id, Puppet::Util::Autoload[klass].object_id,
"Did not retrieve loader object by class")
# Make sure we don't fail on missing files
@@ -117,7 +117,7 @@ TestAutoload.newthing(:#{name.to_s})
f.puts "$loaded = true"
end
- auto = Puppet::Autoload.new(self, "test")
+ auto = Puppet::Util::Autoload.new(self, "test")
# Now make sure autoloading modifies $: as necessary
assert(! $:.include?(dir), "search path already includes libdir")
diff --git a/test/other/config.rb b/test/other/config.rb
index b47b3c97a..fad3e9763 100755
--- a/test/other/config.rb
+++ b/test/other/config.rb
@@ -3,7 +3,7 @@
$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
require 'puppet'
-require 'puppet/config'
+require 'puppet/util/config'
require 'puppettest'
require 'puppettest/parsertesting'
@@ -87,7 +87,7 @@ class TestConfig < Test::Unit::TestCase
def mkconfig
c = nil
assert_nothing_raised {
- c = Puppet::Config.new
+ c = Puppet::Util::Config.new
}
return c
end
@@ -546,7 +546,7 @@ yay = /a/path
user = nonrootuser()
group = nonrootgroup()
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
args[:owner] = user.name
args[:group] = group.name
end
@@ -562,7 +562,7 @@ yay = /a/path
assert_equal(mode, filemode(path), "Modes are not equal")
# OS X is broken in how it chgrps files
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
assert_equal(user.uid, File.stat(path).uid, "UIDS are not equal")
case Facter["operatingsystem"].value
@@ -586,7 +586,7 @@ yay = /a/path
user = nonrootuser()
group = nonrootgroup()
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
args[:owner] = user.name
args[:group] = group.name
end
@@ -601,7 +601,7 @@ yay = /a/path
# OS X and *BSD is broken in how it chgrps files
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
assert_equal(user.uid, File.stat(path).uid, "UIDS are not equal")
case Facter["operatingsystem"].value
@@ -682,9 +682,9 @@ inttest = 27
def test_correct_type_assumptions
config = mkconfig
- file = Puppet::Config::CFile
- element = Puppet::Config::CElement
- bool = Puppet::Config::CBoolean
+ file = Puppet::Util::Config::CFile
+ element = Puppet::Util::Config::CElement
+ bool = Puppet::Util::Config::CBoolean
# We have to keep these ordered, unfortunately.
[
diff --git a/test/other/dsl.rb b/test/other/dsl.rb
index b36cca745..f1fd1a1e9 100755
--- a/test/other/dsl.rb
+++ b/test/other/dsl.rb
@@ -4,7 +4,7 @@ $:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
require 'puppet'
require 'puppet/dsl'
-require 'puppet/autoload'
+require 'puppet/util/autoload'
require 'puppettest'
class TestDSL < Test::Unit::TestCase
diff --git a/test/other/features.rb b/test/other/features.rb
index 1758de783..129c14769 100755
--- a/test/other/features.rb
+++ b/test/other/features.rb
@@ -6,7 +6,7 @@
$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
require 'puppettest'
-require 'puppet/feature'
+require 'puppet/util/feature'
class TestFeatures < Test::Unit::TestCase
include PuppetTest
@@ -14,7 +14,7 @@ class TestFeatures < Test::Unit::TestCase
def setup
super
libdir = tempfile()
- @features = Puppet::Feature.new(libdir)
+ @features = Puppet::Util::Feature.new(libdir)
end
def test_new
diff --git a/test/other/filetype.rb b/test/other/filetype.rb
index efe90ef32..81a2af2c8 100755
--- a/test/other/filetype.rb
+++ b/test/other/filetype.rb
@@ -3,7 +3,7 @@
$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
require 'puppet'
-require 'puppet/filetype'
+require 'puppet/util/filetype'
require 'puppettest'
class TestFileType < Test::Unit::TestCase
@@ -15,7 +15,7 @@ class TestFileType < Test::Unit::TestCase
type = nil
assert_nothing_raised {
- type = Puppet::FileType.filetype(:flat)
+ type = Puppet::Util::FileType.filetype(:flat)
}
assert(type, "Could not retrieve flat filetype")
@@ -59,7 +59,7 @@ class TestFileType < Test::Unit::TestCase
type = nil
assert_nothing_raised {
- type = Puppet::FileType.filetype(:netinfo)
+ type = Puppet::Util::FileType.filetype(:netinfo)
}
assert(type, "Could not retrieve netinfo filetype")
diff --git a/test/other/inifile.rb b/test/other/inifile.rb
index 5b1dfe0ae..bdac23f7d 100755
--- a/test/other/inifile.rb
+++ b/test/other/inifile.rb
@@ -3,7 +3,7 @@
$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
require 'puppet'
-require 'puppet/inifile'
+require 'puppet/util/inifile'
require 'puppettest'
class TestFileType < Test::Unit::TestCase
@@ -11,7 +11,7 @@ class TestFileType < Test::Unit::TestCase
def setup
super
- @file = Puppet::IniConfig::File.new
+ @file = Puppet::Util::IniConfig::File.new
end
def teardown
diff --git a/test/other/loadedfile.rb b/test/other/loadedfile.rb
index 353bacd16..2c6b241fb 100755
--- a/test/other/loadedfile.rb
+++ b/test/other/loadedfile.rb
@@ -3,7 +3,7 @@
$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
require 'puppet'
-require 'puppet/loadedfile'
+require 'puppet/util/loadedfile'
require 'puppettest'
class TestLoadedFile < Test::Unit::TestCase
@@ -14,7 +14,7 @@ class TestLoadedFile < Test::Unit::TestCase
path = tempfile()
File.open(path, "w") { |f| f.puts "yayness" }
assert_nothing_raised {
- file = Puppet::LoadedFile.new(path)
+ file = Puppet::Util::LoadedFile.new(path)
}
assert(!file.changed?, "File incorrectly returned changed")
@@ -34,7 +34,7 @@ class TestLoadedFile < Test::Unit::TestCase
File.open(path, "w") { |f| f.puts "yay" }
file = nil
assert_nothing_raised {
- file = Puppet::LoadedFile.new(path)
+ file = Puppet::Util::LoadedFile.new(path)
}
assert_nothing_raised {
@@ -59,7 +59,7 @@ class TestLoadedFile < Test::Unit::TestCase
File.open(file, "w") { |f| f.puts "" }
obj = nil
assert_nothing_raised {
- obj = Puppet::LoadedFile.new(file)
+ obj = Puppet::Util::LoadedFile.new(file)
}
# Make sure we don't refresh
@@ -86,7 +86,7 @@ class TestLoadedFile < Test::Unit::TestCase
File.open(file, "w") { |f| f.puts "" }
obj = nil
assert_nothing_raised {
- obj = Puppet::LoadedFile.new(file)
+ obj = Puppet::Util::LoadedFile.new(file)
}
Puppet[:filetimeout] = -10
diff --git a/test/other/log.rb b/test/other/log.rb
index 3c720ca15..e1af9897a 100755
--- a/test/other/log.rb
+++ b/test/other/log.rb
@@ -3,7 +3,7 @@
$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
require 'puppet'
-require 'puppet/log'
+require 'puppet/util/log'
require 'puppettest'
class TestLog < Test::Unit::TestCase
@@ -11,22 +11,22 @@ class TestLog < Test::Unit::TestCase
def setup
super
- @oldloglevel = Puppet::Log.level
- Puppet::Log.close
+ @oldloglevel = Puppet::Util::Log.level
+ Puppet::Util::Log.close
end
def teardown
super
- Puppet::Log.close
- Puppet::Log.level = @oldloglevel
- Puppet::Log.newdestination(:console)
+ Puppet::Util::Log.close
+ Puppet::Util::Log.level = @oldloglevel
+ Puppet::Util::Log.newdestination(:console)
end
def getlevels
levels = nil
assert_nothing_raised() {
levels = []
- Puppet::Log.eachlevel { |level| levels << level }
+ Puppet::Util::Log.eachlevel { |level| levels << level }
}
# Don't test the top levels; too annoying
return levels.reject { |level| level == :emerg or level == :crit }
@@ -36,7 +36,7 @@ class TestLog < Test::Unit::TestCase
levels.collect { |level|
next if level == :alert
assert_nothing_raised() {
- Puppet::Log.new(
+ Puppet::Util::Log.new(
:level => level,
:source => "Test",
:message => "Unit test for %s" % level
@@ -48,16 +48,16 @@ class TestLog < Test::Unit::TestCase
def test_logfile
fact = nil
levels = nil
- Puppet::Log.level = :debug
+ Puppet::Util::Log.level = :debug
levels = getlevels
logfile = tempfile()
fact = nil
assert_nothing_raised() {
- Puppet::Log.newdestination(logfile)
+ Puppet::Util::Log.newdestination(logfile)
}
msgs = mkmsgs(levels)
assert(msgs.length == levels.length)
- Puppet::Log.close
+ Puppet::Util::Log.close
count = 0
assert(FileTest.exists?(logfile), "Did not create logfile")
@@ -78,7 +78,7 @@ class TestLog < Test::Unit::TestCase
}
}
assert_nothing_raised() {
- Puppet::Log.newdestination("syslog")
+ Puppet::Util::Log.newdestination("syslog")
}
# there's really no way to verify that we got syslog messages...
msgs = mkmsgs(levels)
@@ -89,16 +89,16 @@ class TestLog < Test::Unit::TestCase
fact = nil
levels = getlevels
assert_nothing_raised() {
- Puppet::Log.newdestination(:console)
+ Puppet::Util::Log.newdestination(:console)
}
msgs = mkmsgs(levels)
assert(msgs.length == levels.length)
- Puppet::Log.close
+ Puppet::Util::Log.close
end
def test_levelmethods
assert_nothing_raised() {
- Puppet::Log.newdestination("/dev/null")
+ Puppet::Util::Log.newdestination("/dev/null")
}
getlevels.each { |level|
assert_nothing_raised() {
@@ -108,18 +108,18 @@ class TestLog < Test::Unit::TestCase
end
def test_output
- Puppet::Log.level = :notice
- assert(Puppet.err("This is an error").is_a?(Puppet::Log))
+ Puppet::Util::Log.level = :notice
+ assert(Puppet.err("This is an error").is_a?(Puppet::Util::Log))
assert(Puppet.debug("This is debugging").nil?)
- Puppet::Log.level = :debug
- assert(Puppet.err("This is an error").is_a?(Puppet::Log))
- assert(Puppet.debug("This is debugging").is_a?(Puppet::Log))
+ Puppet::Util::Log.level = :debug
+ assert(Puppet.err("This is an error").is_a?(Puppet::Util::Log))
+ assert(Puppet.debug("This is debugging").is_a?(Puppet::Util::Log))
end
def test_creatingdirs
dir = tempfile()
file = File.join(dir, "logfile")
- Puppet::Log.newdestination file
+ Puppet::Util::Log.newdestination file
Puppet.info "testing logs"
assert(FileTest.directory?(dir))
assert(FileTest.file?(file))
@@ -140,7 +140,7 @@ class TestLog < Test::Unit::TestCase
assert(property, "Did not get property")
log = nil
assert_nothing_raised {
- log = Puppet::Log.new(
+ log = Puppet::Util::Log.new(
:level => :info,
:source => property,
:message => "A test message"
@@ -165,10 +165,10 @@ class TestLog < Test::Unit::TestCase
# Verify that we can pass strings that match printf args
def test_percentlogs
- Puppet::Log.newdestination :syslog
+ Puppet::Util::Log.newdestination :syslog
assert_nothing_raised {
- Puppet::Log.new(
+ Puppet::Util::Log.new(
:level => :info,
:message => "A message with %s in it"
)
@@ -183,7 +183,7 @@ class TestLog < Test::Unit::TestCase
:check => %w{owner group}
)
assert_nothing_raised {
- msg = Puppet::Log.new(:level => :info, :message => "This is a message")
+ msg = Puppet::Util::Log.new(:level => :info, :message => "This is a message")
}
assert_nothing_raised {
msg.source = file
@@ -217,7 +217,7 @@ class TestLog < Test::Unit::TestCase
def test_destination_matching
dest = nil
assert_nothing_raised {
- dest = Puppet::Log.newdesttype("Destine") do
+ dest = Puppet::Util::Log.newdesttype("Destine") do
def handle(msg)
puts msg
end
@@ -232,36 +232,36 @@ class TestLog < Test::Unit::TestCase
dest.match(:yayness)
}
assert(dest.match("Yayness"), "Did not match yayness")
- Puppet::Log.close(dest)
+ Puppet::Util::Log.close(dest)
end
def test_autoflush
file = tempfile
- Puppet::Log.close(:console)
- Puppet::Log.newdestination(file)
+ Puppet::Util::Log.close(:console)
+ Puppet::Util::Log.newdestination(file)
Puppet.warning "A test"
assert(File.read(file) !~ /A test/,
"File defualted to autoflush")
- Puppet::Log.flush
+ Puppet::Util::Log.flush
assert(File.read(file) =~ /A test/,
"File did not flush")
- Puppet::Log.close(file)
+ Puppet::Util::Log.close(file)
# Now try one with autoflush enabled
Puppet[:autoflush] = true
file = tempfile
- Puppet::Log.newdestination(file)
+ Puppet::Util::Log.newdestination(file)
Puppet.warning "A test"
assert(File.read(file) =~ /A test/,
"File did not autoflush")
- Puppet::Log.close(file)
+ Puppet::Util::Log.close(file)
end
def test_reopen
Puppet[:autoflush] = true
file = tempfile
- Puppet::Log.close(:console)
- Puppet::Log.newdestination(file)
+ Puppet::Util::Log.close(:console)
+ Puppet::Util::Log.newdestination(file)
Puppet.warning "A test"
assert(File.read(file) =~ /A test/,
"File did not flush")
@@ -275,11 +275,11 @@ class TestLog < Test::Unit::TestCase
"File did not rename")
# Now reopen the log
- Puppet::Log.reopen
+ Puppet::Util::Log.reopen
Puppet.warning "Reopen test"
assert(File.read(file) =~ /Reopen test/,
"File did not reopen")
- Puppet::Log.close(file)
+ Puppet::Util::Log.close(file)
end
end
diff --git a/test/other/metrics.rb b/test/other/metrics.rb
index a2904b2a5..c4e375e7b 100755
--- a/test/other/metrics.rb
+++ b/test/other/metrics.rb
@@ -2,8 +2,8 @@
$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
-require 'puppet/metric'
require 'puppet'
+require 'puppet/util/metric'
require 'puppettest'
require 'puppet/type'
diff --git a/test/other/propertychange.rb b/test/other/propertychange.rb
index 75c6056de..e3df577d2 100755
--- a/test/other/propertychange.rb
+++ b/test/other/propertychange.rb
@@ -9,7 +9,7 @@ require 'puppettest'
class TestPropertyChange < Test::Unit::TestCase
include PuppetTest
- class FakeProperty
+ class FakeProperty < Puppet::Type::Property
attr_accessor :is, :should, :parent
def change_to_s
"fake change"
@@ -18,7 +18,7 @@ class TestPropertyChange < Test::Unit::TestCase
@is == @should
end
def log(msg)
- Puppet::Log.create(
+ Puppet::Util::Log.create(
:level => :info,
:source => self,
:message => msg
@@ -44,7 +44,7 @@ class TestPropertyChange < Test::Unit::TestCase
end
def mkchange
- property = FakeProperty.new
+ property = FakeProperty.new :parent => "fakeparent"
property.is = :start
property.should = :finish
property.parent = :parent
diff --git a/test/other/report.rb b/test/other/report.rb
index 1ecebf307..8bd896d9a 100755
--- a/test/other/report.rb
+++ b/test/other/report.rb
@@ -16,7 +16,7 @@ class TestReports < Test::Unit::TestCase
report = fakereport
assert_nothing_raised {
- Puppet::Log.newdestination(report)
+ Puppet::Util::Log.newdestination(report)
}
# Now make a file for testing logging
@@ -35,7 +35,7 @@ class TestReports < Test::Unit::TestCase
assert(! report.logs.include?(log), "Report got log message")
assert_nothing_raised {
- Puppet::Log.close(report)
+ Puppet::Util::Log.close(report)
}
log = file.log "This is another message, yo"
@@ -197,9 +197,9 @@ class TestReports < Test::Unit::TestCase
def test_tagmail_matching
report = Puppet::Transaction::Report.new
- Puppet::Log.close
+ Puppet::Util::Log.close
[%w{one}, %w{one two}, %w{one two three}, %w{one two three four}].each do |tags|
- log = Puppet::Log.new(:level => :notice, :message => tags.join(" "), :tags => tags)
+ log = Puppet::Util::Log.new(:level => :notice, :message => tags.join(" "), :tags => tags)
report << log
end
diff --git a/test/other/storage.rb b/test/other/storage.rb
index 1ad51e4ee..dd68af5bf 100755
--- a/test/other/storage.rb
+++ b/test/other/storage.rb
@@ -28,14 +28,14 @@ class TestStorage < Test::Unit::TestCase
# Load first, since that's what we do in the code base; this creates
# all of the necessary directories.
assert_nothing_raised {
- Puppet::Storage.load
+ Puppet::Util::Storage.load
}
hash = {:a => :b, :c => :d}
state = nil
assert_nothing_raised {
- state = Puppet::Storage.cache(f)
+ state = Puppet::Util::Storage.cache(f)
}
assert(!state.include?("name"))
@@ -45,19 +45,19 @@ class TestStorage < Test::Unit::TestCase
}
assert_nothing_raised {
- Puppet::Storage.store
+ Puppet::Util::Storage.store
}
assert_nothing_raised {
- Puppet::Storage.clear
+ Puppet::Util::Storage.clear
}
assert_nothing_raised {
- Puppet::Storage.load
+ Puppet::Util::Storage.load
}
# Reset it
state = nil
assert_nothing_raised {
- state = Puppet::Storage.cache(f)
+ state = Puppet::Util::Storage.cache(f)
}
assert_equal(state["name"], hash)
@@ -75,11 +75,11 @@ class TestStorage < Test::Unit::TestCase
threads << Thread.new {
9.times { |b|
assert_nothing_raised {
- Puppet::Storage.load
- state = Puppet::Storage.cache(f)
+ Puppet::Util::Storage.load
+ state = Puppet::Util::Storage.cache(f)
value.each { |k,v| state[k] = v }
state[:e] = rand(100)
- Puppet::Storage.store
+ Puppet::Util::Storage.store
}
}
}
@@ -88,13 +88,13 @@ class TestStorage < Test::Unit::TestCase
end
def test_emptyrestore
- Puppet::Storage.load
- Puppet::Storage.store
- Puppet::Storage.clear
- Puppet::Storage.load
+ Puppet::Util::Storage.load
+ Puppet::Util::Storage.store
+ Puppet::Util::Storage.clear
+ Puppet::Util::Storage.load
f = mkfile()
- state = Puppet::Storage.cache(f)
+ state = Puppet::Util::Storage.cache(f)
assert_same Hash, state.class
assert_equal 0, state.size
end
@@ -104,18 +104,18 @@ class TestStorage < Test::Unit::TestCase
one = Puppet::Type.type(:exec).create :title => "/bin/echo one"
[one, :yayness].each do |object|
assert_nothing_raised do
- hash = Puppet::Storage.cache(object)
+ hash = Puppet::Util::Storage.cache(object)
end
assert_equal({}, hash, "Did not get empty hash back for %s" % object)
hash[:testing] = true
assert_nothing_raised do
- hash = Puppet::Storage.cache(object)
+ hash = Puppet::Util::Storage.cache(object)
end
assert_equal({:testing => true}, hash, "Did not get hash back for %s" % object)
end
assert_raise(ArgumentError, "was able to cache from string") do
- Puppet::Storage.cache("somethingelse")
+ Puppet::Util::Storage.cache("somethingelse")
end
end
end
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index 3b6333306..e90952a70 100755
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -11,6 +11,16 @@ require 'puppettest/support/resources'
class TestTransactions < Test::Unit::TestCase
include PuppetTest::FileTesting
include PuppetTest::Support::Resources
+ class Fakeprop <Puppet::Type::Property
+ attr_accessor :path, :is, :should, :name
+ def insync?
+ true
+ end
+ def info(*args)
+ false
+ end
+ end
+
def mkgenerator(&block)
$finished = []
@@ -79,7 +89,7 @@ class TestTransactions < Test::Unit::TestCase
assert(report.logs.length > 0, "Did not get any report logs")
report.logs.each do |obj|
- assert_instance_of(Puppet::Log, obj)
+ assert_instance_of(Puppet::Util::Log, obj)
end
# Then test the metrics
@@ -92,7 +102,7 @@ class TestTransactions < Test::Unit::TestCase
assert(metrics.has_key?("changes"), "Did not get change metrics")
metrics.each do |name, metric|
- assert_instance_of(Puppet::Metric, metric)
+ assert_instance_of(Puppet::Util::Metric, metric)
end
end
@@ -384,20 +394,24 @@ class TestTransactions < Test::Unit::TestCase
:path => path,
:ensure => "file"
)
- svc = Puppet.type(:service).create(
- :name => "thisservicedoesnotexist",
- :subscribe => [:file, path]
+ exec1 = Puppet.type(:exec).create(
+ :path => ENV["PATH"],
+ :command => "touch /this/cannot/possibly/exist",
+ :logoutput => true,
+ :refreshonly => true,
+ :subscribe => file,
+ :title => "one"
)
- exec = Puppet.type(:exec).create(
+ exec2 = Puppet.type(:exec).create(
:path => ENV["PATH"],
:command => "touch %s" % newfile,
:logoutput => true,
:refreshonly => true,
- :subscribe => [:file, path]
+ :subscribe => [file, exec1],
+ :title => "two"
)
- assert_apply(file, svc, exec)
- assert(FileTest.exists?(path), "File did not get created")
+ assert_apply(file, exec1, exec2)
assert(FileTest.exists?(newfile), "Refresh file did not get created")
end
@@ -773,14 +787,10 @@ class TestTransactions < Test::Unit::TestCase
# Make sure changes generated by eval_generated resources have proxies
# set to the top-level resource.
def test_proxy_resources
- Struct.new("FakeEvalProperty", :path, :is, :should, :name)
- Struct::FakeEvalProperty.send(:define_method, :insync?) { true }
- Struct::FakeEvalProperty.send(:define_method, :info) { |*args| false }
-
-
type = mkreducer do
def evaluate
- return Puppet::PropertyChange.new(Struct::FakeEvalProperty.new(:path, :is, :should, self.name))
+ return Puppet::PropertyChange.new(Fakeprop.new(
+ :path => :path, :is => :is, :should => :should, :name => self.name, :parent => "a parent"))
end
end
diff --git a/test/puppet/conffiles.rb b/test/puppet/conffiles.rb
index 201ecc5e6..6336968aa 100755
--- a/test/puppet/conffiles.rb
+++ b/test/puppet/conffiles.rb
@@ -2,9 +2,8 @@
$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
-require 'puppet'
-require 'puppet/config'
require 'puppettest'
+require 'puppet/util/config'
class TestConfFiles < Test::Unit::TestCase
include PuppetTest
@@ -73,7 +72,7 @@ class TestConfFiles < Test::Unit::TestCase
path = tempfile()
sampledata { |data|
- config = Puppet::Config.new
+ config = Puppet::Util::Config.new
data.each { |section, hash|
hash.each { |param, value|
config.setdefaults(section, param => [value, value])
diff --git a/test/puppet/defaults.rb b/test/puppet/defaults.rb
index 033fb71bc..19db3fe05 100755
--- a/test/puppet/defaults.rb
+++ b/test/puppet/defaults.rb
@@ -67,7 +67,7 @@ class TestPuppetDefaults < Test::Unit::TestCase
# we don't want user defaults in /, or root defaults in ~
def testDefaultsInCorrectRoots
notval = nil
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
notval = Regexp.new(File.expand_path("~"))
else
notval = /^\/var|^\/etc/
diff --git a/test/puppet/tc_suidmanager.rb b/test/puppet/tc_suidmanager.rb
index 5561992e3..b90261f44 100755
--- a/test/puppet/tc_suidmanager.rb
+++ b/test/puppet/tc_suidmanager.rb
@@ -25,8 +25,8 @@ class TestSUIDManager < Test::Unit::TestCase
# modification of a closure. Should the bug rear itself again, this
# test will fail.
assert_nothing_raised do
- Puppet::SUIDManager.uid
- Puppet::SUIDManager.uid
+ Puppet::Util::SUIDManager.uid
+ Puppet::Util::SUIDManager.uid
end
end
@@ -34,16 +34,16 @@ class TestSUIDManager < Test::Unit::TestCase
if @run
user = nonrootuser
assert_nothing_raised do
- Puppet::SUIDManager.egid = user.gid
- Puppet::SUIDManager.euid = user.uid
+ Puppet::Util::SUIDManager.egid = user.gid
+ Puppet::Util::SUIDManager.euid = user.uid
end
- assert_equal(Puppet::SUIDManager.euid, Process.euid)
- assert_equal(Puppet::SUIDManager.egid, Process.egid)
+ assert_equal(Puppet::Util::SUIDManager.euid, Process.euid)
+ assert_equal(Puppet::Util::SUIDManager.egid, Process.egid)
assert_nothing_raised do
- Puppet::SUIDManager.euid = 0
- Puppet::SUIDManager.egid = 0
+ Puppet::Util::SUIDManager.euid = 0
+ Puppet::Util::SUIDManager.egid = 0
end
end
end
@@ -61,7 +61,7 @@ class TestSUIDManager < Test::Unit::TestCase
uid, gid = [nil, nil]
assert_nothing_raised do
- Puppet::SUIDManager.asuser(user.uid, user.gid) do
+ Puppet::Util::SUIDManager.asuser(user.uid, user.gid) do
uid = Process.euid
gid = Process.egid
end
@@ -75,7 +75,7 @@ class TestSUIDManager < Test::Unit::TestCase
# NOTE: not sure what shells this will work on..
if @run
user = nonrootuser
- status = Puppet::SUIDManager.system("exit $EUID", user.uid, user.gid)
+ status = Puppet::Util::SUIDManager.system("exit $EUID", user.uid, user.gid)
assert_equal(user.uid, status.exitstatus)
end
end
@@ -90,7 +90,7 @@ class TestSUIDManager < Test::Unit::TestCase
# way that run_and_capture works.
user = nil
uid = nil
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
userobj = nonrootuser()
user = userobj.name
uid = userobj.uid
@@ -98,7 +98,7 @@ class TestSUIDManager < Test::Unit::TestCase
uid = Process.uid
end
cmd = [%{/bin/echo $EUID}]
- output = Puppet::SUIDManager.run_and_capture(cmd, uid)[0].chomp
+ output = Puppet::Util::SUIDManager.run_and_capture(cmd, uid)[0].chomp
assert_equal(uid.to_s, output)
end
end
diff --git a/test/ral/providers/group.rb b/test/ral/providers/group.rb
index ba362c1e6..792d8bcf9 100755
--- a/test/ral/providers/group.rb
+++ b/test/ral/providers/group.rb
@@ -176,7 +176,7 @@ class TestGroupProvider < Test::Unit::TestCase
}
end
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
def test_mkgroup
gobj = nil
comp = nil
diff --git a/test/ral/providers/host/parsed.rb b/test/ral/providers/host/parsed.rb
index 1e50dc58c..2a015e086 100755
--- a/test/ral/providers/host/parsed.rb
+++ b/test/ral/providers/host/parsed.rb
@@ -19,7 +19,7 @@ class TestParsedHostProvider < Test::Unit::TestCase
end
def teardown
- Puppet::FileType.filetype(:ram).clear
+ Puppet::Util::FileType.filetype(:ram).clear
@provider.filetype = @oldfiletype
@provider.clear
super
@@ -32,7 +32,7 @@ class TestParsedHostProvider < Test::Unit::TestCase
# Here we just create a fake host type that answers to all of the methods
# but does not modify our actual system.
def mkfaketype
- @provider.filetype = Puppet::FileType.filetype(:ram)
+ @provider.filetype = Puppet::Util::FileType.filetype(:ram)
end
def mkhosthash
diff --git a/test/ral/providers/mount/parsed.rb b/test/ral/providers/mount/parsed.rb
index 83713708d..d6b507f08 100755
--- a/test/ral/providers/mount/parsed.rb
+++ b/test/ral/providers/mount/parsed.rb
@@ -19,7 +19,7 @@ class TestParsedMounts < Test::Unit::TestCase
end
def teardown
- Puppet::FileType.filetype(:ram).clear
+ Puppet::Util::FileType.filetype(:ram).clear
@provider.filetype = @oldfiletype
@provider.clear
super
@@ -65,7 +65,7 @@ class TestParsedMounts < Test::Unit::TestCase
# Here we just create a fake host type that answers to all of the methods
# but does not modify our actual system.
def mkfaketype
- @provider.filetype = Puppet::FileType.filetype(:ram)
+ @provider.filetype = Puppet::Util::FileType.filetype(:ram)
end
def test_default_target
@@ -146,7 +146,7 @@ class TestParsedMounts < Test::Unit::TestCase
end
end
- if Puppet::SUIDManager.uid == 0 and Facter.value(:operatingsystem) != "Darwin"
+ if Puppet::Util::SUIDManager.uid == 0 and Facter.value(:operatingsystem) != "Darwin"
def test_mountfs
fs = nil
case Facter.value(:hostname)
diff --git a/test/ral/providers/parsedfile.rb b/test/ral/providers/parsedfile.rb
index fb5eb35ad..4f2751f39 100755
--- a/test/ral/providers/parsedfile.rb
+++ b/test/ral/providers/parsedfile.rb
@@ -4,7 +4,7 @@ $:.unshift("../../lib") if __FILE__ =~ /\.rb$/
require 'puppettest'
require 'puppettest/fileparsing'
-require 'puppet/filetype'
+require 'puppet/util/filetype'
require 'puppet/provider/parsedfile'
require 'facter'
@@ -100,8 +100,8 @@ class TestParsedFile < Test::Unit::TestCase
def test_filetype
prov = mkprovider
- flat = Puppet::FileType.filetype(:flat)
- ram = Puppet::FileType.filetype(:ram)
+ flat = Puppet::Util::FileType.filetype(:flat)
+ ram = Puppet::Util::FileType.filetype(:ram)
assert_nothing_raised do
prov.filetype = :flat
end
@@ -126,7 +126,7 @@ class TestParsedFile < Test::Unit::TestCase
end
# The default filetype is 'ram'
- assert_instance_of(Puppet::FileType.filetype(:ram), obj)
+ assert_instance_of(Puppet::Util::FileType.filetype(:ram), obj)
newobj = nil
assert_nothing_raised do
diff --git a/test/ral/providers/parsedport.rb b/test/ral/providers/parsedport.rb
index 929a02327..acd6eda1f 100755
--- a/test/ral/providers/parsedport.rb
+++ b/test/ral/providers/parsedport.rb
@@ -19,7 +19,7 @@ require 'puppettest'
# end
#
# def teardown
-# Puppet::FileType.filetype(:ram).clear
+# Puppet::Util::FileType.filetype(:ram).clear
# @provider.filetype = @oldfiletype
# @provider.clear
# super
diff --git a/test/ral/providers/parsedsshkey.rb b/test/ral/providers/parsedsshkey.rb
index f79e7be94..854a1342a 100755
--- a/test/ral/providers/parsedsshkey.rb
+++ b/test/ral/providers/parsedsshkey.rb
@@ -18,7 +18,7 @@ class TestParsedSSHKey < Test::Unit::TestCase
end
def teardown
- Puppet::FileType.filetype(:ram).clear
+ Puppet::Util::FileType.filetype(:ram).clear
@provider.filetype = @oldfiletype
@provider.clear
super
diff --git a/test/ral/providers/user.rb b/test/ral/providers/user.rb
index 94baca37b..319db0a5f 100755
--- a/test/ral/providers/user.rb
+++ b/test/ral/providers/user.rb
@@ -401,7 +401,7 @@ class TestUserProvider < Test::Unit::TestCase
assert_equal(main.sort, list.sort, "Group list is not equal")
end
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
def test_simpleuser
name = "pptest"
diff --git a/test/ral/types/cron.rb b/test/ral/types/cron.rb
index bf166c70f..3baf6aac3 100755
--- a/test/ral/types/cron.rb
+++ b/test/ral/types/cron.rb
@@ -16,13 +16,13 @@ class TestCron < Test::Unit::TestCase
# god i'm lazy
@crontype = Puppet.type(:cron)
@oldfiletype = @crontype.filetype
- @fakefiletype = Puppet::FileType.filetype(:ram)
+ @fakefiletype = Puppet::Util::FileType.filetype(:ram)
@crontype.filetype = @fakefiletype
end
def teardown
@crontype.filetype = @oldfiletype
- Puppet::FileType.filetype(:ram).clear
+ Puppet::Util::FileType.filetype(:ram).clear
super
end
@@ -138,7 +138,7 @@ class TestCron < Test::Unit::TestCase
end
def test_simpleparsing
- @fakefiletype = Puppet::FileType.filetype(:ram)
+ @fakefiletype = Puppet::Util::FileType.filetype(:ram)
@crontype.filetype = @fakefiletype
@crontype.retrieve(@me)
@@ -362,7 +362,7 @@ class TestCron < Test::Unit::TestCase
obj = nil
assert_nothing_raised {
- obj = type.new(Puppet::SUIDManager.uid)
+ obj = type.new(Puppet::Util::SUIDManager.uid)
}
txt = nil
@@ -522,7 +522,7 @@ class TestCron < Test::Unit::TestCase
end
def test_data
- @fakefiletype = Puppet::FileType.filetype(:ram)
+ @fakefiletype = Puppet::Util::FileType.filetype(:ram)
@crontype.filetype = @fakefiletype
@crontype.retrieve(@me)
diff --git a/test/ral/types/exec.rb b/test/ral/types/exec.rb
index 300e26367..6dd126631 100755
--- a/test/ral/types/exec.rb
+++ b/test/ral/types/exec.rb
@@ -113,59 +113,37 @@ class TestExec < Test::Unit::TestCase
tmpfile = tempfile()
@@tmpfiles.push tmpfile
trans = nil
- File.open(tmpfile, File::WRONLY|File::CREAT|File::TRUNC) { |of|
- of.puts rand(100)
- }
file = Puppet.type(:file).create(
:path => tmpfile,
- :checksum => "md5"
+ :content => "yay"
)
- assert_instance_of(Puppet.type(:file), file)
+ # Get the file in sync
+ assert_apply(file)
+
+ # Now make an exec
+ maker = tempfile()
assert_nothing_raised {
cmd = Puppet.type(:exec).create(
- :command => "pwd",
+ :command => "touch %s" % maker,
:path => "/usr/bin:/bin:/usr/sbin:/sbin",
:subscribe => file,
:refreshonly => true
)
}
- assert_instance_of(Puppet.type(:exec), cmd)
+ assert(cmd, "did not make exec")
- comp = Puppet.type(:component).create(:name => "RefreshTest")
- [file,cmd].each { |obj|
- comp.push obj
- }
- events = nil
- assert_nothing_raised {
- trans = comp.evaluate
- file.retrieve
+ assert_nothing_raised do
+ assert(! cmd.check, "Check passed when refreshonly is set")
+ end
- sum = file.property(:checksum)
- assert(sum.insync?, "checksum is not in sync")
- events = trans.evaluate.collect { |event|
- event.event
- }
- }
- # the first checksum shouldn't result in a changed file
- assert_equal([],events)
- File.open(tmpfile, File::WRONLY|File::CREAT|File::TRUNC) { |of|
- of.puts rand(100)
- of.puts rand(100)
- of.puts rand(100)
- }
- assert_nothing_raised {
- trans = comp.evaluate
- sum = file.property(:checksum)
- events = trans.evaluate.collect { |event| event.event }
- }
-
- # verify that only the file_changed event was kicked off, not the
- # command_executed
- assert_equal(
- [:file_changed, :triggered],
- events
- )
+ assert_events([], file, cmd)
+ assert(! FileTest.exists?(maker), "made file without refreshing")
+
+ # Now change our content, so we throw a refresh
+ file[:content] = "yayness"
+ assert_events([:file_changed, :triggered], file, cmd)
+ assert(FileTest.exists?(maker), "file was not made in refresh")
end
def test_refreshonly
@@ -181,6 +159,9 @@ class TestExec < Test::Unit::TestCase
# Checks should always fail when refreshonly is enabled
assert(!cmd.check, "Check passed with refreshonly true")
+ # Now make sure it passes if we pass in "true"
+ assert(cmd.check(true), "Check failed with refreshonly true while refreshing")
+
# Now set it to false
cmd[:refreshonly] = false
assert(cmd.check, "Check failed with refreshonly false")
@@ -330,7 +311,7 @@ class TestExec < Test::Unit::TestCase
assert_events([:executed_command], comp)
end
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
# Verify that we can execute commands as a special user
def mknverify(file, user, group = nil, id = true)
File.umask(0022)
diff --git a/test/ral/types/file.rb b/test/ral/types/file.rb
index af4a3a8b3..b69d6cd3d 100755
--- a/test/ral/types/file.rb
+++ b/test/ral/types/file.rb
@@ -39,19 +39,19 @@ class TestFile < Test::Unit::TestCase
end
def teardown
- Puppet::Storage.clear
+ Puppet::Util::Storage.clear
system("rm -rf %s" % Puppet[:statefile])
super
end
def initstorage
- Puppet::Storage.init
- Puppet::Storage.load
+ Puppet::Util::Storage.init
+ Puppet::Util::Storage.load
end
def clearstorage
- Puppet::Storage.store
- Puppet::Storage.clear
+ Puppet::Util::Storage.store
+ Puppet::Util::Storage.clear
end
def test_owner
@@ -108,7 +108,7 @@ class TestFile < Test::Unit::TestCase
}
end
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
def test_createasuser
dir = tmpdir()
diff --git a/test/ral/types/filebucket.rb b/test/ral/types/filebucket.rb
index 931c571dc..568a4b203 100755
--- a/test/ral/types/filebucket.rb
+++ b/test/ral/types/filebucket.rb
@@ -51,13 +51,13 @@ class TestFileBucket < Test::Unit::TestCase
end
def initstorage
- Puppet::Storage.init
- Puppet::Storage.load
+ Puppet::Util::Storage.init
+ Puppet::Util::Storage.load
end
def clearstorage
- Puppet::Storage.store
- Puppet::Storage.clear
+ Puppet::Util::Storage.store
+ Puppet::Util::Storage.clear
end
def test_simplebucket
diff --git a/test/ral/types/fileignoresource.rb b/test/ral/types/fileignoresource.rb
index 214a865f5..fa01aecdc 100755
--- a/test/ral/types/fileignoresource.rb
+++ b/test/ral/types/fileignoresource.rb
@@ -20,13 +20,13 @@ class TestFileIgnoreSources < Test::Unit::TestCase
#This is not needed unless using md5 (correct me if I'm wrong)
def initstorage
- Puppet::Storage.init
- Puppet::Storage.load
+ Puppet::Util::Storage.init
+ Puppet::Util::Storage.load
end
def clearstorage
- Puppet::Storage.store
- Puppet::Storage.clear
+ Puppet::Util::Storage.store
+ Puppet::Util::Storage.clear
end
def test_ignore_simple_source
diff --git a/test/ral/types/filesources.rb b/test/ral/types/filesources.rb
index dc4bbdb07..1badfaa11 100755
--- a/test/ral/types/filesources.rb
+++ b/test/ral/types/filesources.rb
@@ -27,8 +27,8 @@ class TestFileSources < Test::Unit::TestCase
end
def initstorage
- Puppet::Storage.init
- Puppet::Storage.load
+ Puppet::Util::Storage.init
+ Puppet::Util::Storage.load
end
# Make a simple recursive tree.
@@ -100,7 +100,7 @@ class TestFileSources < Test::Unit::TestCase
end
assert_equal("file", result[:type])
assert(result[:checksum], "did not get value for checksum")
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
assert(result.has_key?(:owner), "Lost owner in describe")
else
assert(! result.has_key?(:owner),
diff --git a/test/ral/types/service.rb b/test/ral/types/service.rb
index 005f00e63..93e41158c 100755
--- a/test/ral/types/service.rb
+++ b/test/ral/types/service.rb
@@ -230,7 +230,7 @@ class TestLocalService < Test::Unit::TestCase
}
end
- unless Puppet::SUIDManager.uid == 0
+ unless Puppet::Util::SUIDManager.uid == 0
puts "run as root to test service start/stop"
else
def test_servicestartstop
diff --git a/test/ral/types/user.rb b/test/ral/types/user.rb
index 6feb90742..641d9cd82 100755
--- a/test/ral/types/user.rb
+++ b/test/ral/types/user.rb
@@ -67,7 +67,7 @@ class TestUser < Test::Unit::TestCase
user = Puppet.type(:user).create(
:name => name,
:comment => "Puppet Testing User",
- :gid => Puppet::SUIDManager.gid,
+ :gid => Puppet::Util::SUIDManager.gid,
:shell => findshell(),
:home => "/home/%s" % name
)
diff --git a/test/ral/types/zone.rb b/test/ral/types/zone.rb
index d5cb0f739..c1724b93a 100755
--- a/test/ral/types/zone.rb
+++ b/test/ral/types/zone.rb
@@ -189,7 +189,7 @@ end"
"Got incorrect config text")
end
- if Puppet::SUIDManager.uid == 0
+ if Puppet::Util::SUIDManager.uid == 0
# Make sure our ensure process actually works.
def test_ensure_sync
zone = mkzone("ensuretesting")
diff --git a/test/server/logger.rb b/test/server/logger.rb
index 6b7e6a8f4..60d5458ef 100755
--- a/test/server/logger.rb
+++ b/test/server/logger.rb
@@ -13,7 +13,7 @@ class TestLogger < Test::Unit::TestCase
def setup
super
#Puppet[:debug] = true
- Puppet::Log.newdestination :console
+ Puppet::Util::Log.newdestination :console
end
# Test the log driver manually
@@ -25,7 +25,7 @@ class TestLogger < Test::Unit::TestCase
msg = nil
assert_nothing_raised {
- msg = Puppet::Log.create(
+ msg = Puppet::Util::Log.create(
:level => :warning,
:message => "This is a message"
)
@@ -45,7 +45,7 @@ class TestLogger < Test::Unit::TestCase
msg = nil
assert_nothing_raised {
- msg = Puppet::Log.create(
+ msg = Puppet::Util::Log.create(
:level => :warning,
:message => "This is a remote message"
)
@@ -68,7 +68,7 @@ class TestLogger < Test::Unit::TestCase
msg = nil
assert_nothing_raised {
- msg = Puppet::Log.create(
+ msg = Puppet::Util::Log.create(
:level => :warning,
:message => "This is a logclient message"
)
@@ -89,8 +89,8 @@ class TestLogger < Test::Unit::TestCase
clientlog = tempfile()
serverlog = tempfile()
Puppet.warning "serverlog is %s" % serverlog
- Puppet::Log.newdestination clientlog
- Puppet::Log.close(:syslog)
+ Puppet::Util::Log.newdestination clientlog
+ Puppet::Util::Log.close(:syslog)
# For testing
Puppet[:autosign] = true
@@ -109,8 +109,8 @@ class TestLogger < Test::Unit::TestCase
# Start our server
serverpid = fork {
- Puppet::Log.close(clientlog)
- Puppet::Log.newdestination serverlog
+ Puppet::Util::Log.close(clientlog)
+ Puppet::Util::Log.newdestination serverlog
assert_nothing_raised() {
trap(:INT) { logger.shutdown }
logger.start
@@ -137,7 +137,7 @@ class TestLogger < Test::Unit::TestCase
:warning => "XMLRPC2",
:err => "XMLRPC3"
}.each { |level, str|
- msg = CGI.escape(YAML.dump(Puppet::Log.create(
+ msg = CGI.escape(YAML.dump(Puppet::Util::Log.create(
:level => level,
:message => str
)))
@@ -149,7 +149,7 @@ class TestLogger < Test::Unit::TestCase
# and now use the normal client action
# Set the log destination to be the server
- Puppet::Log.newdestination "localhost:%s" % @@port
+ Puppet::Util::Log.newdestination "localhost:%s" % @@port
# And now do some logging
assert_nothing_raised {
diff --git a/test/util/posixtest.rb b/test/util/posixtest.rb
index 354e3ad4c..7939afd46 100755
--- a/test/util/posixtest.rb
+++ b/test/util/posixtest.rb
@@ -106,7 +106,7 @@ class TestPosixUtil < Test::Unit::TestCase
# know them
def test_gidbyunknownid
gid = nil
- group = Puppet::SUIDManager.gid
+ group = Puppet::Util::SUIDManager.gid
assert_nothing_raised {
gid = Puppet::Util.gid(group)
}
@@ -118,7 +118,7 @@ class TestPosixUtil < Test::Unit::TestCase
def user
require 'etc'
unless defined? @user
- obj = Etc.getpwuid(Puppet::SUIDManager.uid)
+ obj = Etc.getpwuid(Puppet::Util::SUIDManager.uid)
@user = obj.name
end
return @user
@@ -134,7 +134,7 @@ class TestPosixUtil < Test::Unit::TestCase
}
assert(uid, "Could not retrieve uid for %s" % user)
- assert_equal(Puppet::SUIDManager.uid, uid, "UIDs did not match")
+ assert_equal(Puppet::Util::SUIDManager.uid, uid, "UIDs did not match")
end
# Then verify we can retrieve a known user by uid
@@ -160,7 +160,7 @@ class TestPosixUtil < Test::Unit::TestCase
# know them
def test_uidbyunknownid
uid = nil
- user = Puppet::SUIDManager.uid
+ user = Puppet::Util::SUIDManager.uid
assert_nothing_raised {
uid = Puppet::Util.uid(user)
}
diff --git a/test/util/utiltest.rb b/test/util/utiltest.rb
index 86db02305..fd7c6c38f 100755
--- a/test/util/utiltest.rb
+++ b/test/util/utiltest.rb
@@ -84,7 +84,7 @@ class TestPuppetUtil < Test::Unit::TestCase
end
end
- unless Puppet::SUIDManager.uid == 0
+ unless Puppet::Util::SUIDManager.uid == 0
$stderr.puts "Run as root to perform Utility tests"
def test_nothing
end
@@ -118,23 +118,23 @@ class TestPuppetUtil < Test::Unit::TestCase
if group
gid = group.gid
else
- gid = Puppet::SUIDManager.gid
+ gid = Puppet::Util::SUIDManager.gid
end
uid = nil
if user
uid = user.uid
else
- uid = Puppet::SUIDManager.uid
+ uid = Puppet::Util::SUIDManager.uid
end
assert_nothing_raised {
- Puppet::SUIDManager.asuser(*args) {
- assert_equal(Puppet::SUIDManager.euid, uid, "UID is %s instead of %s" %
- [Puppet::SUIDManager.euid, uid]
+ Puppet::Util::SUIDManager.asuser(*args) {
+ assert_equal(Puppet::Util::SUIDManager.euid, uid, "UID is %s instead of %s" %
+ [Puppet::Util::SUIDManager.euid, uid]
)
- assert_equal(Puppet::SUIDManager.egid, gid, "GID is %s instead of %s" %
- [Puppet::SUIDManager.egid, gid]
+ assert_equal(Puppet::Util::SUIDManager.egid, gid, "GID is %s instead of %s" %
+ [Puppet::Util::SUIDManager.egid, gid]
)
system("touch %s" % file)
}
@@ -189,7 +189,7 @@ class TestPuppetUtil < Test::Unit::TestCase
rescue
end
- assert(Puppet::SUIDManager.euid == 0, "UID did not get reset")
+ assert(Puppet::Util::SUIDManager.euid == 0, "UID did not get reset")
end
end