grpc: update grpc call for get emane event channel to take in a nem id, since channels may now be unique per nem

This commit is contained in:
Blake Harnden 2021-05-25 10:52:50 -07:00
parent bcd9cc7ac2
commit 8d5c3bd212
4 changed files with 13 additions and 10 deletions

View file

@ -1034,15 +1034,18 @@ class CoreGrpcClient:
response = self.stub.GetNodeConfigService(request)
return dict(response.config)
def get_emane_event_channel(self, session_id: int) -> wrappers.EmaneEventChannel:
def get_emane_event_channel(
self, session_id: int, nem_id: int
) -> wrappers.EmaneEventChannel:
"""
Retrieves the current emane event channel being used for a session.
:param session_id: session to get emane event channel for
:param nem_id: nem id for the desired event channel
:return: emane event channel
:raises grpc.RpcError: when session doesn't exist
"""
request = GetEmaneEventChannelRequest(session_id=session_id)
request = GetEmaneEventChannelRequest(session_id=session_id, nem_id=nem_id)
response = self.stub.GetEmaneEventChannel(request)
return wrappers.EmaneEventChannel.from_proto(response)

View file

@ -1241,12 +1241,12 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
self, request: GetEmaneEventChannelRequest, context: ServicerContext
) -> GetEmaneEventChannelResponse:
session = self.get_session(request.session_id, context)
group = None
port = None
device = None
if session.emane.eventchannel:
group, port, device = session.emane.eventchannel
return GetEmaneEventChannelResponse(group=group, port=port, device=device)
service = session.emane.nem_service.get(request.nem_id)
if not service:
context.abort(grpc.StatusCode.NOT_FOUND, f"unknown nem id {request.nem_id}")
return GetEmaneEventChannelResponse(
group=service.group, port=service.port, device=service.device
)
def ExecuteScript(self, request, context):
existing_sessions = set(self.coreemu.sessions.keys())