Commit 4f1610ae authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

NBI component - IETF L2VPN connector:

- Fixed management of locations
parent d8f035b5
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -88,12 +88,25 @@ class L2VPN_SiteNetworkAccesses(Resource):
            location_refs = set()
            location_refs.add('fake-location')

            device_refs = dict()
            device_refs['fake-device'] = 'fake-location'

            # Add mandatory fields OSM RO driver skips and fix wrong ones
            for site_network_access in site_network_accesses:
                location = 'fake-location'
                if 'location-reference' in site_network_access:
                    location_refs.add(site_network_access['location-reference'])
                    location = site_network_access['location-reference']
                    site_network_access.pop('location-reference')
                #else:
                #    site_network_access['location-reference'] = location
                location_refs.add(location)

                if 'device-reference' in site_network_access:
                    device = site_network_access['device-reference']
                else:
                    site_network_access['location-reference'] = 'fake-location'
                    device = 'fake-device'
                    site_network_access['device-reference'] = device
                device_refs[device] = location

                if 'connection' in site_network_access:
                    connection = site_network_access['connection']
@@ -151,11 +164,15 @@ class L2VPN_SiteNetworkAccesses(Resource):
                'sites': {'site': [{
                    'site-id': site_id,
                    'default-ce-vlan-id': 1,
                    'management': {'type': 'customer-managed'},
                    'management': {'type': 'provider-managed'},
                    'locations': {'location': [
                        {'location-id': location_ref}
                        for location_ref in location_refs
                    ]},
                    'devices': {'device': [
                        {'device-id': device_ref, 'location': location_ref}
                        for device_ref, location_ref in device_refs.items()
                    ]},
                    'site-network-accesses': {
                        'site-network-access': site_network_accesses
                    }
@@ -163,7 +180,7 @@ class L2VPN_SiteNetworkAccesses(Resource):
            }}

            MSG = '[_prepare_request_payload] request_data={:s}'
            LOGGER.debug(MSG.format(str(request_data)))
            LOGGER.warning(MSG.format(str(request_data)))
            return request_data

        errors.append('Unexpected request: {:s}'.format(str(request_data)))