diff options
author | Steven Hardy <shardy@redhat.com> | 2015-01-26 21:09:59 +0000 |
---|---|---|
committer | Steven Hardy <shardy@redhat.com> | 2015-03-05 13:11:09 +0000 |
commit | 3f36600d1c7159f3ba00a2449e381cd32239af4e (patch) | |
tree | eb11dc1d0ed4ecbc4b99c4a81e167adec88f7270 /os_net_config/impl_ifcfg.py | |
parent | 3304fa066d1dae93df0f597c1709c955e3857a5d (diff) |
Enable renaming of interfaces without reboot
When using persist_mapping to rename nics, you can either use
--no-activate then reboot, or with this patch, allow activation
and we'll take the device links down and rename on the fly avoiding
the need for a reboot.
Change-Id: Ife9486c9f5447e9c7a55f90ba075e22b6344ad67
Diffstat (limited to 'os_net_config/impl_ifcfg.py')
-rw-r--r-- | os_net_config/impl_ifcfg.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index 78433d8..47f32a6 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -51,6 +51,7 @@ class IfcfgNetConfig(os_net_config.NetConfig): self.route_data = {} self.bridge_data = {} self.member_names = {} + self.renamed_interfaces = {} logger.info('Ifcfg net config provider created.') def child_members(self, name): @@ -172,6 +173,11 @@ class IfcfgNetConfig(os_net_config.NetConfig): if interface.routes: self._add_routes(interface.name, interface.routes) + if interface.renamed: + logger.info("Interface %s being renamed to %s" + % (interface.hwname, interface.name)) + self.renamed_interfaces[interface.hwname] = interface.name + def add_vlan(self, vlan): """Add a Vlan object to the net config object. @@ -275,6 +281,9 @@ class IfcfgNetConfig(os_net_config.NetConfig): for bridge in restart_bridges: self.ifdown(bridge, iftype='bridge') + for oldname, newname in self.renamed_interfaces.iteritems(): + self.ifrename(oldname, newname) + for location, data in update_files.iteritems(): self.write_config(location, data) |