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:
parent
bcd9cc7ac2
commit
8d5c3bd212
4 changed files with 13 additions and 10 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -7,7 +7,7 @@ import os
|
|||
import threading
|
||||
from dataclasses import dataclass, field
|
||||
from enum import Enum
|
||||
from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple, Type, Union
|
||||
from typing import TYPE_CHECKING, Dict, List, Optional, Set, Type, Union
|
||||
|
||||
from core import utils
|
||||
from core.emane.emanemodel import EmaneModel
|
||||
|
@ -158,7 +158,6 @@ class EmaneManager:
|
|||
# emane event monitoring
|
||||
self.services: Dict[str, EmaneEventService] = {}
|
||||
self.nem_service: Dict[int, EmaneEventService] = {}
|
||||
self.eventchannel: Optional[Tuple[str, int, str]] = None
|
||||
|
||||
def next_nem_id(self, iface: CoreInterface) -> int:
|
||||
nem_id = self.session.options.get_config_int("nem_id_start")
|
||||
|
|
|
@ -33,6 +33,7 @@ message GetEmaneModelConfig {
|
|||
|
||||
message GetEmaneEventChannelRequest {
|
||||
int32 session_id = 1;
|
||||
int32 nem_id = 2;
|
||||
}
|
||||
|
||||
message GetEmaneEventChannelResponse {
|
||||
|
|
Loading…
Reference in a new issue