From c85493b547d63404ec4c3280b2404b13b92892d0 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Tue, 21 Aug 2018 10:31:47 +0200 Subject: examples: add verbose option to ncclient scripts Change-Id: I42f1efed55072ec9885dda2a9dcd3c8d85980d8f Signed-off-by: Marek Gradzki --- examples/ncclient/copy_config.py | 10 ++++++++-- examples/ncclient/edit_config.py | 10 ++++++++-- examples/ncclient/get.py | 10 ++++++++-- examples/ncclient/get_config.py | 10 ++++++++-- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/examples/ncclient/copy_config.py b/examples/ncclient/copy_config.py index e2e95c6c2..227acb128 100755 --- a/examples/ncclient/copy_config.py +++ b/examples/ncclient/copy_config.py @@ -31,9 +31,15 @@ def _copy_config(config_filename, host='localhost', port=2831, username='admin', if __name__ == '__main__': - logger = logging.getLogger("hc2vpp.examples.copy_config") - logging.basicConfig(level=logging.WARNING) argparser = argparse.ArgumentParser(description="Configures VPP using RPC") argparser.add_argument('config_filename', help="name of XML file with element") + argparser.add_argument('--verbose', help="increase output verbosity", action="store_true") args = argparser.parse_args() + + logger = logging.getLogger("hc2vpp.examples.copy_config") + if args.verbose: + logging.basicConfig(level=logging.DEBUG) + else: + logging.basicConfig(level=logging.WARNING) + _copy_config(args.config_filename) diff --git a/examples/ncclient/edit_config.py b/examples/ncclient/edit_config.py index cafb7d475..d43b0b719 100755 --- a/examples/ncclient/edit_config.py +++ b/examples/ncclient/edit_config.py @@ -31,13 +31,19 @@ def _edit_config(config_filename, host='localhost', port=2831, username='admin', logger.debug("Commit successful:\n%s" % commit) if __name__ == '__main__': - logger = logging.getLogger("hc2vpp.examples.edit_config") - logging.basicConfig(level=logging.WARNING) argparser = argparse.ArgumentParser(description="Configures VPP using RPC") argparser.add_argument('config_filename', help="name of XML file with element") argparser.add_argument('-v', '--validate', help="sends RPC is was successful", action="store_true") argparser.add_argument('-c', '--commit', help="commits candidate configuration", action="store_true") + argparser.add_argument('--verbose', help="increase output verbosity", action="store_true") args = argparser.parse_args() + + logger = logging.getLogger("hc2vpp.examples.edit_config") + if args.verbose: + logging.basicConfig(level=logging.DEBUG) + else: + logging.basicConfig(level=logging.WARNING) + _edit_config(args.config_filename, validate=args.validate, commit=args.commit) diff --git a/examples/ncclient/get.py b/examples/ncclient/get.py index 9fe4ab854..44a726015 100755 --- a/examples/ncclient/get.py +++ b/examples/ncclient/get.py @@ -31,9 +31,15 @@ def _get(reply_filename=None, host='localhost', port=2831, username='admin', pas if __name__ == '__main__': - logger = logging.getLogger("hc2vpp.examples.get") - logging.basicConfig(level=logging.WARNING) argparser = argparse.ArgumentParser(description="Obtains VPP state data using RPC") argparser.add_argument('--reply_filename', help="name of XML file to store received state data") + argparser.add_argument('--verbose', help="increase output verbosity", action="store_true") args = argparser.parse_args() + + logger = logging.getLogger("hc2vpp.examples.get") + if args.verbose: + logging.basicConfig(level=logging.DEBUG) + else: + logging.basicConfig(level=logging.WARNING) + _get(args.reply_filename) diff --git a/examples/ncclient/get_config.py b/examples/ncclient/get_config.py index 5fdb6da3a..53b6854d6 100755 --- a/examples/ncclient/get_config.py +++ b/examples/ncclient/get_config.py @@ -31,9 +31,15 @@ def _get_config(reply_filename=None, host='localhost', port=2831, username='admi if __name__ == '__main__': - logger = logging.getLogger("hc2vpp.examples.get_config") - logging.basicConfig(level=logging.WARNING) argparser = argparse.ArgumentParser(description="Obtains VPP configuration using RPC") argparser.add_argument('--reply_filename', help="name of XML file to store received configuration") + argparser.add_argument('--verbose', help="increase output verbosity", action="store_true") args = argparser.parse_args() + + logger = logging.getLogger("hc2vpp.examples.get_config") + if args.verbose: + logging.basicConfig(level=logging.DEBUG) + else: + logging.basicConfig(level=logging.WARNING) + _get_config(args.reply_filename) -- cgit 1.2.3-korg