Commit 1a7aeb0f authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

SIMAP Connector:

- Added forced update when detecting devices, links, and services to prevent inconsistencies in partially-discovered endpoints
parent 2d224479
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -65,8 +65,11 @@ class ObjectCache:
        self._object_cache : Dict[Tuple[str, str], Any] = dict()

    def get(
        self, entity : CachedEntities, *object_uuids : str, auto_retrieve : bool = True
        self, entity : CachedEntities, *object_uuids : str,
        auto_retrieve : bool = True, force_update : bool = False
    ) -> Optional[Any]:
        if force_update: self._update(entity, *object_uuids)

        object_key = compose_object_key(entity, *object_uuids)
        if object_key in self._object_cache:
            return self._object_cache[object_key]
+9 −9
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ class EventDispatcher(BaseEventDispatcher):
        LOGGER.info(MSG.format(grpc_message_to_json_string(device_event)))

        device_uuid = device_event.device_id.device_uuid.uuid
        device = self._object_cache.get(CachedEntities.DEVICE, device_uuid)
        device = self._object_cache.get(CachedEntities.DEVICE, device_uuid, force_update=True)

        device_type = device.device_type
        if device_type in SKIPPED_DEVICE_TYPES:
@@ -296,9 +296,9 @@ class EventDispatcher(BaseEventDispatcher):
        te_topo = self._simap_client.network(topology_name)
        te_topo.update()

        src_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[0][0], auto_retrieve=False)
        src_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[0][0], force_update =True )
        src_endpoint = self._object_cache.get(CachedEntities.ENDPOINT, *(endpoint_uuids[0]), auto_retrieve=False)
        dst_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[1][0], auto_retrieve=False)
        dst_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[1][0], force_update =True )
        dst_endpoint = self._object_cache.get(CachedEntities.ENDPOINT, *(endpoint_uuids[1]), auto_retrieve=False)

        # Skip links that connect two management endpoints
@@ -374,9 +374,9 @@ class EventDispatcher(BaseEventDispatcher):
        te_topo = self._simap_client.network(topology_name)
        te_topo.update()

        src_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[0][0], auto_retrieve=False)
        src_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[0][0], force_update =True )
        src_endpoint = self._object_cache.get(CachedEntities.ENDPOINT, *(endpoint_uuids[0]), auto_retrieve=False)
        dst_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[1][0], auto_retrieve=False)
        dst_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[1][0], force_update =True )
        dst_endpoint = self._object_cache.get(CachedEntities.ENDPOINT, *(endpoint_uuids[1]), auto_retrieve=False)

        # Skip links that connect two management endpoints
@@ -461,9 +461,9 @@ class EventDispatcher(BaseEventDispatcher):
        #domain_topo = self._simap_client.network(domain_name)
        #domain_topo.update()

        #src_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[0][0], auto_retrieve=False)
        #src_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[0][0], force_update =True )
        #src_endpoint = self._object_cache.get(CachedEntities.ENDPOINT, *(endpoint_uuids[0]), auto_retrieve=False)
        #dst_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[1][0], auto_retrieve=False)
        #dst_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[1][0], force_update =True )
        #dst_endpoint = self._object_cache.get(CachedEntities.ENDPOINT, *(endpoint_uuids[1]), auto_retrieve=False)

        #try:
@@ -566,9 +566,9 @@ class EventDispatcher(BaseEventDispatcher):
        #domain_topo = self._simap_client.network(domain_name)
        #domain_topo.update()

        #src_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[0][0], auto_retrieve=False)
        #src_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[0][0], force_update =True )
        #src_endpoint = self._object_cache.get(CachedEntities.ENDPOINT, *(endpoint_uuids[0]), auto_retrieve=False)
        #dst_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[1][0], auto_retrieve=False)
        #dst_device   = self._object_cache.get(CachedEntities.DEVICE,   endpoint_uuids[1][0], force_update =True )
        #dst_endpoint = self._object_cache.get(CachedEntities.ENDPOINT, *(endpoint_uuids[1]), auto_retrieve=False)

        #try: