grpc: removed set session user, added to start session

This commit is contained in:
Blake Harnden 2021-04-24 22:35:45 -07:00
parent d8a3f9e78c
commit f891974e3a
5 changed files with 4 additions and 54 deletions

View file

@ -361,20 +361,6 @@ class CoreGrpcClient:
request = core_pb2.SetSessionStateRequest(session_id=session_id, state=state)
return self.stub.SetSessionState(request)
def set_session_user(
self, session_id: int, user: str
) -> core_pb2.SetSessionUserResponse:
"""
Set session user, used for helping to find files without full paths.
:param session_id: id of session
:param user: user to set for session
:return: response with result of success or failure
:raises grpc.RpcError: when session doesn't exist
"""
request = core_pb2.SetSessionUserRequest(session_id=session_id, user=user)
return self.stub.SetSessionUser(request)
def add_session_server(
self, session_id: int, name: str, host: str
) -> core_pb2.AddSessionServerResponse:

View file

@ -330,6 +330,7 @@ class CoreGrpcClient:
asymmetric_links=asymmetric_links,
config_service_configs=config_service_configs,
options=options,
user=session.user,
)
response = self.stub.StartSession(request)
return response.result, list(response.exceptions)
@ -454,19 +455,6 @@ class CoreGrpcClient:
response = self.stub.SetSessionState(request)
return response.result
def set_session_user(self, session_id: int, user: str) -> bool:
"""
Set session user, used for helping to find files without full paths.
:param session_id: id of session
:param user: user to set for session
:return: True for success, False otherwise
:raises grpc.RpcError: when session doesn't exist
"""
request = core_pb2.SetSessionUserRequest(session_id=session_id, user=user)
response = self.stub.SetSessionUser(request)
return response.result
def add_session_server(self, session_id: int, name: str, host: str) -> bool:
"""
Add distributed session server.

View file

@ -225,6 +225,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
session.clear()
session.directory.mkdir(exist_ok=True)
session.set_state(EventTypes.CONFIGURATION_STATE)
session.user = request.user
# session options
session.options.config_reset()
@ -427,21 +428,6 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
result = False
return core_pb2.SetSessionStateResponse(result=result)
def SetSessionUser(
self, request: core_pb2.SetSessionUserRequest, context: ServicerContext
) -> core_pb2.SetSessionUserResponse:
"""
Sets the user for a session.
:param request: set session user request
:param context: context object
:return: set session user response
"""
logger.debug("set session user: %s", request)
session = self.get_session(request.session_id, context)
session.user = request.user
return core_pb2.SetSessionUserResponse(result=True)
def SetSessionMetadata(
self, request: core_pb2.SetSessionMetadataRequest, context: ServicerContext
) -> core_pb2.SetSessionMetadataResponse:

View file

@ -295,7 +295,7 @@ class CoreClient:
self.reset()
try:
self.session = self.client.get_session(session_id)
self.client.set_session_user(self.session.id, self.user)
self.session.user = self.user
title_file = self.session.file.name if self.session.file else ""
self.master.title(f"CORE Session({self.session.id}) {title_file}")
self.handling_events = self.client.events(

View file

@ -31,8 +31,6 @@ service CoreApi {
}
rpc SetSessionState (SetSessionStateRequest) returns (SetSessionStateResponse) {
}
rpc SetSessionUser (SetSessionUserRequest) returns (SetSessionUserResponse) {
}
rpc AddSessionServer (AddSessionServerRequest) returns (AddSessionServerResponse) {
}
rpc SessionAlert (SessionAlertRequest) returns (SessionAlertResponse) {
@ -181,6 +179,7 @@ message StartSessionRequest {
repeated Link asymmetric_links = 12;
repeated configservices.ConfigServiceConfig config_service_configs = 13;
map<string, string> options = 14;
string user = 15;
}
message StartSessionResponse {
@ -263,15 +262,6 @@ message SetSessionStateResponse {
bool result = 1;
}
message SetSessionUserRequest {
int32 session_id = 1;
string user = 2;
}
message SetSessionUserResponse {
bool result = 1;
}
message AddSessionServerRequest {
int32 session_id = 1;
string name = 2;