diff options
Diffstat (limited to 'os_net_config/impl_ifcfg.py')
-rw-r--r-- | os_net_config/impl_ifcfg.py | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index 84a5139..8284ad5 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -54,6 +54,10 @@ def nfvswitch_config_path(): return "/etc/sysconfig/nfvswitch" +def vpp_config_path(): + return "/etc/vpp/startup.conf" + + def route_config_path(name): return "/etc/sysconfig/network-scripts/route-%s" % name @@ -116,6 +120,7 @@ class IfcfgNetConfig(os_net_config.NetConfig): self.linuxbond_data = {} self.ib_interface_data = {} self.linuxteam_data = {} + self.vpp_interface_data = {} self.member_names = {} self.renamed_interfaces = {} self.bond_primary_ifaces = {} @@ -142,7 +147,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): @@ -623,6 +631,21 @@ class IfcfgNetConfig(os_net_config.NetConfig): if ovs_dpdk_bond.routes: self._add_routes(ovs_dpdk_bond.name, ovs_dpdk_bond.routes) + def add_vpp_interface(self, vpp_interface): + """Add a VppInterface object to the net config object + + :param vpp_interface: The VppInterface object to add + """ + vpp_interface.pci_dev = utils.get_pci_address(vpp_interface.name, + False) + vpp_interface.hwaddr = utils.interface_mac(vpp_interface.name) + if not self.noop: + self.ifdown(vpp_interface.name) + remove_ifcfg_config(vpp_interface.name) + logger.info('adding vpp interface: %s %s' + % (vpp_interface.name, vpp_interface.pci_dev)) + self.vpp_interface_data[vpp_interface.name] = vpp_interface + def generate_ivs_config(self, ivs_uplinks, ivs_interfaces): """Generate configuration content for ivs.""" @@ -687,6 +710,7 @@ class IfcfgNetConfig(os_net_config.NetConfig): restart_bridges = [] restart_linux_bonds = [] restart_linux_teams = [] + restart_vpp = False update_files = {} all_file_names = [] ivs_uplinks = [] # ivs physical uplinks @@ -695,6 +719,7 @@ class IfcfgNetConfig(os_net_config.NetConfig): nfvswitch_internal_ifaces = [] # nfvswitch internal/management ports stop_dhclient_interfaces = [] ovs_needs_restart = False + vpp_interfaces = self.vpp_interface_data.values() for interface_name, iface_data in self.interface_data.items(): route_data = self.route_data.get(interface_name, '') @@ -903,6 +928,15 @@ class IfcfgNetConfig(os_net_config.NetConfig): logger.info('No changes required for InfiniBand iface: %s' % interface_name) + if self.vpp_interface_data: + vpp_path = self.root_dir + vpp_config_path() + vpp_config = utils.generate_vpp_config(vpp_path, vpp_interfaces) + if utils.diff(vpp_path, vpp_config): + restart_vpp = True + update_files[vpp_path] = vpp_config + else: + logger.info('No changes required for VPP') + if cleanup: for ifcfg_file in glob.iglob(cleanup_pattern()): if ifcfg_file not in all_file_names: @@ -929,6 +963,9 @@ class IfcfgNetConfig(os_net_config.NetConfig): for bridge in restart_bridges: self.ifdown(bridge, iftype='bridge') + for vpp_interface in vpp_interfaces: + self.ifdown(vpp_interface.name) + for oldname, newname in self.renamed_interfaces.items(): self.ifrename(oldname, newname) @@ -1006,4 +1043,13 @@ class IfcfgNetConfig(os_net_config.NetConfig): for vlan in restart_vlans: self.ifup(vlan) + if not self.noop: + if restart_vpp: + logger.info('Restarting VPP') + utils.restart_vpp(vpp_interfaces) + + if self.vpp_interface_data: + logger.info('Updating VPP mapping') + utils.update_vpp_mapping(vpp_interfaces) + return update_files |