Commit 725b4c19 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

SIMAP Connector:

- Skipped events reporting partial objects
parent 9c8001fa
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -107,6 +107,13 @@ class EventDispatcher(BaseEventDispatcher):
        device_name = device.name

        topology_uuid, endpoint_names = get_device_endpoint(device)
        if topology_uuid is None:
            MSG = 'DeviceEvent({:s}) skipped, no endpoints to identify topology: {:s}'
            str_device_event = grpc_message_to_json_string(device_event)
            str_device = grpc_message_to_json_string(device)
            LOGGER.warning(MSG.format(str_device_event, str_device))
            return

        topology = self._object_cache.get(CachedEntities.TOPOLOGY, topology_uuid)
        topology_name = topology.name

@@ -128,6 +135,13 @@ class EventDispatcher(BaseEventDispatcher):
        device_name = device.name

        topology_uuid, endpoint_names = get_device_endpoint(device)
        if topology_uuid is None:
            MSG = 'DeviceEvent({:s}) skipped, no endpoints to identify topology: {:s}'
            str_device_event = grpc_message_to_json_string(device_event)
            str_device = grpc_message_to_json_string(device)
            LOGGER.warning(MSG.format(str_device_event, str_device))
            return

        topology = self._object_cache.get(CachedEntities.TOPOLOGY, topology_uuid)
        topology_name = topology.name

@@ -188,6 +202,13 @@ class EventDispatcher(BaseEventDispatcher):
        link_name = link.name

        topology_uuid, endpoint_uuids = get_link_endpoint(link)
        if topology_uuid is None:
            MSG = 'LinkEvent({:s}) skipped, no endpoint_ids to identify topology: {:s}'
            str_link_event = grpc_message_to_json_string(link_event)
            str_link = grpc_message_to_json_string(link)
            LOGGER.warning(MSG.format(str_link_event, str_link))
            return

        topology = self._object_cache.get(CachedEntities.TOPOLOGY, topology_uuid)
        topology_name = topology.name

@@ -230,6 +251,13 @@ class EventDispatcher(BaseEventDispatcher):
        link_name = link.name

        topology_uuid, endpoint_uuids = get_link_endpoint(link)
        if topology_uuid is None:
            MSG = 'LinkEvent({:s}) skipped, no endpoint_ids to identify topology: {:s}'
            str_link_event = grpc_message_to_json_string(link_event)
            str_link = grpc_message_to_json_string(link)
            LOGGER.warning(MSG.format(str_link_event, str_link))
            return

        topology = self._object_cache.get(CachedEntities.TOPOLOGY, topology_uuid)
        topology_name = topology.name

+9 −3
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@


import enum
from typing import Dict, List, Set, Tuple, Union
from typing import List, Optional, Set, Tuple, Union
from common.proto.context_pb2 import (
    EVENTTYPE_CREATE, EVENTTYPE_REMOVE, EVENTTYPE_UPDATE, Device,
    DeviceEvent, Link, LinkEvent, ServiceEvent, SliceEvent, TopologyEvent
@@ -40,11 +40,14 @@ def get_event_type(event : EVENT_TYPE) -> EventTypeEnum:
        raise Exception(MSG.format(str(int_event_type), str_event))


def get_device_endpoint(device : Device) -> Tuple[str, List[str]]:
def get_device_endpoint(device : Device) -> Tuple[Optional[str], List[str]]:
    topology_uuids : Set[str] = set()
    endpoint_device_uuids : Set[str] = set()
    endpoint_names : List[str] = list()

    if len(device.device_endpoints) == 0:
        return None, endpoint_names

    for endpoint in device.device_endpoints:
        topology_uuid = endpoint.endpoint_id.topology_id.topology_uuid.uuid
        topology_uuids.add(topology_uuid)
@@ -85,10 +88,13 @@ def get_device_endpoint(device : Device) -> Tuple[str, List[str]]:
    return topology_uuid, endpoint_names


def get_link_endpoint(link : Link) -> Tuple[str, List[Tuple[str, str]]]:
def get_link_endpoint(link : Link) -> Tuple[Optional[str], List[Tuple[str, str]]]:
    topology_uuids : Set[str] = set()
    endpoint_uuids : List[Tuple[str, str]] = list()

    if len(link.link_endpoint_ids) == 0:
        return None, endpoint_uuids

    for endpoint_id in link.link_endpoint_ids:
        topology_uuid = endpoint_id.topology_id.topology_uuid.uuid
        topology_uuids.add(topology_uuid)