diff --git a/src/opticalcontroller/RSA.py b/src/opticalcontroller/RSA.py index a88903ac5e1d1f823eb75917538425fc5858c8e5..84e1269f2f1be094f2f8f11e931a5a5d56c290be 100644 --- a/src/opticalcontroller/RSA.py +++ b/src/opticalcontroller/RSA.py @@ -269,15 +269,14 @@ class RSA(): print(f"fib updated {fib}") #print(fib) - def update_link_2(self, fib, slots, band,link): + def update_link_2(self, fib, slots, band): #print(fib) for i in slots: fib[band][str(i)] = 0 if 'used' in fib: fib['used'] = True - set_link_update(fib,link) - #print(fib) + def update_optical_band(self, optical_band_id, slots, band): for i in slots: @@ -294,14 +293,13 @@ class RSA(): fib['used'] = False #fib[band].sort() - def restore_link_2(self, fib, slots, band,link): - print("start restoring link") + def restore_link_2(self, fib, slots, band): + 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): for i in slots: @@ -512,7 +510,7 @@ class RSA(): if list_in_list(slots, str_list_to_int(fib[band].keys())): #fiber_list[l] = fib["ID"] #self.update_link(fib, slots, band) - self.update_link_2(fib,slots,band,link) + self.update_link_2(fib,slots,band) break print("INFO: Path forward computation completed") return fiber_list diff --git a/src/opticalcontroller/tools.py b/src/opticalcontroller/tools.py index 12743699181d1384e6277044ff6e1339c1fdc502..7aa462a9110e641c1b40c7c61d304b1a19ca4c47 100644 --- a/src/opticalcontroller/tools.py +++ b/src/opticalcontroller/tools.py @@ -261,65 +261,5 @@ def handle_slot (slot_field, slot): slot_field[key]=value - -def update_optical_band (optical_bands,optical_band_id,band,link): - key_list = optical_bands[optical_band_id][band].keys() - corrected_slots=optical_bands[optical_band_id][band] - print(f"band {band}") - print(f"corrected_slots_before {corrected_slots}") - if (len(key_list) < 20): - corrected_slots=correct_slot(optical_bands[optical_band_id][band]) - - fib={} - print(f"corrected_slots_after {corrected_slots}") - fib['c_slots']=link['optical_details']['c_slots'] - fib['l_slots']=link['optical_details']['l_slots'] - fib['s_slots']=link['optical_details']['s_slots'] - - fib[band]=corrected_slots - fib["src_port"]=optical_bands[optical_band_id]['src_port'] - fib["dst_port"]=optical_bands[optical_band_id]['dst_port'] - fib["local_peer_port"]=link["optical_details"]["local_peer_port"] - fib["remote_peer_port"]=link["optical_details"]["remote_peer_port"] - set_link_update(fib,link,test=f"restoring_optical_band {link['link_id']}") - -def set_link_update (fib:dict,link:dict,test="updating"): - - print(f"invoked from {test}") - print(f"fib updated {fib}") - optical_link = OpticalLink() - linkId = LinkId() - linkId.link_uuid.uuid=link["link_id"]["link_uuid"]["uuid"] - optical_details = OpticalLinkDetails() - optical_link.optical_details.length=0 - if "src_port" in fib : - optical_link.optical_details.src_port=fib["src_port"] - if "dst_port" in fib : - optical_link.optical_details.dst_port=fib["dst_port"] - if "local_peer_port" in fib : - optical_link.optical_details.local_peer_port=fib['local_peer_port'] - if "remote_peer_port" in fib: - optical_link.optical_details.remote_peer_port=fib['remote_peer_port'] - - optical_link.optical_details.used=fib['used'] if 'used' in fib else False - if "c_slots" in fib : - - handle_slot( optical_link.optical_details.c_slots,fib["c_slots"]) - if "s_slots" in fib : - - handle_slot( optical_link.optical_details.s_slots,fib["s_slots"]) - if "l_slots" in fib : - - handle_slot( optical_link.optical_details.l_slots,fib["l_slots"]) - - optical_link.name=link['name'] - - optical_link.link_id.CopyFrom(linkId) - - ctx_client = ContextClient() - ctx_client.connect() - try: - ctx_client.SetOpticalLink(optical_link) - except Exception as err: - print (f"setOpticalLink {err}") +