1 from types import StringTypes
3 from PLC.Faults import *
4 from PLC.Parameter import Parameter
5 from PLC.Table import Row, Table
6 from PLC.SliceAttributeTypes import SliceAttributeType, SliceAttributeTypes
8 class SliceAttribute(Row):
10 Representation of a row in the slice_attribute table. To use,
11 instantiate with a dict of values.
14 table_name = 'slice_attribute'
15 primary_key = 'slice_attribute_id'
17 'slice_attribute_id': Parameter(int, "Slice attribute identifier"),
18 'slice_id': Parameter(int, "Slice identifier"),
19 'node_id': Parameter(int, "Node identifier, if a sliver attribute"),
20 'attribute_type_id': SliceAttributeType.fields['attribute_type_id'],
21 'name': SliceAttributeType.fields['name'],
22 'description': SliceAttributeType.fields['description'],
23 'min_role_id': SliceAttributeType.fields['min_role_id'],
24 # XXX Arbitrary max, make configurable
25 'value': Parameter(str, "Slice attribute value", max = 254),
28 class SliceAttributes(Table):
30 Representation of row(s) from the slice_attribute table in the
34 def __init__(self, api, slice_attribute_id_list = None):
37 sql = "SELECT %s FROM view_slice_attributes" % \
38 ", ".join(SliceAttribute.fields)
40 if slice_attribute_id_list:
41 sql += " WHERE slice_attribute_id IN (%s)" % ", ".join(map(str, slice_attribute_id_list))
43 rows = self.api.db.selectall(sql)
46 self[row['slice_attribute_id']] = SliceAttribute(api, row)