Commit 0d56613c authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

NBI component - IETF L2VPN connector:

- Fixed parsing of encalsulation types
- Fixed adaptations of OSM request on encapsulation types
parent 86c42070
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -113,12 +113,26 @@ def process_site_network_access(
        service_uuid  = network_access['vpn-attachment']['vpn-id']

        network_access_connection = network_access['connection']
        encapsulation_type = network_access_connection['encapsulation-type']

        encapsulation_type = network_access_connection.get('encapsulation-type', 'ietf-l2vpn-svc:ethernet')
        encapsulation_type = encapsulation_type.replace('ietf-l2vpn-svc:', '')
        if encapsulation_type != 'vlan':
            encapsulation_type = network_access_connection['encapsulation-type']
            MSG = 'EncapsulationType({:s}) not supported'
            raise NotImplementedError(MSG.format(str(encapsulation_type)))

        eth_inf_type = network_access_connection.get('eth-inf-type', 'ietf-l2vpn-svc:untagged')
        eth_inf_type = eth_inf_type.replace('ietf-l2vpn-svc:', '')

        if encapsulation_type == 'ethernet' and eth_inf_type == 'untagged':
            if 'tagged-interface' in network_access_connection:
                MSG = 'Malformed NetworkAccessConnection({:s})'
                raise Exception(MSG.format(str(network_access_connection)))
        elif encapsulation_type == 'vlan' and eth_inf_type == 'tagged':
            if 'tagged-interface' not in network_access_connection:
                MSG = 'Malformed NetworkAccessConnection({:s})'
                raise Exception(MSG.format(str(network_access_connection)))
        else:
            encapsulation_type = network_access_connection.get('encapsulation-type', 'ietf-l2vpn-svc:ethernet')
            eth_inf_type = network_access_connection.get('eth-inf-type', 'ietf-l2vpn-svc:untagged')
            MSG = 'Combination EncapsulationType({:s})/EthernetInterfaceType({:s}) not supported'
            raise NotImplementedError(MSG.format(str(encapsulation_type), str(eth_inf_type)))

        cvlan_tag_id = None
        if 'tagged-interface' in network_access_connection:
+6 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ from nbi.service._tools.Authentication import HTTP_AUTH
from nbi.service._tools.HttpStatusCodes import (
    HTTP_CREATED, HTTP_NOCONTENT, HTTP_SERVERERROR
)
from .Constants import DEFAULT_MTU
from .Handlers import process_site_network_access
from .YangValidator import YangValidator

@@ -113,8 +114,12 @@ class L2VPN_SiteNetworkAccesses(Resource):
                    if 'encapsulation-type' in connection:
                        if connection['encapsulation-type'] == 'dot1q-vlan-tagged':
                            connection['encapsulation-type'] = 'vlan'
                            if 'eth-inf-type' not in connection:
                                connection['eth-inf-type'] = 'tagged'
                        else:
                            connection['encapsulation-type'] = 'ethernet'
                            if 'eth-inf-type' not in connection:
                                connection['eth-inf-type'] = 'untagged'
                    if 'tagged-interface' in connection:
                        tagged_interface = connection['tagged-interface']
                        if 'dot1q-vlan-tagged' in tagged_interface:
@@ -131,7 +136,7 @@ class L2VPN_SiteNetworkAccesses(Resource):
                if 'service' not in site_network_access:
                    site_network_access['service'] = dict()
                if 'svc-mtu' not in site_network_access['service']:
                    site_network_access['service']['svc-mtu'] = 1500
                    site_network_access['service']['svc-mtu'] = DEFAULT_MTU

            context_client = ContextClient()
            vpn_services = list()