Commit 78b2795e authored by Andrea Sgambelluri's avatar Andrea Sgambelluri
Browse files

flexigrid deployment of an optical connection

parent 038c5d64
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -131,3 +131,14 @@ DEFAULT_SERVICE_HTTP_BASEURLS = {
    ServiceNameEnum.NBI  .value : None,
    ServiceNameEnum.NBI  .value : None,
    ServiceNameEnum.WEBUI.value : None,
    ServiceNameEnum.WEBUI.value : None,
}
}


def OpticalServiceType(value):
    if value == "multi_granular":
        return 1
    elif value == "flex_grid":
        return 2
    elif value == "pmp":
        return 3
    else:
        return 1
 No newline at end of file
+2 −2
Original line number Original line Diff line number Diff line
@@ -43,8 +43,8 @@ def index():
    return render_template('index.html')
    return render_template('index.html')




#@optical.route('/AddLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:bidir>')
#@optical.route('/AddLightpath/<string:src>/<string:dst>/<int:bitrate>')
@optical.route('/AddLightpath/<string:src>/<string:dst>/<int:bitrate>')
@optical.route('/AddLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:bidir>')
@optical.response(200, 'Success')
@optical.response(200, 'Success')
@optical.response(404, 'Error, not found')
@optical.response(404, 'Error, not found')
class AddLightpath(Resource):
class AddLightpath(Resource):
+7 −13
Original line number Original line Diff line number Diff line
@@ -593,18 +593,6 @@ class RSA():
        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)
        '''
        fibers_f = self.get_fibers_forward(links, slots, band)

        fibers_b = []
        if bidir:
            fibers_b = self.get_fibers_backward(links, fibers_f, slots, band)
        if debug:
            print("forward")
            print(fibers_f)
            print("backward")
            print(fibers_b)
        '''
        add = links[0]
        add = links[0]
        drop = links[-1]
        drop = links[-1]
        inport = "0"
        inport = "0"
@@ -764,6 +752,12 @@ class RSA():
        return t_flows, band, slots, {}, {}
        return t_flows, band, slots, {}, {}


    def rsa_computation(self, src, dst, rate, bidir):
    def rsa_computation(self, src, dst, rate, bidir):
        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.flow_id += 1
        self.db_flows[self.flow_id] = {}
        self.db_flows[self.flow_id] = {}
        self.db_flows[self.flow_id]["flow_id"] = self.flow_id
        self.db_flows[self.flow_id]["flow_id"] = self.flow_id
+18 −6
Original line number Original line Diff line number Diff line
@@ -30,7 +30,7 @@ from common.tools.context_queries.Service import get_service_by_id
from common.tools.grpc.Tools import grpc_message_to_json, grpc_message_to_json_string
from common.tools.grpc.Tools import grpc_message_to_json, grpc_message_to_json_string
from common.tools.object_factory.Context import json_context_id
from common.tools.object_factory.Context import json_context_id
from common.tools.object_factory.Topology import json_topology_id
from common.tools.object_factory.Topology import json_topology_id
from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME
from common.Constants import OpticalServiceType, DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME
from common.Settings import (
from common.Settings import (
    is_deployed_e2e_orch, is_deployed_optical, is_deployed_te
    is_deployed_e2e_orch, is_deployed_optical, is_deployed_te
)
)
@@ -43,7 +43,7 @@ from .service_handler_api.ServiceHandlerFactory import ServiceHandlerFactory
from .task_scheduler.TaskScheduler import TasksScheduler
from .task_scheduler.TaskScheduler import TasksScheduler
from .tools.GeodesicDistance import gps_distance
from .tools.GeodesicDistance import gps_distance
from .tools.OpticalTools import (
from .tools.OpticalTools import (
    add_lightpath, delete_lightpath, adapt_reply, get_device_name_from_uuid,
    add_flex_lightpath, add_lightpath, delete_lightpath, adapt_reply, get_device_name_from_uuid,
    get_optical_band, refresh_opticalcontroller, DelFlexLightpath , extend_optical_band
    get_optical_band, refresh_opticalcontroller, DelFlexLightpath , extend_optical_band
    
    
)
)
@@ -276,6 +276,9 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
            ports = []
            ports = []
            for endpoint_id in service.service_endpoint_ids:
            for endpoint_id in service.service_endpoint_ids:
                endpoint_device_uuid = endpoint_id.device_id.device_uuid.uuid
                endpoint_device_uuid = endpoint_id.device_id.device_uuid.uuid
                if "." in endpoint_device_uuid:
                    endpoint_device_name = endpoint_device_uuid
                else:
                    endpoint_device_name = device_names[endpoint_device_uuid]
                    endpoint_device_name = device_names[endpoint_device_uuid]
                devs.append(endpoint_device_name)
                devs.append(endpoint_device_name)
                ports.append(endpoint_id.endpoint_uuid.uuid)
                ports.append(endpoint_id.endpoint_uuid.uuid)
@@ -283,6 +286,7 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
            dst = devs[1]
            dst = devs[1]
            bidir = None
            bidir = None
            ob_band = None
            ob_band = None
            oc_type = "multi-granular"
            bitrate = 100
            bitrate = 100
            for constraint in service.service_constraints:
            for constraint in service.service_constraints:
                if "bandwidth" in constraint.custom.constraint_type:
                if "bandwidth" in constraint.custom.constraint_type:
@@ -291,10 +295,18 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
                    bidir = int(constraint.custom.constraint_value)
                    bidir = int(constraint.custom.constraint_value)
                elif "optical-band-width" in constraint.custom.constraint_type:
                elif "optical-band-width" in constraint.custom.constraint_type:
                    ob_band = int(constraint.custom.constraint_value)
                    ob_band = int(constraint.custom.constraint_value)
                elif "type" in constraint.custom.constraint_type:
                    oc_type = OpticalServiceType(str(constraint.custom.constraint_value))
                    
                    
            reply_txt = ""
            # to get the reply form the optical module
            # to get the reply form the optical module
            reply_txt = add_lightpath(src, dst, bitrate, bidir, ob_band)
            #multi-granular

            if oc_type == 1:
                reply_txt = add_flex_lightpath(src, dst, bitrate, bidir, ob_band)
            elif oc_type == 2:
                reply_txt = add_lightpath(src, dst, bitrate, bidir)
            else:
                reply_txt = add_flex_lightpath(src, dst, bitrate, bidir, ob_band)
            # 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.info('[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)))
+19 −1
Original line number Original line Diff line number Diff line
@@ -120,7 +120,7 @@ def refresh_opticalcontroller(topology_id : dict):
        log.debug(f"GetTopology Response {res}")
        log.debug(f"GetTopology Response {res}")




def add_lightpath(src, dst, bitrate, bidir, ob_band) -> str:
def add_flex_lightpath(src, dst, bitrate, bidir, ob_band) -> str:
    if not TESTING:
    if not TESTING:
        urlx = ""
        urlx = ""
        headers = {"Content-Type": "application/json"}
        headers = {"Content-Type": "application/json"}
@@ -143,6 +143,24 @@ def add_lightpath(src, dst, bitrate, bidir, ob_band) -> str:
                return reply_uni_txt
                return reply_uni_txt
        return reply_bid_txt
        return reply_bid_txt


def add_lightpath(src, dst, bitrate, bidir) -> str:
    if not TESTING:
        urlx = ""
        headers = {"Content-Type": "application/json"}
        base_url = get_optical_controller_base_url()
        if bidir is None:
            bidir = 1
            urlx = "{:s}/AddLightpath/{:s}/{:s}/{:s}/{:s}".format(base_url, src, dst, str(bitrate), str(bidir))
        r = requests.put(urlx, headers=headers)
        print(f"addpathlight {r}")
        reply = r.text 
        return reply
    else:
        if bidir is not None:
            if bidir == 0:        
                return reply_uni_txt
        return reply_bid_txt
                


def get_optical_band(idx) -> str:
def get_optical_band(idx) -> str:
    if not TESTING:
    if not TESTING: