From cd334af18b34b4fa0c989b9771d1665f3b57a1c1 Mon Sep 17 00:00:00 2001 From: mismaael Date: Sun, 6 Jul 2025 09:23:09 +0000 Subject: [PATCH] deletion of flex grid service from optical controller --- delete0.xml | 97 +++++++++++++++---- delete1.xml | 75 +++++++++++--- delete2.xml | 75 +++++++++++--- src/opticalcontroller/OpticalController.py | 15 ++- src/opticalcontroller/RSA.py | 26 ++--- .../service/task_scheduler/TaskScheduler.py | 26 +++-- src/service/service/tools/OpticalTools.py | 14 +-- 7 files changed, 249 insertions(+), 79 deletions(-) diff --git a/delete0.xml b/delete0.xml index 4acbc5173..a8af1dca6 100644 --- a/delete0.xml +++ b/delete0.xml @@ -1176,66 +1176,129 @@ OTS-DEG4-TTP-TX - MC-TTP-DEG1-AMPRX-IN-186131250 - Media-channel-186131250THz + MC-TTP-DEG1-AMPRX-IN-192081250 + Media-channel-192081250THz openROADM-if:mediaChannelTrailTerminationPoint inService DEG1-AMPRX DEG1-AMPRX-IN OMS-DEG1-TTP-RX - 186206250.0 - 186056250.0 + 192156250.0 + 192006250.0 - NMC-DEG1-AMPRX-IN-186131250 - Media-channel-186131250THz + NMC-DEG1-AMPRX-IN-192081250 + Media-channel-192081250THz openROADM-if:networkMediaChannelConnectionTerminationPoint inService DEG1-AMPRX DEG1-AMPRX-IN OMS-DEG1-TTP-RX - 186131250 + 192081250 150000 - MC-TTP-DEG2-AMPTX-OUT-186131250 - Media-channel-186131250THz + MC-TTP-DEG2-AMPTX-OUT-192081250 + Media-channel-192081250THz openROADM-if:mediaChannelTrailTerminationPoint inService DEG2-AMPTX DEG2-AMPTX-OUT OMS-DEG2-TTP-TX - 186206250.0 - 186056250.0 + 192156250.0 + 192006250.0 - NMC-DEG2-AMPTX-OUT-186131250 - Media-channel-186131250THz + NMC-DEG2-AMPTX-OUT-192081250 + Media-channel-192081250THz openROADM-if:networkMediaChannelConnectionTerminationPoint inService DEG2-AMPTX DEG2-AMPTX-OUT OMS-DEG2-TTP-TX - 186131250 + 192081250 150000 - NMC-DEG1-AMPRX-IN-186131250 to NMC-DEG2-AMPTX-OUT-186131250 + NMC-DEG1-AMPRX-IN-192081250 to NMC-DEG2-AMPTX-OUT-192081250 off 0 - NMC-DEG1-AMPRX-IN-186131250 + NMC-DEG1-AMPRX-IN-192081250 - NMC-DEG2-AMPTX-OUT-186131250 + NMC-DEG2-AMPTX-OUT-192081250 + + + + MC-TTP-DEG2-AMPRX-IN-192081250 + Media-channel-192081250THz + openROADM-if:mediaChannelTrailTerminationPoint + inService + DEG2-AMPRX + DEG2-AMPRX-IN + OMS-DEG2-TTP-RX + + 192156250.0 + 192006250.0 + + + + NMC-DEG2-AMPRX-IN-192081250 + Media-channel-192081250THz + openROADM-if:networkMediaChannelConnectionTerminationPoint + inService + DEG2-AMPRX + DEG2-AMPRX-IN + OMS-DEG2-TTP-RX + + 192081250 + 150000 + + + + MC-TTP-DEG1-AMPTX-OUT-192081250 + Media-channel-192081250THz + openROADM-if:mediaChannelTrailTerminationPoint + inService + DEG1-AMPTX + DEG1-AMPTX-OUT + OMS-DEG1-TTP-TX + + 192156250.0 + 192006250.0 + + + + NMC-DEG1-AMPTX-OUT-192081250 + Media-channel-192081250THz + openROADM-if:networkMediaChannelConnectionTerminationPoint + inService + DEG1-AMPTX + DEG1-AMPTX-OUT + OMS-DEG1-TTP-TX + + 192081250 + 150000 + + + + NMC-DEG2-AMPRX-IN-192081250 to NMC-DEG1-AMPTX-OUT-192081250 + off + 0 + + NMC-DEG2-AMPRX-IN-192081250 + + + NMC-DEG1-AMPTX-OUT-192081250 diff --git a/delete1.xml b/delete1.xml index 7ce366a2c..d45faa083 100644 --- a/delete1.xml +++ b/delete1.xml @@ -1176,52 +1176,101 @@ OTS-DEG4-TTP-TX - NMC-SRG-SRG1-IN3-186131250 - Network-Media-Channel-CTP-186131250THz + NMC-SRG-SRG1-IN3-192081250 + Network-Media-Channel-CTP-192081250THz openROADM-if:networkMediaChannelConnectionTerminationPoint inService SRG1-WSS SRG1-IN3 - 186131250 + 192081250 150000 - MC-TTP-DEG1-AMPTX-OUT-186131250 - Media-channel-186131250THz + MC-TTP-DEG1-AMPTX-OUT-192081250 + Media-channel-192081250THz openROADM-if:mediaChannelTrailTerminationPoint inService DEG1-AMPTX DEG1-AMPTX-OUT OMS-DEG1-TTP-TX - 186206250.0 - 186056250.0 + 192156250.0 + 192006250.0 - NMC-DEG1-AMPTX-OUT-186131250 - Media-channel-186131250THz + NMC-DEG1-AMPTX-OUT-192081250 + Media-channel-192081250THz openROADM-if:networkMediaChannelConnectionTerminationPoint inService DEG1-AMPTX DEG1-AMPTX-OUT OMS-DEG1-TTP-TX - 186131250 + 192081250 150000 - NMC-SRG-SRG1-IN3-186131250 to NMC-DEG1-AMPTX-OUT-186131250 + NMC-SRG-SRG1-IN3-192081250 to NMC-DEG1-AMPTX-OUT-192081250 off 0 - NMC-SRG-SRG1-IN3-186131250 + NMC-SRG-SRG1-IN3-192081250 - NMC-DEG1-AMPTX-OUT-186131250 + NMC-DEG1-AMPTX-OUT-192081250 + + + + MC-TTP-DEG1-AMPRX-IN-192081250 + Media-channel-192081250THz + openROADM-if:mediaChannelTrailTerminationPoint + inService + DEG1-AMPRX + DEG1-AMPRX-IN + OMS-DEG1-TTP-RX + + 192156250.0 + 192006250.0 + + + + NMC-DEG1-AMPRX-IN-192081250 + Media-channel-192081250THz + openROADM-if:networkMediaChannelConnectionTerminationPoint + inService + DEG1-AMPRX + DEG1-AMPRX-IN + OMS-DEG1-TTP-RX + + 192081250 + 150000 + + + + NMC-SRG-SRG1-OUT3-192081250 + Network-Media-Channel-CTP-192081250THz + openROADM-if:networkMediaChannelConnectionTerminationPoint + inService + SRG1-WSS + SRG1-OUT3 + + 192081250 + 150000 + + + + NMC-DEG1-AMPRX-IN-192081250 to NMC-SRG-SRG1-OUT3-192081250 + off + 0 + + NMC-DEG1-AMPRX-IN-192081250 + + + NMC-SRG-SRG1-OUT3-192081250 diff --git a/delete2.xml b/delete2.xml index 6fbeb333f..9a66243ae 100644 --- a/delete2.xml +++ b/delete2.xml @@ -1176,52 +1176,101 @@ OTS-DEG4-TTP-TX - MC-TTP-DEG1-AMPRX-IN-186131250 - Media-channel-186131250THz + MC-TTP-DEG1-AMPRX-IN-192081250 + Media-channel-192081250THz openROADM-if:mediaChannelTrailTerminationPoint inService DEG1-AMPRX DEG1-AMPRX-IN OMS-DEG1-TTP-RX - 186206250.0 - 186056250.0 + 192156250.0 + 192006250.0 - NMC-DEG1-AMPRX-IN-186131250 - Media-channel-186131250THz + NMC-DEG1-AMPRX-IN-192081250 + Media-channel-192081250THz openROADM-if:networkMediaChannelConnectionTerminationPoint inService DEG1-AMPRX DEG1-AMPRX-IN OMS-DEG1-TTP-RX - 186131250 + 192081250 150000 - NMC-SRG-SRG1-OUT1-186131250 - Network-Media-Channel-CTP-186131250THz + NMC-SRG-SRG1-OUT1-192081250 + Network-Media-Channel-CTP-192081250THz openROADM-if:networkMediaChannelConnectionTerminationPoint inService SRG1-WSS SRG1-OUT1 - 186131250 + 192081250 150000 - NMC-DEG1-AMPRX-IN-186131250 to NMC-SRG-SRG1-OUT1-186131250 + NMC-DEG1-AMPRX-IN-192081250 to NMC-SRG-SRG1-OUT1-192081250 off 0 - NMC-DEG1-AMPRX-IN-186131250 + NMC-DEG1-AMPRX-IN-192081250 - NMC-SRG-SRG1-OUT1-186131250 + NMC-SRG-SRG1-OUT1-192081250 + + + + NMC-SRG-SRG1-IN1-192081250 + Network-Media-Channel-CTP-192081250THz + openROADM-if:networkMediaChannelConnectionTerminationPoint + inService + SRG1-WSS + SRG1-IN1 + + 192081250 + 150000 + + + + MC-TTP-DEG1-AMPTX-OUT-192081250 + Media-channel-192081250THz + openROADM-if:mediaChannelTrailTerminationPoint + inService + DEG1-AMPTX + DEG1-AMPTX-OUT + OMS-DEG1-TTP-TX + + 192156250.0 + 192006250.0 + + + + NMC-DEG1-AMPTX-OUT-192081250 + Media-channel-192081250THz + openROADM-if:networkMediaChannelConnectionTerminationPoint + inService + DEG1-AMPTX + DEG1-AMPTX-OUT + OMS-DEG1-TTP-TX + + 192081250 + 150000 + + + + NMC-SRG-SRG1-IN1-192081250 to NMC-DEG1-AMPTX-OUT-192081250 + off + 0 + + NMC-SRG-SRG1-IN1-192081250 + + + NMC-DEG1-AMPTX-OUT-192081250 diff --git a/src/opticalcontroller/OpticalController.py b/src/opticalcontroller/OpticalController.py index fe6376514..7c20a4de5 100644 --- a/src/opticalcontroller/OpticalController.py +++ b/src/opticalcontroller/OpticalController.py @@ -125,10 +125,7 @@ class DelFLightpath(Resource): ob_id = flow["parent_opt_band"] if 'parent_opt_band' in flow else None flow['is_active']=False if flow is not None: - - - bidir = flow["bidir"] - + bidir = flow["bidir"] if bidir: match2 = flow["src"] == dst and flow["dst"] == src and flow["bitrate"] == bitrate if match1 or match2: @@ -161,8 +158,10 @@ class DelFLightpath(Resource): rsa.del_flow(flow,flow_id,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}") + print(f"rsa.links_dict {rsa.links_dict}") + if ob_id: + print(f"vor ob_id {ob_id} rsa.optical_bands {rsa.optical_bands[ob_id]}") + return "flow {} deleted".format(flow_id), 200 else: return "flow {} not matching".format(flow_id), 404 @@ -272,7 +271,7 @@ class DelOpticalBandSimple(Resource): -@optical.route('/DelLightpath////') +@optical.route('/DelLightpath////') @optical.response(200, 'Success') @optical.response(404, 'Error, not found') class DelLightpath(Resource): @@ -283,7 +282,7 @@ class DelLightpath(Resource): match1 = flow["src"] == src and flow["dst"] == dst and flow["bitrate"] == bitrate match2 = flow["src"] == dst and flow["dst"] == src and flow["bitrate"] == bitrate if match1 or match2: - rsa.del_flow(flow) + rsa.del_flow(flow,flow_id) rsa.db_flows[flow_id]["is_active"] = False if debug: print(rsa.links_dict) diff --git a/src/opticalcontroller/RSA.py b/src/opticalcontroller/RSA.py index 95a49113e..e0a8154ed 100644 --- a/src/opticalcontroller/RSA.py +++ b/src/opticalcontroller/RSA.py @@ -128,7 +128,7 @@ class RSA(): path = shortest_path(self.g, self.g.get_vertex(src), self.g.get_vertex(dst)) print("INFO: Path from {} to {} with distance: {}".format(src, dst, self.g.get_vertex(dst).get_distance())) if debug: - print(path) + print(f"compute_path shortest_path {path}") links = [] for i in range(0, len(path) - 1): s = path[i] @@ -304,14 +304,14 @@ class RSA(): fib['used'] = False #fib[band].sort() - def restore_link_2(self, fib, slots, band, link): - print("start restoring link") - for i in slots: - fib[band][str(i)] = 1 - if 'used' in fib: - fib['used'] = False - #fib[band].keys().sort() - #set_link_update(fib,link,test="restoration") + # def restore_link_2(self, fib, slots, band, link): + # print("start restoring link") + # for i in slots: + # fib[band][str(i)] = 1 + # if 'used' in fib: + # fib['used'] = False + # #fib[band].keys().sort() + # #set_link_update(fib,link,test="restoration") def restore_optical_band(self, optical_band_id, slots, band): @@ -357,9 +357,9 @@ class RSA(): link = self.get_link_by_name(l) fib = link["optical_details"] #self.restore_link(fib, slots, band) - self.restore_link_2(fib, slots, band, link=link) + self.restore_link(fib, slots, band) if debug: - print(fib[band]) + print(f"fib[band] {fib[band]}") if o_b_id is not None: if debug: print("restoring OB") @@ -374,13 +374,13 @@ class RSA(): for l in links: r_l = reverse_link(l) if debug: - print(r_l) + print(f"reverse_link {r_l}") rlink = self.get_link_by_name(r_l) fib = rlink["optical_details"] #fib = self.get_link_by_name(r_l)["optical_details"] if list_in_list(slots, str_list_to_int(fib[band].keys())): #self.restore_link(fib, slots, band, link=l) - self.restore_link_2(fib, slots, band, link=rlink) + self.restore_link(fib, slots, band) if debug: print(fib[band]) ''' diff --git a/src/service/service/task_scheduler/TaskScheduler.py b/src/service/service/task_scheduler/TaskScheduler.py index d1b85e550..bfff1fa3a 100644 --- a/src/service/service/task_scheduler/TaskScheduler.py +++ b/src/service/service/task_scheduler/TaskScheduler.py @@ -34,8 +34,8 @@ from .tasks.Task_ServiceDelete import Task_ServiceDelete from .tasks.Task_ServiceSetStatus import Task_ServiceSetStatus from .TaskExecutor import CacheableObjectType, TaskExecutor from .tasks.Task_OpticalServiceConfigDelete import Task_OpticalServiceConfigDelete -from service.service.tools.OpticalTools import delete_lightpath - +from service.service.tools.OpticalTools import delete_lightpath ,DelFlexLightpath +from common.Constants import OpticalServiceType if TYPE_CHECKING: from service.service.service_handler_api.ServiceHandlerFactory import ServiceHandlerFactory @@ -396,19 +396,29 @@ class TasksScheduler: if str_item_key in explored_items: continue connections = self._context_client.ListConnections(item.service_id) has_media_channel,has_optical_band=self.check_service_for_media_channel(connections=connections,item=item.service_id) - + oc_type = 1 if len(service.service_config.config_rules) > 0: - - - reply,code = delete_lightpath( + for constraint in service.service_constraints: + if "type" in constraint.custom.constraint_type: + oc_type = OpticalServiceType(str(constraint.custom.constraint_value)) + if oc_type == 2 : + reply,code = delete_lightpath( params['src'] ,params ['dst'] , params['bitrate'] - , params['ob_id'] - ,delete_band=not has_media_channel , flow_id= params['flow_id'] ) + else : + reply,code = DelFlexLightpath( + params['src'] + ,params ['dst'] + , params['bitrate'] + , params['ob_id'] + ,delete_band=not has_media_channel + , flow_id= params['flow_id'] + ) + logging.info(f'DelFlexpath reply {reply} and code {code}') if code == 400 and reply_not_allowed in reply : MSG = 'Deleteion for the service is not Allowed , Served Lightpaths is not empty' diff --git a/src/service/service/tools/OpticalTools.py b/src/service/service/tools/OpticalTools.py index 9f543cbe8..5eb622317 100644 --- a/src/service/service/tools/OpticalTools.py +++ b/src/service/service/tools/OpticalTools.py @@ -177,7 +177,7 @@ def get_optical_band(idx) -> str: return optical_band_uni_txt -def delete_lightpath( src, dst, bitrate, ob_id, delete_band, flow_id=None) -> str: +def DelFlexLightpath( src, dst, bitrate, ob_id, delete_band, flow_id=None) -> str: reply = "200" delete_band = 1 if delete_band else 0 base_url = get_optical_controller_base_url() @@ -185,8 +185,7 @@ def delete_lightpath( src, dst, bitrate, ob_id, delete_band, flow_id=None) -> st if flow_id is not None: if ob_id is not None : urlx = "{:s}/DelFlexLightpath/{}/{}/{}/{}/{}".format(base_url, src, dst, bitrate, flow_id,ob_id) - else : - urlx = "{:s}/DelFlexLightpath/{}/{}/{}/{}".format(base_url, src, dst, bitrate, flow_id) + else : #urlx = "http://{}:{}/OpticalTFS/DelOpticalBand/{}/{}/{}".format(OPTICAL_IP, OPTICAL_PORT, src, dst, ob_id) urlx = "{:s}/DelOpticalBandSimple/{}".format(base_url, ob_id) @@ -197,15 +196,16 @@ def delete_lightpath( src, dst, bitrate, ob_id, delete_band, flow_id=None) -> st code = r.status_code return (reply, code) -def DelFlexLightpath (flow_id, src, dst, bitrate, o_band_id): +def delete_lightpath ( src, dst, bitrate, flow_id): reply = "200" base_url = get_optical_controller_base_url() if not TESTING: - urlx = "{:s}/DelFlexLightpath/{}/{}/{}/{}/{}".format(base_url, flow_id, src, dst, bitrate, o_band_id) + urlx = "{:s}/DelLightpath/{}/{}/{}/{}".format(base_url, src, dst, bitrate, flow_id) headers = {"Content-Type": "application/json"} r = requests.delete(urlx, headers=headers) - reply = r.text - return reply + reply = r.text + code = r.status_code + return (reply, code) def get_lightpaths() -> str: base_url = get_optical_controller_base_url() -- GitLab