Puppet: System Administration Automated

Support

Ticket #913 (new enhancement)

Opened 1 year ago

Last modified 9 months ago

up2date prefetching list of available packages

Reported by: jdreese Assigned to: community
Priority: normal Milestone:
Component: Red Hat Version:
Severity: normal Keywords: up2date
Cc: Triage Stage: Accepted
Attached Patches: Insufficient Complexity: Unknown

Description

It would be beneficial if up2date could prefetch the list of available packages so that it doesn't have to contact the Red Hat Network for every package specified in a manifest.

Attachments

up2datehelper.py (253 bytes) - added by jdreese on 11/20/07 15:13:23.
up2date helper that pulls a list of available packages from the Red Hat Network
up2date.patch (2.6 kB) - added by jdreese on 11/20/07 15:14:36.
patch for up2date provider that enables prefetching

Change History

11/20/07 15:13:23 changed by jdreese

  • attachment up2datehelper.py added.

up2date helper that pulls a list of available packages from the Red Hat Network

11/20/07 15:14:36 changed by jdreese

  • attachment up2date.patch added.

patch for up2date provider that enables prefetching

11/20/07 17:53:20 changed by luke

Urgh. This patch has caused me to look at the prefetching for yum, since it looks like you've just copied the model it uses. There's no reason to use the @updates class variable.

Something like the following should work just fine:

    def self.prefetch(packages)
        if Process.euid != 0
            raise Puppet::Error, "The yum provider can only be used as root"
        end
        super
        python(YUMHELPER).each_line do |l|
            l.chomp!
            next if l.empty?
            if l[0,4] == "_pkg"
                hash = nevra_to_hash(l[5..-1])
                [hash[:name], "#{hash[:name]}.#{hash[:arch]}"].each do |n|
                    if package = packages[n]
                        package.provider = new(hash)
                    end
                end
            end
        end
    end

Then the latest method just returns properties[:ensure], or whatever the attribute is for the value you want.

In other words, you replace the provider with a new provider that has the prefetched data.

In fact, if you look at the 'prefetch' method in lib/puppet/provider/package.rb, you'll see that the base class already does this, it just does it based on the 'instances' class method.

11/20/07 17:54:28 changed by luke

  • stage changed from Unreviewed to Accepted.
  • patch changed from Code to Insufficient.

11/21/07 03:06:32 changed by lutter

The reason the prefetch doesn't use instances or replace providers is that the rpm::instances method already lists all the currently _installed_ packages. The prefetch lists all the packages that are available as an update.

11/21/07 17:16:29 changed by luke

Ah, right; that makes sense. Don't you need to combine them in some way, though, so that you get both the current state and the latest available version?

04/24/08 07:57:14 changed by luke

  • component changed from library to Red Hat.