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.