Managing the - Actions - database
I have inherited a fairly seasoned Satellite environment which runs rather well.
Lately I have been doing some regression testing and validation and attempting to use the output under Schedule | Actions.
Unfortunately I do not believe that anyone has ever archived (nor deleted) a single event in the history of the server and the number of events are over 100,000 ! When I try to "Select All" my Satellite appears to hang and then I get a JVM core.
Does anyone know of a way to use the API to manage the events? Namely to archive then delete these events.
Thanks in advance for any advice!
Responses
Yes there are APIs available to list, archive and delete actions. List of API's which you can use to list, archive and delete the actions can been seen by going to http://your-satellite-fqdn/rhn/apidoc/handlers/ScheduleHandler.jsp
So in short APIs that you might want to use are :
- listAllActions
- archiveActions
- listArchivedActions
- deleteActions
This feature and APIs were recently release under errata http://rhn.redhat.com/errata/RHBA-2013-0583.html . Do ensure this or latest errata is installed on your satellite.
Paresh
On RHN Satellite, running a SQL query against the DB and deleting records is not recommend and not supported. Instead I will try to help you with the python code.
Here is the example of how you can use API to delete the actions.
list = client.schedule.listArchivedActions(key)
action_ids=[]
for action in list:
action_ids.append(action['id'])del_result=client.schedule.deleteActions(key,action_ids)
Let me know if this helps you get started.
Paresh
In addtion to deleteAction, here is an example to archive failed, completed actions and then delete all archived actions.
#archive all Failed Actions
failed_list = client.schedule.listFailedActions(key)
action_ids=[]
for action in failed_list:
action_ids.append(action['id'])archive_result=client.schedule.archiveActions(key,action_ids)
#archive all Completed Actions
completed_list = client.schedule.listCompletedActions(key)
action_ids=[]
for action in completed_list:
action_ids.append(action['id'])archive_result=client.schedule.archiveActions(key,action_ids)
#delete all Archived Actions
archived_list = client.schedule.listArchivedActions(key)
action_ids=[]
for action in archived_list:
action_ids.append(action['id'])del_result=client.schedule.deleteActions(key,action_ids)
Hope this helps.
Paresh
Good to know. I assume your modified script helped you clean up the archived actions. On one of my test satellites I had around ~5000 archived actions. I didn't have to limit the deletion, all of them deleted in a single api call. You might want to increase the counter from 20/30 to 1000's and see how it goes.
Paresh
Hmmm I am getting an error with this.
Deleting all Failed Actions
Archiving all Completed Actions
Traceback (most recent call last):
File "./deleteactions.py", line 33, in ?
archived_list = client.schedule.listCompletedActions(key)
File "/usr/lib64/python2.4/xmlrpclib.py", line 1096, in __call__
return self.__send(self.__name, args)
File "/usr/lib64/python2.4/xmlrpclib.py", line 1383, in __request
verbose=self.__verbose
File "/usr/lib64/python2.4/xmlrpclib.py", line 1147, in request
return self._parse_response(h.getfile(), sock)
File "/usr/lib64/python2.4/xmlrpclib.py", line 1286, in _parse_response
return u.close()
File "/usr/lib64/python2.4/xmlrpclib.py", line 744, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault -1: 'redstone.xmlrpc.XmlRpcFault: unhandled internal exception: null'>
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
