diff options
author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2023-06-29 16:45:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-29 16:45:09 +0300 |
commit | 1d94ff123d546244d89b36deeeb092f0772c60fe (patch) | |
tree | 427b50b7ccfa2840c9a2abf7b9ddb222424a3884 /src | |
parent | b7afb930e997915c8a4d117b5e138cb0555163c3 (diff) | |
parent | 199657fc60782961e86af2f3f49b246b29b9723c (diff) | |
download | vyos-1x-1d94ff123d546244d89b36deeeb092f0772c60fe.tar.gz vyos-1x-1d94ff123d546244d89b36deeeb092f0772c60fe.zip |
Merge pull request #8 from zdc/sever-sever_T1797-vpp
VPP: T1797: Optimized interfaces add/remove
Diffstat (limited to 'src')
-rwxr-xr-x | src/conf_mode/vpp.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/conf_mode/vpp.py b/src/conf_mode/vpp.py index 25fe159f8..dd01da87e 100755 --- a/src/conf_mode/vpp.py +++ b/src/conf_mode/vpp.py @@ -53,12 +53,12 @@ def _get_pci_address_by_interface(iface) -> str: address = re_obj.groupdict().get('address', '') return address # use VPP - maybe interface already attached to it - vpp_control = VPPControl() + vpp_control = VPPControl(attempts=20, interval=500) pci_addr = vpp_control.get_pci_addr(iface) if pci_addr: return pci_addr - # return empty string if address was not found - return '' + # raise error if PCI address was not found + raise ConfigError(f'Cannot find PCI address for interface {iface}') @@ -148,8 +148,14 @@ def apply(config): call('systemctl daemon-reload') call(f'systemctl restart {service_name}.service') + # Initialize interfaces removed from VPP for iface in config.get('removed_ifaces', []): - HostControl().pci_rescan(iface['iface_pci_addr']) + host_control = HostControl() + # rescan PCI to use a proper driver + host_control.pci_rescan(iface['iface_pci_addr']) + # rename to the proper name + iface_new_name: str = host_control.get_eth_name(iface['iface_pci_addr']) + host_control.rename_iface(iface_new_name, iface['iface_name']) if 'interface' in config: # connect to VPP |