added wlan configs to grpc.StartSession
This commit is contained in:
parent
de936ea315
commit
adbab066c9
3 changed files with 36 additions and 7 deletions
|
@ -148,7 +148,16 @@ class CoreGrpcClient:
|
|||
self.stub = None
|
||||
self.channel = None
|
||||
|
||||
def start_session(self, session_id, nodes, links, location=None, hooks=None):
|
||||
def start_session(
|
||||
self,
|
||||
session_id,
|
||||
nodes,
|
||||
links,
|
||||
location=None,
|
||||
hooks=None,
|
||||
emane_config=None,
|
||||
wlan_configs=None,
|
||||
):
|
||||
"""
|
||||
Start a session.
|
||||
|
||||
|
@ -157,6 +166,8 @@ class CoreGrpcClient:
|
|||
:param list links: list of links to create
|
||||
:param core_pb2.SessionLocation location: location to set
|
||||
:param list[core_pb2.Hook] hooks: session hooks to set
|
||||
:param dict emane_config: emane configuration to set
|
||||
:param list wlan_configs: wlan configurations to set
|
||||
:return:
|
||||
"""
|
||||
request = core_pb2.StartSessionRequest(
|
||||
|
@ -165,6 +176,8 @@ class CoreGrpcClient:
|
|||
links=links,
|
||||
location=location,
|
||||
hooks=hooks,
|
||||
emane_config=emane_config,
|
||||
wlan_configs=wlan_configs,
|
||||
)
|
||||
return self.stub.StartSession(request)
|
||||
|
||||
|
@ -793,8 +806,9 @@ class CoreGrpcClient:
|
|||
:rtype: core_pb2.SetWlanConfigResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
wlan_config = core_pb2.WlanConfig(node_id=node_id, config=config)
|
||||
request = core_pb2.SetWlanConfigRequest(
|
||||
session_id=session_id, node_id=node_id, config=config
|
||||
session_id=session_id, wlan_config=wlan_config
|
||||
)
|
||||
return self.stub.SetWlanConfig(request)
|
||||
|
||||
|
|
|
@ -134,7 +134,15 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
grpcutils.create_nodes(session, request.nodes)
|
||||
|
||||
# emane configs
|
||||
config = session.emane.get_configs()
|
||||
config.update(request.emane_config)
|
||||
|
||||
# wlan configs
|
||||
for wlan_config in request.wlan_configs:
|
||||
session.mobility.set_model_config(
|
||||
wlan_config.node_id, BasicRangeModel.name, wlan_config.config
|
||||
)
|
||||
|
||||
# mobility configs
|
||||
|
||||
# create links
|
||||
|
@ -1218,12 +1226,13 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
"""
|
||||
logging.debug("set wlan config: %s", request)
|
||||
session = self.get_session(request.session_id, context)
|
||||
wlan_config = request.wlan_config
|
||||
session.mobility.set_model_config(
|
||||
request.node_id, BasicRangeModel.name, request.config
|
||||
wlan_config.node_id, BasicRangeModel.name, wlan_config.config
|
||||
)
|
||||
if session.state == EventTypes.RUNTIME_STATE.value:
|
||||
node = self.get_node(session, request.node_id, context)
|
||||
node.updatemodel(request.config)
|
||||
node = self.get_node(session, wlan_config.node_id, context)
|
||||
node.updatemodel(wlan_config.config)
|
||||
return core_pb2.SetWlanConfigResponse(result=True)
|
||||
|
||||
def GetEmaneConfig(self, request, context):
|
||||
|
|
|
@ -136,6 +136,8 @@ message StartSessionRequest {
|
|||
repeated Link links = 3;
|
||||
repeated Hook hooks = 4;
|
||||
SessionLocation location = 5;
|
||||
map<string, string> emane_config = 6;
|
||||
repeated WlanConfig wlan_configs = 7;
|
||||
}
|
||||
|
||||
message StartSessionResponse {
|
||||
|
@ -575,8 +577,7 @@ message GetWlanConfigResponse {
|
|||
|
||||
message SetWlanConfigRequest {
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
map<string, string> config = 3;
|
||||
WlanConfig wlan_config = 2;
|
||||
}
|
||||
|
||||
message SetWlanConfigResponse {
|
||||
|
@ -681,6 +682,11 @@ message EmaneLinkResponse {
|
|||
}
|
||||
|
||||
// data structures for messages below
|
||||
message WlanConfig {
|
||||
int32 node_id = 1;
|
||||
map<string, string> config = 2;
|
||||
}
|
||||
|
||||
message MessageType {
|
||||
enum Enum {
|
||||
NONE = 0;
|
||||
|
|
Loading…
Reference in a new issue