Skip to content
Snippets Groups Projects
Commit 15c8a21b authored by Mohamad Rahhal's avatar Mohamad Rahhal
Browse files

Device component - Ryu Driver:

- Added Topology discovery functionality ( Completed )
parent df552ea6
No related branches found
No related tags found
2 merge requests!359Release TeraFlowSDN 5.0,!296Resolve "(CTTC) Add OpenFlow support through Ryu SDN controller"
...@@ -92,7 +92,7 @@ class TfsApiClient: ...@@ -92,7 +92,7 @@ class TfsApiClient:
device_url = '/devices/device[{:s}]'.format(device_uuid) device_url = '/devices/device[{:s}]'.format(device_uuid)
device_data = { device_data = {
'uuid': device_uuid, 'uuid': device_uuid,
'name': device_name, 'name': device_uuid,
'type': 'packet-switch', 'type': 'packet-switch',
'status': 2, # Uncomment if device_status is included 'status': 2, # Uncomment if device_status is included
'drivers': 'DEVICEDRIVER_RYU', 'drivers': 'DEVICEDRIVER_RYU',
...@@ -109,7 +109,7 @@ class TfsApiClient: ...@@ -109,7 +109,7 @@ class TfsApiClient:
endpoint_url = '/endpoints/endpoint[{:s}]'.format(endpoint_uuid) endpoint_url = '/endpoints/endpoint[{:s}]'.format(endpoint_uuid)
endpoint_data = { endpoint_data = {
'device_uuid': device_uuid, 'device_uuid': device_uuid,
'uuid': port_no, 'uuid': port_name,
'name': port_name, 'name': port_name,
'type': 'copper', 'type': 'copper',
} }
...@@ -120,18 +120,23 @@ class TfsApiClient: ...@@ -120,18 +120,23 @@ class TfsApiClient:
msg = MSG_ERROR.format(str(self._links_url), str(reply.status_code), str(reply)) msg = MSG_ERROR.format(str(self._links_url), str(reply.status_code), str(reply))
LOGGER.error(msg) LOGGER.error(msg)
raise Exception(msg) raise Exception(msg)
for json_link in reply.json(): for json_link in reply.json():
dpid_src = json_link.get('src', {}).get('dpid', '') dpid_src = json_link.get('src', {}).get('dpid', '')
dpid_dst = json_link.get('dst', {}).get('dpid', '') dpid_dst = json_link.get('dst', {}).get('dpid', '')
port_src_name = json_link.get('src', {}).get('name', '') 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', '') port_dst_name = json_link.get('dst', {}).get('name', '')
link_name = f"{port_src_name}=={port_dst_name}" port_name_second = port_dst_name.split('-')[1]
link_uuid = f"{dpid_src}-{port_src_name}==={dpid_dst}-{port_dst_name}" 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 = [ link_endpoint_ids = [
(dpid_src, port_src_name), (dpid_src,port_src_name),
(dpid_dst, port_dst_name), (dpid_dst,port_dst_name) ]
]
LOGGER.info('link_endpoint_ids [{:s}]'.format(link_endpoint_ids)) LOGGER.info(f'link_endpoint_ids are {link_endpoint_ids}')
link_url = '/links/link[{:s}]'.format(link_uuid) link_url = '/links/link[{:s}]'.format(link_uuid)
link_data = { link_data = {
'uuid': link_uuid, 'uuid': link_uuid,
......
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