Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
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"] = 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(self.flow_id)
'''
return self.flow_id, ob_id
else:
print("it is not possible to allocate connection in extended OB {}".format(ob_id))
if band is None:
print("INFO: Not existing optical-band meeting the requirements")
else:
print("INFO: optical-band width specified")
#if no OB I create a new one
links, path = self.compute_path(src, dst)
optical_band_id, temp_links = self.create_optical_band(links, path, bidir, num_slots_ob)
op, num_slots = map_rate_to_slot(rate)
if debug:
print(temp_links)
c_slots, l_slots, s_slots = self.get_slots(temp_links, num_slots, optical_band_id)
if debug:
print(c_slots)
print(l_slots)
print(s_slots)
if len(c_slots) > 0 or len(l_slots) > 0 or len(s_slots) > 0:
flow_list, band_range, slots, fiber_f, fiber_b = self.select_slots_and_ports_fs(temp_links, num_slots, c_slots,
l_slots, s_slots, bidir, optical_band_id)
f0, band = frequency_converter(band_range, slots)
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
if debug:
print(f0, band)
print("INFO: RSA completed for FLex Lightpath with new OB")
if flow_list is None:
self.null_values(self.flow_id)
return self.flow_id, optical_band_id
slots_i = []
for i in slots:
slots_i.append(int(i))
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_links
self.db_flows[self.flow_id]["path"] = 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"] = optical_band_id
self.db_flows[self.flow_id]["new_optical_band"] = 1
self.optical_bands[optical_band_id]["served_lightpaths"].append(self.flow_id)
'''
if bidir:
rev_ob_id = self.optical_bands[optical_band_id]["reverse_optical_band_id"]
self.optical_bands[rev_ob_id]["served_lightpaths"].append(self.flow_id)
'''
return self.flow_id, optical_band_id
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
def extend_optical_band(self, ob_id, band=None):
ob = self.optical_bands[ob_id]
links = ob["links"]
old_band = ob["band"]
band_type = ob["band_type"]
f0 = ob["freq"]
slots = ob[band_type]
if band is None:
num_slots_ob = map_band_to_slot(old_band/1000.0)
else:
num_slots_ob = map_band_to_slot(band)
new_slots = []
for l in links:
link = self.get_link_by_name(l)
fib = link["optical_details"][band_type]
#s_slots = get_side_slots_on_link(link, band_type, num_slots_ob, slots)
s_slots, s_num = get_side_slots_on_link(fib, num_slots_ob, slots)
print("NEW SLOTS {}".format(s_slots))
if len(new_slots) == 0:
new_slots = s_slots
else:
if len(new_slots) < s_num:
new_slots = list_in_list(new_slots, s_slots)
print("NEW SLOTS {}".format(new_slots))
self.augment_optical_band(ob_id, new_slots, band_type)
new_band = int(len(new_slots)*12.5*1000)
print("{}, {},{},{} ".format(old_band, f0, len(new_slots), new_band))
final_band = old_band + new_band
final_f0 = int(f0 + new_band/2)
print("{}, {}".format(final_band, final_f0))
ob["band"] = final_band
ob["freq"] = final_f0
for link_x in links:
link = self.get_link_by_name(link_x)
fib = link["optical_details"]
self.update_link(fib, new_slots, band_type)