# Path: opennsa/database.py
# LOG_SYSTEM = 'opennsa.Database'
#     DT = psycopg2.extensions.new_type((timestamptz_oid,), "timestamptz", castDatetime)
#     HASMANY = ['SubConnections']
#     BELONGSTO = ['ServiceConnection']
#     TABLENAME = 'stp_authz'
#     TABLENAME = 'backend_connection_id'
# def adaptLabel(label):
# def adaptSecuritAttribute(label):
# def adaptDatetime(dt):
#     def make(self, values):
#     def make(self, values):
# def castDatetime(value, cur):
# def setupDatabase(database, user, password=None, host=None, connection_id_start=None):
# def getBackendConnectionId():
#     def gotResult(rows):
# class LabelComposite(CompositeCaster):
# class SecuritAttributeComposite(CompositeCaster):
# class ServiceConnection(DBObject):
# class SubConnection(DBObject):
# class STPAuthz(DBObject):
# class BackendConnectionID(DBObject):
# 
# Path: opennsa/plugin.py
# class BasePlugin:
#     def init(self, cfg, ctx_factory):
#     def connectionRequest(self, header, connection_id, global_reservation_id, description, criteria):
#     def createConnectionId(self):
#     def prunePaths(self, paths):
#     def connectionCreated(self, connection):
#     def connectionTerminated(self, connection):


from zope.interface import implements
from twisted.internet import defer
from twisted.python import log
from opennsa import database, plugin
from opennsa.interface import IPlugin
"""
Plugin for Canarie specific behaviour in OpenNSA.

It creates connection ids to match the Canarie circuit id specification

Author: Henrik Thostrup Jensen < htj at nordu dot net >
Copyright: NORDUnet A/S (2017)
"""






LOG_SYSTEM = 'Canarie'


class CanariePlugin(plugin.BasePlugin):
    implements(IPlugin)

    @defer.inlineCallbacks
    def createConnectionId(self):
        """
        Create a Canarie service identifier for the connection.
        """

# Path: opennsa/database.py
# LOG_SYSTEM = 'opennsa.Database'
#     DT = psycopg2.extensions.new_type((timestamptz_oid,), "timestamptz", castDatetime)
#     HASMANY = ['SubConnections']
#     BELONGSTO = ['ServiceConnection']
#     TABLENAME = 'stp_authz'
#     TABLENAME = 'backend_connection_id'
# def adaptLabel(label):
# def adaptSecuritAttribute(label):
# def adaptDatetime(dt):
#     def make(self, values):
#     def make(self, values):
# def castDatetime(value, cur):
# def setupDatabase(database, user, password=None, host=None, connection_id_start=None):
# def getBackendConnectionId():
#     def gotResult(rows):
# class LabelComposite(CompositeCaster):
# class SecuritAttributeComposite(CompositeCaster):
# class ServiceConnection(DBObject):
# class SubConnection(DBObject):
# class STPAuthz(DBObject):
# class BackendConnectionID(DBObject):
# 
# Path: opennsa/plugin.py
# class BasePlugin:
#     def init(self, cfg, ctx_factory):
#     def connectionRequest(self, header, connection_id, global_reservation_id, description, criteria):
#     def createConnectionId(self):
#     def prunePaths(self, paths):
#     def connectionCreated(self, connection):
#     def connectionTerminated(self, connection):


# Path: opennsa/plugins/canarie.py
from zope.interface import implements
from twisted.internet import defer
from twisted.python import log
from opennsa import database, plugin
from opennsa.interface import IPlugin

"""
Plugin for Canarie specific behaviour in OpenNSA.

It creates connection ids to match the Canarie circuit id specification

Author: Henrik Thostrup Jensen < htj at nordu dot net >
Copyright: NORDUnet A/S (2017)
"""






LOG_SYSTEM = 'Canarie'


class CanariePlugin(plugin.BasePlugin):
    implements(IPlugin)

    @defer.inlineCallbacks
    def createConnectionId(self):
        """
        Create a Canarie service identifier for the connection.
        """

        unique_id = yield database.getBackendConnectionId()