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
This commit is contained in:
James Slagle 2017-12-08 10:33:33 -05:00
parent bb7d8296d7
commit 3de7c2fa00
2 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -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.