Skip to content
Snippets Groups Projects
RSA.py 47.3 KiB
Newer Older
  • Learn to ignore specific revisions
  •         if band is None:
                print("INFO: Not existing optical-band meeting the requirements")
            else:
                print("INFO: optical-band width specified")
            #if no OB I create a new one
            links, path = self.compute_path(src, dst)
            optical_band_id, temp_links = self.create_optical_band(links, path, bidir, num_slots_ob)
            op, num_slots = map_rate_to_slot(rate)
            if debug:
                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)
            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)
    
                f0, band = frequency_converter(band_range, slots)
    
                if debug:
                    print(f0, band)
                print("INFO: RSA completed for FLex Lightpath with new OB")
                if flow_list is None:
                    self.null_values(self.flow_id)
                    return self.flow_id, optical_band_id
                slots_i = []
                for i in slots:
                    slots_i.append(int(i))
    
                self.db_flows[self.flow_id]["flows"] = flow_list
                self.db_flows[self.flow_id]["band_type"] = band_range
                self.db_flows[self.flow_id]["slots"] = slots_i
                self.db_flows[self.flow_id]["fiber_forward"] = fiber_f
                self.db_flows[self.flow_id]["fiber_backward"] = fiber_b
                self.db_flows[self.flow_id]["op-mode"] = op
                self.db_flows[self.flow_id]["n_slots"] = num_slots
                self.db_flows[self.flow_id]["links"] = temp_links
                self.db_flows[self.flow_id]["path"] = path
                self.db_flows[self.flow_id]["band"] = band
                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"] = optical_band_id
                self.db_flows[self.flow_id]["new_optical_band"] = 1
                self.optical_bands[optical_band_id]["served_lightpaths"].append(self.flow_id)
                '''
                if bidir:
                    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)
                '''
            return self.flow_id, optical_band_id
    
    
        def extend_optical_band(self, ob_id, band=None):
            ob = self.optical_bands[ob_id]
            links = ob["links"]
            old_band = ob["band"]
            band_type = ob["band_type"]
            f0 = ob["freq"]
            slots = ob[band_type]
            if band is None:
                num_slots_ob = map_band_to_slot(old_band/1000.0)
            else:
                num_slots_ob = map_band_to_slot(band)
            new_slots = []
            for l in links:
                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))
                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))
            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))
            final_band = old_band + new_band
            final_f0 = int(f0 + new_band/2)
            print("{}, {}".format(final_band, final_f0))
            ob["band"] = final_band
            ob["freq"] = final_f0
            for link_x in links:
                link = self.get_link_by_name(link_x)
                fib = link["optical_details"]
                self.update_link(fib, new_slots, band_type)
            return new_slots