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

Service component:

- Added log message in service handler selection when no suitable handler is found
parent bd873955
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!101Improved Service Handler selection and PathComp Sub-Service inference
...@@ -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