Merge "Only log that mapping file is in use if it's actually true"

This commit is contained in:
Zuul 2018-01-06 06:45:04 +00:00 committed by Gerrit Code Review
commit 0d80458bb7
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.