Skip to content
Snippets Groups Projects
Commit 995e02e6 authored by famelis's avatar famelis
Browse files

fix: add None checks to endpoint names

parent fc618f65
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!57fix: Change p4_service_handler and test scripts for rel2
...@@ -71,6 +71,7 @@ def create_rule_del(endpoint_a, endpoint_b): ...@@ -71,6 +71,7 @@ def create_rule_del(endpoint_a, endpoint_b):
) )
def find_names(uuid_a, uuid_b, device_endpoints): def find_names(uuid_a, uuid_b, device_endpoints):
endpoint_a, endpoint_b = None, None
for endpoint in device_endpoints: for endpoint in device_endpoints:
if endpoint.endpoint_id.endpoint_uuid.uuid == uuid_a: if endpoint.endpoint_id.endpoint_uuid.uuid == uuid_a:
endpoint_a = endpoint.name endpoint_a = endpoint.name
...@@ -139,6 +140,12 @@ class P4ServiceHandler(_ServiceHandler): ...@@ -139,6 +140,12 @@ class P4ServiceHandler(_ServiceHandler):
# Find names from uuids # Find names from uuids
(endpoint_a, endpoint_b) = find_names(matched_endpoint_uuid, endpoint_uuid, device.device_endpoints) (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 # One way
rule = create_rule_set(endpoint_a, endpoint_b) rule = create_rule_set(endpoint_a, endpoint_b)
...@@ -203,6 +210,12 @@ class P4ServiceHandler(_ServiceHandler): ...@@ -203,6 +210,12 @@ class P4ServiceHandler(_ServiceHandler):
# Find names from uuids # Find names from uuids
(endpoint_a, endpoint_b) = find_names(matched_endpoint_uuid, endpoint_uuid, device.device_endpoints) (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 # One way
rule = create_rule_del(endpoint_a, endpoint_b) rule = create_rule_del(endpoint_a, endpoint_b)
......
...@@ -106,7 +106,7 @@ def test_devices_bootstraping( ...@@ -106,7 +106,7 @@ def test_devices_bootstraping(
link_uuid = link['link_id']['link_uuid']['uuid'] link_uuid = link['link_id']['link_uuid']['uuid']
LOGGER.info('Adding Link {:s}'.format(link_uuid)) LOGGER.info('Adding Link {:s}'.format(link_uuid))
response = context_client.SetLink(Link(**link)) response = context_client.SetLink(Link(**link))
assert link_uuid == link_uuid assert response.name == link_uuid
context_client.SetLink(Link(**link)) context_client.SetLink(Link(**link))
def test_devices_bootstrapped(context_client : ContextClient): # pylint: disable=redefined-outer-name def test_devices_bootstrapped(context_client : ContextClient): # pylint: disable=redefined-outer-name
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment