# Path: opennsa/constants.py
# URN_OGF_PREFIX      = 'urn:ogf:network:'
# CS2_SERVICE_TYPE    = 'application/vnd.org.ogf.nsi.cs.v2+soap'
# NML_SERVICE_TYPE    = 'application/vnd.ogf.nsi.topology.v2+xml'
# CS2_REQUESTER       = 'application/vnd.ogf.nsi.cs.v2.requester+soap'
# CS2_PROVIDER        = 'application/vnd.ogf.nsi.cs.v2.provider+soap'
# OPENNSA_REST        = 'application/vnd.net.nordu.opennsa+rest'
# BIDIRECTIONAL       = 'Bidirectional'
# EVTS_AGOLE          = 'http://services.ogf.org/nsi/2013/07/descriptions/EVTS.A-GOLE'
# ETHERNET            = 'ethernet' # bidirectional implied
# ETHERNET_VLAN       = 'vlan'
# MPLS                = 'mpls'
# RESTRICTTRANSIT     = 'restricttransit'
# ETHERNET_NS         = 'http://schemas.ogf.org/nml/2012/10/ethernet'
# NML_ETHERNET_VLAN   = '%s#vlan' % ETHERNET_NS
# NML_MPLS            = 'http://nsi.nordu.net/nml#mpls' # pretty much just made up
# FEATURE_AGGREGATOR  = 'vnd.ogf.nsi.cs.v2.role.aggregator'
# FEATURE_UPA         = 'vnd.ogf.nsi.cs.v2.role.uPA'
# REQUIRE_USER        = 'requireuser'
# REQUIRE_TRACE       = 'requiretrace'
# AGGREGATOR          = 'aggregator'
# ALLOW_HAIRPIN       = 'allowhairpin'
# 
# Path: opennsa/backends/common/genericbackend.py
# class GenericBackendConnections(DBObject):
# class GenericBackend(service.Service):
#     TPC_TIMEOUT = 120 # seconds
#     def __init__(self, network, nrm_ports, connection_manager, parent_requester, log_system, minimum_duration=60):
#     def startService(self):
#     def stopService(self):
#     def getNotificationId(self):
#     def buildSchedule(self):
#     def _getConnection(self, connection_id, requester_nsa):
#     def _authorize(self, source_port, destination_port, header, request_info, start_time=None, end_time=None):
#     def logStateUpdate(self, conn, state_msg):
#     def reserve(self, header, connection_id, global_reservation_id, description, criteria, request_info=None):
#     def reserveCommit(self, header, connection_id, request_info=None):
#     def reserveAbort(self, header, connection_id, request_info=None):
#     def provision(self, header, connection_id, request_info=None):
#     def release(self, header, connection_id, request_info=None):
#     def terminate(self, header, connection_id, request_info=None):
#     def querySummary(self, header, connection_ids=None, global_reservation_ids=None, request_info=None):
#     def queryRecursive(self, header, connection_ids, global_reservation_ids, request_info=None):
#     def _query(self, header, connection_ids, global_reservation_ids, request_info=None):
#     def queryNotification(self, header, connection_id, start_notification=None, end_notification=None):
#     def _doReserve(self, conn, correlation_id):
#     def _doReserveTimeout(self, conn):
#     def _doReserveRollback(self, conn):
#     def _doActivate(self, conn):
#     def _doTeardown(self, conn):
#     def _doEndtime(self, conn):
#     def _doFreeResource(self, conn):


import string
import random
from twisted.python import log
from twisted.internet import defer
from opennsa import constants as cnt
from opennsa.backends.common import genericbackend
"""
NRM backends which just logs actions performed.

Author: Henrik Thostrup Jensen <htj@nordu.net>
Copyright: NORDUnet (2011)
"""






def DUDNSIBackend(network_name, nrm_ports, parent_requester, configuration):

    name = 'DUD NRM %s' % network_name
    nrm_map  = dict( [ (p.name, p) for p in nrm_ports ] ) # for the generic backend
    port_map = dict( [ (p.name, p.interface) for p in nrm_ports ] ) # for the nrm backend

    cm = DUDConnectionManager(name, port_map)

# Path: opennsa/constants.py
# URN_OGF_PREFIX      = 'urn:ogf:network:'
# CS2_SERVICE_TYPE    = 'application/vnd.org.ogf.nsi.cs.v2+soap'
# NML_SERVICE_TYPE    = 'application/vnd.ogf.nsi.topology.v2+xml'
# CS2_REQUESTER       = 'application/vnd.ogf.nsi.cs.v2.requester+soap'
# CS2_PROVIDER        = 'application/vnd.ogf.nsi.cs.v2.provider+soap'
# OPENNSA_REST        = 'application/vnd.net.nordu.opennsa+rest'
# BIDIRECTIONAL       = 'Bidirectional'
# EVTS_AGOLE          = 'http://services.ogf.org/nsi/2013/07/descriptions/EVTS.A-GOLE'
# ETHERNET            = 'ethernet' # bidirectional implied
# ETHERNET_VLAN       = 'vlan'
# MPLS                = 'mpls'
# RESTRICTTRANSIT     = 'restricttransit'
# ETHERNET_NS         = 'http://schemas.ogf.org/nml/2012/10/ethernet'
# NML_ETHERNET_VLAN   = '%s#vlan' % ETHERNET_NS
# NML_MPLS            = 'http://nsi.nordu.net/nml#mpls' # pretty much just made up
# FEATURE_AGGREGATOR  = 'vnd.ogf.nsi.cs.v2.role.aggregator'
# FEATURE_UPA         = 'vnd.ogf.nsi.cs.v2.role.uPA'
# REQUIRE_USER        = 'requireuser'
# REQUIRE_TRACE       = 'requiretrace'
# AGGREGATOR          = 'aggregator'
# ALLOW_HAIRPIN       = 'allowhairpin'
# 
# Path: opennsa/backends/common/genericbackend.py
# class GenericBackendConnections(DBObject):
# class GenericBackend(service.Service):
#     TPC_TIMEOUT = 120 # seconds
#     def __init__(self, network, nrm_ports, connection_manager, parent_requester, log_system, minimum_duration=60):
#     def startService(self):
#     def stopService(self):
#     def getNotificationId(self):
#     def buildSchedule(self):
#     def _getConnection(self, connection_id, requester_nsa):
#     def _authorize(self, source_port, destination_port, header, request_info, start_time=None, end_time=None):
#     def logStateUpdate(self, conn, state_msg):
#     def reserve(self, header, connection_id, global_reservation_id, description, criteria, request_info=None):
#     def reserveCommit(self, header, connection_id, request_info=None):
#     def reserveAbort(self, header, connection_id, request_info=None):
#     def provision(self, header, connection_id, request_info=None):
#     def release(self, header, connection_id, request_info=None):
#     def terminate(self, header, connection_id, request_info=None):
#     def querySummary(self, header, connection_ids=None, global_reservation_ids=None, request_info=None):
#     def queryRecursive(self, header, connection_ids, global_reservation_ids, request_info=None):
#     def _query(self, header, connection_ids, global_reservation_ids, request_info=None):
#     def queryNotification(self, header, connection_id, start_notification=None, end_notification=None):
#     def _doReserve(self, conn, correlation_id):
#     def _doReserveTimeout(self, conn):
#     def _doReserveRollback(self, conn):
#     def _doActivate(self, conn):
#     def _doTeardown(self, conn):
#     def _doEndtime(self, conn):
#     def _doFreeResource(self, conn):


# Path: opennsa/backends/dud.py
import string
import random
from twisted.python import log
from twisted.internet import defer
from opennsa import constants as cnt
from opennsa.backends.common import genericbackend

"""
NRM backends which just logs actions performed.

Author: Henrik Thostrup Jensen <htj@nordu.net>
Copyright: NORDUnet (2011)
"""






def DUDNSIBackend(network_name, nrm_ports, parent_requester, configuration):

    name = 'DUD NRM %s' % network_name
    nrm_map  = dict( [ (p.name, p) for p in nrm_ports ] ) # for the generic backend
    port_map = dict( [ (p.name, p.interface) for p in nrm_ports ] ) # for the nrm backend

    cm = DUDConnectionManager(name, port_map)

    return genericbackend.GenericBackend(network_name, nrm_map, cm, parent_requester, name, minimum_duration=1)