Commit e930ea66 authored by Michal Hažlinský's avatar Michal Hažlinský 👪
Browse files

addd configurable certsd ir for CSD backend

parent 0f15ee4b
......@@ -171,7 +171,7 @@ def _extractErrorMessage(failure):
class CSDConnectionManager:
def __init__(self, port_map, space_user, space_password, space_api_url, space_routers, csd_service_def, csd_customer_id, network_name, csd_descriptions):
def __init__(self, port_map, space_user, space_password, space_api_url, space_routers, csd_service_def, csd_customer_id, network_name, csd_descriptions, csd_certs_dir):
self.network_name = network_name
self.port_map = port_map
self.space_user=space_user
......@@ -181,6 +181,7 @@ class CSDConnectionManager:
self.csd_service_def = csd_service_def
self.csd_customer_id = csd_customer_id
self.csd_descriptions = csd_descriptions
self.csd_certs_dir = csd_certs_dir
def getResource(self, port, label):
......@@ -228,7 +229,7 @@ class CSDConnectionManager:
def setupLink(self, connection_id, source_target, dest_target, bandwidth):
payload = createCSDPayload(connection_id, source_target, dest_target, self.csd_service_def, self.csd_customer_id, self.space_routers, self.csd_descriptions)
headers = self._createHeaders()
contextFactory = opennsaTlsContext(config.DEFAULT_CERTIFICATE_DIR, False)
contextFactory = opennsaTlsContext(self.csd_certs_dir, False)
def linkUp(data):
log.msg('Link %s -> %s up' % (source_target, dest_target), system=LOG_SYSTEM)
......@@ -250,7 +251,7 @@ class CSDConnectionManager:
headers["Accept"] = "*/*"
headers["Authorization"] = self._createAuthzHeader()
serviceID = None
contextFactory = opennsaTlsContext(config.DEFAULT_CERTIFICATE_DIR, False)
contextFactory = opennsaTlsContext(self.csd_certs_dir, False)
def linkDown(data):
log.msg('Link %s -> %s down' % (source_target, dest_target), system=LOG_SYSTEM)
......@@ -265,7 +266,7 @@ class CSDConnectionManager:
headers = {}
#headers["Content-Type"] = "application/vnd.net.juniper.space.service-management.service-order+xml;version=2;charset=UTF-8"
headers["Authorization"] = self._createAuthzHeader()
contextFactory = opennsaTlsContext(config.DEFAULT_CERTIFICATE_DIR, False)
contextFactory = opennsaTlsContext(self.csd_certs_dir, False)
serviceID = 0
nsmap={'a': 'services.schema.networkapi.jmp.juniper.net'}
services = etree.fromstring(data).xpath("/a:Data/a:ServiceResource/a:Service", namespaces=nsmap)
......@@ -313,6 +314,7 @@ def JunosCSDBackend(network_name, nrm_ports, parent_requester, cfg):
csd_service_def = cfg[config.CSD_SERVICE_DEF]
csd_customer_id = cfg[config.CSD_CUSTOMER_ID]
csd_descriptions = cfg.get(config.JUNOS_DESCRIPTIONS, "OpenNSA")
csd_certs_dir = cfg[config.CSD_CERTS_DIR]
space_routers = dict()
......@@ -323,10 +325,6 @@ def JunosCSDBackend(network_name, nrm_ports, parent_requester, cfg):
log.msg("%s" % (junosspace_router))
space_routers[r] = junosspace_router
# csd_services_url = str(cfg[config.NCS_SERVICES_URL]) # convert from unicode
# user = cfg[config.NCS_USER]
# password = cfg[config.NCS_PASSWORD]
cm = CSDConnectionManager(port_map, space_user,space_password,space_api_url,space_routers, csd_service_def, csd_customer_id, network_name, csd_descriptions)
cm = CSDConnectionManager(port_map, space_user,space_password,space_api_url,space_routers, csd_service_def, csd_customer_id, network_name, csd_descriptions, csd_certs_dir)
return genericbackend.GenericBackend(network_name, nrm_map, cm, parent_requester, name)
......@@ -155,6 +155,7 @@ SPACE_CONFIGLET_ACTIVATE_REMOTE = 'configlet_activate_remote'
SPACE_CONFIGLET_DEACTIVATE_LOCAL = 'configlet_deactivate_local'
SPACE_CONFIGLET_DEACTIVATE_REMOTE = 'configlet_deactivate_remote'
#For Junos SPACE CSD plugin backend
CSD_CERTS_DIR = 'csd_certs_dir'
CSD_SERVICE_DEF = 'csd_service_def'
CSD_CUSTOMER_ID = 'csd_customer_id'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment