From: Aleš Mrázek Date: Thu, 2 Mar 2023 15:23:54 +0000 (+0100) Subject: manager: kresctl: print nothing on success X-Git-Tag: v6.0.0a1~4^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e3b50f01ea91e89c890a15b3e4116f91b7268bb;p=thirdparty%2Fknot-resolver.git manager: kresctl: print nothing on success --- diff --git a/doc/manager-client.rst b/doc/manager-client.rst index d5c8157c4..1d202d8b6 100644 --- a/doc/manager-client.rst +++ b/doc/manager-client.rst @@ -143,7 +143,7 @@ Only one of these arguments can be selected during the execution of a single ``k .. option:: -l, --live - Get current configuration JSON-schema directly from the running resolver. + Get configuration JSON-schema from the running resolver. Requires connection to the management API. .. option:: diff --git a/manager/knot_resolver_manager/cli/cmd/config.py b/manager/knot_resolver_manager/cli/cmd/config.py index 80a90dd4f..33e7ea32c 100644 --- a/manager/knot_resolver_manager/cli/cmd/config.py +++ b/manager/knot_resolver_manager/cli/cmd/config.py @@ -244,8 +244,6 @@ class ConfigCommand(Command): print(response) sys.exit(1) - print(f"status: {response.status}") - if self.operation == Operations.GET and self.file: with open(self.file, "w") as f: f.write(reformat(response.body, self.format)) diff --git a/manager/knot_resolver_manager/cli/cmd/reload.py b/manager/knot_resolver_manager/cli/cmd/reload.py index 0ed903c0f..5818a54c1 100644 --- a/manager/knot_resolver_manager/cli/cmd/reload.py +++ b/manager/knot_resolver_manager/cli/cmd/reload.py @@ -29,9 +29,8 @@ class ReloadCommand(Command): return {} def run(self, args: CommandArgs) -> None: - url = f"{args.socket}/reload" - response = request("POST", url) - print(response) + response = request("POST", f"{args.socket}/reload") if response.status != 200: + print(response) sys.exit(1) diff --git a/manager/knot_resolver_manager/cli/cmd/schema.py b/manager/knot_resolver_manager/cli/cmd/schema.py index 9b40e8f7b..0d8a03242 100644 --- a/manager/knot_resolver_manager/cli/cmd/schema.py +++ b/manager/knot_resolver_manager/cli/cmd/schema.py @@ -25,7 +25,7 @@ class SchemaCommand(Command): schema.add_argument( "-l", "--live", - help="Get current configuration JSON-schema directly from the running resolver. Requires connection to the management API.", + help="Get configuration JSON-schema from the running resolver. Requires connection to the management API.", action="store_true", default=False, ) @@ -41,11 +41,10 @@ class SchemaCommand(Command): def run(self, args: CommandArgs) -> None: if self.live: response = request("GET", f"{args.socket}/schema") - if response.status == 200: - schema = response.body - else: + if response.status != 200: print(response) sys.exit(1) + schema = response.body else: schema = json.dumps(KresConfig.json_schema(), indent=4) diff --git a/manager/knot_resolver_manager/cli/cmd/stop.py b/manager/knot_resolver_manager/cli/cmd/stop.py index 471927f63..e792dec33 100644 --- a/manager/knot_resolver_manager/cli/cmd/stop.py +++ b/manager/knot_resolver_manager/cli/cmd/stop.py @@ -11,18 +11,6 @@ class StopCommand(Command): def __init__(self, namespace: argparse.Namespace) -> None: super().__init__(namespace) - def run(self, args: CommandArgs) -> None: - url = f"{args.socket}/stop" - response = request("POST", url) - print(response) - - if response.status != 200: - sys.exit(1) - - @staticmethod - def completion(args: List[str], parser: argparse.ArgumentParser) -> CompWords: - return {} - @staticmethod def register_args_subparser( subparser: "argparse._SubParsersAction[argparse.ArgumentParser]", @@ -31,3 +19,14 @@ class StopCommand(Command): "stop", help="Tells the resolver to shutdown everthing. No process will run after this command." ) return stop, StopCommand + + def run(self, args: CommandArgs) -> None: + response = request("POST", f"{args.socket}/stop") + + if response.status != 200: + print(response) + sys.exit(1) + + @staticmethod + def completion(args: List[str], parser: argparse.ArgumentParser) -> CompWords: + return {} diff --git a/manager/knot_resolver_manager/cli/cmd/validate.py b/manager/knot_resolver_manager/cli/cmd/validate.py index a93e5a9d7..f2bd4c778 100644 --- a/manager/knot_resolver_manager/cli/cmd/validate.py +++ b/manager/knot_resolver_manager/cli/cmd/validate.py @@ -39,11 +39,10 @@ class ValidateCommand(Command): with open(self.input_file, "r") as f: data = f.read() else: - data = input("Type new configuration: ") + data = input("Type configuration to validate: ") try: KresConfig(try_to_parse(data)) - print("config is valid") except (DataParsingError, DataValidationError) as e: print(e) sys.exit(1)