diff --git a/src/device/service/drivers/OpenFlow/TfsApiClient.py b/src/device/service/drivers/OpenFlow/TfsApiClient.py index 5db9c202c6b3d1a10d9f61e9ec7fa43d2547b5b0..aab5f06457ce08ff8cb9ddb612fc130d5c060bc3 100644 --- a/src/device/service/drivers/OpenFlow/TfsApiClient.py +++ b/src/device/service/drivers/OpenFlow/TfsApiClient.py @@ -92,7 +92,7 @@ class TfsApiClient: device_url = '/devices/device[{:s}]'.format(device_uuid) device_data = { 'uuid': device_uuid, - 'name': device_name, + 'name': device_uuid, 'type': 'packet-switch', 'status': 2, # Uncomment if device_status is included 'drivers': 'DEVICEDRIVER_RYU', @@ -109,7 +109,7 @@ class TfsApiClient: endpoint_url = '/endpoints/endpoint[{:s}]'.format(endpoint_uuid) endpoint_data = { 'device_uuid': device_uuid, - 'uuid': port_no, + 'uuid': port_name, 'name': port_name, 'type': 'copper', } @@ -120,18 +120,23 @@ class TfsApiClient: msg = MSG_ERROR.format(str(self._links_url), str(reply.status_code), str(reply)) LOGGER.error(msg) raise Exception(msg) + for json_link in reply.json(): dpid_src = json_link.get('src', {}).get('dpid', '') dpid_dst = json_link.get('dst', {}).get('dpid', '') port_src_name = json_link.get('src', {}).get('name', '') + port_name_secondpart = port_src_name.split('-')[1] port_dst_name = json_link.get('dst', {}).get('name', '') - link_name = f"{port_src_name}=={port_dst_name}" - link_uuid = f"{dpid_src}-{port_src_name}==={dpid_dst}-{port_dst_name}" + port_name_second = port_dst_name.split('-')[1] + switch_name_src = port_src_name.split('-')[0] + switch_name_dest = port_dst_name.split('-')[0] + link_name = f"{dpid_src}-{port_src_name}==={dpid_dst}-{port_dst_name}" + link_uuid = f"{port_src_name}=={port_dst_name}" link_endpoint_ids = [ - (dpid_src, port_src_name), - (dpid_dst, port_dst_name), - ] - LOGGER.info('link_endpoint_ids [{:s}]'.format(link_endpoint_ids)) + (dpid_src,port_src_name), + (dpid_dst,port_dst_name) ] + + LOGGER.info(f'link_endpoint_ids are {link_endpoint_ids}') link_url = '/links/link[{:s}]'.format(link_uuid) link_data = { 'uuid': link_uuid,