Commit 15c8a21b authored by Mohamad Rahhal's avatar Mohamad Rahhal
Browse files

Device component - Ryu Driver:

- Added Topology discovery functionality ( Completed )
parent df552ea6
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -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_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,