From 3de7c2fa00ee6a6acc7fc402b4ce72d4c0a5515c Mon Sep 17 00:00:00 2001 From: James Slagle Date: Fri, 8 Dec 2017 10:33:33 -0500 Subject: [PATCH] Only log that mapping file is in use if it's actually true os-net-config always logs the message "Using mapping file at: /etc/os-net-config/mapping.yaml" even if the file does not exist, in which case it's not actually being used at all. Move the log message to only be shown if the mapping file actually exists and is used. In the case where no mapping file is used, also log a message indicating such. Change-Id: Iea46e215d531e0fed5839c28c116417db464d52d Closes-Bug: #1737191 --- os_net_config/cli.py | 4 ++-- releasenotes/notes/log-mapping-file-8b2a9d8f6a81ba99.yaml | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/log-mapping-file-8b2a9d8f6a81ba99.yaml diff --git a/os_net_config/cli.py b/os_net_config/cli.py index e8589371..311f4d2f 100644 --- a/os_net_config/cli.py +++ b/os_net_config/cli.py @@ -137,8 +137,6 @@ def main(argv=sys.argv): opts = parse_opts(argv) configure_logger(opts.verbose, opts.debug) logger.info('Using config file at: %s' % opts.config_file) - if opts.mapping_file: - logger.info('Using mapping file at: %s' % opts.mapping_file) iface_array = [] provider = None @@ -170,6 +168,7 @@ def main(argv=sys.argv): # This allows you to override the default network naming abstraction # mappings by specifying a specific nicN->name or nicN->MAC mapping if os.path.exists(opts.mapping_file): + logger.info('Using mapping file at: %s' % opts.mapping_file) with open(opts.mapping_file) as cf: iface_map = yaml.load(cf.read()) iface_mapping = iface_map.get("interface_mapping") @@ -177,6 +176,7 @@ def main(argv=sys.argv): persist_mapping = opts.persist_mapping logger.debug('persist_mapping: %s' % persist_mapping) else: + logger.info('Not using any mapping file.') iface_mapping = None persist_mapping = False diff --git a/releasenotes/notes/log-mapping-file-8b2a9d8f6a81ba99.yaml b/releasenotes/notes/log-mapping-file-8b2a9d8f6a81ba99.yaml new file mode 100644 index 00000000..b7966a3e --- /dev/null +++ b/releasenotes/notes/log-mapping-file-8b2a9d8f6a81ba99.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - os-net-config always logs the message "Using mapping file at: + /etc/os-net-config/mapping.yaml" even if the file does not exist, in which + case it's not actually being used at all. Move the log message to only be + shown if the mapping file actually exists and is used. In the case where no + mapping file is used, also log a message indicating such.