diff --git a/daemon/core/api/grpc/client.py b/daemon/core/api/grpc/client.py index e886c7e7..a676c7c2 100644 --- a/daemon/core/api/grpc/client.py +++ b/daemon/core/api/grpc/client.py @@ -408,21 +408,6 @@ class CoreGrpcClient: response = self.stub.GetSession(request) return wrappers.Session.from_proto(response.session) - def set_session_state(self, session_id: int, state: wrappers.SessionState) -> bool: - """ - Set session state. - - :param session_id: id of session - :param state: session state to transition to - :return: True for success, False otherwise - :raises grpc.RpcError: when session doesn't exist - """ - request = core_pb2.SetSessionStateRequest( - session_id=session_id, state=state.value - ) - response = self.stub.SetSessionState(request) - return response.result - def alert( self, session_id: int, diff --git a/daemon/core/api/grpc/server.py b/daemon/core/api/grpc/server.py index 4c546d8e..90e95317 100644 --- a/daemon/core/api/grpc/server.py +++ b/daemon/core/api/grpc/server.py @@ -402,35 +402,6 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): sessions.append(session_summary) return core_pb2.GetSessionsResponse(sessions=sessions) - def SetSessionState( - self, request: core_pb2.SetSessionStateRequest, context: ServicerContext - ) -> core_pb2.SetSessionStateResponse: - """ - Set session state - - :param request: set-session-state request - :param context:context object - :return: set-session-state response - """ - logger.debug("set session state: %s", request) - session = self.get_session(request.session_id, context) - try: - state = EventTypes(request.state) - session.set_state(state) - if state == EventTypes.INSTANTIATION_STATE: - session.directory.mkdir(exist_ok=True) - session.instantiate() - elif state == EventTypes.SHUTDOWN_STATE: - session.shutdown() - elif state == EventTypes.DATACOLLECT_STATE: - session.data_collect() - elif state == EventTypes.DEFINITION_STATE: - session.clear() - result = True - except KeyError: - result = False - return core_pb2.SetSessionStateResponse(result=result) - def CheckSession( self, request: core_pb2.GetSessionRequest, context: ServicerContext ) -> core_pb2.CheckSessionResponse: diff --git a/daemon/proto/core/api/grpc/core.proto b/daemon/proto/core/api/grpc/core.proto index 039c889f..80cbecff 100644 --- a/daemon/proto/core/api/grpc/core.proto +++ b/daemon/proto/core/api/grpc/core.proto @@ -25,8 +25,6 @@ service CoreApi { } rpc CheckSession (CheckSessionRequest) returns (CheckSessionResponse) { } - rpc SetSessionState (SetSessionStateRequest) returns (SetSessionStateResponse) { - } rpc SessionAlert (SessionAlertRequest) returns (SessionAlertResponse) { } @@ -216,15 +214,6 @@ message GetSessionResponse { Session session = 1; } -message SetSessionStateRequest { - int32 session_id = 1; - SessionState.Enum state = 2; -} - -message SetSessionStateResponse { - bool result = 1; -} - message SessionAlertRequest { int32 session_id = 1; ExceptionLevel.Enum level = 2; diff --git a/daemon/tests/test_grpc.py b/daemon/tests/test_grpc.py index bd3c92d3..73485386 100644 --- a/daemon/tests/test_grpc.py +++ b/daemon/tests/test_grpc.py @@ -243,19 +243,6 @@ class TestGrpc: assert len(sessions) == 1 assert found_session is not None - def test_set_session_state(self, grpc_server: CoreGrpcServer): - # given - client = CoreGrpcClient() - session = grpc_server.coreemu.create_session() - - # then - with client.context_connect(): - result = client.set_session_state(session.id, SessionState.DEFINITION) - - # then - assert result is True - assert session.state == EventTypes.DEFINITION_STATE - def test_add_node(self, grpc_server: CoreGrpcServer): # given client = CoreGrpcClient()