diff options
author | Steven Hardy <shardy@redhat.com> | 2015-01-21 17:24:08 +0000 |
---|---|---|
committer | Steven Hardy <shardy@redhat.com> | 2015-02-24 09:20:41 +0000 |
commit | a4ad189558a414c6029b4dfbc8e459339ebe534d (patch) | |
tree | 0c39889bc89c461803f03b4cb9ae89e8bd4c0033 /os_net_config/cli.py | |
parent | 6945fe5afdc12574fe00ad440319b7873f818e84 (diff) |
Add a persist_mapping option to the mapping file
This adds the option to permanently rewrite the configuration so the
aliases are used instead of the system name. This is useful where
you have a variety of hardware and you want to have consistent device
naming accross all platforms - this allows you to essentially rename
the interfaces permanently so they match the abstracted nicN names.
Note, this needs to be run with --cleanup or the old (now conflicting)
configs will still be in place, and it may require a reboot before
the changes are fully applied.
Change-Id: I5af146e764b72c4beaa41c549fabff0af8802152
Diffstat (limited to 'os_net_config/cli.py')
-rw-r--r-- | os_net_config/cli.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/os_net_config/cli.py b/os_net_config/cli.py index d22573d..939eeaa 100644 --- a/os_net_config/cli.py +++ b/os_net_config/cli.py @@ -74,6 +74,14 @@ def parse_opts(argv): help="Cleanup unconfigured interfaces.", required=False) + parser.add_argument( + '--persist-mapping', + dest="persist_mapping", + action='store_true', + help="Make aliases defined in the mapping file permanent " + "(WARNING, permanently renames nics).", + required=False) + opts = parser.parse_args(argv[1:]) return opts @@ -139,13 +147,18 @@ def main(argv=sys.argv): # mappings by specifying a specific nicN->name or nicN->MAC mapping if os.path.exists(opts.mapping_file): with open(opts.mapping_file) as cf: - iface_mapping = yaml.load(cf.read()).get("interface_mapping") + iface_map = yaml.load(cf.read()) + iface_mapping = iface_map.get("interface_mapping") logger.debug('interface_mapping JSON: %s' % str(iface_mapping)) + persist_mapping = opts.persist_mapping + logger.debug('persist_mapping: %s' % persist_mapping) else: iface_mapping = None + persist_mapping = False for iface_json in iface_array: iface_json.update({'nic_mapping': iface_mapping}) + iface_json.update({'persist_mapping': persist_mapping}) obj = objects.object_from_json(iface_json) provider.add_object(obj) files_changed = provider.apply(noop=opts.noop, cleanup=opts.cleanup) |