Skip to content
Snippets Groups Projects
Commit e25a4f15 authored by Mohammad Ismaeel's avatar Mohammad Ismaeel
Browse files

Optical band expansion

parent c0c0a30c
No related branches found
No related tags found
1 merge request!341Draft: Resolve "optical bandwidth expansion"
Showing
with 575 additions and 58 deletions
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
export TFS_REGISTRY_IMAGES="http://localhost:32000/tfs/" export TFS_REGISTRY_IMAGES="http://localhost:32000/tfs/"
# Set the list of components, separated by spaces, you want to build images for, and deploy. # Set the list of components, separated by spaces, you want to build images for, and deploy.
export TFS_COMPONENTS="context device pathcomp opticalcontroller service slice webui tapi" export TFS_COMPONENTS="context device pathcomp opticalcontroller service slice webui"
# Uncomment to activate Monitoring (old) # Uncomment to activate Monitoring (old)
#export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring" #export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring"
......
...@@ -25,9 +25,8 @@ class OpticalBandModel(_Base): ...@@ -25,9 +25,8 @@ class OpticalBandModel(_Base):
__tablename__ = 'opticalband' __tablename__ = 'opticalband'
ob_uuid = Column(UUID(as_uuid=False), primary_key=True) ob_uuid = Column(UUID(as_uuid=False), primary_key=True)
connection_uuid = Column(ForeignKey('connection.connection_uuid', ondelete='RESTRICT'), nullable=False) connection_uuid = Column(ForeignKey('connection.connection_uuid', ondelete='CASCADE'), nullable=False)
channel_uuid = Column(ForeignKey('channel.channel_uuid', ondelete='RESTRICT'), nullable=False) channel_uuid = Column(ForeignKey('channel.channel_uuid', ondelete='RESTRICT'), nullable=False)
created_at = Column(DateTime, nullable=False) created_at = Column(DateTime, nullable=False)
......
...@@ -97,12 +97,15 @@ class AddFlexLightpath(Resource): ...@@ -97,12 +97,15 @@ class AddFlexLightpath(Resource):
return rsa.db_flows[flow_id], 200 return rsa.db_flows[flow_id], 200
else: else:
if len(rsa.optical_bands[optical_band_id]["flows"]) == 0: if len(rsa.optical_bands[optical_band_id]["flows"]) == 0:
print('No Path Found ')
return 'No path found', 404 return 'No path found', 404
else: else:
t1 = time.time() * 1000.0 t1 = time.time() * 1000.0
elapsed = t1 - t0 elapsed = t1 - t0
print("INFO: time elapsed = {} ms".format(elapsed)) print("INFO: time elapsed = {} ms".format(elapsed))
return rsa.optical_bands[optical_band_id], 200 return rsa.optical_bands[optical_band_id], 200
else: else:
return "Error", 404 return "Error", 404
......
...@@ -633,13 +633,14 @@ class RSA(): ...@@ -633,13 +633,14 @@ class RSA():
#function ivoked for fs lightpaths only #function ivoked for fs lightpaths only
def select_slots_and_ports_fs(self, links, n_slots, c, l, s, bidir, o_band_id): def select_slots_and_ports_fs(self, links, n_slots, c, l, s, bidir, o_band_id):
if debug: if debug:
print(self.links_dict) print('select_slots_and_ports_fs links_dict',self.links_dict)
print('self.c_slot_number, self.l_slot_number, s_slot_number',self.c_slot_number, self.l_slot_number,self.s_slot_number)
band, slots = slot_selection(c, l, s, n_slots, self.c_slot_number, self.l_slot_number, self.s_slot_number) band, slots = slot_selection(c, l, s, n_slots, self.c_slot_number, self.l_slot_number, self.s_slot_number)
if band is None: if band is None:
print("No slots available in the three bands") print("No slots available in the three bands")
return None, None, None, None, None return None, None, None, None, None
if debug: if debug:
print(band, slots) print('band, slots',band, slots)
self.get_fibers_forward(links, slots, band) self.get_fibers_forward(links, slots, band)
if bidir: if bidir:
self.get_fibers_backward(links, slots, band) self.get_fibers_backward(links, slots, band)
...@@ -963,7 +964,7 @@ class RSA(): ...@@ -963,7 +964,7 @@ class RSA():
num_slots_ob = "full_band" num_slots_ob = "full_band"
if band is not None: if band is not None:
num_slots_ob = map_band_to_slot(band) num_slots_ob = map_band_to_slot(band)
print(band, num_slots_ob) print('band, num_slots_ob',band, num_slots_ob)
if self.nodes_dict[src]["type"] == "OC-ROADM" and self.nodes_dict[dst]["type"] == "OC-ROADM": if self.nodes_dict[src]["type"] == "OC-ROADM" and self.nodes_dict[dst]["type"] == "OC-ROADM":
print("INFO: ROADM to ROADM connection") print("INFO: ROADM to ROADM connection")
links, path = self.compute_path(src, dst) links, path = self.compute_path(src, dst)
...@@ -1011,12 +1012,13 @@ class RSA(): ...@@ -1011,12 +1012,13 @@ class RSA():
continue continue
op, num_slots = map_rate_to_slot(rate) op, num_slots = map_rate_to_slot(rate)
if debug: if debug:
print('num_slots',num_slots)
print(temp_links2) print(temp_links2)
c_slots, l_slots, s_slots = self.get_slots(temp_links2, num_slots, ob_id) c_slots, l_slots, s_slots = self.get_slots(temp_links2, num_slots, ob_id)
if debug: if debug:
print(c_slots) print('c_slots',c_slots)
print(l_slots) print('l_slots',l_slots)
print(s_slots) print('s_slots',s_slots)
if len(c_slots) >= num_slots or len(l_slots) >= num_slots or len(s_slots) >= num_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, flow_list, band_range, slots, fiber_f, fiber_b = self.select_slots_and_ports_fs(temp_links2, num_slots,
c_slots, c_slots,
...@@ -1057,9 +1059,10 @@ class RSA(): ...@@ -1057,9 +1059,10 @@ class RSA():
return self.flow_id, ob_id return self.flow_id, ob_id
else: else:
print("not enough slots") print("not enough slots")
print("trying to extend OB {}".format(ob_id)) print("trying to extend OB {} and band {}".format(ob_id,band))
new_slots = self.extend_optical_band(ob_id, band=None) new_slots = self.extend_optical_band(ob_id, band=None)
if debug :
print ('new_slots',new_slots)
if len(new_slots) > 0: if len(new_slots) > 0:
band_type = self.optical_bands[ob_id]["band_type"] band_type = self.optical_bands[ob_id]["band_type"]
c_slots = [] c_slots = []
...@@ -1073,12 +1076,14 @@ class RSA(): ...@@ -1073,12 +1076,14 @@ class RSA():
s_slots = new_slots s_slots = new_slots
op, num_slots = map_rate_to_slot(rate) op, num_slots = map_rate_to_slot(rate)
if debug: if debug:
print(temp_links2) print('num_slots2',num_slots)
print('temp_links2',temp_links2)
c_slots, l_slots, s_slots = self.get_slots(temp_links2, num_slots, ob_id) c_slots, l_slots, s_slots = self.get_slots(temp_links2, num_slots, ob_id)
if debug: if debug:
print(c_slots) print('c_slots',c_slots)
print(l_slots) print('l_slots',l_slots)
print(s_slots) print('s_slots',s_slots)
#print(c_slots) #print(c_slots)
#print(l_slots) #print(l_slots)
#print(s_slots) #print(s_slots)
...@@ -1090,8 +1095,8 @@ class RSA(): ...@@ -1090,8 +1095,8 @@ class RSA():
ob_id) ob_id)
f0, band = frequency_converter(band_range, slots) f0, band = frequency_converter(band_range, slots)
if debug: if debug:
print(f0, band) print('f0, band',f0, band)
print("INFO: RSA completed for Flex Lightpath with OB already in place") print("INFO: RSA completed Exetnding for Flex Lightpath with OB already in place")
if flow_list is None: if flow_list is None:
self.null_values(self.flow_id) self.null_values(self.flow_id)
continue continue
...@@ -1113,8 +1118,8 @@ class RSA(): ...@@ -1113,8 +1118,8 @@ class RSA():
self.db_flows[self.flow_id]["freq"] = f0 self.db_flows[self.flow_id]["freq"] = f0
self.db_flows[self.flow_id]["is_active"] = True 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]["parent_opt_band"] = ob_id
self.db_flows[self.flow_id]["new_optical_band"] = 1 #self.db_flows[self.flow_id]["new_optical_band"] = 1
#self.db_flows[self.flow_id]["new_optical_band"] = 2 self.db_flows[self.flow_id]["new_optical_band"] = 2
self.optical_bands[ob_id]["served_lightpaths"].append(self.flow_id) self.optical_bands[ob_id]["served_lightpaths"].append(self.flow_id)
''' '''
if bidir: if bidir:
...@@ -1138,9 +1143,9 @@ class RSA(): ...@@ -1138,9 +1143,9 @@ class RSA():
print(temp_links) print(temp_links)
c_slots, l_slots, s_slots = self.get_slots(temp_links, num_slots, optical_band_id) c_slots, l_slots, s_slots = self.get_slots(temp_links, num_slots, optical_band_id)
if debug: if debug:
print(c_slots) print('c_slots',c_slots)
print(l_slots) print('l_slots',l_slots)
print(s_slots) print('s_slots',s_slots)
if len(c_slots) > 0 or len(l_slots) > 0 or len(s_slots) > 0: 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, 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) l_slots, s_slots, bidir, optical_band_id)
...@@ -1193,14 +1198,15 @@ class RSA(): ...@@ -1193,14 +1198,15 @@ class RSA():
link = self.get_link_by_name(l) link = self.get_link_by_name(l)
fib = link["optical_details"][band_type] fib = link["optical_details"][band_type]
#s_slots = get_side_slots_on_link(link, band_type, num_slots_ob, slots) #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) #s_slots, s_num = get_side_slots_on_link(fib, num_slots_ob, slots)
print("NEW SLOTS {}".format(s_slots)) s_slots,s_num = get_side_slots_on_link_v2(fib, num_slots_ob, slots)
print("NEW SLOTS {} and s_num {}".format(s_slots,s_num))
if len(new_slots) == 0: if len(new_slots) == 0:
new_slots = s_slots new_slots = s_slots
else: else:
if len(new_slots) < s_num: if len(new_slots) < s_num:
new_slots = list_in_list(new_slots, s_slots) new_slots = list_in_list(new_slots, s_slots)
print("NEW SLOTS {}".format(new_slots)) print(" NEW SLOTS extend_optical_band {}".format(new_slots))
self.augment_optical_band(ob_id, new_slots, band_type) self.augment_optical_band(ob_id, new_slots, band_type)
new_band = int(len(new_slots)*12.5*1000) new_band = int(len(new_slots)*12.5*1000)
print("{}, {},{},{} ".format(old_band, f0, len(new_slots), new_band)) print("{}, {},{},{} ".format(old_band, f0, len(new_slots), new_band))
......
...@@ -156,7 +156,9 @@ def get_side_slots_on_link(link, val, old_slots): ...@@ -156,7 +156,9 @@ def get_side_slots_on_link(link, val, old_slots):
starting_slot = keys[-1] starting_slot = keys[-1]
num = 0 num = 0
res = [] res = []
#print(starting_slot) print('starting_slot',starting_slot)
print('y',y)
for slot_id in range(starting_slot, len(y)): for slot_id in range(starting_slot, len(y)):
if link[y[slot_id]] == 1: if link[y[slot_id]] == 1:
num += 1 num += 1
...@@ -167,6 +169,32 @@ def get_side_slots_on_link(link, val, old_slots): ...@@ -167,6 +169,32 @@ def get_side_slots_on_link(link, val, old_slots):
return res, num return res, num
def get_side_slots_on_link_v2(link, val, old_slots):
#link = l["optical_details"][band]
x = list(old_slots.keys())
y = list(link.keys())
keys = str_list_to_int(x)
keys.sort()
#print("AAAA")
#print(link, val, old_slots, keys)
#print(x)
starting_slot = keys[-1]
num = 0
res = []
print('starting_slot',starting_slot)
print('y',y)
for slot_id in range(starting_slot, len(y)+1):
if link[str(slot_id)] == 1:
num += 1
res.append(int(slot_id))
if num == val or slot_id == len(y):
return res, num
def frequency_converter(b, slots): def frequency_converter(b, slots):
l = len(slots) l = len(slots)
if debug: if debug:
......
...@@ -288,8 +288,9 @@ class ServiceServiceServicerImpl(ServiceServiceServicer): ...@@ -288,8 +288,9 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
# reply with 2 transponders and 2 roadms # reply with 2 transponders and 2 roadms
reply_json = json.loads(reply_txt) reply_json = json.loads(reply_txt)
LOGGER.debug('[optical] reply_json[{:s}]={:s}'.format(str(type(reply_json)), str(reply_json))) LOGGER.info('[optical] reply_json[{:s}]={:s}'.format(str(type(reply_json)), str(reply_json)))
optical_band_txt = "" optical_band_txt = ""
if "new_optical_band" in reply_json.keys(): if "new_optical_band" in reply_json.keys():
if reply_json["new_optical_band"] == 1: if reply_json["new_optical_band"] == 1:
if reply_json["parent_opt_band"]: if reply_json["parent_opt_band"]:
...@@ -302,6 +303,9 @@ class ServiceServiceServicerImpl(ServiceServiceServicer): ...@@ -302,6 +303,9 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
LOGGER.debug('expected optical band not found') LOGGER.debug('expected optical band not found')
else: else:
LOGGER.debug('expected optical band not found') LOGGER.debug('expected optical band not found')
elif reply_json["new_optical_band"]==2 :
pass
else: else:
LOGGER.debug('Using existing optical band') LOGGER.debug('Using existing optical band')
else: else:
......
...@@ -130,7 +130,7 @@ class OCServiceHandler(_ServiceHandler): ...@@ -130,7 +130,7 @@ class OCServiceHandler(_ServiceHandler):
) -> List[Union[bool, Exception]]: ) -> List[Union[bool, Exception]]:
is_opticalband =False is_opticalband =False
flows = convert_endpoints_to_flows(endpoints) flows = convert_endpoints_to_flows(endpoints)
service_uuid = self.__service.service_id.service_uuid.uuid
chk_type('endpoints', endpoints, list) chk_type('endpoints', endpoints, list)
if len(endpoints) == 0: return [] if len(endpoints) == 0: return []
......
#!/bin/bash
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License
ip=$(sudo kubectl get all --all-namespaces | grep service/opticalcontrollerservice | awk '{print $4}')
#echo $ip
push=$(curl -X GET "http://$ip:10060/OpticalTFS/GetTopology/admin/admin")
links=$(curl -X GET "http://$ip:10060/OpticalTFS/GetLinks")
echo $links
\ No newline at end of file
...@@ -140,7 +140,15 @@ def get_optical_links (): ...@@ -140,7 +140,15 @@ def get_optical_links ():
try: try:
r = requests.get(urlx, headers=headers) r = requests.get(urlx, headers=headers)
reply = r.json() reply = r.json()
if (reply and 'optical_links' in reply): optical_links = reply["optical_links"] if (reply and 'optical_links' in reply):
optical_links = reply["optical_links"]
for link in optical_links :
for k,v in link['optical_details'].items():
if k == 'c_slots' or k =='l_slots' or k =='s_slots':
sorted_keys = sorted(v.keys(), key=lambda x: int(x), reverse=False)
sorted_dict = {key: v[key] for key in sorted_keys}
link['optical_details'][k] = sorted_dict
logging.info(f"reply {optical_links}") logging.info(f"reply {optical_links}")
except Exception as e : except Exception as e :
......
...@@ -93,9 +93,9 @@ ...@@ -93,9 +93,9 @@
{% if is_deployed_optical() %} {% if is_deployed_optical() %}
<li class="nav-item"> <li class="nav-item">
{% if '/base_optical/' in request.path %} {% if '/base_optical/' in request.path %}
<a class="nav-link active" aria-current="page" href="{{ url_for('base_optical.home') }}">Optical Config</a> <a class="nav-link active" aria-current="page" href="{{ url_for('base_optical.home') }}">Optical View</a>
{% else %} {% else %}
<a class="nav-link" href="{{ url_for('base_optical.home') }}">Optical Config</a> <a class="nav-link" href="{{ url_for('base_optical.home') }}">Optical View</a>
{% endif %} {% endif %}
</li> </li>
{% endif %} {% endif %}
......
...@@ -17,32 +17,60 @@ ...@@ -17,32 +17,60 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block content %} {% block content %}
<h1>Optical Configurations</h1> <h1>Optical View </h1>
<div class="row"> <div class="row">
<div class="col"> <div class="col-12 my-2">
<a href="{{ url_for('opticalconfig.home') }}" class="btn btn-primary" style="margin-bottom: 10px;"> <h5 style="font-weight: bold;">Optical Configuration : </h5>
</div>
Optical Devices <div class="col-12">
</a> <div class="row">
</div> <div class="col">
<div class="col"> <a href="{{ url_for('opticalconfig.home') }}" class="btn btn-primary" style="margin-bottom: 10px;">
<a href="{{ url_for('optical_link.get_optical_links') }}" class="btn btn-primary" style="margin-bottom: 10px;">
Optical Devices
Optical Links </a>
</a>
</div> <a href="{{ url_for('optical_link.home') }}" class="btn btn-primary mx-2" style="margin-bottom: 10px;">
<div class="col">
<a href="{{ url_for('optical_link.get_optical_bands') }}" class="btn btn-primary" style="margin-bottom: 10px;"> Optical Links
</a>
Optical Bands </div>
</a>
</div> </div>
<div class="col">
<a href="{{ url_for('optical_link.get_lightpath') }}" class="btn btn-primary" style="margin-bottom: 10px;"> </div>
<div class="col-12 my-1">
Light Paths <div style="width:100%;height:1px;background-color: gray;"></div>
</a> </div>
<div class="col-12 my-2">
<h5 style="font-weight: bold;">Optical Controller : </h5>
</div>
<div class="col-12">
<div class="row">
<div class="col">
<a href="{{ url_for('optical_link.get_optical_links') }}" class="btn btn-primary" style="margin-bottom: 10px;">
Optical Links
</a>
<a href="{{ url_for('optical_link.get_optical_bands') }}" class="btn btn-primary mx-2" style="margin-bottom: 10px;">
Optical Bands
</a>
<a href="{{ url_for('optical_link.get_lightpath') }}" class="btn btn-primary" style="margin-bottom: 10px;">
Light Paths
</a>
</div>
</div> </div>
</div>
</div> </div>
{% endblock %} {% endblock %}
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
{% block content %} {% block content %}
<div class="row mb-3"> <div class="row mb-3">
<div class="col-sm-3"> <div class="col-sm-3">
<button type="button" class="btn btn-success" onclick="window.location.href='{{ url_for('optical_link.home') }}'"> <button type="button" class="btn btn-success" onclick="window.location.href='{{ url_for('base_optical.home') }}'">
<i class="bi bi-box-arrow-in-left"></i> <i class="bi bi-box-arrow-in-left"></i>
Back to link list Back to link list
</button> </button>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
{% block content %} {% block content %}
<div class="row mb-3"> <div class="row mb-3">
<div class="col-sm-3"> <div class="col-sm-3">
<button type="button" class="btn btn-success" onclick="window.location.href='/base_optical'"> <button type="button" class="btn btn-success" onclick="window.location.href='{{ url_for('base_optical.home') }}'">
<i class="bi bi-box-arrow-in-left"></i> <i class="bi bi-box-arrow-in-left"></i>
Back to link list Back to link list
</button> </button>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
{% block content %} {% block content %}
<div class="row mb-3"> <div class="row mb-3">
<div class="col-sm-3"> <div class="col-sm-3">
<button type="button" class="btn btn-success" onclick="window.location.href='{{ url_for('optical_link.home') }}'"> <button type="button" class="btn btn-success" onclick="window.location.href='{{ url_for('base_optical.home') }}'">
<i class="bi bi-box-arrow-in-left"></i> <i class="bi bi-box-arrow-in-left"></i>
Back to link list Back to link list
</button> </button>
......
xml 0 → 100644
Source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment