Implement Prune Step 4: Remove members from bridgedomains, and remove bridgedomains not in the config

This commit is contained in:
Pim van Pelt
2022-03-24 22:22:55 +00:00
parent cd4d44a2b1
commit 721ac690cd

View File

@ -66,6 +66,9 @@ class Reconciler():
if not self.prune_bvis(): if not self.prune_bvis():
self.logger.warning("Could not prune BVIs from VPP that are not in the config") self.logger.warning("Could not prune BVIs from VPP that are not in the config")
ret = False ret = False
if not self.prune_bridgedomains():
self.logger.warning("Could not prune BridgeDomains from VPP that are not in the config")
ret = False
return ret return ret
def prune_loopbacks(self): def prune_loopbacks(self):
@ -98,6 +101,28 @@ class Reconciler():
self.prune_addresses(vpp_iface.interface_name, addresses) self.prune_addresses(vpp_iface.interface_name, addresses)
return True return True
def prune_bridgedomains(self):
for idx, bridge in self.vpp.config['bridgedomains'].items():
bridgename = "bd%d" % idx
config_ifname, config_iface = bridgedomain.get_by_name(self.cfg, bridgename)
members = []
if not config_iface:
for member in bridge.sw_if_details:
member_ifname = self.vpp.config['interfaces'][member.sw_if_index].interface_name
if interface.is_sub(self.cfg, member_ifname):
self.logger.info("1> set interface l2 tag-rewrite %s disable" % member_ifname)
self.logger.info("1> set interface l3 %s" % member_ifname)
self.logger.info("1> create bridge-domain %d del" % idx)
else:
self.logger.debug("BridgeDomain OK: %s" % (bridgename))
for member in bridge.sw_if_details:
member_ifname = self.vpp.config['interfaces'][member.sw_if_index].interface_name
if 'members' in config_iface and member_ifname in config_iface['members']:
if interface.is_sub(self.cfg, member_ifname):
self.logger.info("1> set interface l2 tag-rewrite %s disable" % member_ifname)
self.logger.info("1> set interface l3 %s" % member_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():