From 3ac1cf5404cc5e2d85d140196c3dec2e7c50b4bb Mon Sep 17 00:00:00 2001 From: ge Date: Sat, 29 Jul 2023 15:10:30 +0300 Subject: [PATCH] upd utils --- node_agent/utils/vmctl.py | 7 +++++-- node_agent/utils/vmexec.py | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/node_agent/utils/vmctl.py b/node_agent/utils/vmctl.py index 2d20bae..b3e8682 100644 --- a/node_agent/utils/vmctl.py +++ b/node_agent/utils/vmctl.py @@ -8,7 +8,7 @@ Usage: na-vmctl [options] status Options: -c, --config Config file [default: /etc/node-agent/config.yaml] - -l, --loglvl Logging level [default: INFO] + -l, --loglvl Logging level -f, --force Force action. On shutdown calls graceful destroy() -9, --sigkill Send SIGKILL to QEMU process. Not affects without --force """ @@ -39,9 +39,12 @@ class Color: def cli(): args = docopt(__doc__) config = pathlib.Path(args['--config']) or None - loglvl = args['--loglvl'].upper() + loglvl = None machine = args[''] + if args['--loglvl']: + loglvl = args['--loglvl'].upper() + if loglvl in levels: logging.basicConfig(level=levels[loglvl]) diff --git a/node_agent/utils/vmexec.py b/node_agent/utils/vmexec.py index 0c217a4..f8b4e1e 100644 --- a/node_agent/utils/vmexec.py +++ b/node_agent/utils/vmexec.py @@ -5,7 +5,7 @@ Usage: na-vmexec [options] Options: -c, --config Config file [default: /etc/node-agent/config.yaml] - -l, --loglvl Logging level [default: INFO] + -l, --loglvl Logging level -s, --shell Guest shell [default: /bin/sh] -t, --timeout QEMU timeout in seconds to stop polling command status [default: 60] """ @@ -35,9 +35,12 @@ class Color: def cli(): args = docopt(__doc__) config = pathlib.Path(args['--config']) or None - loglvl = args['--loglvl'].upper() + loglvl = None machine = args[''] + if args['--loglvl']: + loglvl = args['--loglvl'].upper() + if loglvl in levels: logging.basicConfig(level=levels[loglvl]) @@ -91,6 +94,7 @@ def cli(): print(Color.RED + stderr.strip() + Color.NONE, file=sys.stderr) if stdout: print(Color.GREEN + stdout.strip() + Color.NONE, file=sys.stdout) + sys.exit(exitcode) if __name__ == '__main__': cli()