Commit 505f372f authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

NBI Component - IETF L3VPN:

- Fixed parsing of requests
parent 7db3ffe7
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -100,23 +100,27 @@ def process_site_network_access(
) -> None:
    endpoint_uuid = network_access['site-network-access-id']

    if network_access['type'] != 'ietf-l3vpn-svc:multipoint':
    if network_access['site-network-access-type'] != 'ietf-l3vpn-svc:multipoint':
        MSG = 'Site Network Access Type: {:s}'
        raise NotImplementedError(MSG.format(str(network_access['type'])))
        raise NotImplementedError(MSG.format(str(network_access['site-network-access-type'])))

    device_uuid  = network_access['device-reference']
    service_uuid = network_access['vpn-attachment']['vpn-id']
    
    access_role : str = network_access['vpn-attachment']['site-role']
    access_role = access_role.replace('ietf-l3vpn-svc:', '').replace('-role', '') # hub/spoke
    if access_role not in {'hub', 'spoke'}:
        MSG = 'Site VPN Attackment Role: {:s}'
        raise NotImplementedError(MSG.format(str(network_access['site-network-access-type'])))

    ipv4_allocation = network_access['ip-connection']['ipv4']
    if ipv4_allocation['address-allocation-type'] != 'ietf-l3vpn-svc:static-address':
        MSG = 'Site Network Access IPv4 Allocation Type: {:s}'
        raise NotImplementedError(MSG.format(str(ipv4_allocation['address-allocation-type'])))
    ipv4_provider_address = ipv4_allocation['provider-address']
    #ipv4_customer_address = ipv4_allocation['customer-address']
    ipv4_prefix_length    = ipv4_allocation['prefix-length'   ]
    ipv4_allocation_addresses = ipv4_allocation['addresses']
    ipv4_provider_address = ipv4_allocation_addresses['provider-address']
    #ipv4_customer_address = ipv4_allocation_addresses['customer-address']
    ipv4_prefix_length    = ipv4_allocation_addresses['prefix-length'   ]

    vlan_tag = None
    ipv4_provider_range = netaddr.IPNetwork('{:s}/{:d}'.format(ipv4_provider_address, ipv4_prefix_length))