From c574ace9a001d0996c9fd7994a51e81e49353f91 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Tue, 4 May 2021 14:40:17 -0700 Subject: [PATCH] grpc: removed get node service configs, achieved with get session --- daemon/core/api/grpc/client.py | 19 ------------------- daemon/core/api/grpc/server.py | 18 ------------------ daemon/proto/core/api/grpc/core.proto | 2 -- daemon/proto/core/api/grpc/services.proto | 8 -------- daemon/tests/test_grpcw.py | 18 ------------------ 5 files changed, 65 deletions(-) diff --git a/daemon/core/api/grpc/client.py b/daemon/core/api/grpc/client.py index 278e8d4a..80f3fdd4 100644 --- a/daemon/core/api/grpc/client.py +++ b/daemon/core/api/grpc/client.py @@ -46,7 +46,6 @@ from core.api.grpc.mobility_pb2 import ( SetMobilityConfigRequest, ) from core.api.grpc.services_pb2 import ( - GetNodeServiceConfigsRequest, GetNodeServiceFileRequest, GetNodeServiceRequest, GetServiceDefaultsRequest, @@ -870,24 +869,6 @@ class CoreGrpcClient: response = self.stub.SetServiceDefaults(request) return response.result - def get_node_service_configs( - self, session_id: int - ) -> List[wrappers.NodeServiceConfig]: - """ - Get service data for a node. - - :param session_id: session id - :return: list of node service data - :raises grpc.RpcError: when session doesn't exist - """ - request = GetNodeServiceConfigsRequest(session_id=session_id) - response = self.stub.GetNodeServiceConfigs(request) - node_services = [] - for config in response.configs: - node_service = wrappers.NodeServiceConfig.from_proto(config) - node_services.append(node_service) - return node_services - def get_node_service( self, session_id: int, node_id: int, service: str ) -> wrappers.NodeServiceData: diff --git a/daemon/core/api/grpc/server.py b/daemon/core/api/grpc/server.py index 661d9e59..4f06c4dc 100644 --- a/daemon/core/api/grpc/server.py +++ b/daemon/core/api/grpc/server.py @@ -66,8 +66,6 @@ from core.api.grpc.mobility_pb2 import ( SetMobilityConfigResponse, ) from core.api.grpc.services_pb2 import ( - GetNodeServiceConfigsRequest, - GetNodeServiceConfigsResponse, GetNodeServiceFileRequest, GetNodeServiceFileResponse, GetNodeServiceRequest, @@ -1018,22 +1016,6 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): ] = service_defaults.services return SetServiceDefaultsResponse(result=True) - def GetNodeServiceConfigs( - self, request: GetNodeServiceConfigsRequest, context: ServicerContext - ) -> GetNodeServiceConfigsResponse: - """ - Retrieve all node service configurations. - - :param request: - get-node-service request - :param context: context object - :return: all node service configs response - """ - logger.debug("get node service configs: %s", request) - session = self.get_session(request.session_id, context) - configs = grpcutils.get_node_service_configs(session) - return GetNodeServiceConfigsResponse(configs=configs) - def GetNodeService( self, request: GetNodeServiceRequest, context: ServicerContext ) -> GetNodeServiceResponse: diff --git a/daemon/proto/core/api/grpc/core.proto b/daemon/proto/core/api/grpc/core.proto index c7b2ba6e..2c429e80 100644 --- a/daemon/proto/core/api/grpc/core.proto +++ b/daemon/proto/core/api/grpc/core.proto @@ -75,8 +75,6 @@ service CoreApi { // service rpc rpc SetServiceDefaults (services.SetServiceDefaultsRequest) returns (services.SetServiceDefaultsResponse) { } - rpc GetNodeServiceConfigs (services.GetNodeServiceConfigsRequest) returns (services.GetNodeServiceConfigsResponse) { - } rpc GetNodeService (services.GetNodeServiceRequest) returns (services.GetNodeServiceResponse) { } rpc GetNodeServiceFile (services.GetNodeServiceFileRequest) returns (services.GetNodeServiceFileResponse) { diff --git a/daemon/proto/core/api/grpc/services.proto b/daemon/proto/core/api/grpc/services.proto index cf6d9cbf..f7eb9a3a 100644 --- a/daemon/proto/core/api/grpc/services.proto +++ b/daemon/proto/core/api/grpc/services.proto @@ -91,14 +91,6 @@ message SetServiceDefaultsResponse { bool result = 1; } -message GetNodeServiceConfigsRequest { - int32 session_id = 1; -} - -message GetNodeServiceConfigsResponse { - repeated NodeServiceConfig configs = 1; -} - message GetNodeServiceRequest { int32 session_id = 1; int32 node_id = 2; diff --git a/daemon/tests/test_grpcw.py b/daemon/tests/test_grpcw.py index d3da8742..cfe6dfbd 100644 --- a/daemon/tests/test_grpcw.py +++ b/daemon/tests/test_grpcw.py @@ -710,24 +710,6 @@ class TestGrpcw: assert result is True assert session.services.default_services[node_type] == services - def test_get_node_service_configs(self, grpc_server: CoreGrpcServer): - # given - client = CoreGrpcClient() - session = grpc_server.coreemu.create_session() - node = session.add_node(CoreNode) - service_name = "DefaultRoute" - session.services.set_service(node.id, service_name) - - # then - with client.context_connect(): - services = client.get_node_service_configs(session.id) - - # then - assert len(services) == 1 - service_config = services[0] - assert service_config.node_id == node.id - assert service_config.service == service_name - def test_get_node_service(self, grpc_server: CoreGrpcServer): # given client = CoreGrpcClient()