Skip to content
Snippets Groups Projects
Commit 05fbb8f9 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'fix/service-handler-not-available' into 'develop'

Improved Service Handler selection and PathComp Sub-Service inference

See merge request !101
parents bd873955 0534b061
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!101Improved Service Handler selection and PathComp Sub-Service inference
...@@ -39,14 +39,6 @@ ROUTER_ID = { ...@@ -39,14 +39,6 @@ ROUTER_ID = {
'R149': '5.5.5.5', 'R149': '5.5.5.5',
'R155': '5.5.5.1', 'R155': '5.5.5.1',
'R199': '5.5.5.6', 'R199': '5.5.5.6',
}
VIRTUAL_CIRCUIT = {
'R149': '5.5.5.5',
'R155': '5.5.5.1',
'R199': '5.5.5.6',
} }
class RequestGenerator: class RequestGenerator:
...@@ -269,8 +261,8 @@ class RequestGenerator: ...@@ -269,8 +261,8 @@ class RequestGenerator:
src_device_name = self._device_data[src_device_uuid]['name'] src_device_name = self._device_data[src_device_uuid]['name']
src_endpoint_name = self._device_endpoint_data[src_device_uuid][src_endpoint_uuid]['name'] src_endpoint_name = self._device_endpoint_data[src_device_uuid][src_endpoint_uuid]['name']
src_router_id = ROUTER_ID.get(src_device_name)
src_router_num = int(re.findall(r'^\D*(\d+)', src_device_name)[0]) src_router_num = int(re.findall(r'^\D*(\d+)', src_device_name)[0])
src_router_id = ROUTER_ID.get(src_device_name)
if src_router_id is None: src_router_id = '10.0.0.{:d}'.format(src_router_num) if src_router_id is None: src_router_id = '10.0.0.{:d}'.format(src_router_num)
dst_device_name = self._device_data[dst_device_uuid]['name'] dst_device_name = self._device_data[dst_device_uuid]['name']
...@@ -322,8 +314,8 @@ class RequestGenerator: ...@@ -322,8 +314,8 @@ class RequestGenerator:
src_device_name = self._device_data[src_device_uuid]['name'] src_device_name = self._device_data[src_device_uuid]['name']
src_endpoint_name = self._device_endpoint_data[src_device_uuid][src_endpoint_uuid]['name'] src_endpoint_name = self._device_endpoint_data[src_device_uuid][src_endpoint_uuid]['name']
src_router_id = ROUTER_ID.get(src_device_name)
src_router_num = int(re.findall(r'^\D*(\d+)', src_device_name)[0]) src_router_num = int(re.findall(r'^\D*(\d+)', src_device_name)[0])
src_router_id = ROUTER_ID.get(src_device_name)
if src_router_id is None: src_router_id = '10.0.0.{:d}'.format(src_router_num) if src_router_id is None: src_router_id = '10.0.0.{:d}'.format(src_router_num)
src_address_ip = '10.{:d}.{:d}.{:d}'.format(x, y, src_router_num) src_address_ip = '10.{:d}.{:d}.{:d}'.format(x, y, src_router_num)
......
...@@ -33,12 +33,12 @@ DEVICE_TYPE_TO_DEEPNESS = { ...@@ -33,12 +33,12 @@ DEVICE_TYPE_TO_DEEPNESS = {
DeviceTypeEnum.EMULATED_P4_SWITCH.value : 60, DeviceTypeEnum.EMULATED_P4_SWITCH.value : 60,
DeviceTypeEnum.P4_SWITCH.value : 60, DeviceTypeEnum.P4_SWITCH.value : 60,
DeviceTypeEnum.EMULATED_MICROWAVE_RADIO_SYSTEM.value : 40,
DeviceTypeEnum.MICROWAVE_RADIO_SYSTEM.value : 40,
DeviceTypeEnum.EMULATED_XR_CONSTELLATION.value : 40, DeviceTypeEnum.EMULATED_XR_CONSTELLATION.value : 40,
DeviceTypeEnum.XR_CONSTELLATION.value : 40, DeviceTypeEnum.XR_CONSTELLATION.value : 40,
DeviceTypeEnum.EMULATED_MICROWAVE_RADIO_SYSTEM.value : 30,
DeviceTypeEnum.MICROWAVE_RADIO_SYSTEM.value : 30,
DeviceTypeEnum.EMULATED_OPEN_LINE_SYSTEM.value : 30, DeviceTypeEnum.EMULATED_OPEN_LINE_SYSTEM.value : 30,
DeviceTypeEnum.OPEN_LINE_SYSTEM.value : 30, DeviceTypeEnum.OPEN_LINE_SYSTEM.value : 30,
......
...@@ -12,23 +12,28 @@ ...@@ -12,23 +12,28 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import json import json, logging
from enum import Enum from enum import Enum
from typing import TYPE_CHECKING, Any, Dict, Optional, Union from typing import TYPE_CHECKING, Any, Dict, Optional, Union
from common.method_wrappers.ServiceExceptions import NotFoundException from common.method_wrappers.ServiceExceptions import NotFoundException
from common.proto.context_pb2 import Connection, ConnectionId, Device, DeviceId, Service, ServiceId from common.proto.context_pb2 import Connection, ConnectionId, Device, DeviceDriverEnum, DeviceId, Service, ServiceId
from common.tools.context_queries.Connection import get_connection_by_id from common.tools.context_queries.Connection import get_connection_by_id
from common.tools.context_queries.Device import get_device from common.tools.context_queries.Device import get_device
from common.tools.context_queries.Service import get_service_by_id from common.tools.context_queries.Service import get_service_by_id
from common.tools.grpc.Tools import grpc_message_list_to_json_string
from common.tools.object_factory.Device import json_device_id from common.tools.object_factory.Device import json_device_id
from context.client.ContextClient import ContextClient from context.client.ContextClient import ContextClient
from device.client.DeviceClient import DeviceClient from device.client.DeviceClient import DeviceClient
from service.service.service_handler_api.Exceptions import (
UnsatisfiedFilterException, UnsupportedFilterFieldException, UnsupportedFilterFieldValueException)
from service.service.service_handler_api.ServiceHandlerFactory import ServiceHandlerFactory, get_service_handler_class from service.service.service_handler_api.ServiceHandlerFactory import ServiceHandlerFactory, get_service_handler_class
from service.service.tools.ObjectKeys import get_connection_key, get_device_key, get_service_key from service.service.tools.ObjectKeys import get_connection_key, get_device_key, get_service_key
if TYPE_CHECKING: if TYPE_CHECKING:
from service.service.service_handler_api._ServiceHandler import _ServiceHandler from service.service.service_handler_api._ServiceHandler import _ServiceHandler
LOGGER = logging.getLogger(__name__)
CacheableObject = Union[Connection, Device, Service] CacheableObject = Union[Connection, Device, Service]
class CacheableObjectType(Enum): class CacheableObjectType(Enum):
...@@ -169,5 +174,21 @@ class TaskExecutor: ...@@ -169,5 +174,21 @@ class TaskExecutor:
self, connection : Connection, service : Service, **service_handler_settings self, connection : Connection, service : Service, **service_handler_settings
) -> '_ServiceHandler': ) -> '_ServiceHandler':
connection_devices = self.get_devices_from_connection(connection, exclude_managed_by_controller=True) connection_devices = self.get_devices_from_connection(connection, exclude_managed_by_controller=True)
service_handler_class = get_service_handler_class(self._service_handler_factory, service, connection_devices) try:
return service_handler_class(service, self, **service_handler_settings) service_handler_class = get_service_handler_class(
self._service_handler_factory, service, connection_devices)
return service_handler_class(service, self, **service_handler_settings)
except (UnsatisfiedFilterException, UnsupportedFilterFieldException, UnsupportedFilterFieldValueException):
dict_connection_devices = {
cd_data.name : (cd_uuid, cd_data.name, {
(device_driver, DeviceDriverEnum.Name(device_driver))
for device_driver in cd_data.device_drivers
})
for cd_uuid,cd_data in connection_devices.items()
}
LOGGER.exception(
'Unable to select service handler. service={:s} connection={:s} connection_devices={:s}'.format(
grpc_message_list_to_json_string(service), grpc_message_list_to_json_string(connection),
str(dict_connection_devices)
)
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment