added grpc to get emane event channel being used
This commit is contained in:
parent
ebafa228ff
commit
1375af51cb
4 changed files with 38 additions and 2 deletions
|
@ -26,6 +26,10 @@ from core.api.grpc.configservices_pb2 import (
|
|||
SetNodeConfigServiceRequest,
|
||||
SetNodeConfigServiceResponse,
|
||||
)
|
||||
from core.api.grpc.core_pb2 import (
|
||||
GetEmaneEventChannelRequest,
|
||||
GetEmaneEventChannelResponse,
|
||||
)
|
||||
|
||||
|
||||
class InterfaceHelper:
|
||||
|
@ -1139,6 +1143,10 @@ class CoreGrpcClient:
|
|||
)
|
||||
return self.stub.SetNodeConfigService(request)
|
||||
|
||||
def get_emane_event_channel(self, session_id: int) -> GetEmaneEventChannelResponse:
|
||||
request = GetEmaneEventChannelRequest(session_id=session_id)
|
||||
return self.stub.GetEmaneEventChannel(request)
|
||||
|
||||
def connect(self) -> None:
|
||||
"""
|
||||
Open connection to server, must be closed manually.
|
||||
|
|
|
@ -32,6 +32,10 @@ from core.api.grpc.configservices_pb2 import (
|
|||
SetNodeConfigServiceRequest,
|
||||
SetNodeConfigServiceResponse,
|
||||
)
|
||||
from core.api.grpc.core_pb2 import (
|
||||
GetEmaneEventChannelRequest,
|
||||
GetEmaneEventChannelResponse,
|
||||
)
|
||||
from core.api.grpc.events import EventStreamer
|
||||
from core.api.grpc.grpcutils import (
|
||||
get_config_options,
|
||||
|
@ -1630,3 +1634,14 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
grpc.StatusCode.NOT_FOUND,
|
||||
f"node {node.name} missing service {request.name}",
|
||||
)
|
||||
|
||||
def GetEmaneEventChannel(
|
||||
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)
|
||||
|
|
|
@ -91,6 +91,7 @@ class EmaneManager(ModelManager):
|
|||
self.set_configs(self.emane_config.default_values())
|
||||
|
||||
self.service = None
|
||||
self.eventchannel = None
|
||||
self.event_device = None
|
||||
self.emane_check()
|
||||
|
||||
|
@ -204,13 +205,13 @@ class EmaneManager(ModelManager):
|
|||
if eventnet is not None:
|
||||
# direct EMANE events towards control net bridge
|
||||
self.event_device = eventnet.brname
|
||||
eventchannel = (group, int(port), self.event_device)
|
||||
self.eventchannel = (group, int(port), self.event_device)
|
||||
|
||||
# disabled otachannel for event service
|
||||
# only needed for e.g. antennaprofile events xmit by models
|
||||
logging.info("using %s for event service traffic", self.event_device)
|
||||
try:
|
||||
self.service = EventService(eventchannel=eventchannel, otachannel=None)
|
||||
self.service = EventService(eventchannel=self.eventchannel, otachannel=None)
|
||||
except EventServiceException:
|
||||
logging.exception("error instantiating emane EventService")
|
||||
|
||||
|
|
|
@ -140,6 +140,8 @@ service CoreApi {
|
|||
}
|
||||
rpc GetEmaneModelConfigs (GetEmaneModelConfigsRequest) returns (GetEmaneModelConfigsResponse) {
|
||||
}
|
||||
rpc GetEmaneEventChannel (GetEmaneEventChannelRequest) returns (GetEmaneEventChannelResponse) {
|
||||
}
|
||||
|
||||
// xml rpc
|
||||
rpc SaveXml (SaveXmlRequest) returns (SaveXmlResponse) {
|
||||
|
@ -710,6 +712,16 @@ message GetEmaneModelConfigsResponse {
|
|||
repeated ModelConfig configs = 1;
|
||||
}
|
||||
|
||||
message GetEmaneEventChannelRequest {
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message GetEmaneEventChannelResponse {
|
||||
string group = 1;
|
||||
int32 port = 2;
|
||||
string device = 3;
|
||||
}
|
||||
|
||||
message SaveXmlRequest {
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue