Removing Events
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Tue, 2 Oct 2012 00:20:22 +0000 (20:20 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Tue, 2 Oct 2012 00:20:22 +0000 (20:20 -0400)
PLC/EventObjects.py [deleted file]
PLC/Events.py [deleted file]
PLC/Methods/GetEventObjects.py [deleted file]
PLC/Methods/GetEvents.py [deleted file]

diff --git a/PLC/EventObjects.py b/PLC/EventObjects.py
deleted file mode 100644 (file)
index 5f046bf..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#
-# Functions for interacting with the events table in the database
-#
-# Tony Mack <tmack@cs.princeton.edu>
-# Copyright (C) 2006 The Trustees of Princeton University
-#
-
-from PLC.Faults import *
-from PLC.Parameter import Parameter
-from PLC.Filter import Filter
-from PLC.Debug import profile
-from PLC.Table import Row, Table
-
-class EventObject(Row):
-    """
-    Representation of a row in the event_object table.
-    """
-
-    table_name = 'event_object'
-    primary_key = 'event_id'
-    fields = {
-        'event_id': Parameter(int, "Event identifier"),
-        'person_id': Parameter(int, "Identifier of person responsible for event, if any"),
-        'node_id': Parameter(int, "Identifier of node responsible for event, if any"),
-        'fault_code': Parameter(int, "Event fault code"),
-        'call_name': Parameter(str, "Call responsible for this event"),
-        'call': Parameter(str, "Call responsible for this event, including paramters"),
-        'message': Parameter(str, "High level description of this event"),
-        'runtime': Parameter(float, "Runtime of event"),
-        'time': Parameter(int, "Date and time that the event took place, in seconds since UNIX epoch", ro = True),
-        'object_id': Parameter(int, "ID of objects affected by this event"),
-        'object_type': Parameter(str, "What type of object is this event affecting")
-        }
-
-class EventObjects(Table):
-    """
-    Representation of row(s) from the event_object table in the database.
-    """
-
-    def __init__(self, api, event_filter = None, columns = None):
-        Table.__init__(self, api, EventObject, columns)
-
-        sql = "SELECT %s FROM view_event_objects WHERE True" % \
-            ", ".join(self.columns)
-
-        if event_filter is not None:
-            if isinstance(event_filter, (list, tuple, set, int, long)):
-                event_filter = Filter(EventObject.fields, {'event_id': event_filter})
-                sql += " AND (%s) %s" % event_filter.sql(api, "OR")
-            elif isinstance(event_filter, dict):
-                event_filter = Filter(EventObject.fields, event_filter)
-                sql += " AND (%s) %s" % event_filter.sql(api, "AND")
-            else:
-                raise PLCInvalidArgument, "Wrong event object filter %r"%event_filter
-
-        self.selectall(sql)
diff --git a/PLC/Events.py b/PLC/Events.py
deleted file mode 100644 (file)
index cb5d0e2..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#
-# Functions for interacting with the events table in the database
-#
-# Tony Mack <tmack@cs.princeton.edu>
-# Copyright (C) 2006 The Trustees of Princeton University
-#
-
-from PLC.Faults import *
-from PLC.Parameter import Parameter
-from PLC.Filter import Filter
-from PLC.Debug import profile
-from PLC.Table import Row, Table
-
-class Event(Row):
-    """
-    Representation of a row in the events table.
-    """
-
-    table_name = 'events'
-    primary_key = 'event_id'
-    fields = {
-        'event_id': Parameter(int, "Event identifier"),
-        'person_id': Parameter(int, "Identifier of person responsible for event, if any"),
-        'node_id': Parameter(int, "Identifier of node responsible for event, if any"),
-        'auth_type': Parameter(int, "Type of auth used. i.e. AuthMethod"),
-        'fault_code': Parameter(int, "Event fault code"),
-        'call_name': Parameter(str, "Call responsible for this event"),
-        'call': Parameter(str, "Call responsible for this event, including paramters"),
-        'message': Parameter(str, "High level description of this event"),
-        'runtime': Parameter(float, "Runtime of event"),
-        'time': Parameter(int, "Date and time that the event took place, in seconds since UNIX epoch", ro = True),
-        'object_ids': Parameter([int], "IDs of objects affected by this event"),
-        'object_types': Parameter([str], "What type of object were affected by this event")
-        }
-
-    def add_object(self, object_type, object_id, commit = True):
-        """
-        Relate object to this event.
-        """
-
-        assert 'event_id' in self
-
-        event_id = self['event_id']
-
-        if 'object_ids' not in self:
-            self['object_ids'] = []
-
-        if object_id not in self['object_ids']:
-            self.api.db.do("INSERT INTO event_object (event_id, object_id, object_type)" \
-                           " VALUES(%(event_id)d, %(object_id)d, %(object_type)s)",
-                           locals())
-
-            if commit:
-                self.api.db.commit()
-
-            self['object_ids'].append(object_id)
-
-class Events(Table):
-    """
-    Representation of row(s) from the events table in the database.
-    """
-
-    def __init__(self, api, event_filter = None, columns = None):
-        Table.__init__(self, api, Event, columns)
-
-        sql = "SELECT %s FROM view_events WHERE True" % \
-              ", ".join(self.columns)
-
-        if event_filter is not None:
-            if isinstance(event_filter, (list, tuple, set, int, long)):
-                event_filter = Filter(Event.fields, {'event_id': event_filter})
-            elif isinstance(event_filter, dict):
-                event_filter = Filter(Event.fields, event_filter)
-            else:
-                raise PLCInvalidArgument, "Wrong event object filter %r"%event_filter
-            sql += " AND (%s) %s" % event_filter.sql(api)
-        self.selectall(sql)
diff --git a/PLC/Methods/GetEventObjects.py b/PLC/Methods/GetEventObjects.py
deleted file mode 100644 (file)
index c71c257..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-from PLC.Faults import *
-from PLC.Method import Method
-from PLC.Parameter import Parameter, Mixed
-from PLC.Filter import Filter
-from PLC.EventObjects import EventObject, EventObjects
-from PLC.Auth import Auth
-
-class GetEventObjects(Method):
-    """
-    Returns an array of structs containing details about events and
-    faults. If event_filter is specified and is an array of event
-    identifiers, or a struct of event attributes, only events matching
-    the filter will be returned. If return_fields is specified, only the
-    specified details will be returned.
-    """
-
-    roles = ['admin']
-
-    accepts = [
-        Auth(),
-        Mixed(Filter(EventObject.fields)),
-        Parameter([str], "List of fields to return", nullok = True)
-        ]
-
-    returns = [EventObject.fields]
-
-    def call(self, auth, event_filter = None, return_fields = None):
-        return EventObjects(self.api, event_filter, return_fields)
diff --git a/PLC/Methods/GetEvents.py b/PLC/Methods/GetEvents.py
deleted file mode 100644 (file)
index 4fbb451..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-from PLC.Faults import *
-from PLC.Method import Method
-from PLC.Parameter import Parameter, Mixed
-from PLC.Filter import Filter
-from PLC.Events import Event, Events
-from PLC.Auth import Auth
-
-class GetEvents(Method):
-    """
-    Returns an array of structs containing details about events and
-    faults. If event_filter is specified and is an array of event
-    identifiers, or a struct of event attributes, only events matching
-    the filter will be returned. If return_fields is specified, only the
-    specified details will be returned.
-    """
-
-    roles = ['admin']
-
-    accepts = [
-        Auth(),
-        Mixed([Event.fields['event_id']],
-              Filter(Event.fields)),
-        Parameter([str], "List of fields to return", nullok = True)
-        ]
-
-    returns = [Event.fields]
-
-    def call(self, auth, event_filter = None, return_fields = None):
-        return Events(self.api, event_filter, return_fields)