[Spacewalk-list] Errata Cloning Script

Andy Speagle andy.speagle at wichita.edu
Fri Sep 11 21:15:41 UTC 2009


On Wed, 2009-09-09 at 09:09 -0500, Tom Brown wrote:
> > I promised to post the script I adapted for cloning errata from RHN
> to
> > my Spacewalk server.  I'm sad to say that it's not a completed work
> at
> > this point, but does the basic things.  Some things that are missing
> > and/or are caveats:

Still caveats and changes.  Read on.

> > 1) Updating errata that affect another channel, should you add a
> channel
> > that might be affected by an existing errata.

This should work.  As of right now, you'll process errata from RHN one
RHN-channel at-a-time.  If you add a channel that has an erratum that
affects channels you had before... it should be trivial.  (See further
comments below).

> > 2) I've been a little lazy and have hard-coded my own RHN
> credentials in
> > the script, rather than asking the user for the info, passing it as
> an
> > argument, or reading it from a file.  I'll get around to it later.

I still haven't gotten around to it... I'm not sure I will.  It's
trivial to update the script with your data.

> > 3) I would avoid errata publishing for the time-being.  The
> > functionality exists in the script, but it's not right.  If you pull
> > down an errata that's for both RHEL 4 & 5 (for instance).. you'll
> end up
> > with RHEL 5 packages in your RHEL 4 channels.  I need to work this
> out.

Ok, I have come up with another method for dealing with automagic errata
publishing upon import. 

The problem, as I see it, is that the API has no way of "merging"
errata.  So, to effectively import errata from RHN and have it
meaningful for the appropriate channels, I've taken to breaking up each
erratum.  This avoids having packages meant for RHEL 5... "published"
into RHEL 4 channels.  For instance, if erratum RHSA:XXXX is relevant
for say both 64-bit RHEL 4 and RHEL 5, it will be broken up into
multiple individual errata.  The way I'm doing this on my system (and
it's configurable) is this:

RHEL 5 64-bit:  RHSA:XXXX:R5-64
RHEL 4 64-bit:  RHSA:XXXX:R4-64

Yes... this can potential create a ton of errata on your system, but to
ensure packages are automagically published to the appropriate channels,
this is the only method I could come up with quickly.  There may be a
way in the future to better handle this via the API, but right now, it
eludes me.

> > 4) This is my first attempt at anything with Python.. so it's
> probably
> > quite horrible.  I will be updating this as I develop more, not sure
> if
> > the Spacewalk maintainers want to add something like this to their
> list
> > of user-contributed scripts... but I'd be happy to maintain it
> there, if
> > so.

I continue to flounder.

> Hi Andy
> 
> Do you have any basic useage examples of this please?? eg
> 
> # python spw-clone-errata.py -l myuser -p mypass -c
> rhel-x86_64-server-5
> spw-clone-errata.py:31: DeprecationWarning: the sets module is
> deprecated
>   from sets import Set
> try: spw-clone-errata.py --help

First, I've removed the dependency on the old-n-busted "sets" module.

But, usage examples.  In the new script (attached), there are two
important maps that you as a user will need to configure, if you choose
to do this my way.

1)  Map RHN channel to Spacewalk (SPW) channel:  This map is simply a
python dictionary whose keys are the RHN channel labels and whose values
are YOUR SPW channel labels.  My SPW labels match almost identically the
RHN channels, so this was mostly meaningless for my setup, but I wanted
the user to be able to be more flexible.  What this does for you, is
when you give the script the variable [-c --src-channel], which is the
RHN channel from which you want to pull errata, the errata get mapped to
your SPW channel that corresponds.  For instance, in my setup:

        The RHN channel:  
        
        'rhel-x86_64-server-5' 
        
        is mapped to my SPW channel with the same label. Too easy. But,
        the RHN channel:
        
        'rhel-x86_64-as-4'
        
        is mapped to my SPW channel named:
        
        'rhel-x86_64-server-4'
        
2)  Map RHN channel to Errata suffix:  This map is another dictionary
whose keys are again the RHN channel labels and whose values are the
suffixes that I want added to the "advisory" value of each erratum.
This is as discussed above.  For instance:

        RHN channel:
        
        'rhel-x86_64-server-5'
        
        has this suffix mapped to it:
        
        'R5-64'
        
        Kinda straight-forward.  There may be many philosophical
        problems with this, but for now, until something in the API is
        changed (which I have no skill for), this is all I got.
        
So... usage case.  Let's discuss how I use Spacewalk with RHN.

1)  My goal is to have two sets of RHEL channels.  One set of "default"
channels which contain every package ever released in a given channel on
RHN, such as 'rhel-x86_64-server-5' .. The other set of channels are my
"production" channels to which I clone relevant errata (and therefore
package updates) from the "default" channels.  This gives me release
management control over packages via Spacewalk.  Servers are only
subscribed to "production" channels... as distros and kickstarts are
only based on "prod" channels.

2)  To do this, I am collecting the packages on my SPW server using
mrepo (quite handy) and using spacewalk-repo-sync to get them into my
channels.  This is all scheduled via cron.  (I need to work out some
notifications on nightly updates).  I'd like to find time to work on a
patch for the SPW devs that handles any local packages differently.  As
of now, I basically have package duplication on my system.  I pull the
packages from RHN into local yum repos on my SPW server and then sync
them into SPW, which copies them into the packages repository that SPW
uses... I'd like to fix it so that it handles anything pulled locally
(via file:// URLs) as links (sym or hard) rather than duplicating it.
Pie-in-the-sky.

3)  I'm just now finishing up development of this errata script, and I
should be ready to go.  To use this script, in my environment, I invoke
it like this:

# ./spw-clone-errata.py -s <server> -l <user> -p <pass> -c <RHN channel>
-u

Usage details:

# ./spw-clone-errata.py -h
usage: spw-clone-errata.py [options]

options:
  -h, --help            show this help message and exit
  -s SRC_SERVER, --spw-server=SRC_SERVER
                        Spacewalk Server (spacewalk.mydomain.org)
  -l LOGIN, --login=LOGIN
                        RHN Login
  -p PASSWD, --password=PASSWD
                        RHN password
  -c SRC_CHANNEL, --src-channel=SRC_CHANNEL
                        Source Channel Label: ie."rhel-x86_64-server-5"
  -b BDATE, --begin-date=BDATE
                        Beginning Date: ie. "19000101" (defaults to
                        "19000101")
  -e EDATE, --end-date=EDATE
                        Ending Date: ie. "19001231" (defaults to TODAY)
  -u, --publish         Publish Errata (into destination channels)
  -v, --verbose         
  -q, --quiet

-----

I've not quite completed the exact procedure for cloning these errata to
"production" channels... that's next.

Does this help at all?  New script is attached.

> thanks

Sure... hope this is helpful.
-- 
Andy Speagle

"THE Student" - UCATS
Wichita State University
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spw-clone-errata.py
Type: text/x-python
Size: 22659 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/spacewalk-list/attachments/20090911/074f9a8b/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://listman.redhat.com/archives/spacewalk-list/attachments/20090911/074f9a8b/attachment.sig>


More information about the Spacewalk-list mailing list