I could observe that yumhelper.py can run quite some time
and use quite a lot of memory (up to 100MB!) if you're
using many repositories. As the yumhelper is only needed
if you use latest as a ensure-keyword it makes no sense
for people like me letting puppet fetch these details
always, if you're never going to use latest. Therefor this
patch changes the behaviour, that the yumhelper is only
called, if @updates is accessed the first time.
=> lazy loading.
Signed-off-by: duritong <[EMAIL PROTECTED]>
---
lib/puppet/provider/package/yum.rb | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/lib/puppet/provider/package/yum.rb
b/lib/puppet/provider/package/yum.rb
index 7998b92..03bb3d5 100755
--- a/lib/puppet/provider/package/yum.rb
+++ b/lib/puppet/provider/package/yum.rb
@@ -7,10 +7,6 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm,
:source => :rpm do
YUMHELPER = File::join(File::dirname(__FILE__), "yumhelper.py")
- class << self
- attr_reader :updates
- end
-
if command('rpm')
confine :true => begin
rpm('--version')
@@ -24,11 +20,14 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm,
:source => :rpm do
defaultfor :operatingsystem => [:fedora, :centos, :redhat]
def self.prefetch(packages)
- @updates = {}
if Process.euid != 0
raise Puppet::Error, "The yum provider can only be used as root"
end
super
+ end
+
+ def self.fetch_yumlatest
+ @updates = {}
python(YUMHELPER).each_line do |l|
l.chomp!
next if l.empty?
@@ -42,6 +41,11 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm,
:source => :rpm do
end
end
+ def self.updates
+ self.fetch_yumlatest unless defined? @updates
+ @updates
+ end
+
def install
should = @resource.should(:ensure)
self.debug "Ensuring => #{should}"
--
1.5.5.1
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---