grpc: removed get mobility configs, achieved with get session
This commit is contained in:
parent
618d89b8db
commit
9205fe1764
5 changed files with 14 additions and 75 deletions
|
@ -41,7 +41,6 @@ from core.api.grpc.emane_pb2 import (
|
|||
)
|
||||
from core.api.grpc.mobility_pb2 import (
|
||||
GetMobilityConfigRequest,
|
||||
GetMobilityConfigsRequest,
|
||||
MobilityActionRequest,
|
||||
MobilityConfig,
|
||||
SetMobilityConfigRequest,
|
||||
|
@ -769,23 +768,6 @@ class CoreGrpcClient:
|
|||
response = self.stub.DeleteLink(request)
|
||||
return response.result
|
||||
|
||||
def get_mobility_configs(
|
||||
self, session_id: int
|
||||
) -> Dict[int, Dict[str, wrappers.ConfigOption]]:
|
||||
"""
|
||||
Get all mobility configurations.
|
||||
|
||||
:param session_id: session id
|
||||
:return: dict of node id to mobility configuration dict
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = GetMobilityConfigsRequest(session_id=session_id)
|
||||
response = self.stub.GetMobilityConfigs(request)
|
||||
configs = {}
|
||||
for node_id, mapped_config in response.configs.items():
|
||||
configs[node_id] = wrappers.ConfigOption.from_dict(mapped_config.config)
|
||||
return configs
|
||||
|
||||
def get_mobility_config(
|
||||
self, session_id: int, node_id: int
|
||||
) -> Dict[str, wrappers.ConfigOption]:
|
||||
|
|
|
@ -59,8 +59,6 @@ from core.api.grpc.grpcutils import get_config_options, get_links, get_net_stats
|
|||
from core.api.grpc.mobility_pb2 import (
|
||||
GetMobilityConfigRequest,
|
||||
GetMobilityConfigResponse,
|
||||
GetMobilityConfigsRequest,
|
||||
GetMobilityConfigsResponse,
|
||||
MobilityAction,
|
||||
MobilityActionRequest,
|
||||
MobilityActionResponse,
|
||||
|
@ -901,22 +899,6 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
session.broadcast_link(link_data)
|
||||
return core_pb2.DeleteLinkResponse(result=True)
|
||||
|
||||
def GetMobilityConfigs(
|
||||
self, request: GetMobilityConfigsRequest, context: ServicerContext
|
||||
) -> GetMobilityConfigsResponse:
|
||||
"""
|
||||
Retrieve all mobility configurations from a session
|
||||
|
||||
:param request:
|
||||
get-mobility-configurations request
|
||||
:param context: context object
|
||||
:return: get-mobility-configurations response that has a list of configurations
|
||||
"""
|
||||
logger.debug("get mobility configs: %s", request)
|
||||
session = self.get_session(request.session_id, context)
|
||||
configs = grpcutils.get_mobility_configs(session)
|
||||
return GetMobilityConfigsResponse(configs=configs)
|
||||
|
||||
def GetMobilityConfig(
|
||||
self, request: GetMobilityConfigRequest, context: ServicerContext
|
||||
) -> GetMobilityConfigResponse:
|
||||
|
|
|
@ -65,8 +65,6 @@ service CoreApi {
|
|||
}
|
||||
|
||||
// mobility rpc
|
||||
rpc GetMobilityConfigs (mobility.GetMobilityConfigsRequest) returns (mobility.GetMobilityConfigsResponse) {
|
||||
}
|
||||
rpc GetMobilityConfig (mobility.GetMobilityConfigRequest) returns (mobility.GetMobilityConfigResponse) {
|
||||
}
|
||||
rpc SetMobilityConfig (mobility.SetMobilityConfigRequest) returns (mobility.SetMobilityConfigResponse) {
|
||||
|
@ -75,10 +73,6 @@ service CoreApi {
|
|||
}
|
||||
|
||||
// service rpc
|
||||
rpc GetServices (services.GetServicesRequest) returns (services.GetServicesResponse) {
|
||||
}
|
||||
rpc GetServiceDefaults (services.GetServiceDefaultsRequest) returns (services.GetServiceDefaultsResponse) {
|
||||
}
|
||||
rpc SetServiceDefaults (services.SetServiceDefaultsRequest) returns (services.SetServiceDefaultsResponse) {
|
||||
}
|
||||
rpc GetNodeServiceConfigs (services.GetNodeServiceConfigsRequest) returns (services.GetNodeServiceConfigsResponse) {
|
||||
|
@ -95,10 +89,6 @@ service CoreApi {
|
|||
}
|
||||
|
||||
// config services
|
||||
rpc GetConfigServices (configservices.GetConfigServicesRequest) returns (configservices.GetConfigServicesResponse) {
|
||||
}
|
||||
rpc GetConfigServiceDefaults (configservices.GetConfigServiceDefaultsRequest) returns (configservices.GetConfigServiceDefaultsResponse) {
|
||||
}
|
||||
rpc GetNodeConfigServiceConfigs (configservices.GetNodeConfigServiceConfigsRequest) returns (configservices.GetNodeConfigServiceConfigsResponse) {
|
||||
}
|
||||
rpc GetNodeConfigService (configservices.GetNodeConfigServiceRequest) returns (configservices.GetNodeConfigServiceResponse) {
|
||||
|
@ -121,8 +111,6 @@ service CoreApi {
|
|||
}
|
||||
rpc SetEmaneConfig (emane.SetEmaneConfigRequest) returns (emane.SetEmaneConfigResponse) {
|
||||
}
|
||||
rpc GetEmaneModels (emane.GetEmaneModelsRequest) returns (emane.GetEmaneModelsResponse) {
|
||||
}
|
||||
rpc GetEmaneModelConfig (emane.GetEmaneModelConfigRequest) returns (emane.GetEmaneModelConfigResponse) {
|
||||
}
|
||||
rpc SetEmaneModelConfig (emane.SetEmaneModelConfigRequest) returns (emane.SetEmaneModelConfigResponse) {
|
||||
|
@ -131,6 +119,8 @@ service CoreApi {
|
|||
}
|
||||
rpc EmanePathlosses (stream emane.EmanePathlossesRequest) returns (emane.EmanePathlossesResponse) {
|
||||
}
|
||||
rpc EmaneLink (emane.EmaneLinkRequest) returns (emane.EmaneLinkResponse) {
|
||||
}
|
||||
|
||||
// xml rpc
|
||||
rpc SaveXml (SaveXmlRequest) returns (SaveXmlResponse) {
|
||||
|
@ -141,10 +131,20 @@ service CoreApi {
|
|||
// utilities
|
||||
rpc GetInterfaces (GetInterfacesRequest) returns (GetInterfacesResponse) {
|
||||
}
|
||||
rpc EmaneLink (emane.EmaneLinkRequest) returns (emane.EmaneLinkResponse) {
|
||||
}
|
||||
rpc ExecuteScript (ExecuteScriptRequest) returns (ExecuteScriptResponse) {
|
||||
}
|
||||
|
||||
// globals
|
||||
rpc GetEmaneModels (emane.GetEmaneModelsRequest) returns (emane.GetEmaneModelsResponse) {
|
||||
}
|
||||
rpc GetConfigServices (configservices.GetConfigServicesRequest) returns (configservices.GetConfigServicesResponse) {
|
||||
}
|
||||
rpc GetConfigServiceDefaults (configservices.GetConfigServiceDefaultsRequest) returns (configservices.GetConfigServiceDefaultsResponse) {
|
||||
}
|
||||
rpc GetServices (services.GetServicesRequest) returns (services.GetServicesResponse) {
|
||||
}
|
||||
rpc GetServiceDefaults (services.GetServiceDefaultsRequest) returns (services.GetServiceDefaultsResponse) {
|
||||
}
|
||||
}
|
||||
|
||||
// rpc request/response messages
|
||||
|
|
|
@ -17,14 +17,6 @@ message MobilityConfig {
|
|||
map<string, string> config = 2;
|
||||
}
|
||||
|
||||
message GetMobilityConfigsRequest {
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message GetMobilityConfigsResponse {
|
||||
map<int32, common.MappedConfig> configs = 1;
|
||||
}
|
||||
|
||||
message GetMobilityConfigRequest {
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
|
|
|
@ -624,23 +624,6 @@ class TestGrpcw:
|
|||
# then
|
||||
assert len(models) > 0
|
||||
|
||||
def test_get_mobility_configs(self, grpc_server: CoreGrpcServer):
|
||||
# given
|
||||
client = CoreGrpcClient()
|
||||
session = grpc_server.coreemu.create_session()
|
||||
wlan = session.add_node(WlanNode)
|
||||
session.mobility.set_model_config(wlan.id, Ns2ScriptedMobility.name, {})
|
||||
|
||||
# then
|
||||
with client.context_connect():
|
||||
configs = client.get_mobility_configs(session.id)
|
||||
|
||||
# then
|
||||
assert len(configs) > 0
|
||||
assert wlan.id in configs
|
||||
config = configs[wlan.id]
|
||||
assert len(config) > 0
|
||||
|
||||
def test_get_mobility_config(self, grpc_server: CoreGrpcServer):
|
||||
# given
|
||||
client = CoreGrpcClient()
|
||||
|
|
Loading…
Reference in a new issue