Commit 0feae055 authored by Mohammad Ismaeel's avatar Mohammad Ismaeel
Browse files

premerge code cleaning

parent b4292d18
Loading
Loading
Loading
Loading
+7 −87
Original line number Diff line number Diff line
@@ -43,8 +43,6 @@ def create_media_channel (resources):
        with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"):
            with tag('wavelength-router', xmlns="http://openconfig.net/yang/wavelength-router"):
                    with tag('media-channels'):
                        
                    
                            src,dest=flow
                            with tag('channel', operation="create"):
                            #with tag('channel'):
@@ -62,7 +60,6 @@ def create_media_channel (resources):
                                        else:
                                            with tag(resource['resource_key']):text(resource['value'])

                  
                                if src is not None and src != '0':                    
                                    with tag('source'):
                                            with tag('config'):  
@@ -72,10 +69,7 @@ def create_media_channel (resources):
                                            with tag('config'):  
                                                with tag('port-name'):text(dest)  
                                                       
                                                       
        n+=1           
                                         
                            
        result = indent(
                    doc.getvalue(),
                    indentation = ' '*2,
@@ -93,25 +87,17 @@ def create_optical_band (resources) :
                   ,'frequency','optical-band-parent'
                   ,'handled_flow','bidir']
    config,ports,index= filter_config(resources,unwanted_keys=unwanted_keys)

    #with tag('config'):
    n = 0
    for flow in ports:
        doc, tag, text = Doc().tagtext()
        with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"):
            with tag('wavelength-router', xmlns="http://openconfig.net/yang/wavelength-router"):
                with tag('optical-bands',xmlns="http://flex-scale-project.eu/yang/flex-scale-mg-on"):
                   
                
                        #with tag('optical-band', operation="create"):
                        src,dest=flow

                        with tag('optical-band'):
                            if index is not None:
                                with tag('index'):text(str(int(index)+n))
                            with tag('config'):
                                #if index is not None:
                                #    with tag('index'):text(str(int(index)+i))
                                for resource in config:       
                                    if resource['resource_key'] == "index":
                                        with tag('index'):text(str(int(index)+n))
@@ -128,8 +114,6 @@ def create_optical_band (resources) :
                                    with tag('config'):  
                                        with tag('port-name'):text(src)   
        n +=1                
                                
                                
        result = indent(
                    doc.getvalue(),
                    indentation = ' '*2,
@@ -162,21 +146,6 @@ def disable_media_channel (resources):
                            with tag('index'):text(str(int(index) + n))

        n +=1                        




        ''' 
        doc, tag, text = Doc().tagtext()
        #with tag('config'):
        with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"):
        with tag('wavelength-router', xmlns="http://openconfig.net/yang/wavelength-router"):
            with tag('media-channels'):
                with tag("channel",operation="delete"):
                    with tag('index'):text(str(int(index)))
                    with tag('config'):
                        with tag('index'):text(str(int(index)))
        '''                        
        result = indent(
                    doc.getvalue(),
                    indentation = ' '*2,
@@ -192,7 +161,7 @@ def disable_optical_band (resources:list,state:str):
                   ,'channel_namespace','frequency'
                   ,'operational-mode', 'optical-band-parent'
                   ,"bidir"]
    config,ports,index= seperate_port_config(resources,unwanted_keys=unwanted_keys)
    _,_,index= seperate_port_config(resources,unwanted_keys=unwanted_keys)
    doc, tag, text = Doc().tagtext()
    #with tag('config'):
    with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"):
@@ -218,7 +187,7 @@ def disable_optical_band (resources:list,state:str):
def disable_optical_band_v2 (resources:list,state:str):
    results=[]
    unwanted_keys=['destination_port','source_port','channel_namespace','frequency','operational-mode', 'optical-band-parent']
    config,ports,index= seperate_port_config(resources,unwanted_keys=unwanted_keys)
    _,ports,index= seperate_port_config(resources,unwanted_keys=unwanted_keys)
    n = 0
    for flow in ports:
        doc, tag, text = Doc().tagtext()
@@ -232,21 +201,6 @@ def disable_optical_band_v2 (resources:list,state:str):
                            with tag('index'):text(str(int(index) + n))
    
        n +=1                


        '''
        doc, tag, text = Doc().tagtext()
        #with tag('config'):
        with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"):
        with tag('wavelength-router', xmlns="http://openconfig.net/yang/wavelength-router"):
            with tag('optical-bands',xmlns="http://flex-scale-project.eu/yang/flex-scale-mg-on"):
                with tag('optical-band',operation="delete"):
                    if index is not None:
                        with tag('index'):text(index)
                    with tag('config'):
                        with tag('index'):text(index)
                    
        '''
        result = indent(
                    doc.getvalue(),
                    indentation = ' '*2,
@@ -260,26 +214,7 @@ def disable_optical_band_v2 (resources:list,state:str):
def delete_optical_band (resources:list):
    results=[]
    unwanted_keys=['destination_port','source_port','channel_namespace','frequency','operational-mode', 'optical-band-parent']
    config,ports,index= seperate_port_config(resources,unwanted_keys=unwanted_keys)
    # doc, tag, text = Doc().tagtext()
    # #with tag('config'):
    # with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"):
    #   with tag('wavelength-router', xmlns="http://openconfig.net/yang/wavelength-router"):
    #     with tag('optical-bands',xmlns="http://flex-scale-project.eu/yang/flex-scale-mg-on"):
    #         with tag('optical-band',operation="delete"):
    #             if index is not None:
    #                 with tag('index'):text(index)
    #             with tag('config'):
    #                 with tag('index'):text(index)
                   
    # result = indent(
    #             doc.getvalue(),
    #             indentation = ' '*2,
    #             newline = ''
    #         )
    # results.append(result)
    # return results

    _,ports,index= seperate_port_config(resources,unwanted_keys=unwanted_keys)
    n = 0
    for key,v in ports.items():
        if isinstance(v,list): 
@@ -297,21 +232,6 @@ def delete_optical_band (resources:list):
                            with tag('index'):text(str(int(index) + n))
    
        n +=1                


        '''
        doc, tag, text = Doc().tagtext()
        #with tag('config'):
        with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"):
        with tag('wavelength-router', xmlns="http://openconfig.net/yang/wavelength-router"):
            with tag('optical-bands',xmlns="http://flex-scale-project.eu/yang/flex-scale-mg-on"):
                with tag('optical-band',operation="delete"):
                    if index is not None:
                        with tag('index'):text(index)
                    with tag('config'):
                        with tag('index'):text(index)
                    
        '''
        result = indent(
                    doc.getvalue(),
                    indentation = ' '*2, 
+0 −1
Original line number Diff line number Diff line
@@ -175,7 +175,6 @@ class OCServiceHandler(_ServiceHandler):
            except Exception as e: # pylint: disable=broad-except
                LOGGER.exception('Unable to DeleteEndpoint({:s})'.format(str(endpoint)))
                results.append(e)
        LOGGER.info(f"delete_endpoints_flows-> {flows}")
        for device_uuid, dev_flows in flows.items():
            try:
                channel_indexes= []
+0 −3
Original line number Diff line number Diff line
@@ -398,9 +398,6 @@ def conn_flows(endpoints : List[Tuple[str, str, Optional[str]]], bidir : int):






def endpoints_to_flows(endpoints : List[Tuple[str, str, Optional[str]]], bidir : int, is_ob: bool)->Dict:
    if is_ob:
        entries = ob_flows(endpoints, bidir)
+0 −15
Original line number Diff line number Diff line
@@ -54,32 +54,17 @@ class Task_OpticalConnectionConfigure(_Task):
        service_handler=None
        service_handlers = self._task_executor.get_service_handlers(connection, service, **service_handler_settings)
        for _, (handler, connection_devices) in service_handlers.items():
             logging.info(f"type_servicehandler {type(handler)}")
             if service_handler is None : service_handler=handler
             else :
                 if type(handler) != type(service_handler) : 
                     raise Exception("Devices are not compatible ")
             
        connection_uuid = connection.connection_id.connection_uuid.uuid
        logging.info(f"connection->  uuid{connection_uuid}")
        endpointids_to_set = endpointids_to_raw(connection.path_hops_endpoint_ids)
        logging.info(f" _endpointids_to_set-> {endpointids_to_set}")
        errors = list()
       
        connection_uuid = connection.connection_id.connection_uuid.uuid
        results_setendpoint = service_handler.SetEndpoint(endpointids_to_set, connection_uuid=connection_uuid)

        # for _, (service_handler, connection_devices) in service_handlers.items():
        #     logging.info(f" connection_devices-> {connection_devices}")
        #     _endpointids_to_set = [
        #         (device_uuid, endpoint_uuid, topology_uuid)
        #         for device_uuid, endpoint_uuid, topology_uuid in endpointids_to_set
        #         if device_uuid in connection_devices
        #     ]
        #     logging.info(f" results_endpointids_to_set-> {_endpointids_to_set}")
        # results_setendpoint = service_handler.SetEndpoint(
        #         _endpointids_to_set, connection_uuid=connection_uuid
        #     )
        errors.extend(check_errors_setendpoint(endpointids_to_set, results_setendpoint))

        if len(errors) > 0:
+47 −47

File changed.

Contains only whitespace changes.

+12 −12

File changed.

Contains only whitespace changes.

Loading