Package pulp :: Package server :: Module auditing
[hide private]
[frames] | no frames]

Module auditing

source code

Classes [hide private]
  MethodInspector
Class for method inspection.
Functions [hide private]
 
audit(params=None, record_result=False)
API class instance method decorator meant to log calls that constitute events on pulp's model instances.
source code
 
events(spec=None, fields=None, limit=None, errors_only=False)
Query function that returns events according to the pymongo spec.
source code
 
events_on_api(api, fields=None, limit=None, errors_only=False)
Return all recorded events for a given api.
source code
 
events_by_principal(principal, fields=None, limit=None, errors_only=False)
Return all recorded events for a given principal (caller).
source code
 
events_in_datetime_range(lower_bound=None, upper_bound=None, fields=None, limit=None, errors_only=False)
Return all events in a given time range.
source code
 
events_since_delta(delta, fields=None, limit=None, errors_only=False)
Return all the events that occurred in the last time delta from now.
source code
 
cull_events(delta)
Reaper function that removes all events older than the passed in time delta from the database.
source code
 
_check_crontab()
Check to see that the cull auditing events crontab entry exists, and add it if it doesn't.
source code
 
_clear_crontab()
Check to see that the cull auditing events crontab entry exists, and remove it if it does.
source code
 
_get_lifetime()
Get the configured auditing lifeteime as a datetime.timedelta instance.
source code
Variables [hide private]
  _objdb = get_object_db('events', ['id'], ['timestamp', 'princi...
  _log = logging.getLogger('auditing')
Function Details [hide private]

audit(params=None, record_result=False)

source code 

API class instance method decorator meant to log calls that constitute events on pulp's model instances. Any call to a decorated method will both record the event in the database and log it to a special log file.

A decorated method may have an optional keyword argument, 'principal', passed in that represents the user or other entity making the call. This optional keyword argument is not passed to the underlying method, unless the pass_principal flag is True.

Parameters:
  • params (list or tuple of str's or None) - list of names of parameters to record the values of, None records all parameters
  • record_result (bool) - whether or not to record the result

events(spec=None, fields=None, limit=None, errors_only=False)

source code 

Query function that returns events according to the pymongo spec. The results are sorted by timestamp into descending order.

Parameters:
  • spec (dict or pymongo.son.SON instance) - pymongo spec for filtering events
  • fields (list or tuple of str) - iterable of fields to include from each document
  • limit (int or None) - limit the number of results, None means no limit
  • errors_only (bool) - if True, only return events that match the spec and have an exception associated with them, otherwise return all events that match spec
Returns:
list of events containing fields and matching spec

events_on_api(api, fields=None, limit=None, errors_only=False)

source code 

Return all recorded events for a given api.

Parameters:
  • api (str) - name of the api
  • fields (list or tuple of str) - iterable of fields to include from each document
  • limit (int or None) - limit the number of results, None means no limit
  • errors_only (bool) - if True, only return events that match the spec and have an exception associated with them, otherwise return all events that match spec
Returns:
list of events for the given api containing fields

events_by_principal(principal, fields=None, limit=None, errors_only=False)

source code 

Return all recorded events for a given principal (caller).

Parameters:
  • principal (model object or dict) - principal that triggered the event (i.e. User instance)
  • fields (list or tuple of str) - iterable of fields to include from each document
  • limit (int or None) - limit the number of results, None means no limit
  • errors_only (bool) - if True, only return events that match the spec and have an exception associated with them, otherwise return all events that match spec
Returns:
list of events for the given principal containing fields

events_in_datetime_range(lower_bound=None, upper_bound=None, fields=None, limit=None, errors_only=False)

source code 

Return all events in a given time range.

Parameters:
  • lower_bound (datetime.datetime instance or None) - lower time bound, None = oldest in db
  • fields (list or tuple of str) - iterable of fields to include from each document
  • limit (int or None) - limit the number of results, None means no limit
  • errors_only (bool) - if True, only return events that match the spec and have an exception associated with them, otherwise return all events that match spec
Returns:
list of events in the given time range containing fields

events_since_delta(delta, fields=None, limit=None, errors_only=False)

source code 

Return all the events that occurred in the last time delta from now.

Parameters:
  • delta (datetime.timedelta instance) - length of time frame to return events from
  • fields (list or tuple of str) - iterable of fields to include from each document
  • limit (int or None) - limit the number of results, None means no limit
  • errors_only (bool) - if True, only return events that match the spec and have an exception associated with them, otherwise return all events that match spec
Returns:
list of events in the given length of time containing fields

cull_events(delta)

source code 

Reaper function that removes all events older than the passed in time delta from the database.

Parameters:
  • delta (dateteime.timedelta instance or None) - length of time from current time to keep events, None means don't keep any events
Returns:
the number of events removed from the database

_get_lifetime()

source code 

Get the configured auditing lifeteime as a datetime.timedelta instance.

Returns:
dateteime.timedelta instance

Variables Details [hide private]

_objdb

Value:
get_object_db('events', ['id'], ['timestamp', 'principal', 'api'])