Commit 6c633636 authored by Mohammad Ismaeel's avatar Mohammad Ismaeel
Browse files

reading from context

parent 6655cdbe
Loading
Loading
Loading
Loading
(16 KiB)

File changed.

No diff preview for this file type.

+2 −1
Original line number Diff line number Diff line
@@ -36,12 +36,13 @@ class SlotType(TypeDecorator):
            slot={}
            for k,v in value.items():
                slot[k]=v
            logging.info(f"dict from slotType {slot}")    
           
            value = json.dumps(slot)

        return value

    def process_result_value(self, value, dialect):
        logging.info(f"dict from slotType {value}")    
        if value is not None:
            value = json.loads(value)
        return value
+28 −5
Original line number Diff line number Diff line
@@ -208,16 +208,39 @@ class GetFlows(Resource):
        except:
            return "Error", 404
        
@optical.route('/GetTopology/<path:topology_id>',methods=(['GET']))
@optical.route('/GetTopology/<path:context_id>/<path:topology_id>',methods=['GET'])
@optical.response(200, 'Success')
@optical.response(404, 'Error, not found')
class GetTopology(Resource):
    @staticmethod
    def get(topology_id:TopologyId):
    def get(context_id:str,topology_id:str):
        
        topog_id = TopologyId()
        topog_id.topology_uuid.uuid=topology_id
        topog_id.context_id.context_uuid.uuid=context_id
       
        try:
            nodes , links = readTopologyDataFromContext(topology_id)
            print(f"nodes {nodes} and links {links}")
            links_dict={"optical_links":[]}
            node_dict = {}
            i=0
            nodes , topo = readTopologyDataFromContext(topog_id)
          
            for node in nodes : 
                links_dict["optical_links"].append(node)
            for device in topo :
                    dic = {}
                    dic= {
                                        "id":device.device_id.device_uuid.uuid,
                                       "ip":f"10.30.2.{207+i}",
                                       "port":"50001",
                                       "type":"OC-ROADM" if device.device_type =="optical-roadm" else "OC-ROADM",
                                       "driver": "OpticalOC"
                                }
                    node_dict[device.name]=dic
                    i+=1
            print(f"refresh_opticacontroller optical_links_dict  {links_dict}")    
            print(f"refresh_opticacontroller node_dict  {node_dict}") 
            rsa = RSA(node_dict, links_dict)   
            return "Done"
        except Exception as e:
            print(f"err {e}")
@@ -232,7 +255,7 @@ if __name__ == '__main__':
    nodes_dict, links_dict = readTopologyData(nodes_json, topology_json)

   
    rsa = RSA(nodes_dict, links_dict)
    #rsa = RSA(nodes_dict, links_dict)
    #print(rsa.init_link_slots2(testing))

    app.run(host='0.0.0.0', port=10060)
+2 −2
Original line number Diff line number Diff line
@@ -255,7 +255,7 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
            topology_details = context_client.GetTopologyDetails(
                TopologyId(**topology_id_x))
        
            #refresh_opticalcontroller(TopologyId(**topology_id_x))
            refresh_opticalcontroller(topology_id_x)
            # devices = get_devices_in_topology(context_client, TopologyId(**topology_id_x), ContextId(**context_id_x))
            devices = topology_details.devices
            context_uuid_x = topology_details.topology_id.context_id.context_uuid.uuid
+7 −4
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ from service.service.service_handler_api.Exceptions import (
)
from service.service.service_handler_api.ServiceHandlerFactory import ServiceHandlerFactory, get_service_handler_class
from service.service.tools.ObjectKeys import get_connection_key, get_device_key, get_service_key

from service.service.tools.object_uuid import opticalconfig_get_uuid
if TYPE_CHECKING:
    from service.service.service_handler_api._ServiceHandler import _ServiceHandler

@@ -120,24 +120,27 @@ class TaskExecutor:
    def configure_optical_device(self, device : Device, settings : str, flows : list, is_opticalband : bool):
        device_key = get_device_key(device.device_id)
        optical_config_id = OpticalConfigId()
        optical_config_id.opticalconfig_uuid = device.device_id.device_uuid.uuid
        optical_config_id.opticalconfig_uuid = opticalconfig_get_uuid(device.device_id)
        
        optical_config = OpticalConfig()
  
        setting = settings.value if settings else ""

        new_config = {}
        try:
            result = self._context_client.SelectOpticalConfig(optical_config_id)
            LOGGER.info(f"configure_optical_device {result}")
            new_config = json.loads(result.config)
            if result is not None :
                new_config["new_config"] = setting
                new_config["is_opticalband"] = is_opticalband
                new_config["flow"] = flows
                result.config = str(new_config)
                result.config = json.dumps(new_config)
                optical_config.CopyFrom(result)
                self._device_client.ConfigureOpticalDevice(optical_config)
            self._store_grpc_object(CacheableObjectType.DEVICE, device_key, device)
        except Exception as e:
            LOGGER.info("error in config my config %s",e)
            LOGGER.info("error in configure_optical_device  %s",e)

    def get_device_controller(self, device : Device) -> Optional[Device]:
        #json_controller = None
Loading