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)
|
response = self.stub.GetNodeConfigService(request)
|
||||||
return dict(response.config)
|
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.
|
Retrieves the current emane event channel being used for a session.
|
||||||
|
|
||||||
:param session_id: session to get emane event channel for
|
:param session_id: session to get emane event channel for
|
||||||
|
:param nem_id: nem id for the desired event channel
|
||||||
:return: emane event channel
|
:return: emane event channel
|
||||||
:raises grpc.RpcError: when session doesn't exist
|
: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)
|
response = self.stub.GetEmaneEventChannel(request)
|
||||||
return wrappers.EmaneEventChannel.from_proto(response)
|
return wrappers.EmaneEventChannel.from_proto(response)
|
||||||
|
|
||||||
|
|
|
@ -1241,12 +1241,12 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
||||||
self, request: GetEmaneEventChannelRequest, context: ServicerContext
|
self, request: GetEmaneEventChannelRequest, context: ServicerContext
|
||||||
) -> GetEmaneEventChannelResponse:
|
) -> GetEmaneEventChannelResponse:
|
||||||
session = self.get_session(request.session_id, context)
|
session = self.get_session(request.session_id, context)
|
||||||
group = None
|
service = session.emane.nem_service.get(request.nem_id)
|
||||||
port = None
|
if not service:
|
||||||
device = None
|
context.abort(grpc.StatusCode.NOT_FOUND, f"unknown nem id {request.nem_id}")
|
||||||
if session.emane.eventchannel:
|
return GetEmaneEventChannelResponse(
|
||||||
group, port, device = session.emane.eventchannel
|
group=service.group, port=service.port, device=service.device
|
||||||
return GetEmaneEventChannelResponse(group=group, port=port, device=device)
|
)
|
||||||
|
|
||||||
def ExecuteScript(self, request, context):
|
def ExecuteScript(self, request, context):
|
||||||
existing_sessions = set(self.coreemu.sessions.keys())
|
existing_sessions = set(self.coreemu.sessions.keys())
|
||||||
|
|
|
@ -7,7 +7,7 @@ import os
|
||||||
import threading
|
import threading
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from enum import Enum
|
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 import utils
|
||||||
from core.emane.emanemodel import EmaneModel
|
from core.emane.emanemodel import EmaneModel
|
||||||
|
@ -158,7 +158,6 @@ class EmaneManager:
|
||||||
# emane event monitoring
|
# emane event monitoring
|
||||||
self.services: Dict[str, EmaneEventService] = {}
|
self.services: Dict[str, EmaneEventService] = {}
|
||||||
self.nem_service: Dict[int, EmaneEventService] = {}
|
self.nem_service: Dict[int, EmaneEventService] = {}
|
||||||
self.eventchannel: Optional[Tuple[str, int, str]] = None
|
|
||||||
|
|
||||||
def next_nem_id(self, iface: CoreInterface) -> int:
|
def next_nem_id(self, iface: CoreInterface) -> int:
|
||||||
nem_id = self.session.options.get_config_int("nem_id_start")
|
nem_id = self.session.options.get_config_int("nem_id_start")
|
||||||
|
|
|
@ -33,6 +33,7 @@ message GetEmaneModelConfig {
|
||||||
|
|
||||||
message GetEmaneEventChannelRequest {
|
message GetEmaneEventChannelRequest {
|
||||||
int32 session_id = 1;
|
int32 session_id = 1;
|
||||||
|
int32 nem_id = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetEmaneEventChannelResponse {
|
message GetEmaneEventChannelResponse {
|
||||||
|
|
Loading…
Reference in a new issue