diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-10-22 22:24:02 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-10-22 22:24:02 +0000 |
commit | 8fe558cca075ab85619a73f4a80408de58810ef7 (patch) | |
tree | ca33c7b76fe502cde31d0734e078f54b2a537968 | |
parent | 5ab12f97eae989c03b0444cf51ad423fdc6e01f7 (diff) | |
download | puppet-8fe558cca075ab85619a73f4a80408de58810ef7.tar.gz puppet-8fe558cca075ab85619a73f4a80408de58810ef7.tar.xz puppet-8fe558cca075ab85619a73f4a80408de58810ef7.zip |
general cleanup, as i move towards running it locally
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@723 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet/client.rb | 3 | ||||
-rwxr-xr-x | lib/puppet/type/package/apt.rb | 4 | ||||
-rw-r--r-- | lib/puppet/type/pfile.rb | 8 | ||||
-rwxr-xr-x | lib/puppet/type/pfile/group.rb | 22 | ||||
-rwxr-xr-x | lib/puppet/type/pfile/mode.rb | 12 | ||||
-rwxr-xr-x | lib/puppet/type/pfile/source.rb | 1 | ||||
-rwxr-xr-x | lib/puppet/type/pfile/uid.rb | 22 | ||||
-rwxr-xr-x | test/certmgr/tc_certmgr.rb | 5 |
8 files changed, 67 insertions, 10 deletions
diff --git a/lib/puppet/client.rb b/lib/puppet/client.rb index ac2ec420c..b47d235a8 100644 --- a/lib/puppet/client.rb +++ b/lib/puppet/client.rb @@ -86,7 +86,7 @@ module Puppet end def cert=(cert) - Puppet.debug "Adding certificate" + #Puppet.debug "Adding certificate" @http.cert = cert @http.verify_mode = OpenSSL::SSL::VERIFY_PEER end @@ -99,6 +99,7 @@ module Puppet hash[:Path] ||= "/RPC2" hash[:Server] ||= "localhost" hash[:Port] ||= Puppet[:masterport] + Puppet.debug "Creating client for %s" % hash[:Server] @puppetserver = hash[:Server] diff --git a/lib/puppet/type/package/apt.rb b/lib/puppet/type/package/apt.rb index 9267fbcd8..4dd93fed7 100755 --- a/lib/puppet/type/package/apt.rb +++ b/lib/puppet/type/package/apt.rb @@ -19,7 +19,7 @@ module Puppet # Add the package version str += "=%s" % should end - cmd = "apt-get install %s" % str + cmd = "apt-get -q -y install %s" % str Puppet.info "Executing %s" % cmd.inspect output = %x{#{cmd} 2>&1} @@ -41,7 +41,7 @@ module Puppet if output =~ /Versions:\s*\n((\n|.)+)^$/ versions = $1 version = versions.split(/\n/).collect { |version| - if version =~ /(.+)\(/ + if version =~ /^([^\(]+)\(/ $1 else Puppet.warning "Could not match version '%s'" % version diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index 2373ac8e4..39198a286 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -166,6 +166,9 @@ module Puppet # default to true self[:backup] = true + # Used for caching clients + @clients = {} + super end @@ -500,7 +503,10 @@ module Puppet end # FIXME We should cache a copy of this server #sourceobj.server = Puppet::NetworkClient.new(args) - sourceobj.server = Puppet::Client::FileClient.new(args) + unless @clients.include?(source) + @clients[source] = Puppet::Client::FileClient.new(args) + end + sourceobj.server = @clients[source] tmp = uri.path if tmp =~ %r{^/(\w+)} diff --git a/lib/puppet/type/pfile/group.rb b/lib/puppet/type/pfile/group.rb index 3444d2ec3..0e16af4ad 100755 --- a/lib/puppet/type/pfile/group.rb +++ b/lib/puppet/type/pfile/group.rb @@ -8,6 +8,28 @@ module Puppet @name = :group @event = :inode_changed + def id2name(id) + begin + group = Etc.getgrgid(id) + rescue ArgumentError + return nil + end + if group.gid == "" + return nil + else + return group.name + end + end + + # We want to print names, not numbers + def is_to_s + id2name(@is) || @is + end + + def should_to_s + id2name(self.should) || self.should + end + def retrieve stat = @parent.stat(true) diff --git a/lib/puppet/type/pfile/mode.rb b/lib/puppet/type/pfile/mode.rb index b432dc639..66b9adf80 100755 --- a/lib/puppet/type/pfile/mode.rb +++ b/lib/puppet/type/pfile/mode.rb @@ -12,11 +12,19 @@ module Puppet # Our modes are octal, so make sure they print correctly. def is_to_s - "%o" % @is + if @is.is_a?(Integer) + return "%o" % @is + else + return @is + end end def should_to_s - "%o" % self.should + if @should.is_a?(Integer) + return "%o" % @should + else + return @should + end end def shouldprocess(should) diff --git a/lib/puppet/type/pfile/source.rb b/lib/puppet/type/pfile/source.rb index db2055172..d6678a705 100755 --- a/lib/puppet/type/pfile/source.rb +++ b/lib/puppet/type/pfile/source.rb @@ -99,6 +99,7 @@ module Puppet @is = :notfound end else + Puppet.info "File does not have checksum" @is = :notfound end diff --git a/lib/puppet/type/pfile/uid.rb b/lib/puppet/type/pfile/uid.rb index 176988eb1..4ac7523bf 100755 --- a/lib/puppet/type/pfile/uid.rb +++ b/lib/puppet/type/pfile/uid.rb @@ -7,6 +7,28 @@ module Puppet @name = :owner @event = :inode_changed + def id2name(id) + begin + user = Etc.getpwuid(id) + rescue ArgumentError + return nil + end + if user.uid == "" + return nil + else + return user.name + end + end + + # We want to print names, not numbers + def is_to_s + id2name(@is) || @is + end + + def should_to_s + id2name(self.should) || self.should + end + def retrieve unless stat = @parent.stat(true) @is = :notfound diff --git a/test/certmgr/tc_certmgr.rb b/test/certmgr/tc_certmgr.rb index ec1cb62c4..c0ec7c934 100755 --- a/test/certmgr/tc_certmgr.rb +++ b/test/certmgr/tc_certmgr.rb @@ -21,11 +21,10 @@ require 'puppettest' # and test whether we've got things in the right scopes class TestCertMgr < Test::Unit::TestCase + include TestPuppet def setup Puppet[:loglevel] = :debug if __FILE__ == $0 #@dir = File.join(Puppet[:certdir], "testing") - @dir = "/tmp/puppetcertestingdir" - Puppet[:ssldir] = @dir system("mkdir -p %s" % @dir) @@tmpfiles = [@dir] end @@ -220,8 +219,6 @@ class TestCertMgr < Test::Unit::TestCase def test_interactiveca ca = nil - Puppet[:ssldir] = "/tmp/puppetinteractivecatest" - @@tmpfiles << Puppet[:ssldir] assert_nothing_raised { ca = Puppet::SSLCertificates::CA.new |