Prune Step 6: Remove BondEthernets and their member interfaces that are not in the config

This commit is contained in:
Pim van Pelt
2022-03-24 23:17:56 +00:00
parent 731f7ecbb4
commit c381c7cbaa
2 changed files with 24 additions and 1 deletions

View File

@ -153,7 +153,7 @@ and finally for all interfaces, they are synchronized with the configuratino (IP
* Remove tag-rewrite options on if it has encapsulation * Remove tag-rewrite options on if it has encapsulation
1. Retrieve all BondEthernets from VPP 1. Retrieve all BondEthernets from VPP
* Remove those that do not exist in the config * Remove those that do not exist in the config
* Remove all member interfaces that are not in the config, return them to L3 mode * Remove all member interfaces that are not in the config
* Remove all IP addresses that are not in the config * Remove all IP addresses that are not in the config
1. Retrieve all Tunnels from VPP 1. Retrieve all Tunnels from VPP
* Remove those that do not exist in the config * Remove those that do not exist in the config

View File

@ -72,6 +72,9 @@ class Reconciler():
if not self.prune_l2xcs(): if not self.prune_l2xcs():
self.logger.warning("Could not prune L2 Cross Connects from VPP that are not in the config") self.logger.warning("Could not prune L2 Cross Connects from VPP that are not in the config")
ret = False ret = False
if not self.prune_bondethernets():
self.logger.warning("Could not prune BondEthernets from VPP that are not in the config")
ret = False
return ret return ret
def prune_loopbacks(self): def prune_loopbacks(self):
@ -150,6 +153,26 @@ class Reconciler():
self.logger.debug("L2XC OK: %s -> %s" % (vpp_rx_ifname, vpp_tx_ifname)) self.logger.debug("L2XC OK: %s -> %s" % (vpp_rx_ifname, vpp_tx_ifname))
return True return True
def prune_bondethernets(self):
for idx, bond in self.vpp.config['bondethernets'].items():
vpp_ifname = bond.interface_name
config_ifname, config_iface = bondethernet.get_by_name(self.cfg, vpp_ifname)
if not config_iface:
for member in self.vpp.config['bondethernet_members'][idx]:
self.logger.info("1> bond del %s" % self.vpp.config['interfaces'][member].interface_name)
self.logger.info("1> delete bond %s" % (vpp_ifname))
continue
for member in self.vpp.config['bondethernet_members'][idx]:
member_ifname = self.vpp.config['interfaces'][member].interface_name
if 'interfaces' in config_iface and not member_ifname in config_iface['interfaces']:
self.logger.info("2> bond del %s" % member_ifname)
addresses = []
if 'addresses' in config_iface:
addresses = config_iface['addresses']
self.prune_addresses(vpp_ifname, addresses)
self.logger.debug("BondEthernet OK: %s" % (vpp_ifname))
return True
def __parent_iface_by_encap(self, sup_sw_if_index, outer, dot1ad=True): def __parent_iface_by_encap(self, sup_sw_if_index, outer, dot1ad=True):
""" Returns the idx of an interface on a given super_sw_if_index with given dot1q/dot1ad outer and inner-dot1q=0 """ """ Returns the idx of an interface on a given super_sw_if_index with given dot1q/dot1ad outer and inner-dot1q=0 """
for idx, iface in self.vpp.config['interfaces'].items(): for idx, iface in self.vpp.config['interfaces'].items():