grpc: added session options to session wrapped object, updated get_session and start_session to utilize this change, updated pygui to leverage as well

This commit is contained in:
Blake Harnden 2021-04-22 16:12:33 -07:00
parent 597834a993
commit 7938379e6d
7 changed files with 42 additions and 21 deletions

View file

@ -314,6 +314,7 @@ class CoreGrpcClient:
config=service_config.config,
)
config_service_configs.append(config_service_config)
options = {k: v.value for k, v in session.options.items()}
request = core_pb2.StartSessionRequest(
session_id=session.id,
nodes=nodes,
@ -328,6 +329,7 @@ class CoreGrpcClient:
service_file_configs=service_file_configs,
asymmetric_links=asymmetric_links,
config_service_configs=config_service_configs,
options=options,
)
response = self.stub.StartSession(request)
return response.result, list(response.exceptions)

View file

@ -226,6 +226,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
session.directory.mkdir(exist_ok=True)
session.set_state(EventTypes.CONFIGURATION_STATE)
# session options
session.options.config_reset()
for key, value in request.options.items():
session.options.set_config(key, value)
# location
if request.HasField("location"):
grpcutils.session_location(session, request.location)
@ -571,6 +576,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
service_configs = grpcutils.get_node_service_configs(session)
config_service_configs = grpcutils.get_node_config_service_configs(session)
session_file = str(session.file_path) if session.file_path else None
options = get_config_options(session.options.get_configs(), session.options)
session_proto = core_pb2.Session(
id=session.id,
state=session.state.value,
@ -590,6 +596,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
mobility_configs=mobility_configs,
metadata=session.metadata,
file=session_file,
options=options,
)
return core_pb2.GetSessionResponse(session=session_proto)

View file

@ -753,6 +753,7 @@ class Session:
emane_config: Dict[str, ConfigOption]
metadata: Dict[str, str]
file: Path
options: Dict[str, ConfigOption]
def set_node(self, node: Node) -> None:
self.nodes[node.id] = node
@ -792,6 +793,7 @@ class Session:
node = nodes[node_id]
node.mobility_config = ConfigOption.from_dict(mapped_config.config)
file_path = Path(proto.file) if proto.file else None
options = ConfigOption.from_dict(proto.options)
return Session(
id=proto.id,
state=SessionState(proto.state),
@ -806,6 +808,7 @@ class Session:
emane_config=ConfigOption.from_dict(proto.emane_config),
metadata=dict(proto.metadata),
file=file_path,
options=options,
)