From ebafa228ff625c79573ea2bbb991acfb0403795f Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Fri, 14 Feb 2020 13:40:10 -0800 Subject: [PATCH] added files/directories to grpc set_node_service --- daemon/core/api/grpc/client.py | 12 +++++++++--- daemon/core/api/grpc/grpcutils.py | 13 ++++++++++--- daemon/core/gui/coreclient.py | 13 +++++++++---- daemon/core/gui/dialogs/serviceconfig.py | 6 +++--- daemon/proto/core/api/grpc/core.proto | 2 ++ daemon/tests/test_grpc.py | 2 +- 6 files changed, 34 insertions(+), 14 deletions(-) diff --git a/daemon/core/api/grpc/client.py b/daemon/core/api/grpc/client.py index 0f939921..9c6b15c6 100644 --- a/daemon/core/api/grpc/client.py +++ b/daemon/core/api/grpc/client.py @@ -834,9 +834,11 @@ class CoreGrpcClient: session_id: int, node_id: int, service: str, - startup: List[str], - validate: List[str], - shutdown: List[str], + files: List[str] = None, + directories: List[str] = None, + startup: List[str] = None, + validate: List[str] = None, + shutdown: List[str] = None, ) -> core_pb2.SetNodeServiceResponse: """ Set service data for a node. @@ -844,6 +846,8 @@ class CoreGrpcClient: :param session_id: session id :param node_id: node id :param service: service name + :param files: service files + :param directories: service directories :param startup: startup commands :param validate: validation commands :param shutdown: shutdown commands @@ -853,6 +857,8 @@ class CoreGrpcClient: config = core_pb2.ServiceConfig( node_id=node_id, service=service, + files=files, + directories=directories, startup=startup, validate=validate, shutdown=shutdown, diff --git a/daemon/core/api/grpc/grpcutils.py b/daemon/core/api/grpc/grpcutils.py index c0ba3ceb..b9cf33ef 100644 --- a/daemon/core/api/grpc/grpcutils.py +++ b/daemon/core/api/grpc/grpcutils.py @@ -376,9 +376,16 @@ def service_configuration(session: Session, config: core_pb2.ServiceConfig) -> N """ session.services.set_service(config.node_id, config.service) service = session.services.get_service(config.node_id, config.service) - service.startup = tuple(config.startup) - service.validate = tuple(config.validate) - service.shutdown = tuple(config.shutdown) + if config.files: + service.files = tuple(config.files) + if config.directories: + service.directories = tuple(config.directories) + if config.startup: + service.startup = tuple(config.startup) + if config.validate: + service.validate = tuple(config.validate) + if config.shutdown: + service.shutdown = tuple(config.shutdown) def get_service_configuration(service: Type[CoreService]) -> core_pb2.NodeServiceData: diff --git a/daemon/core/gui/coreclient.py b/daemon/core/gui/coreclient.py index f99147be..7fa31ee3 100644 --- a/daemon/core/gui/coreclient.py +++ b/daemon/core/gui/coreclient.py @@ -625,7 +625,12 @@ class CoreClient: shutdowns: List[str], ) -> core_pb2.NodeServiceData: response = self.client.set_node_service( - self.session_id, node_id, service_name, startups, validations, shutdowns + self.session_id, + node_id, + service_name, + startup=startups, + validate=validations, + shutdown=shutdowns, ) logging.info( "Set %s service for node(%s), Startup: %s, Validation: %s, Shutdown: %s, Result: %s", @@ -713,9 +718,9 @@ class CoreClient: self.session_id, config_proto.node_id, config_proto.service, - config_proto.startup, - config_proto.validate, - config_proto.shutdown, + startup=config_proto.startup, + validate=config_proto.validate, + shutdown=config_proto.shutdown, ) for config_proto in self.get_service_file_configs_proto(): self.client.set_node_service_file( diff --git a/daemon/core/gui/dialogs/serviceconfig.py b/daemon/core/gui/dialogs/serviceconfig.py index e8c13019..b528e32a 100644 --- a/daemon/core/gui/dialogs/serviceconfig.py +++ b/daemon/core/gui/dialogs/serviceconfig.py @@ -426,9 +426,9 @@ class ServiceConfigDialog(Dialog): config = self.core.set_node_service( self.node_id, self.service_name, - startup_commands, - validate_commands, - shutdown_commands, + startups=startup_commands, + validations=validate_commands, + shutdowns=shutdown_commands, ) if self.node_id not in self.service_configs: self.service_configs[self.node_id] = {} diff --git a/daemon/proto/core/api/grpc/core.proto b/daemon/proto/core/api/grpc/core.proto index 975a0a87..fbf0367a 100644 --- a/daemon/proto/core/api/grpc/core.proto +++ b/daemon/proto/core/api/grpc/core.proto @@ -771,6 +771,8 @@ message ServiceConfig { repeated string startup = 3; repeated string validate = 4; repeated string shutdown = 5; + repeated string files = 6; + repeated string directories = 7; } message ServiceFileConfig { diff --git a/daemon/tests/test_grpc.py b/daemon/tests/test_grpc.py index 2e2685ac..d26c46e4 100644 --- a/daemon/tests/test_grpc.py +++ b/daemon/tests/test_grpc.py @@ -935,7 +935,7 @@ class TestGrpc: # then with client.context_connect(): response = client.set_node_service( - session.id, node.id, service_name, [], validate, [] + session.id, node.id, service_name, validate=validate ) # then