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