grpc: removed get model configs, can be achieved with get session

This commit is contained in:
Blake Harnden 2021-05-04 13:51:17 -07:00
parent 639b29a134
commit 618d89b8db
5 changed files with 0 additions and 74 deletions

View file

@ -35,7 +35,6 @@ from core.api.grpc.emane_pb2 import (
GetEmaneConfigRequest,
GetEmaneEventChannelRequest,
GetEmaneModelConfigRequest,
GetEmaneModelConfigsRequest,
GetEmaneModelsRequest,
SetEmaneConfigRequest,
SetEmaneModelConfigRequest,
@ -1106,24 +1105,6 @@ class CoreGrpcClient:
response = self.stub.SetEmaneModelConfig(request)
return response.result
def get_emane_model_configs(
self, session_id: int
) -> List[wrappers.EmaneModelConfig]:
"""
Get all EMANE model configurations for a session.
:param session_id: session to get emane model configs
:return: list of emane model configs
:raises grpc.RpcError: when session doesn't exist
"""
request = GetEmaneModelConfigsRequest(session_id=session_id)
response = self.stub.GetEmaneModelConfigs(request)
configs = []
for config_proto in response.configs:
config = wrappers.EmaneModelConfig.from_proto(config_proto)
configs.append(config)
return configs
def save_xml(self, session_id: int, file_path: str) -> None:
"""
Save the current scenario to an XML file.

View file

@ -47,8 +47,6 @@ from core.api.grpc.emane_pb2 import (
GetEmaneEventChannelResponse,
GetEmaneModelConfigRequest,
GetEmaneModelConfigResponse,
GetEmaneModelConfigsRequest,
GetEmaneModelConfigsResponse,
GetEmaneModelsRequest,
GetEmaneModelsResponse,
SetEmaneConfigRequest,
@ -1292,23 +1290,6 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
session.emane.set_model_config(_id, model_config.model, model_config.config)
return SetEmaneModelConfigResponse(result=True)
def GetEmaneModelConfigs(
self, request: GetEmaneModelConfigsRequest, context: ServicerContext
) -> GetEmaneModelConfigsResponse:
"""
Retrieve all EMANE model configurations of a session
:param request:
get-EMANE-model-configurations request
:param context: context object
:return: get-EMANE-model-configurations response that has all the EMANE
configurations
"""
logger.debug("get emane model configs: %s", request)
session = self.get_session(request.session_id, context)
configs = grpcutils.get_emane_model_configs(session)
return GetEmaneModelConfigsResponse(configs=configs)
def SaveXml(
self, request: core_pb2.SaveXmlRequest, context: ServicerContext
) -> core_pb2.SaveXmlResponse:

View file

@ -127,8 +127,6 @@ service CoreApi {
}
rpc SetEmaneModelConfig (emane.SetEmaneModelConfigRequest) returns (emane.SetEmaneModelConfigResponse) {
}
rpc GetEmaneModelConfigs (emane.GetEmaneModelConfigsRequest) returns (emane.GetEmaneModelConfigsResponse) {
}
rpc GetEmaneEventChannel (emane.GetEmaneEventChannelRequest) returns (emane.GetEmaneEventChannelResponse) {
}
rpc EmanePathlosses (stream emane.EmanePathlossesRequest) returns (emane.EmanePathlossesResponse) {

View file

@ -49,10 +49,6 @@ message SetEmaneModelConfigResponse {
bool result = 1;
}
message GetEmaneModelConfigsRequest {
int32 session_id = 1;
}
message GetEmaneModelConfig {
int32 node_id = 1;
string model = 2;
@ -60,10 +56,6 @@ message GetEmaneModelConfig {
map<string, common.ConfigOption> config = 4;
}
message GetEmaneModelConfigsResponse {
repeated GetEmaneModelConfig configs = 1;
}
message GetEmaneEventChannelRequest {
int32 session_id = 1;
}

View file

@ -562,32 +562,6 @@ class TestGrpcw:
assert len(config) > 1
assert config[config_key] == config_value
def test_get_emane_model_configs(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
session.set_location(47.57917, -122.13232, 2.00000, 1.0)
options = NodeOptions(emane=EmaneIeee80211abgModel.name)
emane_network = session.add_node(EmaneNet, options=options)
session.emane.set_model(emane_network, EmaneIeee80211abgModel)
config_key = "platform_id_start"
config_value = "2"
session.emane.set_model_config(
emane_network.id, EmaneIeee80211abgModel.name, {config_key: config_value}
)
# then
with client.context_connect():
configs = client.get_emane_model_configs(session.id)
# then
assert len(configs) == 1
model_config = configs[0]
assert emane_network.id == model_config.node_id
assert model_config.model == EmaneIeee80211abgModel.name
assert len(model_config.config) > 0
assert model_config.iface_id is None
def test_set_emane_model_config(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()