Rice University logo
Top blue bar image
A place to post stuff

Scripting RHN Re-activations

Here’s the situation: You’ve fixed something in your RHN Satellite activation key that should have been in there, or you’ve added functionality, but when you apply the change, you’d also like to apply those changes to machines that have already been registered with that activation key. Unfortunately, there’s no nice button to make that happen in the current version.

Hopefully you’ve been using system groups to keep track of machines deployed with your activation keys, because you’ll need to load that group into the system set manager and run a small python script one each machine as root. The idea is to re-register the machines to rhn, using each machine’s custom re-activation key to ensure that they reattach to their original system profile when you do so. Note: This will work if you’ve added something to the activation key, say a new config or software channel, but it won’t take away channels you want to remove.

Here’s the script:

    import xmlrpclib
    import sys
    import os
    import string

    system_id = "/etc/sysconfig/rhn/systemid"

    keys = sys.argv[1:]

    if os.path.exists(system_id):
        client =  xmlrpclib.Server("http://rhn.rice.edu/rpc/api")
except Exception as inst:
    # xml rpc due to  a old/bad system id
    print type(inst)
    print inst.args
    print inst
    print "Could not get reactivation key, exiting"
    command = "rhnreg_ks --force --activationkey=" + string.join(keys, ",")

Tags: ,

Comments are closed.