grpc: removed get/set session options, now accomplished through get_session and start_session

This commit is contained in:
Blake Harnden 2021-04-24 21:37:00 -07:00
parent 3d356272f1
commit d4c008e564
4 changed files with 4 additions and 81 deletions

View file

@ -407,33 +407,6 @@ class CoreGrpcClient:
response = self.stub.GetSession(request)
return wrappers.Session.from_proto(response.session)
def get_session_options(self, session_id: int) -> Dict[str, wrappers.ConfigOption]:
"""
Retrieve session options as a dict with id mapping.
:param session_id: id of session
:return: session configuration options
:raises grpc.RpcError: when session doesn't exist
"""
request = core_pb2.GetSessionOptionsRequest(session_id=session_id)
response = self.stub.GetSessionOptions(request)
return wrappers.ConfigOption.from_dict(response.config)
def set_session_options(self, session_id: int, config: Dict[str, str]) -> bool:
"""
Set options for a session.
:param session_id: id of session
:param config: configuration values to set
:return: True for success, False otherwise
:raises grpc.RpcError: when session doesn't exist
"""
request = core_pb2.SetSessionOptionsRequest(
session_id=session_id, config=config
)
response = self.stub.SetSessionOptions(request)
return response.result
def get_session_metadata(self, session_id: int) -> Dict[str, str]:
"""
Retrieve session metadata as a dict with id mapping.

View file

@ -667,11 +667,11 @@ class Geo:
@dataclass
class Node:
id: int
name: str
type: NodeType
id: int = None
name: str = None
type: NodeType = NodeType.DEFAULT
model: str = None
position: Position = None
position: Position = Position(x=0, y=0)
services: Set[str] = field(default_factory=set)
config_services: Set[str] = field(default_factory=set)
emane: str = None

View file

@ -25,10 +25,6 @@ service CoreApi {
}
rpc CheckSession (CheckSessionRequest) returns (CheckSessionResponse) {
}
rpc GetSessionOptions (GetSessionOptionsRequest) returns (GetSessionOptionsResponse) {
}
rpc SetSessionOptions (SetSessionOptionsRequest) returns (SetSessionOptionsResponse) {
}
rpc SetSessionMetadata (SetSessionMetadataRequest) returns (SetSessionMetadataResponse) {
}
rpc GetSessionMetadata (GetSessionMetadataRequest) returns (GetSessionMetadataResponse) {
@ -244,23 +240,6 @@ message GetSessionResponse {
Session session = 1;
}
message GetSessionOptionsRequest {
int32 session_id = 1;
}
message GetSessionOptionsResponse {
map<string, common.ConfigOption> config = 2;
}
message SetSessionOptionsRequest {
int32 session_id = 1;
map<string, string> config = 2;
}
message SetSessionOptionsResponse {
bool result = 1;
}
message SetSessionMetadataRequest {
int32 session_id = 1;
map<string, string> config = 2;

View file

@ -274,18 +274,6 @@ class TestGrpcw:
assert len(sessions) == 1
assert found_session is not None
def test_get_session_options(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
# then
with client.context_connect():
config = client.get_session_options(session.id)
# then
assert len(config) > 0
def test_get_session_location(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
@ -331,23 +319,6 @@ class TestGrpcw:
assert session.location.refscale == scale
assert session.location.refgeo == lat_lon_alt
def test_set_session_options(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
# then
option = "enablerj45"
value = "1"
with client.context_connect():
result = client.set_session_options(session.id, {option: value})
# then
assert result is True
assert session.options.get_config(option) == value
config = session.options.get_configs()
assert len(config) > 0
def test_set_session_metadata(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()