Commit 995e02e6 authored by kesnar's avatar kesnar
Browse files

fix: add None checks to endpoint names

parent fc618f65
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ def create_rule_del(endpoint_a, endpoint_b):
    )

def find_names(uuid_a, uuid_b, device_endpoints):
    endpoint_a, endpoint_b = None, None
    for endpoint in device_endpoints:
        if endpoint.endpoint_id.endpoint_uuid.uuid == uuid_a:
            endpoint_a = endpoint.name
@@ -139,6 +140,12 @@ class P4ServiceHandler(_ServiceHandler):
                    
                    # Find names from uuids
                    (endpoint_a, endpoint_b) = find_names(matched_endpoint_uuid, endpoint_uuid, device.device_endpoints)
                    if endpoint_a is None:
                        LOGGER.exception('Unable to find name of endpoint({:s})'.format(str(matched_endpoint_uuid)))
                        raise Exception('Unable to find name of endpoint({:s})'.format(str(matched_endpoint_uuid)))
                    if endpoint_b is None:
                        LOGGER.exception('Unable to find name of endpoint({:s})'.format(str(endpoint_uuid)))
                        raise Exception('Unable to find name of endpoint({:s})'.format(str(endpoint_uuid)))

                    # One way
                    rule = create_rule_set(endpoint_a, endpoint_b) 
@@ -203,6 +210,12 @@ class P4ServiceHandler(_ServiceHandler):

                    # Find names from uuids
                    (endpoint_a, endpoint_b) = find_names(matched_endpoint_uuid, endpoint_uuid, device.device_endpoints)
                    if endpoint_a is None:
                        LOGGER.exception('Unable to find name of endpoint({:s})'.format(str(matched_endpoint_uuid)))
                        raise Exception('Unable to find name of endpoint({:s})'.format(str(matched_endpoint_uuid)))
                    if endpoint_b is None:
                        LOGGER.exception('Unable to find name of endpoint({:s})'.format(str(endpoint_uuid)))
                        raise Exception('Unable to find name of endpoint({:s})'.format(str(endpoint_uuid)))

                    # One way
                    rule = create_rule_del(endpoint_a, endpoint_b) 
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ def test_devices_bootstraping(
        link_uuid = link['link_id']['link_uuid']['uuid']
        LOGGER.info('Adding Link {:s}'.format(link_uuid))
        response = context_client.SetLink(Link(**link))
        assert link_uuid == link_uuid
        assert response.name == link_uuid
        context_client.SetLink(Link(**link))

def test_devices_bootstrapped(context_client : ContextClient):  # pylint: disable=redefined-outer-name