Commit 78eb3b3d authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

PathComp component - FrontEnd:

- Fixed sub-service composition
parent 9e78473a
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -114,7 +114,10 @@ def convert_explicit_path_hops_to_connections(
        elif prv_res_class[2] is None and res_class[2] is not None:
            # entering domain of a device controller, create underlying connection
            LOGGER.debug('  entering domain of a device controller, create underlying connection')
            if len(connection_stack.queue) > 0:
                prv_service_type = connection_stack.queue[-1].service_type
            else:
                prv_service_type = None
            service_type = get_service_type(res_class[1], prv_service_type)
            connection_entry = ConnectionEntry(service_type=service_type, path_hops=[path_hop])
            connection_stack.put(connection_entry)
@@ -123,6 +126,7 @@ def convert_explicit_path_hops_to_connections(
            LOGGER.debug('  leaving domain of a device controller, terminate underlying connection')
            connection = connection_stack.get()
            connections.append(connection)
            if len(connection_stack.queue) > 0:
                connection_stack.queue[-1].dependencies.append(connection)
                connection_stack.queue[-1].path_hops.append(path_hop)
        elif prv_res_class[2] is not None and res_class[2] is not None:
+14 −3
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
# limitations under the License.


from typing import Optional
from common.DeviceTypes import DeviceTypeEnum
from common.proto.context_pb2 import ServiceTypeEnum

@@ -47,11 +48,21 @@ SERVICE_TYPE_L3NM = {ServiceTypeEnum.SERVICETYPE_L3NM}
SERVICE_TYPE_LXNM = {ServiceTypeEnum.SERVICETYPE_L3NM, ServiceTypeEnum.SERVICETYPE_L2NM}
SERVICE_TYPE_TAPI = {ServiceTypeEnum.SERVICETYPE_TAPI_CONNECTIVITY_SERVICE}

def get_service_type(device_type : DeviceTypeEnum, prv_service_type : ServiceTypeEnum) -> ServiceTypeEnum:
    if device_type in PACKET_DEVICE_TYPES and prv_service_type in SERVICE_TYPE_LXNM: return prv_service_type
def get_service_type(
    device_type : DeviceTypeEnum, prv_service_type : Optional[ServiceTypeEnum] = None
) -> ServiceTypeEnum:
    if device_type is DeviceTypeEnum.NCE: return ServiceTypeEnum.SERVICETYPE_L3NM
    if (
        device_type in PACKET_DEVICE_TYPES and
        prv_service_type is not None and
        prv_service_type in SERVICE_TYPE_LXNM
    ): return prv_service_type
    if device_type in L2_DEVICE_TYPES: return ServiceTypeEnum.SERVICETYPE_L2NM
    if device_type in OPTICAL_DEVICE_TYPES: return ServiceTypeEnum.SERVICETYPE_TAPI_CONNECTIVITY_SERVICE
    if device_type in NETWORK_DEVICE_TYPES: return prv_service_type
    if (
        device_type in NETWORK_DEVICE_TYPES and
        prv_service_type is not None
    ): return prv_service_type

    str_fields = ', '.join([
        'device_type={:s}'.format(str(device_type)),