Commit 9e097570 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Fixed CI/CD pipeline:

- Import of unrequired/deleted methods
- Update CI/CD pipeline for OFC24
- Activate CI/CD for WebUI
parent 21ded725
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ include:
  #- local: '/src/policy/.gitlab-ci.yml'
  #- local: '/src/automation/.gitlab-ci.yml'
  #- local: '/src/forecaster/.gitlab-ci.yml'
  #- local: '/src/webui/.gitlab-ci.yml'
  - local: '/src/webui/.gitlab-ci.yml'
  #- local: '/src/l3_distributedattackdetector/.gitlab-ci.yml'
  #- local: '/src/l3_centralizedattackdetector/.gitlab-ci.yml'
  #- local: '/src/l3_attackmitigator/.gitlab-ci.yml'
+46 −68
Original line number Diff line number Diff line
@@ -12,18 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import time
from flask import Flask
from flask import render_template
from flask_restplus import Resource, Api
from tools import *
from variables import *
from RSA import RSA
import time , logging
from common.proto.context_pb2 import TopologyId , OpticalLink
import json
from google.protobuf.message import Message
from common.proto.context_pb2 import TopologyId
from google.protobuf.json_format import MessageToDict
from common.tools.object_factory.OpticalLink import order_dict


global rsa
global links_dict
rsa = None
@@ -105,6 +104,8 @@ class AddFlexLightpath(Resource):
                    return rsa.optical_bands[optical_band_id], 200
        else:
            return "Error", 404


# @optical.route('/DelFlexLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:o_band_id>')
@optical.route('/DelFlexLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:o_band_id>')
@optical.route('/DelFlexLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:o_band_id>/<int:flow_id>')
@@ -147,17 +148,12 @@ class DelFLightpath(Resource):
                        return "flow {} not matching".format(flow_id), 404
                else:
                    if match1:
                      
                        # if delete_band !=0 and ob_id is not None:
                        #     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
                            

                        rsa.del_flow(flow,flow_id,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}")
@@ -168,9 +164,6 @@ class DelFLightpath(Resource):
                return "flow id {} does not exist".format(flow_id), 404


         


@optical.route('/DelOpticalBand/<string:src>/<string:dst>/<int:o_band_id>',methods=['DELETE'])
@optical.response(200, 'Success')
@optical.response(404, 'Error, not found')
@@ -227,11 +220,6 @@ class DelOpticalBand(Resource):
                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')
@@ -267,6 +255,7 @@ class GetFlows(Resource):
        except:
            return "Error", 404


@optical.route('/GetOpticalBands')
@optical.response(200, 'Success')
@optical.response(404, 'Error, not found')
@@ -338,20 +327,17 @@ class GetTopology(Resource):
                link_dict_type = MessageToDict(link, preserving_proto_field_name=True)

                if "c_slots" in link_dict_type["optical_details"]:
                          link_dict_type["optical_details"]["c_slots"]=order_dict(link_dict_type["optical_details"]["c_slots"])
                    link_dict_type["optical_details"]["c_slots"] = link_dict_type["optical_details"]["c_slots"]

                if "l_slots" in link_dict_type["optical_details"]:
                          link_dict_type["optical_details"]["l_slots"]=order_dict(link_dict_type["optical_details"]["l_slots"])
                    link_dict_type["optical_details"]["l_slots"] = link_dict_type["optical_details"]["l_slots"]

                if "s_slots" in link_dict_type["optical_details"]:
                          link_dict_type["optical_details"]["s_slots"]=order_dict(link_dict_type["optical_details"]["s_slots"])
                    link_dict_type["optical_details"]["s_slots"] = link_dict_type["optical_details"]["s_slots"]

                links_dict["optical_links"].append(link_dict_type)

                    
                
            for device in nodes :
                    dev_dic = {}
                dev_dic = {
                    "id":device.device_id.device_uuid.uuid,
                    #"ip":f"10.30.2.{207+i}",
@@ -367,18 +353,10 @@ class GetTopology(Resource):
            rsa = RSA(node_dict, links_dict)
            if debug:
                print(rsa.init_link_slots2(testing))
            
            
            return "ok", 200
        except Exception as e:
            print(f"err {e}")
            return "Error", 400



    
if __name__ == '__main__':
    

    
    app.run(host='0.0.0.0', port=10060)
+1 −0
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ end2end_test ofc24:
    - kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/serviceservice -c server
    - kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/sliceservice -c server
    - kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/nbiservice -c server
    - kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/webuiservice -c server
    - kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/opticalcontrollerservice -c server
    - if docker ps -a | grep ${TEST_NAME}; then docker rm -f ${TEST_NAME}; fi

+22 −27
Original line number Diff line number Diff line
@@ -16,11 +16,8 @@
from flask import current_app, render_template, Blueprint, flash, session, redirect, url_for
from common.proto.context_pb2 import Empty, OpticalLink, LinkId, OpticalLinkList
from common.tools.context_queries.EndPoint import get_endpoint_names
from common.tools.context_queries.Link import get_link
from common.tools.context_queries.Topology import get_topology
from common.tools.object_factory.OpticalLink import order_dict
from context.client.ContextClient import ContextClient
import logging

optical_link = Blueprint('optical_link', __name__, url_prefix='/optical_link')
context_client = ContextClient()
@@ -42,16 +39,17 @@ def home():
    if grpc_topology is None:
        flash('Context({:s})/Topology({:s}) not found'.format(str(context_uuid), str(topology_uuid)), 'danger')
    else:
        topo_link_uuids = {link_id.link_uuid.uuid for link_id in grpc_topology.link_ids}
        grpc_links : OpticalLinkList = context_client.GetOpticalLinkList(Empty())
        for link_ in grpc_links.optical_links:
           
            links.append(link_)
            endpoint_ids.extend(link_.link_endpoint_ids)
        device_names, endpoints_data = get_endpoint_names(context_client, endpoint_ids)
    context_client.close()

    return render_template('optical_link/home.html', links=links, device_names=device_names, endpoints_data=endpoints_data)
    return render_template(
        'optical_link/home.html', links=links, device_names=device_names,
        endpoints_data=endpoints_data
    )


@optical_link.route('detail/<path:link_uuid>', methods=('GET', 'POST'))
@@ -68,22 +66,21 @@ def detail(link_uuid: str):
        device_names, endpoints_data = dict(), dict()
    else:
        device_names, endpoints_data = get_endpoint_names(context_client, link_obj.link_endpoint_ids)
        c_slots= order_dict( link_obj.optical_details.c_slots)
        l_slots= order_dict( link_obj.optical_details.l_slots)
        s_slots= order_dict( link_obj.optical_details.s_slots)
        c_slots = link_obj.optical_details.c_slots
        l_slots = link_obj.optical_details.l_slots
        s_slots = link_obj.optical_details.s_slots

    context_client.close()

    return render_template('optical_link/detail.html',link=link_obj, device_names=device_names, endpoints_data=endpoints_data
                           ,c_slots=c_slots,l_slots=l_slots,s_slots=s_slots)
    return render_template(
        'optical_link/detail.html', link=link_obj, device_names=device_names,
        endpoints_data=endpoints_data, c_slots=c_slots, l_slots=l_slots, s_slots=s_slots
    )


@optical_link.get('<path:link_uuid>/delete')
def delete(link_uuid):
    try:

       

        request = LinkId()
        request.link_uuid.uuid = link_uuid # pylint: disable=no-member
        context_client.connect()
@@ -99,12 +96,10 @@ def delete(link_uuid):

@optical_link.get("delete_all")
def delete_all():
    
    try:
        context_client.connect()
        optical_link_list : OpticalLinkList = context_client.GetOpticalLinkList(Empty())
        for optical_link in optical_link_list.optical_links:
            
            context_client.DeleteOpticalLink(optical_link.link_id)
        context_client.close()
        flash(f"All Optical Link Deleted Successfully",'success')