2 # Thierry Parmentelat - INRIA
4 from PLC.Faults import *
5 from PLC.Parameter import Parameter
6 from PLC.Interfaces import Interface, Interfaces
7 from PLC.TagTypes import TagType, TagTypes
8 from PLC.Storage.AlchemyObject import AlchemyObj
10 class Ilink(AlchemyObj):
12 Representation of a row in the ilink table.
13 To use, instantiate with a dict of values.
18 'ilink_id': Parameter(int, "ilink identifier", primary_key=True),
19 'tag_type_id': TagType.fields['tag_type_id'],
20 'src_interface_id': Parameter(int, "source interface identifier"),
21 'dst_interface_id': Parameter(int, "destination interface identifier"),
22 'value': Parameter( str, "optional ilink value"),
25 def sync(self, insert=False, validate=True):
26 AlchemyObj.sync(self, commit, validate)
27 if 'ilink_id' in self:
28 AlchemyObj.insert(self, dict(self))
30 AlchemyObj.update(self, {'ilink_id': self['ilink_id']}, dict(self))
32 def delete(self, commit=True):
33 assert 'ilink_id' in self
34 AlchemyObj.delete(self, dict(self))
38 Representation of row(s) from the ilink table in the
42 def __init__(self, api, ilink_filter = None, columns = None):
44 ilinks = Ilink().select()
45 elif isinstance(ilink_filter, (list, tuple, set, int, long)):
46 ilinks = Ilink().select(filter={'ilink_id': ilink_filter})
47 elif isinstance(ilink_filter, dict):
48 ilink_filter = Ilink().select(filter=ilink_filter)
50 raise PLCInvalidArgument, "Wrong ilink filter %r"%ilink_filter