From: Tony Mack Date: Sat, 9 Mar 2013 02:23:27 +0000 (-0500) Subject: adding new table definitions X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=5be88b7b2e442c1fc6f15a62f70fd2a355eb1240;p=plcapi.git adding new table definitions --- diff --git a/PLC/ConfFileNodes.py b/PLC/ConfFileNodes.py new file mode 100644 index 00000000..4c87fa00 --- /dev/null +++ b/PLC/ConfFileNodes.py @@ -0,0 +1,61 @@ +from types import StringTypes +import time +import re +import datetime + +from PLC.Faults import * +from PLC.Parameter import Parameter, Mixed +from PLC.Filter import Filter +from PLC.Debug import profile +from PLC.Timestamp import Timestamp +from PLC.Storage.AlchemyObject import AlchemyObj + +class ConfFileNode(AlchemyObj): + """ + Representation of a row in the conf_file_node table. To use, optionally + instantiate with a dict of values. Update as you would a + dict. Commit to the database with sync().To use, instantiate + with a dict of values. + """ + + tablename = 'conf_file_node' + + fields = { + 'conf_file_id': Parameter(int, "Conf file identifier", primary_key=True), + 'node_id': Parameter(int, "Node identifier", indexed=True), + } + + tags = {} + + def sync(self, commit = True, validate=True): + """ + Add the record + """ + AlchemyObj.sync(self, commit, validate) + AlchemyObj.insert(self, dict(self)) + + def delete(self, commit = True): + """ + Delete existing slice. + """ + AlchemyObj.delete(self, dict(self)) + + +class ConfFileNodes(list): + """ + Representation of row(s) from the conf_file_nodes table in the + database. + """ + + def __init__(self, api, filter = None, columns = None): + + # the view that we're selecting upon: start with view_slices + if not filter: + conf_file_nodes = ConfFileNode().select() + elif isinstance(filter, dict): + conf_file_nodes = ConfFileNode().select(filter=filter) + else: + raise PLCInvalidArgument, "Wrong conf_file_node filter %r"%filter + + for conf_file_node in conf_file_nodes: + self.append(ConfFileNode(api, object=conf_file_node)) diff --git a/PLC/PCUNodePorts.py b/PLC/PCUNodePorts.py new file mode 100644 index 00000000..f5910dd6 --- /dev/null +++ b/PLC/PCUNodePorts.py @@ -0,0 +1,62 @@ +from types import StringTypes +import time +import re +import datetime + +from PLC.Faults import * +from PLC.Parameter import Parameter, Mixed +from PLC.Filter import Filter +from PLC.Debug import profile +from PLC.Timestamp import Timestamp +from PLC.Storage.AlchemyObject import AlchemyObj + +class PCUNodePort(AlchemyObj): + """ + Representation of a row in the pcu_node_ports table. To use, optionally + instantiate with a dict of values. Update as you would a + dict. Commit to the database with sync().To use, instantiate + with a dict of values. + """ + + tablename = 'pcu_node_port' + + fields = { + 'pcu_id': Parameter(int, "PCU identifier", primary_key=True), + 'node_id': Parameter(int, "Node identifier", primary_key=True), + 'port': Parameter(int, "port", indexed=True), + } + + tags = {} + + def sync(self, commit = True, validate=True): + """ + Add the record + """ + AlchemyObj.sync(self, commit, validate) + AlchemyObj.insert(self, dict(self)) + + def delete(self, commit = True): + """ + Delete existing slice. + """ + AlchemyObj.delete(self, dict(self)) + + +class PCUNodePorts(list): + """ + Representation of row(s) from the pcu_node_port table in the + database. + """ + + def __init__(self, api, filter = None, columns = None): + + # the view that we're selecting upon: start with view_slices + if not filter: + pcu_node_ports = PCUNodePort().select() + elif isinstance(filter, dict): + pcu_node_ports = PCUNodePort().select(filter=filter) + else: + raise PLCInvalidArgument, "Wrong pcu_node_port filter %r"%filter + + for pcu_node_port in pcu_node_ports: + self.append(PCUNodePort(api, object=pcu_node_port)) diff --git a/PLC/PCUNodes.py b/PLC/PCUNodes.py new file mode 100644 index 00000000..719dfd2d --- /dev/null +++ b/PLC/PCUNodes.py @@ -0,0 +1,61 @@ +from types import StringTypes +import time +import re +import datetime + +from PLC.Faults import * +from PLC.Parameter import Parameter, Mixed +from PLC.Filter import Filter +from PLC.Debug import profile +from PLC.Timestamp import Timestamp +from PLC.Storage.AlchemyObject import AlchemyObj + +class PCUNode(AlchemyObj): + """ + Representation of a row in the pcu_node table. To use, optionally + instantiate with a dict of values. Update as you would a + dict. Commit to the database with sync().To use, instantiate + with a dict of values. + """ + + tablename = 'pcu_node' + + fields = { + 'pcu_id': Parameter(int, "PCU identifier", primary_key=True), + 'node_id': Parameter(int, "Node identifier", indexed=True), + } + + tags = {} + + def sync(self, commit = True, validate=True): + """ + Add the record + """ + AlchemyObj.sync(self, commit, validate) + AlchemyObj.insert(self, dict(self)) + + def delete(self, commit = True): + """ + Delete existing slice. + """ + AlchemyObj.delete(self, dict(self)) + + +class PCUNodes(list): + """ + Representation of row(s) from the slices table in the + database. + """ + + def __init__(self, api, filter = None, columns = None): + + # the view that we're selecting upon: start with view_slices + if not filter: + pcu_nodes = PCUNode().select() + elif isinstance(filter, dict): + pcu_nodes = PCUNode().select(filter=filter) + else: + raise PLCInvalidArgument, "Wrong pcu_node filter %r"%filter + + for pcu_node in pcu_nodes: + self.append(PCUNode(api, object=pcu_node)) diff --git a/PLC/SliceNodeWhitelists.py b/PLC/SliceNodeWhitelists.py new file mode 100644 index 00000000..5eb1d3fb --- /dev/null +++ b/PLC/SliceNodeWhitelists.py @@ -0,0 +1,61 @@ +from types import StringTypes +import time +import re +import datetime + +from PLC.Faults import * +from PLC.Parameter import Parameter, Mixed +from PLC.Filter import Filter +from PLC.Debug import profile +from PLC.Timestamp import Timestamp +from PLC.Storage.AlchemyObject import AlchemyObj + +class SliceNodeWhitelist(AlchemyObj): + """ + Representation of a row in the slice_node_whitelist table. To use, optionally + instantiate with a dict of values. Update as you would a + dict. Commit to the database with sync().To use, instantiate + with a dict of values. + """ + + tablename = 'slice_node_whitelist' + + fields = { + 'slice_id': Parameter(int, "Slice identifier", primary_key=True), + 'node_id': Parameter(int, "Node identifier", indexed=True), + } + + tags = {} + + def sync(self, commit = True, validate=True): + """ + Add the record + """ + AlchemyObj.sync(self, commit, validate) + AlchemyObj.insert(self, dict(self)) + + def delete(self, commit = True): + """ + Delete existing slice. + """ + AlchemyObj.delete(self, dict(self)) + + +class SliceNodeWhitelists(list): + """ + Representation of row(s) from the slice_node_whitelist table in the + database. + """ + + def __init__(self, api, filter = None, columns = None): + + # the view that we're selecting upon: start with view_slices + if not filter: + slice_node_whitelist = SliceNodeWhitelist().select() + elif isinstance(filter, dict): + slices_node_whitelist = SliceNodeWhitelist().select(filter=filter) + else: + raise PLCInvalidArgument, "Wrong slice_node_whitelist filter %r"%filter + + for slice_node in slice_node_whitelist: + self.append(SliceNodeWhitelist(api, object=slice_node))