Commit e37dc37e authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'tmp-integration' into 'develop'

Resolve "Optical bandwidth expansion"

See merge request !341
parents 7499455d ea337a8f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
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 service slice nbi webui"
export TFS_COMPONENTS="context device pathcomp service nbi webui"

# Uncomment to activate Monitoring (old)
#export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring"
+38 −0
Original line number Diff line number Diff line
@@ -94,6 +94,10 @@ service ContextService {
  rpc DeleteOpticalLink      (LinkId           ) returns (Empty            ) {}
  rpc GetOpticalLinkList     (Empty            ) returns (OpticalLinkList  ) {}

  rpc GetOpticalBand         (Empty            ) returns (OpticalBandList)  {}
  rpc SelectOpticalBand      (OpticalBandId    ) returns (OpticalBand)  {}


  rpc DeleteServiceConfigRule(ServiceConfigRule) returns (Empty            ) {}
}

@@ -695,6 +699,8 @@ message AuthenticationResult {
  bool authenticated = 2;
}



// ---------------- Experimental ------------------------
message OpticalConfigId {
  string opticalconfig_uuid = 1;
@@ -715,6 +721,8 @@ message OpticalConfigEvent {
}




// ---- Optical Link ----

message OpticalEndPointId {
@@ -730,6 +738,7 @@ message OpticalLinkList {


message OpticalLinkDetails {

  float length = 1;
  string src_port = 2;
  string dst_port = 3;
@@ -739,6 +748,7 @@ message OpticalLinkDetails {
  map<string, int32> c_slots = 7;
  map<string, int32> l_slots = 8;
  map<string, int32> s_slots = 9;
  
}

message OpticalLink {
@@ -749,6 +759,34 @@ message OpticalLink {
}


message ChannelId {
  Uuid channel_uuid = 1;
}

message OpticalBandId {
  Uuid opticalband_uuid = 1;
}


message OpticalBand {
  
   OpticalBandId opticalband_id = 1 ; 
   ConnectionId connection_id =2 ; 
    ChannelId channel_id = 3;
    ServiceId service_id =4;
    oneof field {
      Service service =5 ;
      Connection connection =6 ;
      string channel = 7;
    }

}

message OpticalBandList {
   repeated OpticalBand opticalbands =1 ;

}


////////////////// Config Rule Delete ////////////

+34 −1
Original line number Diff line number Diff line
@@ -14,9 +14,11 @@


from common.method_wrappers.ServiceExceptions import InvalidArgumentsException
from context.client.ContextClient import ContextClient
import logging
from typing import Optional, Union
from uuid import UUID, uuid4, uuid5

from common.proto.context_pb2 import OpticalBand, OpticalBandId, Empty
# Generate a UUIDv5-like from the SHA-1 of "TFS" and no namespace to be used as the NAMESPACE for all
# the context UUIDs generated. For efficiency purposes, the UUID is hardcoded; however, it is produced
# using the following code:
@@ -64,3 +66,34 @@ def opticalconfig_get_uuid(
    raise InvalidArgumentsException([
        ('name', device_name),
    ], extra_details=['At least one is required to produce a OpticalConfig UUID'])


def ob_get_uuid(
    ob_name:str , allow_random : bool = False
) -> str:
   
    if ( ob_name is not None):
        
        
      result = get_uuid_from_string(f'ob_{ob_name}')
 
      return result 
    if allow_random: return get_uuid_random()

    raise InvalidArgumentsException([
        ('ob_name ', ob_name),
    ], extra_details=['ob_name is required to produce a Optical band UUID'])



def find_optical_band (ob_index)->OpticalBand:

    op_uuid = ob_get_uuid(ob_index)
    op_id=OpticalBandId()
    op_id.opticalband_uuid.uuid =op_uuid
    try:
        ctxt = ContextClient()
        target_ob= ctxt.SelectOpticalBand(op_id)
        return target_ob
    except Exception as e : 
            logging.debug(f"error in finding optical band {e}")
+41 −0
Original line number Diff line number Diff line
@@ -38,3 +38,44 @@ def correct_slot(dic: dict) -> dict:
                _dict[key]=1
            #print(f"result {_dict}")
    return _dict


## To be deleted , needed now for development purpose ## 

def order_list (lst:list[tuple])->list:
    if (len(lst)<=1):
        return lst
    else :
        pivot,bit_val =lst[0]
        lst_smaller = []
        lst_greater = []
        for element in lst[1:]:
            key,val=element
            if (key <= pivot):
                lst_smaller.append(element)
            else :
                lst_greater.append(element)
        return order_list(lst_smaller) + [(pivot,bit_val)] + order_list(lst_greater)

def list_to_dict (lst:list[tuple[int,int]])->dict:
    dct = dict()
    for ele in lst :
        key,value = ele
        dct[str(key)]=value
    return dct

def order_dict (dct:dict)->dict:
    lst = list()
    for key,value in sorted(dct.items()):
        lst.append((int(key),value))
    ordered_lst= order_list(lst)
    if (len(ordered_lst)>0):
        return list_to_dict (ordered_lst)

def order_dict_v1 (dct:dict)->dict:
    lst = list()
    for key,value in dct.items():
        lst.append((int(key),value))
    ordered_lst= order_list(lst)
    if (len(ordered_lst)>0):
        return list_to_dict (ordered_lst)
+23 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ from common.proto.context_pb2 import (
    Service, ServiceConfigRule, ServiceEvent, ServiceFilter, ServiceId, ServiceIdList, ServiceList,
    Slice, SliceEvent, SliceFilter, SliceId, SliceIdList, SliceList,
    Topology, TopologyDetails, TopologyEvent, TopologyId, TopologyIdList, TopologyList,
    OpticalBand, OpticalBandId, OpticalBandList
)
from common.proto.context_pb2_grpc import ContextServiceStub
from common.proto.context_policy_pb2_grpc import ContextPolicyServiceStub
@@ -491,6 +492,28 @@ class ContextClient:
        LOGGER.debug('DeleteOpticalChannel result: {:s}'.format(grpc_message_to_json_string(response)))
        return response
    
    
    @RETRY_DECORATOR
    def GetOpticalBand(self, request : Empty) -> OpticalBandList:
        LOGGER.debug('GetOpticalBand request: {:s}'.format(grpc_message_to_json_string(request)))
        response = self.stub.GetOpticalBand(request)
        LOGGER.debug('GetOpticalBand result: {:s}'.format(grpc_message_to_json_string(response)))
        return response
    
    @RETRY_DECORATOR
    def SelectOpticalBand(self, request : OpticalBandId) -> OpticalBand:
        LOGGER.debug('SelectOpticalBand request: {:s}'.format(grpc_message_to_json_string(request)))
        response = self.stub.SelectOpticalBand(request)
        LOGGER.debug('SelectOpticalBand result: {:s}'.format(grpc_message_to_json_string(response)))
        return response

    @RETRY_DECORATOR
    def SetOpticalBand(self,request : OpticalBand) -> Empty:
        LOGGER.debug('SetOpticalBand request: {:s}'.format(grpc_message_to_json_string(request)))
        response = self.stub.SetOpticalBand(request)
        LOGGER.debug('SetOpticalBand result: {:s}'.format(grpc_message_to_json_string(response)))
        return response
    
    #--------------------------- Optical Link ------------------------
    def GetOpticalLinkList(self, request: Empty) -> OpticalLinkList:
        LOGGER.debug('ListOpticalLinks request: {:s}'.format(grpc_message_to_json_string(request)))
Loading