arsa - archiving/deleting old Red Hat Satellite actions
Hi folks,
I just developed a little Python script for archiving and deleting old Red Hat Satellite actions.
As you might know everything you trigger using the WebUI is registered as an action - if you're maintaining a bigger system landscape you might end up in a long list of completed/archived actions after a couple of days. I'm not very familiar with the database design of Red Hat Satellite but I think it's basically a good idea to clean this stuff up sometimes.
I couldn't find a "delete all actions" button in the WebUI and so I decided to create a tiny script for this after reading the Spacewalk API
The script is called arsa (archive Spacewalk actions) and is also compatible with Spacewalk and SUSE Manager.
It can be downloaded on GitHub.
Authentication information can be provided in multiple ways. By default the script prompts for username and password.
If you need to automate this you can assign two shell variables:
- SPACEWALK_LOGIN - a username
- SPACEWALK_PASSWORD - the appropriate password
Another (and more secure) possibility is to create an "authfile" and pass this file to the script (-a / --authfile). This file needs to have two lines containing the username (first line) and the password (second line). You will also have to set the file permissions to 0600.
Per default the script uses localhost as hostname for logging in. You can also change this behaviour (-s / --server).
Some examples:
Listing all completed actions (login information are prompted):
$ ./arsa.py -l Username: mylogin Password: things I'd like to clean (completed): ------------------------------------- action #1494 ('Remote Command on mymachine.localdomain.loc.')
Removing all completed and archived actions (login information are provided using shell variables):
$ SATELLITE_LOGIN=mylogin SATELLITE_PASSWORD=mypass ./arsa.py -r Archving action #1494 ('Remote Command on mymachine.localdomain.loc.')... Deleting action #1494 ('Remote Command on mymachine.localdomain.loc.')... Deleting action #1493 ('Remote Command on myothermachine.localdomain.loc.')...
Additional parameters can be found in the integrated help:
$ ./arsa.py -h Usage: arsa.py [options] arsa.py is used to archive completed actions and remove archived actions on Spacewalk, Red Hat Satellite and SUSE Manager. Login credentials are assigned using the following shell variables: SATELLITE_LOGIN username SATELLITE_PASSWORD password It is also possible to create an authfile (permissions 0600) for usage with this script. The first line needs to contain the username, the second line should consist of the appropriate password. If you're not defining variables or an authfile you will be prompted to enter your login information. Checkout the GitHub page for updates: https://github.com/stdevel/arsa Options: --version show program's version number and exit -h, --help show this help message and exit -a FILE, --authfile=FILE defines an auth file to use instead of shell variables -s SERVER, --server=SERVER defines the server to use -q, --quiet don't print status messages to stdout -d, --debug enable debugging outputs -r, --remove archives completed actions and removes all archived actions -l, --list-only only lists actions that would be archived
Maybe this helps somebody here - I use this script inside a cronjob to regularly clean-up old actions.
Best regards,
Christian!
Responses