2 # Thierry Parmentelat - INRIA
4 from PLC.Faults import *
5 from PLC.Parameter import Parameter
6 from PLC.Filter import Filter
7 from PLC.Table import Row, Table
8 from PLC.Interfaces import Interface, Interfaces
9 from PLC.TagTypes import TagType, TagTypes
13 Representation of a row in the ilink table.
14 To use, instantiate with a dict of values.
18 primary_key = 'ilink_id'
20 'ilink_id': Parameter(int, "ilink identifier"),
21 'tag_type_id': TagType.fields['tag_type_id'],
22 'src_interface_id': Parameter(int, "source interface identifier"),
23 'dst_interface_id': Parameter(int, "destination interface identifier"),
24 'value': Parameter( str, "optional ilink value"),
29 Representation of row(s) from the ilink table in the
33 def __init__(self, api, ilink_filter = None, columns = None):
34 Table.__init__(self, api, Ilink, columns)
36 sql = "SELECT %s FROM view_ilinks WHERE True" % \
37 ", ".join(self.columns)
39 if ilink_filter is not None:
40 if isinstance(ilink_filter, (list, tuple, set, int, long)):
41 ilink_filter = Filter(Ilink.fields, {'ilink_id': ilink_filter})
42 elif isinstance(ilink_filter, dict):
43 ilink_filter = Filter(Ilink.fields, ilink_filter)
45 raise PLCInvalidArgument, "Wrong ilink filter %r"%ilink_filter
46 sql += " AND (%s) %s" % ilink_filter.sql(api)