Scheduled maintenance on Saturday, 27 September 2025, from 07:00 AM to 4:00 PM GMT (09:00 AM to 6:00 PM CEST) - some services may be unavailable -

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

Merge branch 'cnit_transponders' of https://labs.etsi.org/rep/tfs/controller...

Merge branch 'cnit_transponders' of https://labs.etsi.org/rep/tfs/controller into cnit-optical-band-expansion
parents e25a4f15 c14dc8d7
Branches
No related tags found
1 merge request!341Draft: Resolve "optical bandwidth expansion"
Showing
with 848 additions and 128 deletions
sudo microk8s refresh-certs --cert ca.crt
sudo microk8s refresh-certs --cert front-proxy-client.crt
sudo microk8s refresh-certs --cert server.crt
fast.sh 0 → 100755
#!/bin/bash
# Copyright 2022-2024 ETSI OSG/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.
# ----- TeraFlowSDN ------------------------------------------------------------
# Set the URL of the internal MicroK8s Docker registry where the images will be uploaded to.
export TFS_REGISTRY_IMAGES="http://localhost:32000/tfs/"
# 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 nbi webui"
# Uncomment to activate Monitoring (old)
#export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring"
# Uncomment to activate Monitoring Framework (new)
#export TFS_COMPONENTS="${TFS_COMPONENTS} kpi_manager kpi_value_writer kpi_value_api telemetry analytics automation"
# Uncomment to activate QoS Profiles
#export TFS_COMPONENTS="${TFS_COMPONENTS} qos_profile"
# Uncomment to activate BGP-LS Speaker
#export TFS_COMPONENTS="${TFS_COMPONENTS} bgpls_speaker"
# Uncomment to activate Optical Controller
# To manage optical connections, "service" requires "opticalcontroller" to be deployed
# before "service", thus we "hack" the TFS_COMPONENTS environment variable prepending the
# "opticalcontroller" only if "service" is already in TFS_COMPONENTS, and re-export it.
#if [[ "$TFS_COMPONENTS" == *"service"* ]]; then
# BEFORE="${TFS_COMPONENTS% service*}"
# AFTER="${TFS_COMPONENTS#* service}"
# export TFS_COMPONENTS="${BEFORE} opticalcontroller service ${AFTER}"
#fi
# Uncomment to activate ZTP
#export TFS_COMPONENTS="${TFS_COMPONENTS} ztp"
# Uncomment to activate Policy Manager
#export TFS_COMPONENTS="${TFS_COMPONENTS} policy"
# Uncomment to activate Optical CyberSecurity
#export TFS_COMPONENTS="${TFS_COMPONENTS} dbscanserving opticalattackmitigator opticalattackdetector opticalattackmanager"
# Uncomment to activate L3 CyberSecurity
#export TFS_COMPONENTS="${TFS_COMPONENTS} l3_attackmitigator l3_centralizedattackdetector"
# Uncomment to activate TE
#export TFS_COMPONENTS="${TFS_COMPONENTS} te"
# Uncomment to activate Forecaster
#export TFS_COMPONENTS="${TFS_COMPONENTS} forecaster"
# Uncomment to activate E2E Orchestrator
#export TFS_COMPONENTS="${TFS_COMPONENTS} e2e_orchestrator"
# Uncomment to activate DLT and Interdomain
#export TFS_COMPONENTS="${TFS_COMPONENTS} interdomain dlt"
#if [[ "$TFS_COMPONENTS" == *"dlt"* ]]; then
# export KEY_DIRECTORY_PATH="src/dlt/gateway/keys/priv_sk"
# export CERT_DIRECTORY_PATH="src/dlt/gateway/keys/cert.pem"
# export TLS_CERT_PATH="src/dlt/gateway/keys/ca.crt"
#fi
# Uncomment to activate QKD App
# To manage QKD Apps, "service" requires "qkd_app" to be deployed
# before "service", thus we "hack" the TFS_COMPONENTS environment variable prepending the
# "qkd_app" only if "service" is already in TFS_COMPONENTS, and re-export it.
#if [[ "$TFS_COMPONENTS" == *"service"* ]]; then
# BEFORE="${TFS_COMPONENTS% service*}"
# AFTER="${TFS_COMPONENTS#* service}"
# export TFS_COMPONENTS="${BEFORE} qkd_app service ${AFTER}"
#fi
# Uncomment to activate Load Generator
#export TFS_COMPONENTS="${TFS_COMPONENTS} load_generator"
# Set the tag you want to use for your images.
export TFS_IMAGE_TAG="dev"
# Set the name of the Kubernetes namespace to deploy TFS to.
export TFS_K8S_NAMESPACE="tfs"
# Set additional manifest files to be applied after the deployment
export TFS_EXTRA_MANIFESTS="manifests/nginx_ingress_http.yaml"
# Uncomment to monitor performance of components
#export TFS_EXTRA_MANIFESTS="${TFS_EXTRA_MANIFESTS} manifests/servicemonitors.yaml"
# Uncomment when deploying Optical CyberSecurity
#export TFS_EXTRA_MANIFESTS="${TFS_EXTRA_MANIFESTS} manifests/cachingservice.yaml"
# Set the new Grafana admin password
export TFS_GRAFANA_PASSWORD="admin123+"
# Disable skip-build flag to rebuild the Docker images.
export TFS_SKIP_BUILD="YES"
# ----- CockroachDB ------------------------------------------------------------
# Set the namespace where CockroackDB will be deployed.
export CRDB_NAMESPACE="crdb"
# Set the external port CockroackDB Postgre SQL interface will be exposed to.
export CRDB_EXT_PORT_SQL="26257"
# Set the external port CockroackDB HTTP Mgmt GUI interface will be exposed to.
export CRDB_EXT_PORT_HTTP="8081"
# Set the database username to be used by Context.
export CRDB_USERNAME="tfs"
# Set the database user's password to be used by Context.
export CRDB_PASSWORD="tfs123"
# Set the database name to be used by Context.
export CRDB_DATABASE="tfs"
# Set CockroachDB installation mode to 'single'. This option is convenient for development and testing.
# See ./deploy/all.sh or ./deploy/crdb.sh for additional details
export CRDB_DEPLOY_MODE="single"
# Disable flag for dropping database, if it exists.
export CRDB_DROP_DATABASE_IF_EXISTS=""
# Disable flag for re-deploying CockroachDB from scratch.
export CRDB_REDEPLOY="YES"
# ----- NATS -------------------------------------------------------------------
# Set the namespace where NATS will be deployed.
export NATS_NAMESPACE="nats"
# Set the external port NATS Client interface will be exposed to.
export NATS_EXT_PORT_CLIENT="4222"
# Set the external port NATS HTTP Mgmt GUI interface will be exposed to.
export NATS_EXT_PORT_HTTP="8222"
# Set NATS installation mode to 'single'. This option is convenient for development and testing.
# See ./deploy/all.sh or ./deploy/nats.sh for additional details
export NATS_DEPLOY_MODE="single"
# Disable flag for re-deploying NATS from scratch.
export NATS_REDEPLOY=""
# ----- QuestDB ----------------------------------------------------------------
# Set the namespace where QuestDB will be deployed.
export QDB_NAMESPACE="qdb"
# Set the external port QuestDB Postgre SQL interface will be exposed to.
export QDB_EXT_PORT_SQL="8812"
# Set the external port QuestDB Influx Line Protocol interface will be exposed to.
export QDB_EXT_PORT_ILP="9009"
# Set the external port QuestDB HTTP Mgmt GUI interface will be exposed to.
export QDB_EXT_PORT_HTTP="9000"
# Set the database username to be used for QuestDB.
export QDB_USERNAME="admin"
# Set the database user's password to be used for QuestDB.
export QDB_PASSWORD="quest"
# Set the table name to be used by Monitoring for KPIs.
export QDB_TABLE_MONITORING_KPIS="tfs_monitoring_kpis"
# Set the table name to be used by Slice for plotting groups.
export QDB_TABLE_SLICE_GROUPS="tfs_slice_groups"
# Disable flag for dropping tables if they exist.
export QDB_DROP_TABLES_IF_EXIST=""
# Disable flag for re-deploying QuestDB from scratch.
export QDB_REDEPLOY=""
# ----- K8s Observability ------------------------------------------------------
# Set the external port Prometheus Mgmt HTTP GUI interface will be exposed to.
export PROM_EXT_PORT_HTTP="9090"
# Set the external port Grafana HTTP Dashboards will be exposed to.
export GRAF_EXT_PORT_HTTP="3000"
# ----- Apache Kafka -----------------------------------------------------------
# Set the namespace where Apache Kafka will be deployed.
export KFK_NAMESPACE="kafka"
# Set the port Apache Kafka server will be exposed to.
export KFK_SERVER_PORT="9092"
# Set the flag to YES for redeploying of Apache Kafka
export KFK_REDEPLOY=""
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -16,6 +16,7 @@ import json, logging ,datetime
from sqlalchemy.dialects.postgresql import insert
from common.message_broker.MessageBroker import MessageBroker
from common.DeviceTypes import DeviceTypeEnum
from sqlalchemy import inspect
from sqlalchemy.engine import Engine
from sqlalchemy.orm import Session, sessionmaker
from sqlalchemy_cockroachdb import run_transaction
......@@ -70,6 +71,7 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig):
if config_type == DeviceTypeEnum.OPTICAL_TRANSPONDER._value_:
is_transpondre = True
transceivers = []
if channel_namespace is None and 'channel_namespace' in config:
channel_namespace=config['channel_namespace']
if 'transceivers' in config and len(config['transceivers']['transceiver']) > 0:
......
......@@ -291,6 +291,23 @@ def disable_media_channel (resources):
unwanted_keys=['destination_port','source_port','channel_namespace','frequency','operational-mode', 'optical-band-parent']
config,ports,index= seperate_port_config(resources,unwanted_keys=unwanted_keys)
n = 0
for flow in ports:
doc, tag, text = Doc().tagtext()
with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"):
with tag('wavelength-router', xmlns="http://openconfig.net/yang/wavelength-router"):
with tag('media-channels'):
with tag("channel",operation="delete"):
with tag('index'):text(str(int(index) + n))
with tag('config'):
with tag('index'):text(str(int(index) + n))
n +=1
'''
doc, tag, text = Doc().tagtext()
#with tag('config'):
with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"):
......@@ -300,7 +317,7 @@ def disable_media_channel (resources):
with tag('index'):text(str(int(index)))
with tag('config'):
with tag('index'):text(str(int(index)))
'''
result = indent(
doc.getvalue(),
indentation = ' '*2,
......@@ -337,6 +354,41 @@ def delete_optical_band (resources:list):
results=[]
unwanted_keys=['destination_port','source_port','channel_namespace','frequency','operational-mode', 'optical-band-parent']
config,ports,index= seperate_port_config(resources,unwanted_keys=unwanted_keys)
# doc, tag, text = Doc().tagtext()
# #with tag('config'):
# with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"):
# with tag('wavelength-router', xmlns="http://openconfig.net/yang/wavelength-router"):
# with tag('optical-bands',xmlns="http://flex-scale-project.eu/yang/flex-scale-mg-on"):
# with tag('optical-band',operation="delete"):
# if index is not None:
# with tag('index'):text(index)
# with tag('config'):
# with tag('index'):text(index)
# result = indent(
# doc.getvalue(),
# indentation = ' '*2,
# newline = ''
# )
# results.append(result)
# return results
n = 0
for flow in ports:
doc, tag, text = Doc().tagtext()
with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"):
with tag('wavelength-router', xmlns="http://openconfig.net/yang/wavelength-router"):
with tag('optical-bands',xmlns="http://flex-scale-project.eu/yang/flex-scale-mg-on"):
with tag('optical-band',operation="delete"):
if index is not None:
with tag('index'):text(str(int(index) + n))
with tag('config'):
with tag('index'):text(str(int(index) + n))
n +=1
'''
doc, tag, text = Doc().tagtext()
#with tag('config'):
with tag('config',xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"):
......@@ -348,6 +400,7 @@ def delete_optical_band (resources:list):
with tag('config'):
with tag('index'):text(index)
'''
result = indent(
doc.getvalue(),
indentation = ' '*2,
......
......@@ -204,28 +204,88 @@ def extract_tranceiver (data_xml:str,dic:dict):
dic['transceiver']=component_names
return dic
def extract_interface (xml_data:str,dic:dict):
def extract_interfaces (xml_data:str):
xml_bytes = xml_data.encode("utf-8")
root = ET.fromstring(xml_bytes)
namespaces = {
'ns': 'urn:ietf:params:xml:ns:netconf:base:1.0',
'oc': 'http://openconfig.net/yang/interfaces',
}
ip_namespaces = {
'oc': 'http://openconfig.net/yang/interfaces',
'ip': 'http://openconfig.net/yang/interfaces/ip',
}
interfaces = root.findall('.//oc:interfaces/oc:interface', namespaces)
interface_names = [interface.find('oc:name', namespaces).text for interface in interfaces]
interface_enabled=[interface.find('oc:config/oc:enabled', namespaces).text for interface in interfaces]
ip_address_element = root.find('.//ip:ip', ip_namespaces)
interface_prefix_length=root.find('.//ip:prefix-length',ip_namespaces)
if (len(interface_names) > 0):
dic['interface']={"name":interface_names[0],'ip':ip_address_element.text,'enabled':interface_enabled[0],"prefix-length":interface_prefix_length.text}
else :
dic['interface']={}
return dic
namespace = {'oc': 'http://openconfig.net/yang/interfaces'}
interfaces_result = []
interfaces = root.findall('.//oc:interface',namespace)
#print(f"component {components}")
for interface in interfaces:
iface = {}
name = interface.find('.//oc:name',namespace)
enabled = interface.find('.//oc:enabled',namespace)
state= interface.find('.//oc:state',namespace)
if state is not None :
ifindex=state.find('.//oc:ifindex',namespace)
operation_status = state.find('.//oc:oper-status',namespace)
counters = state.find('.//oc:counters',namespace)
if ifindex is not None :
iface["ifindex"]=ifindex.text
if operation_status is not None :
iface['operation_status']=operation_status.text
if counters is not None :
in_octets = counters.find('.//oc:in-octets',namespace)
in_pkts=counters.find('.//oc:in-pkts',namespace)
in_broadcast_pkts=counters.find('.//oc:in-broadcast-pkts',namespace)
in_multicast_pkts=counters.find('.//oc:in-multicast-pkts',namespace)
in_errors=counters.find('.//oc:in-errors',namespace)
in_discards=counters.find('.//oc:in-discards',namespace)
in_unicast_pkts=counters.find('.//oc:in-unicast-pkts',namespace)
out_pkts=counters.find('.//oc:out-pkts',namespace)
out_broadcast_pkts=counters.find('.//oc:out-broadcast-pkts',namespace)
out_multicast_pkts=counters.find('.//oc:out-multicast-pkts',namespace)
out_errors=counters.find('.//oc:out-errors',namespace)
out_discards=counters.find('.//oc:out-discards',namespace)
out_unicast_pkts=counters.find('.//oc:out-unicast-pkts',namespace)
last_clear= counters.find('.//oc:last-clear',namespace)
if in_octets is not None :
iface["in_octets"]=in_octets.text
if in_pkts is not None :
iface["in_pkts"]=in_pkts.text
if in_broadcast_pkts is not None :
iface["in_broadcast_pkts"]=in_broadcast_pkts.text
if in_multicast_pkts is not None :
iface["in_multicast_pkts"]=in_multicast_pkts.text
if in_errors is not None :
iface["in_errors"]=in_errors.text
if in_discards is not None :
iface["in_discards"]=in_discards.text
if in_unicast_pkts is not None :
iface["in_unicast_pkts"]=in_unicast_pkts.text
if out_pkts is not None :
iface["out_pkts"]=out_pkts.text
if out_broadcast_pkts is not None :
iface["out_broadcast_pkts"]=out_broadcast_pkts.text
if out_multicast_pkts is not None :
iface["out_multicast_pkts"]=out_multicast_pkts.text
if out_errors is not None :
iface["out_errors"]=out_errors.text
if out_discards is not None :
iface["out_discards"]=out_discards.text
if out_unicast_pkts is not None :
iface["out_unicast_pkts"]=out_unicast_pkts.text
if last_clear is not None :
iface["last_clear"]=last_clear.text
if name is not None:
iface["name"]=name.text
if enabled is not None :
iface ["status"]=enabled.text
interfaces_result.append(iface)
return interfaces_result
def has_opticalbands(xml_data:str):
xml_bytes = xml_data.encode("utf-8")
......@@ -270,6 +330,7 @@ def transponder_values_extractor(data_xml:str,resource_keys:list,dic:dict):
ports = extract_ports_based_on_type(data_xml)
optical_channels_params=[]
ports_result=[]
interfaces=[]
if (is_opticalband):
endpoints=channel_names
else:
......@@ -288,8 +349,8 @@ def transponder_values_extractor(data_xml:str,resource_keys:list,dic:dict):
endpoints.append({"endpoint_uuid":{"uuid":channel_name}})
optical_channels_params.append(dic)
#transceivers_dic=extract_tranceiver(data_xml=data_xml,dic={})
transceivers_dic={"transceiver":[]}
#interfaces_dic=extract_interface(xml_data=data_xml,dic={})
#transceivers_dic={"transceiver":[]}
interfaces=extract_interfaces(xml_data=data_xml)
if len(ports)>0 :
for port in ports :
endpoint_name,endpoint_id=port
......
......@@ -135,7 +135,7 @@ class DelFLightpath(Resource):
match2 = flow["src"] == dst and flow["dst"] == src and flow["bitrate"] == bitrate
if match1 or match2:
ob_id = flow["parent_opt_band"]
rsa.del_flow(flow, ob_id)
rsa.del_flow(flow, flow_id, ob_id)
rsa.db_flows[flow_id]["is_active"] = False
if flow_id in rsa.optical_bands[ob_id]["served_lightpaths"]:
rsa.optical_bands[ob_id]["served_lightpaths"].remove(flow_id)
......@@ -154,6 +154,8 @@ class DelFLightpath(Resource):
# print(f"delete_lightpath {delete_band} and ob_id {ob_id}")
# if len( rsa.optical_bands[ob_id]["served_lightpaths"]) != 0:
# return "DELETE_NOT_ALLOWED" ,400
ob_id = flow["parent_opt_band"]
rsa.del_flow(flow,flow_id,ob_id)
if debug:
......@@ -183,6 +185,7 @@ class DelOpticalBand(Resource):
if flow is not None:
bidir = flow["bidir"]
if bidir:
match1 = flow["src"] == src and flow["dst"] == dst and flow["bitrate"]
match2 = flow["src"] == dst and flow["dst"] == src and flow["bitrate"]
if match1 or match2:
ob_id = flow["parent_opt_band"]
......@@ -217,6 +220,48 @@ class DelOpticalBand(Resource):
return "ob_id {} does not exist".format(ob_id), 404
@optical.route('/DelOpticalBandSimple/<int:o_band_id>',methods=['DELETE'])
@optical.response(200, 'Success')
@optical.response(404, 'Error, not found')
class DelOpticalBandSimple(Resource):
@staticmethod
def delete(o_band_id):
flow = None
ob_id=None
if o_band_id is not None:
if o_band_id in rsa.optical_bands.keys():
flow=rsa.optical_bands[o_band_id]
ob_id=o_band_id
if flow is not None:
bidir = flow["bidir"]
if bidir:
if len( rsa.optical_bands[ob_id]["served_lightpaths"]) != 0:
return "DELETE_NOT_ALLOWED" ,400
rsa.optical_bands[ob_id]["is_active"] = False
rsa.del_band(flow,ob_id)
if debug:
print(rsa.links_dict)
return "ob_id {} deleted".format(ob_id), 200
else:
if len( rsa.optical_bands[ob_id]["served_lightpaths"]) != 0:
return "DELETE_NOT_ALLOWED" ,400
rsa.optical_bands[ob_id]["is_active"] = False
rsa.del_band(flow,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}")
return "ob_id {} deleted".format(ob_id), 200
else :
return "flow for ob_id {} not found".format(ob_id),400
else:
return "ob_id {} does not exist".format(ob_id), 404
@optical.route('/DelLightpath/<int:flow_id>/<string:src>/<string:dst>/<int:bitrate>')
@optical.response(200, 'Success')
@optical.response(404, 'Error, not found')
......
......@@ -321,9 +321,10 @@ class RSA():
#link = self.links_dict[l]
#f = fiber_f[l]
#fib = link['fibers'][f]
fib = self.get_link_by_name(l)["optical_details"]
self.restore_link(fib, slots, band)
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)
if debug:
print(fib[band])
......@@ -343,10 +344,9 @@ class RSA():
r_l = reverse_link(l)
if debug:
print(r_l)
# link = self.links_dict[l]
# f = fiber_f[l]
# fib = link['fibers'][f]
fib = self.get_link_by_name(r_l)["optical_details"]
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)
if debug:
......@@ -385,12 +385,17 @@ class RSA():
path = flow["path"]
bidir = flow["bidir"]
links = []
slots = []
if o_b_id is not None:
links= self.optical_bands[o_b_id]["links"]
band = self.optical_bands[o_b_id]["band_type"]
n_slots =self.optical_bands[o_b_id]["n_slots"]
if n_slots > 0:
slots=[i+1 for i in range(n_slots)]
#slots=[i+1 for i in range(n_slots)]
for key in self.optical_bands[o_b_id][band].keys():
slots.append(int(key))
slots.sort()
for l in links:
if debug:
......@@ -409,8 +414,14 @@ class RSA():
if debug:
print(fib[band])
if o_b_id is not None:
print(f"invoking restore_link_2 fib: {fib} , slots {slots} , band {band} ")
#self.restore_link(fib, slots, band)
self.restore_link_2(fib, slots, band, link = link)
self.optical_bands[o_b_id]["is_active"]=False
if debug:
print(fib[band])
if debug:
print("restoring OB")
print(f"invoking restore_optical_band o_b_id: {o_b_id} , slots {slots} , band {band} ")
......@@ -421,28 +432,13 @@ class RSA():
r_l = reverse_link(l)
if debug:
print(r_l)
# link = self.links_dict[l]
# f = fiber_f[l]
# fib = link['fibers'][f]
fib = self.get_link_by_name(r_l)["optical_details"]
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)
self.restore_link_2(fib, slots, band, link=rlink)
if debug:
print(fib[band])
'''
for rl in fiber_b.keys():
if debug:
print(rl)
print(fiber_b[rl])
#rlink = self.links_dict[rl]
#rf = fiber_b[rl]
#rfib = rlink['fibers'][rf]
rfib = self.get_fiber_details(rl, fiber_b[rl])
if not list_in_list(slots, rfib[band]):
self.restore_link(rfib, slots, band)
if debug:
print(rfib[band])
'''
#changed according to TFS development
#if o_b_id is not None:
# rev_o_band_id = self.optical_bands[o_b_id]["reverse_optical_band_id"]
......@@ -816,6 +812,12 @@ class RSA():
def create_optical_band(self, links, path, bidir, num_slots):
print("INFO: Creating optical-band of {} slots".format(num_slots))
if self.opt_band_id == 0:
self.opt_band_id += 1
else:
if (self.optical_bands[self.opt_band_id]["bidir"] == 1):
self.opt_band_id += 2
else:
self.opt_band_id += 1
forw_opt_band_id = self.opt_band_id
self.optical_bands[forw_opt_band_id] = {}
......@@ -974,6 +976,12 @@ class RSA():
optical_band_id, temp_links = self.create_optical_band(links, path, bidir, num_slots_ob)
return None, optical_band_id
print("INFO: TP to TP connection")
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
......@@ -1180,6 +1188,7 @@ class RSA():
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
def extend_optical_band(self, ob_id, band=None):
......
......@@ -369,6 +369,7 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
"dst":None,
"bitrate":None,
'ob_id':None,
'bidir': None,
'flow_id':None
}
devs = []
......@@ -384,32 +385,34 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
src = get_device_name_from_uuid(devices, devs[0])
dst = get_device_name_from_uuid(devices, devs[1])
bitrate = 100
bidir = 0
for constraint in service.service_constraints:
if "bandwidth" in constraint.custom.constraint_type:
bitrate = int(float(constraint.custom.constraint_value))
break
if "bidirectionality" in constraint.custom.constraint_type:
bidir = int(constraint.custom.constraint_value)
bitrate = int(float(
service.service_constraints[0].custom.constraint_value
))
#bitrate = int(float(service.service_constraints[0].custom.constraint_value))
#bidir = int(float(service.service_constraints[0].custom.constraint_value))
if len(service.service_config.config_rules) > 0:
c_rules_dict = json.loads(
service.service_config.config_rules[0].custom.resource_value)
ob_id=None
flow_id=None
if "ob_id" in c_rules_dict:
ob_id = c_rules_dict["ob_id"]
if ("flow_id" in c_rules_dict):
flow_id = c_rules_dict["flow_id"]
#if ("ob_id" in c_rules_dict):
# ob_id = c_rules_dict["ob_id"]
params['bitrate']=bitrate
params['dst']=dst
params['src']=src
params['ob_id']=ob_id
params['flow_id']=flow_id
params['bidir'] = bidir
tasks_scheduler = TasksScheduler(self.service_handler_factory)
tasks_scheduler.compose_from_optical_service(service, params=params, is_delete=True)
......
......@@ -104,7 +104,6 @@ class OCServiceHandler(_ServiceHandler):
LOGGER.info(f"endpoints {endpoints} is_opticalband {is_opticalband} ")
#flows = endpoints_to_flows(endpoints, bidir, is_opticalband)
#handled_flows=handle_flows_names(flows=flows,task_executor=self.__task_executor)
results = []
......
......@@ -35,7 +35,7 @@ def convert_endpoints_to_flows(endpoints : List[Tuple[str, str, Optional[str]]])
while(i < end):
endpoint = endpoints[i]
device_uuid, endpoint_uuid = endpoint[0:2]
log.debug("current OCTools step {}, {}, {}".format(i, device_uuid, endpoint_uuid))
log.info("current OCTools step {}, {}, {}".format(i, device_uuid, endpoint_uuid))
if device_uuid not in entries.keys():
entries[device_uuid] = []
if i == 0:
......@@ -45,7 +45,7 @@ def convert_endpoints_to_flows(endpoints : List[Tuple[str, str, Optional[str]]])
next_device_uuid, next_endpoint_uuid = next_endpoint[0:2]
if next_device_uuid == device_uuid:
bidir = 1
log.debug("connection is bidirectional")
log.info("connection is bidirectional")
entry_tuple = next_endpoint_uuid, "0"
entries[device_uuid].append(entry_tuple)
i = i + 1
......@@ -65,11 +65,11 @@ def convert_endpoints_to_flows(endpoints : List[Tuple[str, str, Optional[str]]])
entry_tuple = endpoint_uuid, next_endpoint_uuid
entries[device_uuid].append(entry_tuple)
i = i + 1
log.debug("current OCTools step {}, {}, {}".format(i, next_device_uuid, device_uuid))
log.info("current OCTools step {}, {}, {}".format(i, next_device_uuid, device_uuid))
else:
log.debug("ERROR in unidirectional connection 4")
return {}
if bidir:
else:
log.debug("Ocheck i {}, {}, {}".format(i, i+1, end-1))
if i + 1 == end-1:
log.debug("current OCTools step {}, {}, {}".format(i, device_uuid, endpoint_uuid))
......
......@@ -195,6 +195,7 @@ class TaskExecutor:
# new_optical_config.config= json.dumps(new_config)
# new_optical_config.opticalconfig_id.CopyFrom (optical_config_id)
# new_optical_config.device_id.CopyFrom(device.device_id)
LOGGER.info(f"SSSSSSS->{result}")
self._device_client.DisableOpticalDevice(result)
except Exception as e:
errors.append(e)
......
......@@ -163,7 +163,9 @@ def delete_lightpath( src, dst, bitrate, ob_id, delete_band, flow_id=None) -> st
if flow_id is not None:
urlx = "{:s}/DelFlexLightpath/{}/{}/{}/{}/{}".format(base_url, src, dst, bitrate, ob_id, flow_id)
else :
urlx = "{:s}/DelOpticalBand/{}/{}/{}".format(base_url, src, dst, ob_id)
#urlx = "http://{}:{}/OpticalTFS/DelOpticalBand/{}/{}/{}".format(OPTICAL_IP, OPTICAL_PORT, src, dst, ob_id)
urlx = "{:s}/DelOpticalBandSimple/{}".format(base_url, ob_id)
headers = {"Content-Type": "application/json"}
r = requests.delete(urlx, headers=headers)
reply = r.text
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment