In Satellite, I've written a script to do that for all the "Show differences 
..." actions.  It takes completed and failed actions, moves them to archived 
actions, then deletes them from archived actions.

It can easily be adjusted to purge a wider range of actions, and probably to 
accommodate the age of the items.

It archives/purges 500 items at a time until they are all done.

Including it as a .txt, but it's written in Python.


> -----Original Message-----
> From: [email protected] [mailto:spacewalk-list-
> [email protected]] On Behalf Of Paul Robert Marino
> Sent: Thursday, May 01, 2014 1:02 PM
> To: [email protected]
> Subject: Re: [Spacewalk-list] Is there a native function in spacewalk for
> archiving and then deleting old "actions"
> 
> As far as I know no there isn't but it may be possible to use the
> API's to do that.
> 
> On Thu, May 1, 2014 at 12:33 PM, Andy Ingham <[email protected]> wrote:
> > The process of manually "archiving" old actions and then deleting them
> > (via the GUI) is very tedious.
> >
> > Is there a built-in way to have then cycle from "completed" (at least) to
> > "archived" when they reach X days/weeks/months old.  Similarly, is there a
> > native way of having archived actions older than X months "deleted"?
> >
> > Just want to make sure I'm not missing an easy way to do this before
> > trying to roll something on my own.
> >
> > Thanks!
> >
> > Andy
> >
> > Andy Ingham
> > IT Infrastructure
> > Fuqua School of Business
> > Duke University
> >
> >
> >
> >
> > _______________________________________________
> > Spacewalk-list mailing list
> > [email protected]
> > https://www.redhat.com/mailman/listinfo/spacewalk-list
> 
> _______________________________________________
> Spacewalk-list mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/spacewalk-list
#!/bin/env python
'''
Delete completed jobs.  In this case, the only jobs we delete are:
-jobs that show differences between config files are on Satellite as opposed to 
what is on the client.
 They litter the list of completed jobs.
We can expand this to allow the user the option of only archiving, but for now 
it processes a 
specific set of jobs, so there is no need to do that.
It purges 500 jobs at a time.
'''

import sys

def purgeJobs(client,key,purgeList,purgeType):
    if purgeType == "archive":
        print "Moving items to archive..."
        arch_result = client.schedule.archiveActions(key,purgeList)
    elif purgeType == "delete":
        print "Deleting items..."
        arch_result = client.schedule.deleteActions(key,purgeList)
    else:
        print "Unknown action %s" % purgeType
        sys.exit(1)

    if arch_result == 1:
        return
    else:
        print "Error performing '%s' on selected items" % purgeType
        sys.exit(1)

def main():
    # before we can delete a job we must archive it
    # first, purge from the list of completed actions
    purgelist = []
    completedList = client.schedule.listCompletedActions(key)
    for item in completedList:
        if "differences" in item['name'] and item['inProgressSystems'] == 0:
            print "Adding job %s to list" % item['id']
            purgelist.append(item['id'])
            if len(purgelist) > 500:
                purgeJobs(client,key,purgelist,"archive")
                purgelist = []
    # also purge from the list of failed actions
    failedList = client.schedule.listFailedActions(key)
    for item in failedList:
        if "differences" in item['name'] and item['inProgressSystems'] == 0:
            print "Adding job %s to list" % item['id']
            purgelist.append(item['id'])
            if len(purgelist) > 500:
                purgeJobs(client,key,purgelist,"archive")
                purgelist = []
    if len(purgelist) > 0:
        purgeJobs(client,key,purgelist,"archive")

    archiveList = client.schedule.listArchivedActions(key)
    purgelist = []
    for item in archiveList:
        if "differences" in item['name'] and item['inProgressSystems'] == 0:
            print "Adding item %s to list" % item['id']
            purgelist.append(item['id'])
            if len(purgelist) > 500:
                purgeJobs(client,key,purgelist,"delete")
                purgelist = []
    if len(purgelist) > 0:
        purgeJobs(client,key,purgelist,"delete")
    return

# Login to Satellite, define "client" and "key"
# client = 
# key = 

if __name__ == "__main__":
    main()
    client.auth.logout(key)

_______________________________________________
Spacewalk-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-list

Reply via email to