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