Commit 0a3559d4 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'cnit-optical-band-expansion' into 'tmp-integration'

Integrate "cnit-optical-band-expansion" into "tmp-integration"

See merge request !398
parents 8e4fe4ca 397388a7
Loading
Loading
Loading
Loading
+12 −14
Original line number Diff line number Diff line
@@ -28,8 +28,6 @@ class OpticalBandModel(_Base):
    connection_uuid     = Column(ForeignKey('connection.connection_uuid', ondelete='CASCADE'), nullable=False)
    channel_uuid        = Column(ForeignKey('channel.channel_uuid', ondelete='CASCADE'), nullable=False)
    created_at          = Column(DateTime, nullable=False)


    ob_channel          = relationship('ChannelModel') # back_populates='connections'
    ob_connection       = relationship('ConnectionModel') # lazy='joined', back_populates='connection'
   
+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 −6
Original line number Diff line number Diff line
@@ -125,10 +125,7 @@ class DelFLightpath(Resource):
                   ob_id = flow["parent_opt_band"]
                   flow['is_active']=False
            if flow is not None:
                
            
                bidir = flow["bidir"]
              
                if bidir:
                    match2 = flow["src"] == dst and flow["dst"] == src and flow["bitrate"] == bitrate
                    if match1 or match2:
@@ -187,10 +184,7 @@ class DelOpticalBand(Resource):
                    ob_id=o_band_id 
              
                if flow is not None:
                
            
                    bidir = flow["bidir"]
                
                    if bidir:
                        match1 = flow["src"] == src and flow["dst"] == dst and flow["bitrate"]
                        match2 = flow["src"] == dst and flow["dst"] == src and flow["bitrate"] 
+0 −3
Original line number Diff line number Diff line
@@ -271,13 +271,10 @@ def handle_slot (slot_field, slot):
def update_optical_band (optical_bands,optical_band_id,band,link):
    key_list = optical_bands[optical_band_id][band].keys()
    corrected_slots=optical_bands[optical_band_id][band]
    print(f"band {band}")
    print(f"corrected_slots_before {corrected_slots}")
    if (len(key_list) < 20):
        corrected_slots=correct_slot(optical_bands[optical_band_id][band])
        
    fib={}
    print(f"corrected_slots_after {corrected_slots}")    
    fib['c_slots']=link['optical_details']['c_slots']
    fib['l_slots']=link['optical_details']['l_slots']
    fib['s_slots']=link['optical_details']['s_slots']
+7 −6
Original line number Diff line number Diff line
@@ -389,6 +389,7 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
                "dst"     : None,
                "bitrate" : None,
                'ob_id'   : None,
                'bidir'   : None,
                'flow_id' : None
            }
            devs = []
Loading