diff --git a/src/opticalcontroller/OpticalController.py b/src/opticalcontroller/OpticalController.py index c6c00fe9ac83bd66a3cafb04d7bb99f2860bbf75..c0bc877e9286e03938024c5a6195c4a9d6b04711 100644 --- a/src/opticalcontroller/OpticalController.py +++ b/src/opticalcontroller/OpticalController.py @@ -115,29 +115,26 @@ class AddFlexLightpath(Resource): @optical.response(404, 'Error, not found') class DelFLightpath(Resource): @staticmethod - def delete( src, dst, bitrate, o_band_id,flow_id=None): - flow = None - match1=False - ob_id=None + def delete( src, dst, bitrate, o_band_id, flow_id=None): + flow = None + match1 = False + ob_id = None 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"] - flow['is_active']=False + flow = rsa.db_flows[flow_id] + match1 = flow["src"] == src and flow["dst"] == dst and flow["bitrate"] == bitrate + ob_id = flow["parent_opt_band"] + flow['is_active'] = False + if flow is not None: - - bidir = flow["bidir"] - 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: + if flow_id in rsa.optical_bands[ob_id]["served_lightpaths"]: 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"] @@ -166,34 +163,29 @@ class DelFLightpath(Resource): return "flow id {} does not exist".format(flow_id), 404 -@optical.route('/DelOpticalBand/<string:src>/<string:dst>/<int:o_band_id>',methods=['DELETE']) +@optical.route('/DelOpticalBand/<string:src>/<string:dst>/<int:o_band_id>', methods=['DELETE']) @optical.response(200, 'Success') @optical.response(404, 'Error, not found') class DelOpticalBand(Resource): @staticmethod def delete( src, dst, o_band_id): flow = None - - ob_id=None - if o_band_id is not None : - + ob_id = None + if o_band_id is not None: 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 - + flow = rsa.optical_bands[o_band_id] + match1 = flow["src"] == src and flow["dst"] == dst and flow["bitrate"] + ob_id = o_band_id + if flow is not None: - - bidir = flow["bidir"] - if bidir: - match2 = flow["src"] == dst and flow["dst"] == src and flow["bitrate"] + 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: + # if flow_id in rsa.optical_bands[ob_id]["served_lightpaths"]: # 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"]