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

working with all new features

parent ff7c4811
Loading
Loading
Loading
Loading
+114 −2
Original line number Diff line number Diff line
@@ -1260,9 +1260,121 @@ class RSA():
                existing_ob = self.get_optical_bands(roadm_src, roadm_dst)

                if len(existing_ob) > 0:
                    #first checking if provided band id is passed
                    if preferred is not None:
                        ob_id = int(preferred)
                        if "is_active" in self.optical_bands[ob_id].keys():
                            is_active = self.optical_bands[ob_id]["is_active"]
                            if is_active:
                                op, num_slots = map_rate_to_slot(rate)
                                if debug:
                                    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)
                                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,
                                                                                                                    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 not None:
                                        slots_i = []
                                        for i in slots:
                                            slots_i.append(int(i))
                                        # return links, path, flow_list, band_range, slots, fiber_f, fiber_b, op, num_slots, f0, band
                                        #        links, path, flows, bx, slots, fiber_f, fiber_b, op, n_slots, f0, band
                                        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_links2
                                        self.db_flows[self.flow_id]["path"] = temp_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"] = ob_id
                                        self.db_flows[self.flow_id]["new_optical_band"] = 0
                                        self.optical_bands[ob_id]["served_lightpaths"].append(self.flow_id)
                                        '''
                                        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)
                                        '''
                                        return self.flow_id, ob_id
                                else:
                                    print("not enough slots")
                                    print("trying to extend OB {}".format(ob_id))
                                    new_slots = self.extend_optical_band(ob_id, band=None)
                                    if len(new_slots) > 0:
                                        band_type = self.optical_bands[ob_id]["band_type"]
                                        c_slots = []
                                        l_slots = []
                                        s_slots = []
                                        if band_type == "c_slots":
                                            c_slots = new_slots
                                        elif band_type == "l_slots":
                                            l_slots = new_slots
                                        else:
                                            s_slots = new_slots
                                        op, num_slots = map_rate_to_slot(rate)
                                        if debug:
                                            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)
                                        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,
                                                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 not None:
                                                slots_i = []
                                                for i in slots:
                                                    slots_i.append(int(i))
                                                # return links, path, flow_list, band_range, slots, fiber_f, fiber_b, op, num_slots, f0, band
                                                #        links, path, flows, bx, slots, fiber_f, fiber_b, op, n_slots, f0, band
                                                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_links2
                                                self.db_flows[self.flow_id]["path"] = temp_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"] = ob_id
                                                #self.db_flows[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:
                                                    rev_ob_id = self.optical_bands[ob_id]["reverse_optical_band_id"]
                                                    self.optical_bands[rev_ob_id]["served_lightpaths"].append(flow_id)
                                                '''
                                                return self.flow_id, ob_id
                                        else:
                                            print("it is not possible to allocate connection in extended OB {}".format(ob_id))
                    #checking other existing OB                        
                    print("INFO: Evaluating existing OB  {}".format(existing_ob))
                    #first checking in existing OB
                    ob_found = 0
                    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"]
+5 −1
Original line number Diff line number Diff line
@@ -324,9 +324,13 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
                        dj_optical_band_id = int(constraint.custom.constraint_value)
                        logging.info(f"{dj_optical_band_id}")
                    elif "preferred_band" in constraint.custom.constraint_type:
                        #used only for optical band specification
                        logging.info(f"{constraint.custom.constraint_type}={constraint.custom.constraint_value}")
                        preferred = str(constraint.custom.constraint_value)
                        logging.info(f"{preferred}")    
                    elif "optical_band_id" in constraint.custom.constraint_type:
                        #re-use the same tag for the preferred optical band with media-channel
                        preferred = int(constraint.custom.constraint_value)
            reply_txt = ""
            # to get the reply form the optical module
            #multi-granular
+3 −3
Original line number Diff line number Diff line
@@ -149,14 +149,14 @@ def add_flex_lightpath(src, dst, bitrate, bidir, pref, ob_band, dj_optical_band_
        if ob_band is None:
            if bidir is None:
                bidir = 1
            urlx = "{:s}/AddFlexLightpath/{:s}/{:s}/{:s}/{:s}/{:s}".format(base_url, src, dst, str(bitrate), prefs, str(bidir))
            urlx = "{:s}/AddFlexLightpath/{:s}/{:s}/{:s}/{:s}/{:s}".format(base_url, src, dst, str(bitrate), str(prefs), str(bidir))
        else:
            if bidir is None:
                bidir = 1
            if dj_optical_band_id is None:
                urlx = "{:s}/AddFlexLightpath/{:s}/{:s}/{:s}/{:s}/{:s}/{:s}".format(base_url, src, dst, str(bitrate), prefs, str(bidir), str(ob_band))
                urlx = "{:s}/AddFlexLightpath/{:s}/{:s}/{:s}/{:s}/{:s}/{:s}".format(base_url, src, dst, str(bitrate), str(prefs), str(bidir), str(ob_band))
            else:
                urlx = "{:s}/AddFlexLightpath/{:s}/{:s}/{:s}/{:s}/{:s}/{:s}/{:s}".format(base_url, src, dst, str(bitrate), prefs, str(bidir), str(ob_band), str(dj_optical_band_id))                
                urlx = "{:s}/AddFlexLightpath/{:s}/{:s}/{:s}/{:s}/{:s}/{:s}/{:s}".format(base_url, src, dst, str(bitrate), str(prefs), str(bidir), str(ob_band), str(dj_optical_band_id))                
        r = requests.put(urlx, headers=headers)
        print(f"addpathlight {r}")
        reply = r.text 
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ def test_service_recompute_connection(
        name = service.name
        print(name)

        if name == "optical-band1":
        if name == "optical-band-C1":
            response = context_client.ListConnections(service_id)
            print("AAAAAAAAA")
            print('  ServiceId[{:s}] => Connections[{:d}] = {:s}'.format(
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ def test_service_recompute_connection(
        name = service.name
        print(name)

        if name == "optical-band2":
        if name == "optical-band-C2":
            response = context_client.ListConnections(service_id)
            print("AAAAAAAAA")
            print('  ServiceId[{:s}] => Connections[{:d}] = {:s}'.format(