Commit b2eeea80 authored by Andrea Sgambelluri's avatar Andrea Sgambelluri
Browse files

Merge branch 'ofc_polimi' of https://labs.etsi.org/rep/tfs/controller into cnit_ofc26

parents d2956430 71b2c55f
Loading
Loading
Loading
Loading
+33 −8
Original line number Original line Diff line number Diff line
@@ -70,23 +70,25 @@ class AddLightpath(Resource):


#@optical.route('/AddFlexLightpath/<string:src>/<string:dst>/<int:bitrate>')
#@optical.route('/AddFlexLightpath/<string:src>/<string:dst>/<int:bitrate>')
@optical.route('/AddFlexLightpath/<string:src>/<string:dst>/<int:bitrate>',
@optical.route('/AddFlexLightpath/<string:src>/<string:dst>/<int:bitrate>',
               defaults={"bidir": 1, "band": None})
               defaults={"bidir": 1, "band": None, "obx_idx": None})
@optical.route('/AddFlexLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:bidir>',
@optical.route('/AddFlexLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:bidir>',
               defaults={"band": None})
               defaults={"band": None, "obx_idx": None})
@optical.route('/AddFlexLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:bidir>/<int:band>',)
@optical.route('/AddFlexLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:bidir>/<int:band>',
               defaults={"obx_idx": None})
@optical.route('/AddFlexLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:bidir>/<int:band>/<int:obx_idx>')
@optical.response(200, 'Success')
@optical.response(200, 'Success')
@optical.response(404, 'Error, not found')
@optical.response(404, 'Error, not found')
class AddFlexLightpath(Resource):
class AddFlexLightpath(Resource):
    @staticmethod
    @staticmethod
    def put(src, dst, bitrate, bidir=1, band=None):
    def put(src, dst, bitrate, bidir=1, band=None, obx_idx = None):


        print("INFO: New FlexLightpath request from {} to {} with rate {} ".format(src, dst, bitrate))
        print("INFO: New MGON request from {} to {} with rate {} and band {}".format(src, dst, bitrate, band))
        t0 = time.time()*1000.0
        t0 = time.time()*1000.0
        if debug:
        #if debug:
            rsa.g.printGraph()
        #    rsa.g.printGraph()


        if rsa is not None:
        if rsa is not None:
            flow_id, optical_band_id = rsa.rsa_fs_computation(src, dst, bitrate, bidir, band)
            flow_id, optical_band_id = rsa.rsa_fs_computation(src, dst, bitrate, bidir, band, obx_idx)
            if flow_id is not None:
            if flow_id is not None:
                if rsa.db_flows[flow_id]["op-mode"] == 0:
                if rsa.db_flows[flow_id]["op-mode"] == 0:
                    return 'No path found', 404
                    return 'No path found', 404
@@ -106,6 +108,7 @@ class AddFlexLightpath(Resource):
                    return rsa.optical_bands[optical_band_id], 200
                    return rsa.optical_bands[optical_band_id], 200
        else:
        else:
            return "Error", 404
            return "Error", 404

# @optical.route('/DelFlexLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:o_band_id>')
# @optical.route('/DelFlexLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:o_band_id>')
@optical.route('/DelFlexLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:flow_id>')
@optical.route('/DelFlexLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:flow_id>')
@optical.route('/DelFlexLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:flow_id>/<int:o_band_id>')
@optical.route('/DelFlexLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:flow_id>/<int:o_band_id>')
@@ -330,6 +333,28 @@ class GetBand(Resource):
                return rsa.optical_bands[ob_idx], 200
                return rsa.optical_bands[ob_idx], 200
        return {}, 404
        return {}, 404


@optical.route('/ReconfigFlexLightpath/<int:flow_id_val>')
@optical.response(200, 'Success')
@optical.response(404, 'Error, not found')
class ReconfigFlexLightpath(Resource):
    @staticmethod
    def put(flow_id_val):
        print("INFO: Reconfiguring optical {}".format(flow_id_val))
        t0 = time.time()*1000.0
        if rsa is not None:
            flow_idx, optical_band_id = rsa.rsa_fs_recomputation(flow_id_val)
            if flow_idx is not None:
                if rsa.db_flows[flow_idx]["op-mode"] == 0:
                    return 'No path found', 404
                t1 = time.time() * 1000.0
                elapsed = t1 - t0
                print("INFO: time elapsed = {} ms".format(elapsed))
                print(flow_idx, optical_band_id)
                return rsa.db_flows[flow_idx], 200
            else:
                return "Error", 404
        else:
            return "Error", 404


@optical.route('/GetLinks')
@optical.route('/GetLinks')
@optical.response(200, 'Success')
@optical.response(200, 'Success')
+212 −32
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@ import logging
from opticalcontroller.dijkstra import *
from opticalcontroller.dijkstra import *
from opticalcontroller.tools import *
from opticalcontroller.tools import *
from opticalcontroller.variables import *
from opticalcontroller.variables import *

LOGGER = logging.getLogger(__name__)
LOGGER = logging.getLogger(__name__)


def print(*args) -> None:
def print(*args) -> None:
@@ -143,7 +142,31 @@ class RSA():
        self.g.reset_graph()
        self.g.reset_graph()
        return links, path
        return links, path


    def get_slots(self, links, slots, optical_band_id=None):
    def compute_disjoint_path(self, src, dst, path1=None):
        if path1 == None:
            path1 = shortest_path(self.g, self.g.get_vertex(src), self.g.get_vertex(dst))
        path = disjoint_path(self.g, src, dst, path1, False)      
        print("INFO: Path from {} to {} with distance: {}".format(src, dst, self.g.get_vertex(dst).get_distance()))
        if debug:
            print(path)
        links = []
        for i in range(0, len(path) - 1):
            s = path[i]
            if debug:
                print(s)
            if i < len(path) - 1:
                d = path[i + 1]
                link_id = "{}-{}".format(s, d)
                if debug:
                    #print(link_id, self.links_dict[link_id])
                    print(link_id, self.get_link_by_name(link_id))

                links.append(link_id)
        self.g.reset_graph()
        return links, path


    def get_slots(self, links, slots, optical_band_id=None, old_band_x=None):


        if isinstance(slots, int):
        if isinstance(slots, int):
            val_c = slots
            val_c = slots
@@ -240,6 +263,7 @@ class RSA():
                l_slots[l] = combine(l_slots[l], consecutives(fib["l_slots"], val_l))
                l_slots[l] = combine(l_slots[l], consecutives(fib["l_slots"], val_l))
                l_found = 1'''
                l_found = 1'''
        if optical_band_id is not None:
        if optical_band_id is not None:
            print(f"NEW_DISJOINT: {self.optical_bands[optical_band_id]}")
            if "c_slots" in self.optical_bands[optical_band_id].keys():
            if "c_slots" in self.optical_bands[optical_band_id].keys():
                if len(self.optical_bands[optical_band_id]["c_slots"]) > 0:
                if len(self.optical_bands[optical_band_id]["c_slots"]) > 0:
                    a_c = c_sts
                    a_c = c_sts
@@ -252,17 +276,25 @@ class RSA():
            if "l_slots" in self.optical_bands[optical_band_id].keys():
            if "l_slots" in self.optical_bands[optical_band_id].keys():
                if len(self.optical_bands[optical_band_id]["l_slots"]) > 0:
                if len(self.optical_bands[optical_band_id]["l_slots"]) > 0:
                    a_l = l_sts
                    a_l = l_sts
                    b_l = consecutives(self.optical_bands[optical_band_id]["l_slots"], val_c)
                    b_l = consecutives(self.optical_bands[optical_band_id]["l_slots"], val_l)
                    l_sts = common_slots(a_l, b_l)
                    l_sts = common_slots(a_l, b_l)
            else:
            else:
                l_sts = []
                l_sts = []
            if "s_slots" in self.optical_bands[optical_band_id].keys():
            if "s_slots" in self.optical_bands[optical_band_id].keys():
                if len(self.optical_bands[optical_band_id]["s_slots"]) > 0:
                if len(self.optical_bands[optical_band_id]["s_slots"]) > 0:
                    a_s = s_sts
                    a_s = s_sts
                    b_s = consecutives(str_list_to_int(self.optical_bands[optical_band_id]["s_slots"].keys()), val_c)
                    b_s = consecutives(self.optical_bands[optical_band_id]["s_slots"], val_s)
                    s_sts = common_slots(a_s, b_s)
                    s_sts = common_slots(a_s, b_s)
            else:
            else:
                s_sts = []
                s_sts = []
        if old_band_x == "c_slots":
            c_sts = []
            l_sts = []
        if old_band_x == "l_slots":
            c_sts = []
            l_sts = []
        if old_band_x == "s_slots":
            s_sts = []
        
        
        return c_sts, l_sts, s_sts
        return c_sts, l_sts, s_sts


@@ -479,7 +511,6 @@ class RSA():
            self.del_flow(flow,flow_id=flow_id,o_b_id=o_b_id)           
            self.del_flow(flow,flow_id=flow_id,o_b_id=o_b_id)           
            
            
             
             
             
    def get_fibers_forward(self, links, slots, band):
    def get_fibers_forward(self, links, slots, band):
        fiber_list = {}
        fiber_list = {}
        add = links[0]
        add = links[0]
@@ -648,16 +679,17 @@ class RSA():
            print(self.links_dict)
            print(self.links_dict)
        band, slots = slot_selection(c, l, s, n_slots, self.c_slot_number, self.l_slot_number, self.s_slot_number)
        band, slots = slot_selection(c, l, s, n_slots, self.c_slot_number, self.l_slot_number, self.s_slot_number)
        if band is None:
        if band is None:
            print("No slots available in the three bands")
            print("ERROR: No slots available in the three bands")
            return None, None, None, None, None
            return None, None, None, None, None
        if debug:
        if debug:
            print(band, slots)
            print(f"INFO: XXXX {band}, {slots}")
        self.get_fibers_forward(links, slots, band)
        self.get_fibers_forward(links, slots, band)
        if bidir:
        if bidir:
            self.get_fibers_backward(links, slots, band)
            self.get_fibers_backward(links, slots, band)


        #fibers_f = self.get_fibers_forward(links, slots, band)
        #fibers_f = self.get_fibers_forward(links, slots, band)
        self.update_optical_band(o_band_id, slots, band)
        self.update_optical_band(o_band_id, slots, band)
        print("INFO: 1")
        #fibers_b = []
        #fibers_b = []
        #if bidir:
        #if bidir:
        #    fibers_b = self.get_fibers_backward(links, fibers_f, slots, band)
        #    fibers_b = self.get_fibers_backward(links, fibers_f, slots, band)
@@ -686,6 +718,7 @@ class RSA():
            #r_inport = self.links_dict[add]['fibers'][f]["local_peer_port"]
            #r_inport = self.links_dict[add]['fibers'][f]["local_peer_port"]
            r_inport = lx["local_peer_port"]
            r_inport = lx["local_peer_port"]
            t_flows[src]["b"] = {"in": r_inport, "out": port_0}
            t_flows[src]["b"] = {"in": r_inport, "out": port_0}
        print("INFO: 2")
        
        
        #R1 rules
        #R1 rules
        t_flows[dst] = {}
        t_flows[dst] = {}
@@ -733,12 +766,13 @@ class RSA():
            #r_inport = self.links_dict[drop]['fibers'][f]["remote_peer_port"]
            #r_inport = self.links_dict[drop]['fibers'][f]["remote_peer_port"]
            r_inport = ly["remote_peer_port"]
            r_inport = ly["remote_peer_port"]
            t_flows[dst]["b"] = {"in": port_0, "out": r_inport}
            t_flows[dst]["b"] = {"in": port_0, "out": r_inport}
        print("INFO: 3")
        
        
        if debug:
        #if debug:
            print(self.links_dict)
        #    print(self.links_dict)

        print("INFO: 4")
        if debug:
        #if debug:
            print(t_flows)
        #    print(t_flows)
        print("INFO: Flow matrix computed for Flex Lightpath")
        print("INFO: Flow matrix computed for Flex Lightpath")


        return t_flows, band, slots, {}, {}
        return t_flows, band, slots, {}, {}
@@ -828,10 +862,10 @@ class RSA():
        self.optical_bands[ob_id]["s_slots"] = []
        self.optical_bands[ob_id]["s_slots"] = []
        self.optical_bands[ob_id]["served_lightpaths"] = []
        self.optical_bands[ob_id]["served_lightpaths"] = []
        self.optical_bands[ob_id]["reverse_optical_band_id"] = 0
        self.optical_bands[ob_id]["reverse_optical_band_id"] = 0
        self.db_flows[self.flow_id]["parent_opt_band"] = 0
        #self.db_flows[flow_id]["parent_opt_band"] = 0
        self.db_flows[self.flow_id]["new_optical_band"] = 0
        #self.db_flows[flow_id]["new_optical_band"] = 0


    def create_optical_band(self, links, path, bidir, num_slots):
    def create_optical_band(self, links, path, bidir, num_slots, old_band_x=None):
        print("INFO: Creating optical-band of {} slots".format(num_slots))
        print("INFO: Creating optical-band of {} slots".format(num_slots))
        if self.opt_band_id == 0:
        if self.opt_band_id == 0:
            self.opt_band_id += 1
            self.opt_band_id += 1
@@ -880,8 +914,7 @@ class RSA():
        if bidir:
        if bidir:
            self.optical_bands[back_opt_band_id]["src"] = path[-1]
            self.optical_bands[back_opt_band_id]["src"] = path[-1]
        '''
        '''

        c_slots, l_slots, s_slots = self.get_slots(links, num_slots, optical_band_id=None, old_band_x=old_band_x)
        c_slots, l_slots, s_slots = self.get_slots(links, num_slots)
        if debug:
        if debug:
            print(c_slots)
            print(c_slots)
            print(l_slots)
            print(l_slots)
@@ -895,7 +928,7 @@ class RSA():
                print(f0, band)
                print(f0, band)
            print("INFO: RSA completed for optical band")
            print("INFO: RSA completed for optical band")
            if flow_list is None:
            if flow_list is None:
                self.null_values(self.flow_id)
                self.null_values_ob(self.opt_band_id)
                return self.flow_id, []
                return self.flow_id, []
            #slots_i = []
            #slots_i = []
            #for i in slots:
            #for i in slots:
@@ -983,18 +1016,31 @@ class RSA():
                result.append(ob_id)
                result.append(ob_id)
        return result
        return result


    def rsa_fs_computation(self, src, dst, rate, bidir, band):
    def rsa_fs_computation(self, src, dst, rate, bidir, band, bandx_id):
        num_slots_ob = "full_band"
        if band is not None:
        if band is not None:
            num_slots_ob = map_band_to_slot(band)
            num_slots_ob = map_band_to_slot(band)
            print(band, num_slots_ob)
            print(band, num_slots_ob)
        else:
            num_slots_ob = "full_band"
        if self.nodes_dict[src]["type"] == "OC-ROADM" and self.nodes_dict[dst]["type"] == "OC-ROADM":
        if self.nodes_dict[src]["type"] == "OC-ROADM" and self.nodes_dict[dst]["type"] == "OC-ROADM":
            print("INFO: ROADM to ROADM connection")
            print("INFO: ROADM to ROADM connection")
            old_band_x = None
            if bandx_id != None:
                if bandx_id in self.optical_bands.keys():
                    path_x = self.optical_bands[bandx_id]["path"]
                    old_band_x = self.optical_bands[bandx_id]["band_type"]
                    links, path = self.compute_disjoint_path(src, dst, path_x)
                else:
                    links, path = self.compute_disjoint_path(src, dst, None)
                if len(path) < 1:
                    print("INFO: no disjoint path found, installing in the shortest path")
                    links, path = self.compute_path(src, dst)
            else:
                links, path = self.compute_path(src, dst)
                links, path = self.compute_path(src, dst)
            if len(path) < 1:
            if len(path) < 1:
                self.null_values_ob(self.opt_band_id)
                self.null_values_ob(self.opt_band_id)
                return self.flow_id, []
                return self.opt_band_id, []
            optical_band_id, temp_links = self.create_optical_band(links, path, bidir, num_slots_ob)
            optical_band_id, temp_links = self.create_optical_band(links, path, bidir, num_slots_ob, old_band_x)
            return None, optical_band_id
            return None, optical_band_id
        print("INFO: TP to TP connection")
        print("INFO: TP to TP connection")
        if self.flow_id == 0:
        if self.flow_id == 0:
@@ -1004,6 +1050,9 @@ class RSA():
                self.flow_id += 2
                self.flow_id += 2
            else:
            else:
                self.flow_id += 1
                self.flow_id += 1
        if band is not None:
            num_slots_ob = map_band_to_slot(band)
            print(band, num_slots_ob)
        self.db_flows[self.flow_id] = {}
        self.db_flows[self.flow_id] = {}
        self.db_flows[self.flow_id]["flow_id"] = self.flow_id
        self.db_flows[self.flow_id]["flow_id"] = self.flow_id
        self.db_flows[self.flow_id]["src"] = src
        self.db_flows[self.flow_id]["src"] = src
@@ -1082,7 +1131,7 @@ class RSA():
                            '''
                            '''
                            if bidir:
                            if bidir:
                                rev_ob_id = self.optical_bands[ob_id]["reverse_optical_band_id"]
                                rev_ob_id = self.optical_bands[ob_id]["reverse_optical_band_id"]
                                self.optical_bands[rev_ob_id]["served_lightpaths"].append(self.flow_id)
                                self.optical_bands[rev_ob_id]["served_lightpaths"].append(flow_id)
                            '''
                            '''
                            return self.flow_id, ob_id
                            return self.flow_id, ob_id
                        else:
                        else:
@@ -1143,13 +1192,13 @@ class RSA():
                                    self.db_flows[self.flow_id]["freq"] = f0
                                    self.db_flows[self.flow_id]["freq"] = f0
                                    self.db_flows[self.flow_id]["is_active"] = True
                                    self.db_flows[self.flow_id]["is_active"] = True
                                    self.db_flows[self.flow_id]["parent_opt_band"] = ob_id
                                    self.db_flows[self.flow_id]["parent_opt_band"] = ob_id
                                    #self.db_flows[self.flow_id]["new_optical_band"] = 1
                                    #self.db_flows[flow_id]["new_optical_band"] = 1
                                    self.db_flows[self.flow_id]["new_optical_band"] = 2
                                    self.db_flows[self.flow_id]["new_optical_band"] = 2
                                    self.optical_bands[ob_id]["served_lightpaths"].append(self.flow_id)
                                    self.optical_bands[ob_id]["served_lightpaths"].append(self.flow_id)
                                    '''
                                    '''
                                    if bidir:
                                    if bidir:
                                        rev_ob_id = self.optical_bands[ob_id]["reverse_optical_band_id"]
                                        rev_ob_id = self.optical_bands[ob_id]["reverse_optical_band_id"]
                                        self.optical_bands[rev_ob_id]["served_lightpaths"].append(self.flow_id)
                                        self.optical_bands[rev_ob_id]["served_lightpaths"].append(flow_id)
                                    '''
                                    '''
                                    return self.flow_id, ob_id
                                    return self.flow_id, ob_id
                                else:
                                else:
@@ -1203,11 +1252,142 @@ class RSA():
            '''
            '''
            if bidir:
            if bidir:
                rev_ob_id = self.optical_bands[optical_band_id]["reverse_optical_band_id"]
                rev_ob_id = self.optical_bands[optical_band_id]["reverse_optical_band_id"]
                self.optical_bands[rev_ob_id]["served_lightpaths"].append(self.flow_id)
                self.optical_bands[rev_ob_id]["served_lightpaths"].append(flow_id)
            '''
            '''
            
            
        return self.flow_id, optical_band_id
        return self.flow_id, optical_band_id


    def move_flow(self, flow_id, slots, band, links, bidir, o_b_id = None):
        for l in links:
            link = self.get_link_by_name(l)
            fib = link["optical_details"]
            #self.restore_link(fib, slots, band)
            self.restore_link_2(fib, slots, band, link=link)
        if o_b_id is not None: 
            if debug:
                print("restoring OB")
            print(f"invoking restore_optical_band o_b_id: {o_b_id} , slots {slots} , band {band} ")    
            self.restore_optical_band(o_b_id, slots, band)
            if flow_id in self.optical_bands[o_b_id]["served_lightpaths"]:
                if flow_id in self.optical_bands[o_b_id]["served_lightpaths"]:
                    self.optical_bands[o_b_id]["served_lightpaths"].remove(flow_id)

            #self.restore_optical_band_2(o_b_id, slots, band,links)
        if bidir:
            for l in links:
                r_l = reverse_link(l)
                if debug:
                    print(r_l)
                rlink = self.get_link_by_name(r_l)
                fib = rlink["optical_details"]
                #fib = self.get_link_by_name(r_l)["optical_details"]
                if list_in_list(slots, str_list_to_int(fib[band].keys())):
                    #self.restore_link(fib, slots, band, link=l)
                    self.restore_link_2(fib, slots, band, link=rlink)
                    if debug:
                        print(fib[band])

        return True

    def rsa_fs_recomputation(self, flow_idy):
        flow_idx = int(flow_idy)
        print(f"INFO: Reconifguring connection {flow_idx}")
        if flow_idx not in self.db_flows.keys():
            print(f"ERROR: key not present {flow_idx}")
        else:
            print(self.db_flows[flow_idx])
        #self.db_flows[flow_idx] = {}
        src = self.db_flows[flow_idx]["src"]
        dst = self.db_flows[flow_idx]["dst"]
        rate = self.db_flows[flow_idx]["bitrate"]
        bidir = self.db_flows[flow_idx]["bidir"]
        flow_list = self.db_flows[flow_idx]["flows"]
        band_type = self.db_flows[flow_idx]["band_type"]
        slots_init = self.db_flows[flow_idx]["slots"] 
        fiber_f = self.db_flows[flow_idx]["fiber_forward"]
        fiber_b = self.db_flows[flow_idx]["fiber_backward"]
        op = self.db_flows[flow_idx]["op-mode"]
        num_slots = self.db_flows[flow_idx]["n_slots"]
        links = self.db_flows[flow_idx]["links"]
        path = self.db_flows[flow_idx]["path"]
        band = self.db_flows[flow_idx]["band"]
        f0 = self.db_flows[flow_idx]["freq"]
        ob_idx = self.db_flows[flow_idx]["parent_opt_band"]
        
        r1 = ""
        r2 = ""
        if len(links) == 2:
            [t1, r1] = links[0].split("-")                    
            [r2, t2] = links[1].split("-")
        else:
            return 0, 0
        existing_ob = self.get_optical_bands(r1, r2)
        if len(existing_ob) > 0:
            print("INFO: Trying to move connection to an existing OB")
            #first checking in existing OB
            for ob_id in existing_ob:
                if "is_active" in self.optical_bands[ob_id].keys():
                    is_active = self.optical_bands[ob_id]["is_active"]
                    if not is_active:
                        continue
                op, num_slots = map_rate_to_slot(rate)
                if debug:
                    print(links)
                
                c_slots, l_slots, s_slots = self.get_slots(links, num_slots, ob_id)
                if debug:
                    print(c_slots)
                    print(l_slots)
                    print(s_slots)
                if band_type == "c_slots":
                    c_slots = []
                elif band_type == "l_slots":
                    l_slots = []
                elif band_type == "s_slots":
                    s_slots = []
                if len(c_slots) >= num_slots or len(l_slots) >= num_slots or len(s_slots) >= num_slots:
                    flow_list, band_range, slots, fiber_f, fiber_b = self.select_slots_and_ports_fs(links, num_slots,
                                                                                                            c_slots,
                                                                                                            l_slots, s_slots, bidir,
                                                                                                            ob_id)
                                                                                                    
                    f0, band = frequency_converter(band_range, slots)
                    if debug:
                        print(f0, band)
                    print("INFO: RSA completed for Flex Lightpath with OB already in place")
                    if flow_list is None:
                        continue
                    slots_i = []
                    for i in slots:
                        slots_i.append(int(i))
                    self.db_flows[flow_idx]["flows"] = flow_list
                    self.db_flows[flow_idx]["band_type"] = band_range
                    self.db_flows[flow_idx]["slots"] = slots_i
                    self.db_flows[flow_idx]["fiber_forward"] = fiber_f
                    self.db_flows[flow_idx]["fiber_backward"] = fiber_b
                    self.db_flows[flow_idx]["op-mode"] = op
                    self.db_flows[flow_idx]["n_slots"] = num_slots
                    #self.db_flows[flow_idx]["links"] = temp_links2
                    #self.db_flows[flow_idx]["path"] = temp_path
                    self.db_flows[flow_idx]["band"] = band
                    self.db_flows[flow_idx]["freq"] = f0
                    self.db_flows[flow_idx]["is_active"] = True
                    self.db_flows[flow_idx]["parent_opt_band"] = ob_id
                    self.db_flows[flow_idx]["new_optical_band"] = 0
                    self.optical_bands[ob_id]["served_lightpaths"].append(flow_idx)
                    '''
                    if bidir:
                        rev_ob_id = self.optical_bands[ob_id]["reverse_optical_band_id"]
                        self.optical_bands[rev_ob_id]["served_lightpaths"].append(flow_id)
                    '''
                    self.move_flow(flow_idx, slots_init, band_type, links, bidir, ob_idx)
                    return flow_idx, ob_id
                else:
                    continue
            print("not enough slots")
            return None, 0
            
                        
    def extend_optical_band(self, ob_id, band=None):
    def extend_optical_band(self, ob_id, band=None):
        ob = self.optical_bands[ob_id]
        ob = self.optical_bands[ob_id]
        links = ob["links"]
        links = ob["links"]
+157 −12

File changed.

Preview size limit exceeded, changes collapsed.

+222 −85

File changed.

Preview size limit exceeded, changes collapsed.

+143 −6

File changed.

Preview size limit exceeded, changes collapsed.

Loading