Newer
Older
links, path = self.compute_path(src, dst)
if len(path) < 1:
self.null_values_ob(self.opt_band_id)
return self.flow_id, []
optical_band_id, temp_links = self.create_optical_band(links, path, bidir, num_slots_ob)
return None, optical_band_id
if self.flow_id == 0:
self.flow_id += 1
else:
if (self.db_flows[self.flow_id]["bidir"] == 1):
self.flow_id += 2
else:
self.flow_id += 1
self.db_flows[self.flow_id] = {}
self.db_flows[self.flow_id]["flow_id"] = self.flow_id
self.db_flows[self.flow_id]["src"] = src
self.db_flows[self.flow_id]["dst"] = dst
self.db_flows[self.flow_id]["bitrate"] = rate
self.db_flows[self.flow_id]["bidir"] = bidir
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
if band is None:
temp_links2 = []
temp_path = []
src_links = get_links_from_node(self.links_dict, src)
dst_links = get_links_to_node(self.links_dict, dst)
if len(src_links.keys()) >= 1:
temp_links2.append(list(src_links.keys())[0])
if len(dst_links.keys()) >= 1:
temp_links2.append(list(dst_links.keys())[0])
if len(temp_links2) == 2:
[t_src, roadm_src] = temp_links2[0].split('-')
[roadm_dst, t_dst] = temp_links2[1].split('-')
temp_path.append(t_src)
temp_path.append(roadm_src)
temp_path.append(roadm_dst)
temp_path.append(t_dst)
existing_ob = self.get_optical_bands(roadm_src, roadm_dst)
if len(existing_ob) > 0:
print("INFO: Evaluating existing OB {}".format(existing_ob))
#first checking in existing OB
ob_found = 0
for ob_id in existing_ob:
if "is_active" in self.optical_bands[ob_id].keys():
is_active = self.optical_bands[ob_id]["is_active"]
if not is_active:
continue
op, num_slots = map_rate_to_slot(rate)
if debug:
print(temp_links2)
c_slots, l_slots, s_slots = self.get_slots(temp_links2, num_slots, ob_id)
if debug:
print(c_slots)
print(l_slots)
print(s_slots)
if len(c_slots) >= num_slots or len(l_slots) >= num_slots or len(s_slots) >= num_slots:
flow_list, band_range, slots, fiber_f, fiber_b = self.select_slots_and_ports_fs(temp_links2, num_slots,
c_slots,
l_slots, s_slots, bidir,
ob_id)
f0, band = frequency_converter(band_range, slots)
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
if debug:
print(f0, band)
print("INFO: RSA completed for Flex Lightpath with OB already in place")
if flow_list is None:
self.null_values(self.flow_id)
continue
slots_i = []
for i in slots:
slots_i.append(int(i))
# return links, path, flow_list, band_range, slots, fiber_f, fiber_b, op, num_slots, f0, band
# links, path, flows, bx, slots, fiber_f, fiber_b, op, n_slots, f0, band
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"] = 0
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("not enough slots")
print("trying to extend OB {}".format(ob_id))
new_slots = self.extend_optical_band(ob_id, band=None)
if len(new_slots) > 0:
band_type = self.optical_bands[ob_id]["band_type"]
c_slots = []
l_slots = []
s_slots = []
if band_type == "c_slots":
c_slots = new_slots
elif band_type == "l_slots":
l_slots = new_slots
else:
s_slots = new_slots
op, num_slots = map_rate_to_slot(rate)
if debug:
c_slots, l_slots, s_slots = self.get_slots(temp_links2, num_slots, ob_id)
if debug:
print(c_slots)
print(l_slots)
print(s_slots)
#print(c_slots)
#print(l_slots)
#print(s_slots)
if len(c_slots) >= num_slots or len(l_slots) >= num_slots or len(s_slots) >= num_slots:
flow_list, band_range, slots, fiber_f, fiber_b = self.select_slots_and_ports_fs(
temp_links2, num_slots,
c_slots,
l_slots, s_slots, bidir,
ob_id)
f0, band = frequency_converter(band_range, slots)
if debug:
print(f0, band)
print("INFO: RSA completed for Flex Lightpath with OB already in place")
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
if flow_list is None:
self.null_values(self.flow_id)
continue
slots_i = []
for i in slots:
slots_i.append(int(i))
# return links, path, flow_list, band_range, slots, fiber_f, fiber_b, op, num_slots, f0, band
# links, path, flows, bx, slots, fiber_f, fiber_b, op, n_slots, f0, band
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)
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
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)
'''
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)
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)