diff --git a/src/opticalcontroller/OpticalController.py b/src/opticalcontroller/OpticalController.py index fd2e07724d0b5ee10049b1d6b9f83a8d600d55cf..fdf30332b1549bb14351f9c85c82f3146da1f705 100644 --- a/src/opticalcontroller/OpticalController.py +++ b/src/opticalcontroller/OpticalController.py @@ -102,20 +102,13 @@ class DelFLightpath(Resource): flow = None match1=False ob_id=None - print(f"delete_lightpath {delete_band} and ob_id {ob_id} and flow_id {flow_id}") if flow_id is not None: if flow_id in rsa.db_flows.keys(): flow = rsa.db_flows[flow_id] match1 = flow["src"] == src and flow["dst"] == dst and flow["bitrate"] == bitrate ob_id = flow["parent_opt_band"] - else : - if o_band_id in rsa.db_flows.keys(): - flow=rsa.db_flows[o_band_id] - match1 = flow["src"] == src and flow["dst"] == dst and flow["bitrate"] == bitrate - ob_id=o_band_id - print(f"delete_lightpath {delete_band} and ob_id {ob_id}") - print(f"and flow {flow}") + flow['is_active']=False if flow is not None: @@ -141,13 +134,13 @@ class DelFLightpath(Resource): else: if match1: - if delete_band !=0 and ob_id is not None: - print(f"delete_lightpath {delete_band} and ob_id {ob_id}") - if len( rsa.optical_bands[ob_id]["served_lightpaths"]) != 0: - return "DELETE_NOT_ALLOWED" ,400 + # if delete_band !=0 and ob_id is not None: + # print(f"delete_lightpath {delete_band} and ob_id {ob_id}") + # if len( rsa.optical_bands[ob_id]["served_lightpaths"]) != 0: + # return "DELETE_NOT_ALLOWED" ,400 - rsa.del_handler(flow,flow_id,ob_id,delete_band) + rsa.del_flow(flow,flow_id,ob_id) @@ -164,66 +157,66 @@ class DelFLightpath(Resource): -@optical.route('/DelOpticalBand/<string:src>/<string:dst>/<int:o_band_id>/<int:delete_band>') +@optical.route('/DelOpticalBand/<string:src>/<string:dst>/<int:o_band_id>/<int:delete_band>',methods=['DELETE']) @optical.response(200, 'Success') @optical.response(404, 'Error, not found') class DelOpticalBand(Resource): @staticmethod - def delete( src, dst, bitrate, o_band_id,delete_band,flow_id=None): + def delete( src, dst, o_band_id,delete_band): flow = None - match1=False + match1=True ob_id=None - print(f"delete_lightpath {delete_band} and ob_id {ob_id} and flow_id {flow_id}") - - - if o_band_id in rsa.optical_bands.keys(): - flow=rsa.optical_bands[o_band_id] - match1 = flow["src"] == src and flow["dst"] == dst - ob_id=o_band_id - print(f"delete_lightpath {delete_band} and ob_id {ob_id}") - print(f"and flow {flow}") - if flow is not None: - + if o_band_id is not None : - bidir = flow["bidir"] + if o_band_id in rsa.optical_bands.keys(): + flow=rsa.optical_bands[o_band_id] + #match1 = flow["src"] == src and flow["dst"] == dst + ob_id=o_band_id - if bidir: - match2 = flow["src"] == dst and flow["dst"] == src and flow["bitrate"] == bitrate - if match1 or match2: - ob_id = flow["parent_opt_band"] - rsa.del_flow(flow, ob_id) - rsa.db_flows[flow_id]["is_active"] = False - if flow_id in rsa.optical_bands[ob_id]["served_lightpaths"].remove: - rsa.optical_bands[ob_id]["served_lightpaths"].remove(flow_id) - #if rsa.optical_bands[ob_id]["reverse_optical_band_id"] != 0: - # rev_ob_id = rsa.optical_bands[ob_id]["reverse_optical_band_id"] - # rsa.optical_bands[rev_ob_id]["served_lightpaths"].remove(flow_id) - - if debug: - print(rsa.links_dict) - return "flow {} deleted".format(flow_id), 200 + if flow is not None: + + + bidir = flow["bidir"] + + if bidir: + match2 = flow["src"] == dst and flow["dst"] == src and flow["bitrate"] + if match1 or match2: + ob_id = flow["parent_opt_band"] + #rsa.del_flow(flow, ob_id) + rsa.optical_bands[ob_id]["is_active"] = False + # if flow_id in rsa.optical_bands[ob_id]["served_lightpaths"].remove: + # rsa.optical_bands[ob_id]["served_lightpaths"].remove(flow_id) + #if rsa.optical_bands[ob_id]["reverse_optical_band_id"] != 0: + # rev_ob_id = rsa.optical_bands[ob_id]["reverse_optical_band_id"] + # rsa.optical_bands[rev_ob_id]["served_lightpaths"].remove(flow_id) + + if debug: + print(rsa.links_dict) + return "ob_id {} deleted".format(ob_id), 200 + else: + return "ob_id {} not matching".format(ob_id), 404 else: - return "flow {} not matching".format(flow_id), 404 - else: - if match1: - - if ob_id is not None: - - if len( rsa.optical_bands[ob_id]["served_lightpaths"]) != 0: - return "DELETE_NOT_ALLOWED" ,400 + if match1: + + if ob_id is not None: + + if len( rsa.optical_bands[ob_id]["served_lightpaths"]) != 0: + return "DELETE_NOT_ALLOWED" ,400 - rsa.del_band(flow,ob_id,delete_band) + rsa.del_band(flow,ob_id) + - - - if debug: - print(f"vor ob_id {ob_id} rsa.optical_bands {rsa.optical_bands[ob_id]}") - print(f"rsa.links_dict {rsa.links_dict}") - return "flow {} deleted".format(flow_id), 200 - else: - return "flow {} not matching".format(flow_id), 404 + + if debug: + print(f"vor ob_id {ob_id} rsa.optical_bands {rsa.optical_bands[ob_id]}") + print(f"rsa.links_dict {rsa.links_dict}") + return "ob_id {} deleted".format(ob_id), 200 + else: + return "ob_id {} not matching".format(ob_id), 404 + else : + return "flow for ob_id {} not found".format(ob_id),400 else: - return "flow id {} does not exist".format(flow_id), 404 + return "ob_id {} does not exist".format(ob_id), 404 diff --git a/src/opticalcontroller/RSA.py b/src/opticalcontroller/RSA.py index 19824e5a727f7ee4bf9095b48d31c22bac6cacfa..5f3b10c8516652c8d8080b8dff7342e829f85b26 100644 --- a/src/opticalcontroller/RSA.py +++ b/src/opticalcontroller/RSA.py @@ -338,23 +338,12 @@ class RSA(): #f = fiber_f[l] #fib = link['fibers'][f] fib = self.get_link_by_name(l)["optical_details"] - print(f"del_flow_fib {fib } and band {band}") - print(f"del_flow { str_list_to_int(fib[band].keys())}") - ''' - if list_in_list(slots, str_list_to_int(fib[band].keys())): - #self.restore_link(fib, slots, band) - print("invoking restore_link_2 from del_flow") - self.restore_link_2(fib, slots, band,link=l) - if debug: - print(fib[band]) - ''' - print(f"invoking restore_link_2 fib: {fib} , slots {slots} , band {band} ") + self.restore_link(fib, slots, band) if debug: print(fib[band]) - if flow_id in self.optical_bands[o_b_id]["served_lightpaths"]: - self.optical_bands[o_b_id]["served_lightpaths"].remove(flow_id) + if o_b_id is not None: @@ -405,8 +394,7 @@ class RSA(): print(f"delete band {flow} ") - if len(self.optical_bands[o_b_id]["served_lightpaths"])>0: - return False + flows = flow["flows"] band = None #slots = flow["slots"]