From 3f36600d1c7159f3ba00a2449e381cd32239af4e Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Mon, 26 Jan 2015 21:09:59 +0000 Subject: 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 --- os_net_config/impl_ifcfg.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'os_net_config/impl_ifcfg.py') 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) -- cgit 1.2.3-korg