2 from PLC.Faults import *
3 from PLC.Parameter import Parameter
4 from PLC.Filter import Filter
5 from PLC.Table import Row, Table
6 # seems to cause import loops
7 #from PLC.Slices import Slice, Slices
8 from PLC.Nodes import Node, Nodes
9 from PLC.NodeGroups import NodeGroup, NodeGroups
10 from PLC.TagTypes import TagType, TagTypes
14 Representation of a row in the slice_tag table. To use,
15 instantiate with a dict of values.
18 table_name = 'slice_tag'
19 primary_key = 'slice_tag_id'
21 'slice_tag_id': Parameter(int, "Slice tag identifier"),
22 'slice_id': Parameter(int, "Slice identifier"),
23 'name': Parameter(str, "Slice name"),
24 'node_id': Node.fields['node_id'],
25 'nodegroup_id': NodeGroup.fields['nodegroup_id'],
26 'tag_type_id': TagType.fields['tag_type_id'],
27 'tagname': TagType.fields['tagname'],
28 'description': TagType.fields['description'],
29 'category': TagType.fields['category'],
30 'min_role_id': TagType.fields['min_role_id'],
31 'value': Parameter(str, "Slice attribute value"),
34 class SliceTags(Table):
36 Representation of row(s) from the slice_tag table in the
40 def __init__(self, api, slice_tag_filter = None, columns = None):
41 Table.__init__(self, api, SliceTag, columns)
43 sql = "SELECT %s FROM view_slice_tags WHERE True" % \
44 ", ".join(self.columns)
46 if slice_tag_filter is not None:
47 if isinstance(slice_tag_filter, (list, tuple, set)):
48 slice_tag_filter = Filter(SliceTag.fields, {'slice_tag_id': slice_tag_filter})
49 elif isinstance(slice_tag_filter, dict):
50 slice_tag_filter = Filter(SliceTag.fields, slice_tag_filter)
51 sql += " AND (%s) %s" % slice_tag_filter.sql(api)