diff options
author | Radostin Stoyanov <rstoyanov1@gmail.com> | 2017-06-16 11:08:23 +0100 |
---|---|---|
committer | Cédric Bosdonnat <cbosdonnat@suse.com> | 2017-06-19 14:55:52 +0200 |
commit | dfbfc0f2613bf746948da871e3aa0ec054f6bd4f (patch) | |
tree | 033e409dcaff0680e020a28e8d6d912615a1fa7f /src | |
parent | 4ca83f7b40bc147b9d59cc38de0e5bea44abdbda (diff) | |
download | virt-bootstrap.git-dfbfc0f2613bf746948da871e3aa0ec054f6bd4f.tar.gz virt-bootstrap.git-dfbfc0f2613bf746948da871e3aa0ec054f6bd4f.tar.xz virt-bootstrap.git-dfbfc0f2613bf746948da871e3aa0ec054f6bd4f.zip |
Add "debug" and "quiet" flags
These flags aim to control the logging level [1] of virt-bootstrap.
Default = INFO (Confirmation that things are working as expected)
--debug = DEBUG (Detailed information,
typically of interest only when diagnosing problems)
--quiet = WARNING (An indication that something unexpected happened,
or indicative of some problem in the near future)
[1] https://docs.python.org/3/howto/logging.html
Diffstat (limited to 'src')
-rwxr-xr-x | src/virtBootstrap/virt_bootstrap.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/virtBootstrap/virt_bootstrap.py b/src/virtBootstrap/virt_bootstrap.py index 3973720..2ee505e 100755 --- a/src/virtBootstrap/virt_bootstrap.py +++ b/src/virtBootstrap/virt_bootstrap.py @@ -26,6 +26,7 @@ import gettext import sys import os from textwrap import dedent +from logging import getLogger, DEBUG, INFO, WARNING from subprocess import CalledProcessError, Popen, PIPE try: from urlparse import urlparse @@ -85,6 +86,10 @@ def bootstrap(args): """ Get source object and call unpack method """ + # Set log level + logger = getLogger() + logger.setLevel(DEBUG if args.debug else WARNING if args.quiet else INFO) + source = get_source(args) if not os.path.exists(args.dest): os.makedirs(args.dest) @@ -128,6 +133,11 @@ def main(): parser.add_argument("-f", "--format", default='dir', choices=['dir', 'qcow2'], help=_("Format to be used for the root filesystem")) + parser.add_argument("-d", "--debug", action="store_true", + help=_("Show debug messages")) + parser.add_argument("-q", "--quiet", action="store_true", + help=_("Suppresses messages notifying about" + "current state or actions of virt-bootstrap")) # TODO add UID / GID mapping parameters try: |