diff --git a/src/common/tests/MockServicerImpl_Context.py b/src/common/tests/MockServicerImpl_Context.py index 27ff45fc58c675fe28090a186059244e2f1178c1..f81a18135cb873a719b3dc3c79bc67e93dc6f997 100644 --- a/src/common/tests/MockServicerImpl_Context.py +++ b/src/common/tests/MockServicerImpl_Context.py @@ -103,23 +103,33 @@ class MockServicerImpl_Context(ContextServiceServicer): def ListContextIds(self, request: Empty, context : grpc.ServicerContext) -> ContextIdList: LOGGER.info('[ListContextIds] request={:s}'.format(grpc_message_to_json_string(request))) - return ContextIdList(context_ids=[context.context_id for context in get_entries(self.database, 'context')]) + reply = ContextIdList(context_ids=[context.context_id for context in get_entries(self.database, 'context')]) + LOGGER.info('[ListContextIds] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def ListContexts(self, request: Empty, context : grpc.ServicerContext) -> ContextList: LOGGER.info('[ListContexts] request={:s}'.format(grpc_message_to_json_string(request))) - return ContextList(contexts=get_entries(self.database, 'context')) + reply = ContextList(contexts=get_entries(self.database, 'context')) + LOGGER.info('[ListContexts] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def GetContext(self, request: ContextId, context : grpc.ServicerContext) -> Context: LOGGER.info('[GetContext] request={:s}'.format(grpc_message_to_json_string(request))) - return get_entry(context, self.database, 'context', request.context_uuid.uuid) + reply = get_entry(context, self.database, 'context', request.context_uuid.uuid) + LOGGER.info('[GetContext] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def SetContext(self, request: Context, context : grpc.ServicerContext) -> ContextId: LOGGER.info('[SetContext] request={:s}'.format(grpc_message_to_json_string(request))) - return self._set(request, 'context', request.context_id.context_uuid.uuid, 'context_id', TOPIC_CONTEXT) + reply = self._set(request, 'context', request.context_id.context_uuid.uuid, 'context_id', TOPIC_CONTEXT) + LOGGER.info('[SetContext] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def RemoveContext(self, request: ContextId, context : grpc.ServicerContext) -> Empty: LOGGER.info('[RemoveContext] request={:s}'.format(grpc_message_to_json_string(request))) - return self._del(request, 'context', request.context_uuid.uuid, 'context_id', TOPIC_CONTEXT, context) + reply = self._del(request, 'context', request.context_uuid.uuid, 'context_id', TOPIC_CONTEXT, context) + LOGGER.info('[RemoveContext] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def GetContextEvents(self, request: Empty, context : grpc.ServicerContext) -> Iterator[ContextEvent]: LOGGER.info('[GetContextEvents] request={:s}'.format(grpc_message_to_json_string(request))) @@ -131,29 +141,39 @@ class MockServicerImpl_Context(ContextServiceServicer): def ListTopologyIds(self, request: ContextId, context : grpc.ServicerContext) -> TopologyIdList: LOGGER.info('[ListTopologyIds] request={:s}'.format(grpc_message_to_json_string(request))) topologies = get_entries(self.database, 'topology[{:s}]'.format(str(request.context_uuid.uuid))) - return TopologyIdList(topology_ids=[topology.topology_id for topology in topologies]) + reply = TopologyIdList(topology_ids=[topology.topology_id for topology in topologies]) + LOGGER.info('[ListTopologyIds] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def ListTopologies(self, request: ContextId, context : grpc.ServicerContext) -> TopologyList: LOGGER.info('[ListTopologies] request={:s}'.format(grpc_message_to_json_string(request))) topologies = get_entries(self.database, 'topology[{:s}]'.format(str(request.context_uuid.uuid))) - return TopologyList(topologies=[topology for topology in topologies]) + reply = TopologyList(topologies=[topology for topology in topologies]) + LOGGER.info('[ListTopologies] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def GetTopology(self, request: TopologyId, context : grpc.ServicerContext) -> Topology: LOGGER.info('[GetTopology] request={:s}'.format(grpc_message_to_json_string(request))) container_name = 'topology[{:s}]'.format(str(request.context_id.context_uuid.uuid)) - return get_entry(context, self.database, container_name, request.topology_uuid.uuid) + reply = get_entry(context, self.database, container_name, request.topology_uuid.uuid) + LOGGER.info('[GetTopology] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def SetTopology(self, request: Topology, context : grpc.ServicerContext) -> TopologyId: LOGGER.info('[SetTopology] request={:s}'.format(grpc_message_to_json_string(request))) container_name = 'topology[{:s}]'.format(str(request.topology_id.context_id.context_uuid.uuid)) topology_uuid = request.topology_id.topology_uuid.uuid - return self._set(request, container_name, topology_uuid, 'topology_id', TOPIC_TOPOLOGY) + reply = self._set(request, container_name, topology_uuid, 'topology_id', TOPIC_TOPOLOGY) + LOGGER.info('[SetTopology] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def RemoveTopology(self, request: TopologyId, context : grpc.ServicerContext) -> Empty: LOGGER.info('[RemoveTopology] request={:s}'.format(grpc_message_to_json_string(request))) container_name = 'topology[{:s}]'.format(str(request.context_id.context_uuid.uuid)) topology_uuid = request.topology_uuid.uuid - return self._del(request, container_name, topology_uuid, 'topology_id', TOPIC_TOPOLOGY, context) + reply = self._del(request, container_name, topology_uuid, 'topology_id', TOPIC_TOPOLOGY, context) + LOGGER.info('[RemoveTopology] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def GetTopologyEvents(self, request: Empty, context : grpc.ServicerContext) -> Iterator[TopologyEvent]: LOGGER.info('[GetTopologyEvents] request={:s}'.format(grpc_message_to_json_string(request))) @@ -164,23 +184,33 @@ class MockServicerImpl_Context(ContextServiceServicer): def ListDeviceIds(self, request: Empty, context : grpc.ServicerContext) -> DeviceIdList: LOGGER.info('[ListDeviceIds] request={:s}'.format(grpc_message_to_json_string(request))) - return DeviceIdList(device_ids=[device.device_id for device in get_entries(self.database, 'device')]) + reply = DeviceIdList(device_ids=[device.device_id for device in get_entries(self.database, 'device')]) + LOGGER.info('[ListDeviceIds] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def ListDevices(self, request: Empty, context : grpc.ServicerContext) -> DeviceList: LOGGER.info('[ListDevices] request={:s}'.format(grpc_message_to_json_string(request))) - return DeviceList(devices=get_entries(self.database, 'device')) + reply = DeviceList(devices=get_entries(self.database, 'device')) + LOGGER.info('[ListDevices] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def GetDevice(self, request: DeviceId, context : grpc.ServicerContext) -> Device: LOGGER.info('[GetDevice] request={:s}'.format(grpc_message_to_json_string(request))) - return get_entry(context, self.database, 'device', request.device_uuid.uuid) + reply = get_entry(context, self.database, 'device', request.device_uuid.uuid) + LOGGER.info('[GetDevice] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def SetDevice(self, request: Context, context : grpc.ServicerContext) -> DeviceId: LOGGER.info('[SetDevice] request={:s}'.format(grpc_message_to_json_string(request))) - return self._set(request, 'device', request.device_id.device_uuid.uuid, 'device_id', TOPIC_DEVICE) + reply = self._set(request, 'device', request.device_id.device_uuid.uuid, 'device_id', TOPIC_DEVICE) + LOGGER.info('[SetDevice] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def RemoveDevice(self, request: DeviceId, context : grpc.ServicerContext) -> Empty: LOGGER.info('[RemoveDevice] request={:s}'.format(grpc_message_to_json_string(request))) - return self._del(request, 'device', request.device_uuid.uuid, 'device_id', TOPIC_DEVICE, context) + reply = self._del(request, 'device', request.device_uuid.uuid, 'device_id', TOPIC_DEVICE, context) + LOGGER.info('[RemoveDevice] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def GetDeviceEvents(self, request: Empty, context : grpc.ServicerContext) -> Iterator[DeviceEvent]: LOGGER.info('[GetDeviceEvents] request={:s}'.format(grpc_message_to_json_string(request))) @@ -191,23 +221,33 @@ class MockServicerImpl_Context(ContextServiceServicer): def ListLinkIds(self, request: Empty, context : grpc.ServicerContext) -> LinkIdList: LOGGER.info('[ListLinkIds] request={:s}'.format(grpc_message_to_json_string(request))) - return LinkIdList(link_ids=[link.link_id for link in get_entries(self.database, 'link')]) + reply = LinkIdList(link_ids=[link.link_id for link in get_entries(self.database, 'link')]) + LOGGER.info('[ListLinkIds] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def ListLinks(self, request: Empty, context : grpc.ServicerContext) -> LinkList: LOGGER.info('[ListLinks] request={:s}'.format(grpc_message_to_json_string(request))) - return LinkList(links=get_entries(self.database, 'link')) + reply = LinkList(links=get_entries(self.database, 'link')) + LOGGER.info('[ListLinks] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def GetLink(self, request: LinkId, context : grpc.ServicerContext) -> Link: LOGGER.info('[GetLink] request={:s}'.format(grpc_message_to_json_string(request))) - return get_entry(context, self.database, 'link', request.link_uuid.uuid) + reply = get_entry(context, self.database, 'link', request.link_uuid.uuid) + LOGGER.info('[GetLink] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def SetLink(self, request: Context, context : grpc.ServicerContext) -> LinkId: LOGGER.info('[SetLink] request={:s}'.format(grpc_message_to_json_string(request))) - return self._set(request, 'link', request.link_id.link_uuid.uuid, 'link_id', TOPIC_LINK) + reply = self._set(request, 'link', request.link_id.link_uuid.uuid, 'link_id', TOPIC_LINK) + LOGGER.info('[SetLink] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def RemoveLink(self, request: LinkId, context : grpc.ServicerContext) -> Empty: LOGGER.info('[RemoveLink] request={:s}'.format(grpc_message_to_json_string(request))) - return self._del(request, 'link', request.link_uuid.uuid, 'link_id', TOPIC_LINK, context) + reply = self._del(request, 'link', request.link_uuid.uuid, 'link_id', TOPIC_LINK, context) + LOGGER.info('[RemoveLink] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def GetLinkEvents(self, request: Empty, context : grpc.ServicerContext) -> Iterator[LinkEvent]: LOGGER.info('[GetLinkEvents] request={:s}'.format(grpc_message_to_json_string(request))) @@ -219,29 +259,39 @@ class MockServicerImpl_Context(ContextServiceServicer): def ListSliceIds(self, request: ContextId, context : grpc.ServicerContext) -> SliceIdList: LOGGER.info('[ListSliceIds] request={:s}'.format(grpc_message_to_json_string(request))) slices = get_entries(self.database, 'slice[{:s}]'.format(str(request.context_uuid.uuid))) - return SliceIdList(slice_ids=[slice.slice_id for slice in slices]) + reply = SliceIdList(slice_ids=[slice.slice_id for slice in slices]) + LOGGER.info('[ListSliceIds] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def ListSlices(self, request: ContextId, context : grpc.ServicerContext) -> SliceList: LOGGER.info('[ListSlices] request={:s}'.format(grpc_message_to_json_string(request))) slices = get_entries(self.database, 'slice[{:s}]'.format(str(request.context_uuid.uuid))) - return SliceList(slices=[slice for slice in slices]) + reply = SliceList(slices=[slice for slice in slices]) + LOGGER.info('[ListSlices] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def GetSlice(self, request: SliceId, context : grpc.ServicerContext) -> Slice: LOGGER.info('[GetSlice] request={:s}'.format(grpc_message_to_json_string(request))) container_name = 'slice[{:s}]'.format(str(request.context_id.context_uuid.uuid)) - return get_entry(context, self.database, container_name, request.slice_uuid.uuid) + reply = get_entry(context, self.database, container_name, request.slice_uuid.uuid) + LOGGER.info('[GetSlice] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def SetSlice(self, request: Slice, context : grpc.ServicerContext) -> SliceId: LOGGER.info('[SetSlice] request={:s}'.format(grpc_message_to_json_string(request))) container_name = 'slice[{:s}]'.format(str(request.slice_id.context_id.context_uuid.uuid)) slice_uuid = request.slice_id.slice_uuid.uuid - return self._set(request, container_name, slice_uuid, 'slice_id', TOPIC_SLICE) + reply = self._set(request, container_name, slice_uuid, 'slice_id', TOPIC_SLICE) + LOGGER.info('[SetSlice] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def RemoveSlice(self, request: SliceId, context : grpc.ServicerContext) -> Empty: LOGGER.info('[RemoveSlice] request={:s}'.format(grpc_message_to_json_string(request))) container_name = 'slice[{:s}]'.format(str(request.context_id.context_uuid.uuid)) slice_uuid = request.slice_uuid.uuid - return self._del(request, container_name, slice_uuid, 'slice_id', TOPIC_SLICE, context) + reply = self._del(request, container_name, slice_uuid, 'slice_id', TOPIC_SLICE, context) + LOGGER.info('[RemoveSlice] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def GetSliceEvents(self, request: Empty, context : grpc.ServicerContext) -> Iterator[SliceEvent]: LOGGER.info('[GetSliceEvents] request={:s}'.format(grpc_message_to_json_string(request))) @@ -253,29 +303,39 @@ class MockServicerImpl_Context(ContextServiceServicer): def ListServiceIds(self, request: ContextId, context : grpc.ServicerContext) -> ServiceIdList: LOGGER.info('[ListServiceIds] request={:s}'.format(grpc_message_to_json_string(request))) services = get_entries(self.database, 'service[{:s}]'.format(str(request.context_uuid.uuid))) - return ServiceIdList(service_ids=[service.service_id for service in services]) + reply = ServiceIdList(service_ids=[service.service_id for service in services]) + LOGGER.info('[ListServiceIds] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def ListServices(self, request: ContextId, context : grpc.ServicerContext) -> ServiceList: LOGGER.info('[ListServices] request={:s}'.format(grpc_message_to_json_string(request))) services = get_entries(self.database, 'service[{:s}]'.format(str(request.context_uuid.uuid))) - return ServiceList(services=[service for service in services]) + reply = ServiceList(services=[service for service in services]) + LOGGER.info('[ListServices] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def GetService(self, request: ServiceId, context : grpc.ServicerContext) -> Service: LOGGER.info('[GetService] request={:s}'.format(grpc_message_to_json_string(request))) container_name = 'service[{:s}]'.format(str(request.context_id.context_uuid.uuid)) - return get_entry(context, self.database, container_name, request.service_uuid.uuid) + reply = get_entry(context, self.database, container_name, request.service_uuid.uuid) + LOGGER.info('[GetService] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def SetService(self, request: Service, context : grpc.ServicerContext) -> ServiceId: LOGGER.info('[SetService] request={:s}'.format(grpc_message_to_json_string(request))) container_name = 'service[{:s}]'.format(str(request.service_id.context_id.context_uuid.uuid)) service_uuid = request.service_id.service_uuid.uuid - return self._set(request, container_name, service_uuid, 'service_id', TOPIC_SERVICE) + reply = self._set(request, container_name, service_uuid, 'service_id', TOPIC_SERVICE) + LOGGER.info('[SetService] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def RemoveService(self, request: ServiceId, context : grpc.ServicerContext) -> Empty: LOGGER.info('[RemoveService] request={:s}'.format(grpc_message_to_json_string(request))) container_name = 'service[{:s}]'.format(str(request.context_id.context_uuid.uuid)) service_uuid = request.service_uuid.uuid - return self._del(request, container_name, service_uuid, 'service_id', TOPIC_SERVICE, context) + reply = self._del(request, container_name, service_uuid, 'service_id', TOPIC_SERVICE, context) + LOGGER.info('[RemoveService] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def GetServiceEvents(self, request: Empty, context : grpc.ServicerContext) -> Iterator[ServiceEvent]: LOGGER.info('[GetServiceEvents] request={:s}'.format(grpc_message_to_json_string(request))) @@ -288,17 +348,23 @@ class MockServicerImpl_Context(ContextServiceServicer): LOGGER.info('[ListConnectionIds] request={:s}'.format(grpc_message_to_json_string(request))) container_name = 'service_connections[{:s}/{:s}]'.format( str(request.context_id.context_uuid.uuid), str(request.service_uuid.uuid)) - return ConnectionIdList(connection_ids=[c.connection_id for c in get_entries(self.database, container_name)]) + reply = ConnectionIdList(connection_ids=[c.connection_id for c in get_entries(self.database, container_name)]) + LOGGER.info('[ListConnectionIds] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def ListConnections(self, request: ServiceId, context : grpc.ServicerContext) -> ConnectionList: LOGGER.info('[ListConnections] request={:s}'.format(grpc_message_to_json_string(request))) container_name = 'service_connections[{:s}/{:s}]'.format( str(request.context_id.context_uuid.uuid), str(request.service_uuid.uuid)) - return ConnectionList(connections=get_entries(self.database, container_name)) + reply = ConnectionList(connections=get_entries(self.database, container_name)) + LOGGER.info('[ListConnections] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def GetConnection(self, request: ConnectionId, context : grpc.ServicerContext) -> Connection: LOGGER.info('[GetConnection] request={:s}'.format(grpc_message_to_json_string(request))) - return get_entry(context, self.database, 'connection', request.connection_uuid.uuid) + reply = get_entry(context, self.database, 'connection', request.connection_uuid.uuid) + LOGGER.info('[GetConnection] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def SetConnection(self, request: Connection, context : grpc.ServicerContext) -> ConnectionId: LOGGER.info('[SetConnection] request={:s}'.format(grpc_message_to_json_string(request))) @@ -306,7 +372,9 @@ class MockServicerImpl_Context(ContextServiceServicer): str(request.service_id.context_id.context_uuid.uuid), str(request.service_id.service_uuid.uuid)) connection_uuid = request.connection_id.connection_uuid.uuid set_entry(self.database, container_name, connection_uuid, request) - return self._set(request, 'connection', connection_uuid, 'connection_id', TOPIC_CONNECTION) + reply = self._set(request, 'connection', connection_uuid, 'connection_id', TOPIC_CONNECTION) + LOGGER.info('[SetConnection] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def RemoveConnection(self, request: ConnectionId, context : grpc.ServicerContext) -> Empty: LOGGER.info('[RemoveConnection] request={:s}'.format(grpc_message_to_json_string(request))) @@ -315,7 +383,9 @@ class MockServicerImpl_Context(ContextServiceServicer): str(connection.service_id.context_id.context_uuid.uuid), str(connection.service_id.service_uuid.uuid)) connection_uuid = request.connection_uuid.uuid del_entry(context, self.database, container_name, connection_uuid) - return self._del(request, 'connection', connection_uuid, 'connection_id', TOPIC_CONNECTION, context) + reply = self._del(request, 'connection', connection_uuid, 'connection_id', TOPIC_CONNECTION, context) + LOGGER.info('[RemoveConnection] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply def GetConnectionEvents(self, request: Empty, context : grpc.ServicerContext) -> Iterator[ConnectionEvent]: LOGGER.info('[GetConnectionEvents] request={:s}'.format(grpc_message_to_json_string(request)))