Commit e25a4f15 authored by Mohammad Ismaeel's avatar Mohammad Ismaeel
Browse files

Optical band expansion

parent c0c0a30c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
export TFS_REGISTRY_IMAGES="http://localhost:32000/tfs/"

# Set the list of components, separated by spaces, you want to build images for, and deploy.
export TFS_COMPONENTS="context device pathcomp opticalcontroller service slice  webui tapi"
export TFS_COMPONENTS="context device pathcomp opticalcontroller service slice  webui"

# Uncomment to activate Monitoring (old)
#export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring"
+1 −2
Original line number Diff line number Diff line
@@ -25,9 +25,8 @@ class OpticalBandModel(_Base):
    __tablename__ = 'opticalband'

    ob_uuid = Column(UUID(as_uuid=False), primary_key=True)
    connection_uuid    = Column(ForeignKey('connection.connection_uuid', ondelete='RESTRICT'), nullable=False)
    connection_uuid    = Column(ForeignKey('connection.connection_uuid', ondelete='CASCADE'), nullable=False)
    channel_uuid    = Column(ForeignKey('channel.channel_uuid', ondelete='RESTRICT'), nullable=False)
    
    created_at      = Column(DateTime, nullable=False)


+4 −1
Original line number Diff line number Diff line
@@ -97,12 +97,15 @@ class AddFlexLightpath(Resource):
                return rsa.db_flows[flow_id], 200
            else:
                if len(rsa.optical_bands[optical_band_id]["flows"]) == 0:
                    print('No Path Found ')

                    return 'No path found', 404
                else:
                    t1 = time.time() * 1000.0
                    elapsed = t1 - t0
                    print("INFO: time elapsed = {} ms".format(elapsed))
                   
                    
                    return rsa.optical_bands[optical_band_id], 200
        else:
            return "Error", 404
+28 −22
Original line number Diff line number Diff line
@@ -633,13 +633,14 @@ class RSA():
    #function ivoked for fs lightpaths only
    def select_slots_and_ports_fs(self, links, n_slots, c, l, s, bidir, o_band_id):
        if debug:
            print(self.links_dict)
            print('select_slots_and_ports_fs links_dict',self.links_dict)
            print('self.c_slot_number, self.l_slot_number,  s_slot_number',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:
            print("No slots available in the three bands")
            return None, None, None, None, None
        if debug:
            print(band, slots)
            print('band, slots',band, slots)
        self.get_fibers_forward(links, slots, band)
        if bidir:
            self.get_fibers_backward(links, slots, band)
@@ -963,7 +964,7 @@ class RSA():
        num_slots_ob = "full_band"
        if band is not None:
            num_slots_ob = map_band_to_slot(band)
            print(band, num_slots_ob)
            print('band, num_slots_ob',band, num_slots_ob)
        if self.nodes_dict[src]["type"] == "OC-ROADM" and self.nodes_dict[dst]["type"] == "OC-ROADM":
            print("INFO: ROADM to ROADM connection")
            links, path = self.compute_path(src, dst)
@@ -1011,12 +1012,13 @@ class RSA():
                                continue
                        op, num_slots = map_rate_to_slot(rate)
                        if debug:
                            print('num_slots',num_slots)
                            print(temp_links2)
                        c_slots, l_slots, s_slots = self.get_slots(temp_links2, num_slots, ob_id)
                        if debug:
                            print(c_slots)
                            print(l_slots)
                            print(s_slots)
                            print('c_slots',c_slots)
                            print('l_slots',l_slots)
                            print('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(temp_links2, num_slots,
                                                                                                            c_slots,
@@ -1057,9 +1059,10 @@ class RSA():
                            return self.flow_id, ob_id
                        else:
                            print("not enough slots")
                            print("trying to extend OB {}".format(ob_id))
                            print("trying to extend OB {} and band {}".format(ob_id,band))
                            new_slots = self.extend_optical_band(ob_id, band=None)

                            if debug : 
                                print ('new_slots',new_slots)
                            if len(new_slots) > 0:
                                band_type = self.optical_bands[ob_id]["band_type"]
                                c_slots = []
@@ -1073,12 +1076,14 @@ class RSA():
                                    s_slots = new_slots
                                op, num_slots = map_rate_to_slot(rate)
                                if debug:
                                    print(temp_links2)
                                    print('num_slots2',num_slots)

                                    print('temp_links2',temp_links2)
                                c_slots, l_slots, s_slots = self.get_slots(temp_links2, num_slots, ob_id)
                                if debug:
                                    print(c_slots)
                                    print(l_slots)
                                    print(s_slots)
                                   print('c_slots',c_slots)
                                   print('l_slots',l_slots)
                                   print('s_slots',s_slots)
                                #print(c_slots)
                                #print(l_slots)
                                #print(s_slots)
@@ -1090,8 +1095,8 @@ class RSA():
                                        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")
                                        print('f0, band',f0, band)
                                    print("INFO: RSA completed Exetnding for Flex Lightpath with OB already in place")
                                    if flow_list is None:
                                        self.null_values(self.flow_id)
                                        continue
@@ -1113,8 +1118,8 @@ class RSA():
                                    self.db_flows[self.flow_id]["freq"] = f0
                                    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]["new_optical_band"] = 1
                                    #self.db_flows[self.flow_id]["new_optical_band"] = 2
                                    #self.db_flows[self.flow_id]["new_optical_band"] = 1
                                    self.db_flows[self.flow_id]["new_optical_band"] = 2
                                    self.optical_bands[ob_id]["served_lightpaths"].append(self.flow_id)
                                    '''
                                    if bidir:
@@ -1138,9 +1143,9 @@ class RSA():
            print(temp_links)
        c_slots, l_slots, s_slots = self.get_slots(temp_links, num_slots, optical_band_id)
        if debug:
            print(c_slots)
            print(l_slots)
            print(s_slots)
            print('c_slots',c_slots)
            print('l_slots',l_slots)
            print('s_slots',s_slots)
        if len(c_slots) > 0 or len(l_slots) > 0 or len(s_slots) > 0:
            flow_list, band_range, slots, fiber_f, fiber_b = self.select_slots_and_ports_fs(temp_links, num_slots, c_slots,
                                                                                            l_slots, s_slots, bidir, optical_band_id)
@@ -1193,14 +1198,15 @@ class RSA():
            link = self.get_link_by_name(l)
            fib = link["optical_details"][band_type]
            #s_slots = get_side_slots_on_link(link, band_type, num_slots_ob, slots)
            s_slots, s_num = get_side_slots_on_link(fib, num_slots_ob, slots)
            print("NEW SLOTS {}".format(s_slots))
            #s_slots, s_num = get_side_slots_on_link(fib, num_slots_ob, slots)
            s_slots,s_num = get_side_slots_on_link_v2(fib, num_slots_ob, slots)
            print("NEW SLOTS {} and s_num {}".format(s_slots,s_num))
            if len(new_slots) == 0:
                new_slots = s_slots
            else:
                if len(new_slots) < s_num:
                    new_slots = list_in_list(new_slots, s_slots)
        print("NEW SLOTS {}".format(new_slots))
        print(" NEW SLOTS  extend_optical_band {}".format(new_slots))
        self.augment_optical_band(ob_id, new_slots, band_type)
        new_band = int(len(new_slots)*12.5*1000)
        print("{}, {},{},{} ".format(old_band, f0, len(new_slots), new_band))
+29 −1
Original line number Diff line number Diff line
@@ -156,7 +156,9 @@ def get_side_slots_on_link(link, val, old_slots):
    starting_slot = keys[-1]
    num = 0
    res = []
    #print(starting_slot)
    print('starting_slot',starting_slot)
    print('y',y)
    
    for slot_id in range(starting_slot, len(y)):
        if link[y[slot_id]] == 1:
            num += 1
@@ -167,6 +169,32 @@ def get_side_slots_on_link(link, val, old_slots):
            return res, num


def get_side_slots_on_link_v2(link, val, old_slots):
    #link = l["optical_details"][band]
    x = list(old_slots.keys())
    y = list(link.keys())
    keys = str_list_to_int(x)
    keys.sort()

    #print("AAAA")
    #print(link, val, old_slots, keys)
    #print(x)
    starting_slot = keys[-1]
    num = 0
    res = []
    print('starting_slot',starting_slot)
    print('y',y)
    
    for slot_id in range(starting_slot, len(y)+1):
        if link[str(slot_id)] == 1:
            num += 1
            res.append(int(slot_id))
       
        if num == val or slot_id == len(y):
            return res, num



def frequency_converter(b, slots):
    l = len(slots)
    if debug:
Loading