From e299d3dd160a6cdedb656c6345d863c4b01f619c Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Tue, 4 May 2021 15:02:23 -0700 Subject: [PATCH] grpc: removed set node service file, achieved with start session, removed get node config service configs, achieved with get session --- daemon/core/api/grpc/client.py | 36 ------------------ daemon/core/api/grpc/server.py | 38 ------------------- .../proto/core/api/grpc/configservices.proto | 8 ---- daemon/proto/core/api/grpc/core.proto | 6 +-- daemon/proto/core/api/grpc/services.proto | 9 ----- daemon/tests/test_grpcw.py | 21 ---------- 6 files changed, 1 insertion(+), 117 deletions(-) diff --git a/daemon/core/api/grpc/client.py b/daemon/core/api/grpc/client.py index a260e7e4..b0a3ec11 100644 --- a/daemon/core/api/grpc/client.py +++ b/daemon/core/api/grpc/client.py @@ -24,7 +24,6 @@ from core.api.grpc import ( from core.api.grpc.configservices_pb2 import ( GetConfigServiceDefaultsRequest, GetConfigServicesRequest, - GetNodeConfigServiceConfigsRequest, GetNodeConfigServiceRequest, GetNodeConfigServicesRequest, SetNodeConfigServiceRequest, @@ -52,7 +51,6 @@ from core.api.grpc.services_pb2 import ( GetServicesRequest, ServiceActionRequest, ServiceDefaults, - SetNodeServiceFileRequest, SetServiceDefaultsRequest, ) from core.api.grpc.wlan_pb2 import ( @@ -905,22 +903,6 @@ class CoreGrpcClient: response = self.stub.GetNodeServiceFile(request) return response.data - def set_node_service_file( - self, session_id: int, service_file_config: wrappers.ServiceFileConfig - ) -> bool: - """ - Set a service file for a node. - - :param session_id: session id - :param service_file_config: configuration to set - :return: True for success, False otherwise - :raises grpc.RpcError: when session or node doesn't exist - """ - config = service_file_config.to_proto() - request = SetNodeServiceFileRequest(session_id=session_id, config=config) - response = self.stub.SetNodeServiceFile(request) - return response.result - def service_action( self, session_id: int, @@ -1131,24 +1113,6 @@ class CoreGrpcClient: response = self.stub.GetConfigServiceDefaults(request) return wrappers.ConfigServiceDefaults.from_proto(response) - def get_node_config_service_configs( - self, session_id: int - ) -> List[wrappers.ConfigServiceConfig]: - """ - Retrieves all node config service configurations for a session. - - :param session_id: session to get config service configurations for - :return: list of node config service configs - :raises grpc.RpcError: when session doesn't exist - """ - request = GetNodeConfigServiceConfigsRequest(session_id=session_id) - response = self.stub.GetNodeConfigServiceConfigs(request) - configs = [] - for config_proto in response.configs: - config = wrappers.ConfigServiceConfig.from_proto(config_proto) - configs.append(config) - return configs - def get_node_config_service( self, session_id: int, node_id: int, name: str ) -> Dict[str, str]: diff --git a/daemon/core/api/grpc/server.py b/daemon/core/api/grpc/server.py index 2dd7e9a8..8fee64ef 100644 --- a/daemon/core/api/grpc/server.py +++ b/daemon/core/api/grpc/server.py @@ -26,8 +26,6 @@ from core.api.grpc.configservices_pb2 import ( GetConfigServiceDefaultsResponse, GetConfigServicesRequest, GetConfigServicesResponse, - GetNodeConfigServiceConfigsRequest, - GetNodeConfigServiceConfigsResponse, GetNodeConfigServiceRequest, GetNodeConfigServiceResponse, GetNodeConfigServicesRequest, @@ -78,8 +76,6 @@ from core.api.grpc.services_pb2 import ( ServiceAction, ServiceActionRequest, ServiceActionResponse, - SetNodeServiceFileRequest, - SetNodeServiceFileResponse, SetServiceDefaultsRequest, SetServiceDefaultsResponse, ) @@ -1052,25 +1048,6 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): ) return GetNodeServiceFileResponse(data=file_data.data) - def SetNodeServiceFile( - self, request: SetNodeServiceFileRequest, context: ServicerContext - ) -> SetNodeServiceFileResponse: - """ - Store the customized service file in the service config - - :param request: - set-node-service-file request - :param context: context object - :return: set-node-service-file response - """ - logger.debug("set node service file: %s", request) - session = self.get_session(request.session_id, context) - config = request.config - session.services.set_service_file( - config.node_id, config.service, config.file, config.data - ) - return SetNodeServiceFileResponse(result=True) - def ServiceAction( self, request: ServiceActionRequest, context: ServicerContext ) -> ServiceActionResponse: @@ -1427,21 +1404,6 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): templates=templates, config=config, modes=modes ) - def GetNodeConfigServiceConfigs( - self, request: GetNodeConfigServiceConfigsRequest, context: ServicerContext - ) -> GetNodeConfigServiceConfigsResponse: - """ - Get current custom templates and config for configuration services for a given - node. - - :param request: get node config service configs request - :param context: grpc context - :return: get node config service configs response - """ - session = self.get_session(request.session_id, context) - configs = grpcutils.get_node_config_service_configs(session) - return GetNodeConfigServiceConfigsResponse(configs=configs) - def GetNodeConfigServices( self, request: GetNodeConfigServicesRequest, context: ServicerContext ) -> GetNodeConfigServicesResponse: diff --git a/daemon/proto/core/api/grpc/configservices.proto b/daemon/proto/core/api/grpc/configservices.proto index f1272df8..e8d93fb0 100644 --- a/daemon/proto/core/api/grpc/configservices.proto +++ b/daemon/proto/core/api/grpc/configservices.proto @@ -57,14 +57,6 @@ message GetConfigServiceDefaultsResponse { repeated ConfigMode modes = 3; } -message GetNodeConfigServiceConfigsRequest { - int32 session_id = 1; -} - -message GetNodeConfigServiceConfigsResponse { - repeated ConfigServiceConfig configs = 1; -} - message GetNodeConfigServiceRequest { int32 session_id = 1; int32 node_id = 2; diff --git a/daemon/proto/core/api/grpc/core.proto b/daemon/proto/core/api/grpc/core.proto index 3dabbb74..b03a101c 100644 --- a/daemon/proto/core/api/grpc/core.proto +++ b/daemon/proto/core/api/grpc/core.proto @@ -79,13 +79,11 @@ service CoreApi { } rpc GetNodeServiceFile (services.GetNodeServiceFileRequest) returns (services.GetNodeServiceFileResponse) { } - rpc SetNodeServiceFile (services.SetNodeServiceFileRequest) returns (services.SetNodeServiceFileResponse) { - } rpc ServiceAction (services.ServiceActionRequest) returns (services.ServiceActionResponse) { } // config services - rpc GetNodeConfigServiceConfigs (configservices.GetNodeConfigServiceConfigsRequest) returns (configservices.GetNodeConfigServiceConfigsResponse) { + rpc GetConfigServiceDefaults (configservices.GetConfigServiceDefaultsRequest) returns (configservices.GetConfigServiceDefaultsResponse) { } rpc GetNodeConfigService (configservices.GetNodeConfigServiceRequest) returns (configservices.GetNodeConfigServiceResponse) { } @@ -135,8 +133,6 @@ service CoreApi { } 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) { diff --git a/daemon/proto/core/api/grpc/services.proto b/daemon/proto/core/api/grpc/services.proto index f6766a75..602131a3 100644 --- a/daemon/proto/core/api/grpc/services.proto +++ b/daemon/proto/core/api/grpc/services.proto @@ -112,15 +112,6 @@ message GetNodeServiceFileResponse { string data = 1; } -message SetNodeServiceFileRequest { - int32 session_id = 1; - ServiceFileConfig config = 2; -} - -message SetNodeServiceFileResponse { - bool result = 1; -} - message ServiceActionRequest { int32 session_id = 1; int32 node_id = 2; diff --git a/daemon/tests/test_grpcw.py b/daemon/tests/test_grpcw.py index 7719f021..10d9022c 100644 --- a/daemon/tests/test_grpcw.py +++ b/daemon/tests/test_grpcw.py @@ -27,7 +27,6 @@ from core.api.grpc.wrappers import ( NodeType, Position, ServiceAction, - ServiceFileConfig, ServiceValidationMode, SessionLocation, SessionState, @@ -737,26 +736,6 @@ class TestGrpcw: # then assert data is not None - def test_set_node_service_file(self, grpc_server: CoreGrpcServer): - # given - client = CoreGrpcClient() - session = grpc_server.coreemu.create_session() - node = session.add_node(CoreNode) - config = ServiceFileConfig( - node.id, "DefaultRoute", "defaultroute.sh", "echo hello" - ) - - # then - with client.context_connect(): - result = client.set_node_service_file(session.id, config) - - # then - assert result is True - service_file = session.services.get_service_file( - node, config.service, config.file - ) - assert service_file.data == config.data - def test_service_action(self, grpc_server: CoreGrpcServer): # given client = CoreGrpcClient()