From 571a05e09fa6186db4b44efe493b13532b144424 Mon Sep 17 00:00:00 2001 From: Henrik Thostrup Jensen <htj@nordu.net> Date: Wed, 22 Jun 2016 15:18:45 +0200 Subject: [PATCH] allow mpls and no label in nml topology generation --- opennsa/constants.py | 13 ++++++++----- opennsa/topology/nml.py | 5 ++++- opennsa/topology/nmlxml.py | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/opennsa/constants.py b/opennsa/constants.py index 09f43762..1139b986 100644 --- a/opennsa/constants.py +++ b/opennsa/constants.py @@ -23,20 +23,23 @@ BIDIRECTIONAL = 'Bidirectional' EVTS_AGOLE = 'http://services.ogf.org/nsi/2013/07/descriptions/EVTS.A-GOLE' -ETHERNET_NS = 'http://schemas.ogf.org/nml/2012/10/ethernet' -NML_ETHERNET_VLAN = '%s#vlan' % ETHERNET_NS - -# Port types +# port types ETHERNET = 'ethernet' # bidirectional implied ETHERNET_VLAN = 'vlan' MPLS = 'mpls' RESTRICTTRANSIT = 'restricttransit' +# nml +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' -# Policies +# policies REQUIRE_USER = 'requireuser' REQUIRE_TRACE = 'requiretrace' diff --git a/opennsa/topology/nml.py b/opennsa/topology/nml.py index 9008d478..3e477e82 100644 --- a/opennsa/topology/nml.py +++ b/opennsa/topology/nml.py @@ -82,7 +82,10 @@ class BidirectionalPort(object): assert type(name) is str, 'Port name must be a string' assert isinstance(inbound_port, Port), 'Inbound port must be a <Port>' assert isinstance(outbound_port, Port), 'Outbound port must be a <Port>' - assert inbound_port.label().type_ == outbound_port.label().type_, 'Port labels must match each other' + if inbound_port.label() is None and outbound_port.label() is None: + pass # ok + else: + assert inbound_port.label().type_ == outbound_port.label().type_, 'Port labels must match each other' assert not id_.startswith('urn:'), 'URNs are not used in core OpenNSA NML (id: %s)' % id_ self.id_ = id_ diff --git a/opennsa/topology/nmlxml.py b/opennsa/topology/nmlxml.py index f603dc82..72a3bc20 100644 --- a/opennsa/topology/nmlxml.py +++ b/opennsa/topology/nmlxml.py @@ -53,7 +53,8 @@ NML_HASSERVICE = NML_NS + 'hasService' NML_LABEL_MAPPING = { - cnt.ETHERNET_VLAN : cnt.NML_ETHERNET_VLAN + cnt.ETHERNET_VLAN : cnt.NML_ETHERNET_VLAN, + cnt.MPLS : cnt.NML_MPLS } NSI_SERVICE_DEFINITION = ET.QName('{%s}serviceDefinition' % NSI_DEF_NS) -- GitLab