diff --git a/src/service/service/service_handlers/p4/p4_service_handler.py b/src/service/service/service_handlers/p4/p4_service_handler.py index b068e0776a4d6abbf8c2c0a9ab1725873d1e9ded..6f2cfb5a9bc4dac991eecd14ba7b6eb1218bdaa2 100644 --- a/src/service/service/service_handlers/p4/p4_service_handler.py +++ b/src/service/service/service_handlers/p4/p4_service_handler.py @@ -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) diff --git a/src/tests/p4/tests/test_functional_bootstrap.py b/src/tests/p4/tests/test_functional_bootstrap.py index c2a2837ab7943815175bae1ae031bdb8982fbae7..5e39490f23fe0635eaee502c1b8b8ffb9566f307 100644 --- a/src/tests/p4/tests/test_functional_bootstrap.py +++ b/src/tests/p4/tests/test_functional_bootstrap.py @@ -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