upd utils

This commit is contained in:
ge 2023-07-29 15:10:30 +03:00
parent 5dd15cf01d
commit 3ac1cf5404
2 changed files with 11 additions and 4 deletions

View File

@ -8,7 +8,7 @@ Usage: na-vmctl [options] status <machine>
Options: Options:
-c, --config <file> Config file [default: /etc/node-agent/config.yaml] -c, --config <file> Config file [default: /etc/node-agent/config.yaml]
-l, --loglvl <lvl> Logging level [default: INFO] -l, --loglvl <lvl> Logging level
-f, --force Force action. On shutdown calls graceful destroy() -f, --force Force action. On shutdown calls graceful destroy()
-9, --sigkill Send SIGKILL to QEMU process. Not affects without --force -9, --sigkill Send SIGKILL to QEMU process. Not affects without --force
""" """
@ -39,9 +39,12 @@ class Color:
def cli(): def cli():
args = docopt(__doc__) args = docopt(__doc__)
config = pathlib.Path(args['--config']) or None config = pathlib.Path(args['--config']) or None
loglvl = args['--loglvl'].upper() loglvl = None
machine = args['<machine>'] machine = args['<machine>']
if args['--loglvl']:
loglvl = args['--loglvl'].upper()
if loglvl in levels: if loglvl in levels:
logging.basicConfig(level=levels[loglvl]) logging.basicConfig(level=levels[loglvl])

View File

@ -5,7 +5,7 @@ Usage: na-vmexec [options] <machine> <command>
Options: Options:
-c, --config <file> Config file [default: /etc/node-agent/config.yaml] -c, --config <file> Config file [default: /etc/node-agent/config.yaml]
-l, --loglvl <lvl> Logging level [default: INFO] -l, --loglvl <lvl> Logging level
-s, --shell <shell> Guest shell [default: /bin/sh] -s, --shell <shell> Guest shell [default: /bin/sh]
-t, --timeout <sec> QEMU timeout in seconds to stop polling command status [default: 60] -t, --timeout <sec> QEMU timeout in seconds to stop polling command status [default: 60]
""" """
@ -35,9 +35,12 @@ class Color:
def cli(): def cli():
args = docopt(__doc__) args = docopt(__doc__)
config = pathlib.Path(args['--config']) or None config = pathlib.Path(args['--config']) or None
loglvl = args['--loglvl'].upper() loglvl = None
machine = args['<machine>'] machine = args['<machine>']
if args['--loglvl']:
loglvl = args['--loglvl'].upper()
if loglvl in levels: if loglvl in levels:
logging.basicConfig(level=levels[loglvl]) logging.basicConfig(level=levels[loglvl])
@ -91,6 +94,7 @@ def cli():
print(Color.RED + stderr.strip() + Color.NONE, file=sys.stderr) print(Color.RED + stderr.strip() + Color.NONE, file=sys.stderr)
if stdout: if stdout:
print(Color.GREEN + stdout.strip() + Color.NONE, file=sys.stdout) print(Color.GREEN + stdout.strip() + Color.NONE, file=sys.stdout)
sys.exit(exitcode)
if __name__ == '__main__': if __name__ == '__main__':
cli() cli()