Loading src/simap_connector/service/simap_updater/SimapUpdater.py +92 −4 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ import logging, queue, threading from typing import Any, Optional from common.DeviceTypes import DeviceTypeEnum from common.proto.context_pb2 import DeviceEvent, Empty, LinkEvent, TopologyEvent from common.tools.grpc.BaseEventCollector import BaseEventCollector from common.tools.grpc.BaseEventDispatcher import BaseEventDispatcher Loading Loading @@ -63,7 +64,10 @@ class EventDispatcher(BaseEventDispatcher): topology_uuid = topology_event.topology_id.topology_uuid.uuid topology = self._object_cache.get(CachedEntities.TOPOLOGY, topology_uuid) topology_name = topology.name self._simap_client.network(topology_name).create() # Theoretically it should be create(), but given we have multiple clients # updating same SIMAP server, use update to skip tricks on get-check-create-or-update. self._simap_client.network(topology_name).update() MSG = 'Topology Created: {:s}' LOGGER.info(MSG.format(grpc_message_to_json_string(topology_event))) Loading Loading @@ -104,7 +108,34 @@ class EventDispatcher(BaseEventDispatcher): device_uuid = device_event.device_id.device_uuid.uuid device = self._object_cache.get(CachedEntities.DEVICE, device_uuid) device_name = device.name device_type = device.device_type SKIPPED_DEVICE_TYPES = { DeviceTypeEnum.EMULATED_IP_SDN_CONTROLLER.value, DeviceTypeEnum.IP_SDN_CONTROLLER.value, DeviceTypeEnum.NCE.value, DeviceTypeEnum.TERAFLOWSDN_CONTROLLER.value, } if device_type in SKIPPED_DEVICE_TYPES: MSG = ( 'DeviceEvent({:s}) skipped, is of a skipped device type. ' 'SIMAP should be updated by him: {: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 device_controller_uuid = device.controller_id.device_uuid.uuid if len(device_controller_uuid) > 0: MSG = ( 'DeviceEvent({:s}) skipped, is a remotely-managed device. ' 'SIMAP should be populated by remote controller: {: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_uuid, endpoint_names = get_device_endpoint(device) if topology_uuid is None: Loading @@ -120,6 +151,7 @@ class EventDispatcher(BaseEventDispatcher): te_topo = self._simap_client.network(topology_name) te_topo.update() device_name = device.name te_topo.node(device_name).create(termination_point_ids=endpoint_names) MSG = 'Device Created: {:s}' Loading @@ -132,7 +164,34 @@ class EventDispatcher(BaseEventDispatcher): device_uuid = device_event.device_id.device_uuid.uuid device = self._object_cache.get(CachedEntities.DEVICE, device_uuid) device_name = device.name device_type = device.device_type SKIPPED_DEVICE_TYPES = { DeviceTypeEnum.EMULATED_IP_SDN_CONTROLLER.value, DeviceTypeEnum.IP_SDN_CONTROLLER.value, DeviceTypeEnum.NCE.value, DeviceTypeEnum.TERAFLOWSDN_CONTROLLER.value, } if device_type in SKIPPED_DEVICE_TYPES: MSG = ( 'DeviceEvent({:s}) skipped, is of a skipped device type. ' 'SIMAP should be updated by him: {: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 device_controller_uuid = device.controller_id.device_uuid.uuid if len(device_controller_uuid) > 0: MSG = ( 'DeviceEvent({:s}) skipped, is a remotely-managed device. ' 'SIMAP should be updated by remote controller: {: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_uuid, endpoint_names = get_device_endpoint(device) if topology_uuid is None: Loading @@ -148,6 +207,7 @@ class EventDispatcher(BaseEventDispatcher): te_topo = self._simap_client.network(topology_name) te_topo.update() device_name = device.name te_device = te_topo.node(device_name) te_device.update() Loading @@ -164,7 +224,34 @@ class EventDispatcher(BaseEventDispatcher): device_uuid = device_event.device_id.device_uuid.uuid device = self._object_cache.get(CachedEntities.DEVICE, device_uuid) device_name = device.name device_type = device.device_type SKIPPED_DEVICE_TYPES = { DeviceTypeEnum.EMULATED_IP_SDN_CONTROLLER.value, DeviceTypeEnum.IP_SDN_CONTROLLER.value, DeviceTypeEnum.NCE.value, DeviceTypeEnum.TERAFLOWSDN_CONTROLLER.value, } if device_type in SKIPPED_DEVICE_TYPES: MSG = ( 'DeviceEvent({:s}) skipped, is of a skipped device type. ' 'SIMAP should be updated by him: {: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 device_controller_uuid = device.controller_id.device_uuid.uuid if len(device_controller_uuid) > 0: MSG = ( 'DeviceEvent({:s}) skipped, is a remotely-managed device. ' 'SIMAP should be updated by remote controller: {: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_uuid, endpoint_names = get_device_endpoint(device) topology = self._object_cache.get(CachedEntities.TOPOLOGY, topology_uuid) Loading @@ -173,6 +260,7 @@ class EventDispatcher(BaseEventDispatcher): te_topo = self._simap_client.network(topology_name) te_topo.update() device_name = device.name te_device = te_topo.node(device_name) for endpoint_name in endpoint_names: te_device.termination_point(endpoint_name).delete() Loading Loading
src/simap_connector/service/simap_updater/SimapUpdater.py +92 −4 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ import logging, queue, threading from typing import Any, Optional from common.DeviceTypes import DeviceTypeEnum from common.proto.context_pb2 import DeviceEvent, Empty, LinkEvent, TopologyEvent from common.tools.grpc.BaseEventCollector import BaseEventCollector from common.tools.grpc.BaseEventDispatcher import BaseEventDispatcher Loading Loading @@ -63,7 +64,10 @@ class EventDispatcher(BaseEventDispatcher): topology_uuid = topology_event.topology_id.topology_uuid.uuid topology = self._object_cache.get(CachedEntities.TOPOLOGY, topology_uuid) topology_name = topology.name self._simap_client.network(topology_name).create() # Theoretically it should be create(), but given we have multiple clients # updating same SIMAP server, use update to skip tricks on get-check-create-or-update. self._simap_client.network(topology_name).update() MSG = 'Topology Created: {:s}' LOGGER.info(MSG.format(grpc_message_to_json_string(topology_event))) Loading Loading @@ -104,7 +108,34 @@ class EventDispatcher(BaseEventDispatcher): device_uuid = device_event.device_id.device_uuid.uuid device = self._object_cache.get(CachedEntities.DEVICE, device_uuid) device_name = device.name device_type = device.device_type SKIPPED_DEVICE_TYPES = { DeviceTypeEnum.EMULATED_IP_SDN_CONTROLLER.value, DeviceTypeEnum.IP_SDN_CONTROLLER.value, DeviceTypeEnum.NCE.value, DeviceTypeEnum.TERAFLOWSDN_CONTROLLER.value, } if device_type in SKIPPED_DEVICE_TYPES: MSG = ( 'DeviceEvent({:s}) skipped, is of a skipped device type. ' 'SIMAP should be updated by him: {: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 device_controller_uuid = device.controller_id.device_uuid.uuid if len(device_controller_uuid) > 0: MSG = ( 'DeviceEvent({:s}) skipped, is a remotely-managed device. ' 'SIMAP should be populated by remote controller: {: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_uuid, endpoint_names = get_device_endpoint(device) if topology_uuid is None: Loading @@ -120,6 +151,7 @@ class EventDispatcher(BaseEventDispatcher): te_topo = self._simap_client.network(topology_name) te_topo.update() device_name = device.name te_topo.node(device_name).create(termination_point_ids=endpoint_names) MSG = 'Device Created: {:s}' Loading @@ -132,7 +164,34 @@ class EventDispatcher(BaseEventDispatcher): device_uuid = device_event.device_id.device_uuid.uuid device = self._object_cache.get(CachedEntities.DEVICE, device_uuid) device_name = device.name device_type = device.device_type SKIPPED_DEVICE_TYPES = { DeviceTypeEnum.EMULATED_IP_SDN_CONTROLLER.value, DeviceTypeEnum.IP_SDN_CONTROLLER.value, DeviceTypeEnum.NCE.value, DeviceTypeEnum.TERAFLOWSDN_CONTROLLER.value, } if device_type in SKIPPED_DEVICE_TYPES: MSG = ( 'DeviceEvent({:s}) skipped, is of a skipped device type. ' 'SIMAP should be updated by him: {: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 device_controller_uuid = device.controller_id.device_uuid.uuid if len(device_controller_uuid) > 0: MSG = ( 'DeviceEvent({:s}) skipped, is a remotely-managed device. ' 'SIMAP should be updated by remote controller: {: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_uuid, endpoint_names = get_device_endpoint(device) if topology_uuid is None: Loading @@ -148,6 +207,7 @@ class EventDispatcher(BaseEventDispatcher): te_topo = self._simap_client.network(topology_name) te_topo.update() device_name = device.name te_device = te_topo.node(device_name) te_device.update() Loading @@ -164,7 +224,34 @@ class EventDispatcher(BaseEventDispatcher): device_uuid = device_event.device_id.device_uuid.uuid device = self._object_cache.get(CachedEntities.DEVICE, device_uuid) device_name = device.name device_type = device.device_type SKIPPED_DEVICE_TYPES = { DeviceTypeEnum.EMULATED_IP_SDN_CONTROLLER.value, DeviceTypeEnum.IP_SDN_CONTROLLER.value, DeviceTypeEnum.NCE.value, DeviceTypeEnum.TERAFLOWSDN_CONTROLLER.value, } if device_type in SKIPPED_DEVICE_TYPES: MSG = ( 'DeviceEvent({:s}) skipped, is of a skipped device type. ' 'SIMAP should be updated by him: {: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 device_controller_uuid = device.controller_id.device_uuid.uuid if len(device_controller_uuid) > 0: MSG = ( 'DeviceEvent({:s}) skipped, is a remotely-managed device. ' 'SIMAP should be updated by remote controller: {: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_uuid, endpoint_names = get_device_endpoint(device) topology = self._object_cache.get(CachedEntities.TOPOLOGY, topology_uuid) Loading @@ -173,6 +260,7 @@ class EventDispatcher(BaseEventDispatcher): te_topo = self._simap_client.network(topology_name) te_topo.update() device_name = device.name te_device = te_topo.node(device_name) for endpoint_name in endpoint_names: te_device.termination_point(endpoint_name).delete() Loading