diff options
Diffstat (limited to 'os_net_config/impl_ifcfg.py')
-rw-r--r-- | os_net_config/impl_ifcfg.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index 6d3c681..cf3b257 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -34,6 +34,13 @@ def ifcfg_config_path(name): return "/etc/sysconfig/network-scripts/ifcfg-%s" % name +def remove_ifcfg_config(ifname): + if re.match('[\w-]+$', ifname): + ifcfg_file = ifcfg_config_path(ifname) + if os.path.exists(ifcfg_file): + os.remove(ifcfg_file) + + # NOTE(dprince): added here for testability def bridge_config_path(name): return ifcfg_config_path(name) @@ -135,7 +142,10 @@ class IfcfgNetConfig(os_net_config.NetConfig): data += "HOTPLUG=yes\n" else: data += "HOTPLUG=no\n" - data += "NM_CONTROLLED=no\n" + if base_opt.nm_controlled: + data += "NM_CONTROLLED=yes\n" + else: + data += "NM_CONTROLLED=no\n" if not base_opt.dns_servers and not base_opt.use_dhcp: data += "PEERDNS=no\n" if isinstance(base_opt, objects.Vlan): @@ -587,6 +597,8 @@ class IfcfgNetConfig(os_net_config.NetConfig): # Bind the dpdk interface utils.bind_dpdk_interfaces(ifname, ovs_dpdk_port.driver, self.noop) + if not self.noop: + remove_ifcfg_config(ifname) data = self._add_common(ovs_dpdk_port) logger.debug('ovs dpdk port data: %s' % data) @@ -605,6 +617,8 @@ class IfcfgNetConfig(os_net_config.NetConfig): # checks are added at the object creation stage. ifname = dpdk_port.members[0].name utils.bind_dpdk_interfaces(ifname, dpdk_port.driver, self.noop) + if not self.noop: + remove_ifcfg_config(ifname) data = self._add_common(ovs_dpdk_bond) logger.debug('ovs dpdk bond data: %s' % data) @@ -683,6 +697,7 @@ class IfcfgNetConfig(os_net_config.NetConfig): nfvswitch_interfaces = [] # nfvswitch physical interfaces nfvswitch_internal_ifaces = [] # nfvswitch internal/management ports stop_dhclient_interfaces = [] + ovs_needs_restart = False for interface_name, iface_data in self.interface_data.items(): route_data = self.route_data.get(interface_name, '') @@ -708,6 +723,11 @@ class IfcfgNetConfig(os_net_config.NetConfig): update_files[route6_path] = route6_data if "BOOTPROTO=dhcp" not in iface_data: stop_dhclient_interfaces.append(interface_name) + # Openvswitch needs to be restarted when OVSDPDKPort or + # OVSDPDKBond is added + if "OVSDPDK" in iface_data: + ovs_needs_restart = True + else: logger.info('No changes required for interface: %s' % interface_name) @@ -915,6 +935,16 @@ class IfcfgNetConfig(os_net_config.NetConfig): for oldname, newname in self.renamed_interfaces.items(): self.ifrename(oldname, newname) + # DPDK initialization is done before running os-net-config, to make + # the DPDK ports available when enabled. DPDK Hotplug support is + # supported only in OvS 2.7 version. Until then, OvS needs to be + # restarted after adding a DPDK port. This change will be removed on + # migration to OvS 2.7 where DPDK Hotplug support is available. + if ovs_needs_restart: + msg = "Restart openvswitch" + self.execute(msg, '/usr/bin/systemctl', + 'restart', 'openvswitch') + for location, data in update_files.items(): self.write_config(location, data) |