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

PathComp component - Frontend:

- Added special logic to manage pure-packet connectivity services without sub-services
parent d0172421
Loading
Loading
Loading
Loading
+29 −12
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@

import json, logging, requests, uuid
from typing import Dict, List, Optional, Tuple, Union
from common.DeviceTypes import DeviceTypeEnum
from common.proto.context_pb2 import (
    ConfigRule, Connection, Device, DeviceList, EndPointId, Link, LinkList, Service, ServiceStatusEnum, ServiceTypeEnum
)
@@ -251,6 +252,22 @@ class _Algorithm:
                ]

                self.logger.debug('path_hops = {:s}'.format(str(path_hops)))
                device_types = {v[0]['device_type'] for k,v in self.device_dict.items()}
                DEVICES_BASIC_CONNECTION = {
                    DeviceTypeEnum.DATACENTER.value,    DeviceTypeEnum.EMULATED_DATACENTER.value,
                    DeviceTypeEnum.CLIENT.value,        DeviceTypeEnum.EMULATED_CLIENT.value,
                    DeviceTypeEnum.PACKET_ROUTER.value, DeviceTypeEnum.EMULATED_PACKET_ROUTER.value,
                }
                self.logger.debug('device_types = {:s}'.format(str(device_types)))
                self.logger.debug('DEVICES_BASIC_CONNECTION = {:s}'.format(str(DEVICES_BASIC_CONNECTION)))
                is_basic_connection = device_types.issubset(DEVICES_BASIC_CONNECTION)
                self.logger.debug('is_basic_connection = {:s}'.format(str(is_basic_connection)))
                if is_basic_connection:
                    self.logger.info('Assuming basic connections...')
                    connections = convert_explicit_path_hops_to_plain_connection(
                        path_hops, main_service_uuid, main_service_type)
                    self.logger.debug('BASIC connections = {:s}'.format(str(connections)))
                else:
                    try:
                        _device_dict = {k:v[0] for k,v in self.device_dict.items()}
                        self.logger.debug('self.device_dict = {:s}'.format(str(_device_dict)))