+ #
+ # bridge-vlan-vni-map
+ #
+ fail = False
+ cached_vlans, cached_vnis = self.get_vlan_vni_ranges(self.cache.get_vlan_vni(ifaceobj.name))
+
+ for bridge_vlan_vni_map in ifaceobj.get_attr_value("bridge-vlan-vni-map"):
+
+ if fail:
+ ifaceobjcurr.update_config_with_status("bridge-vlan-vni-map", bridge_vlan_vni_map, 1)
+ continue
+
+ try:
+ vlans_str, vni_str = bridge_vlan_vni_map.split("=")
+ except:
+ ifaceobjcurr.update_config_with_status("bridge-vlan-vni-map", bridge_vlan_vni_map, 1)
+ return self.__warn_bridge_vlan_vni_map_syntax_error(bridge_vlan_vni_map)
+
+ vlans_list = self._ranges_to_ints([vlans_str]) # self.bridge_vlan_vni_map_convert_user_config_to_set(vlans_str)
+ vnis_list = self._ranges_to_ints([vni_str]) #self.bridge_vlan_vni_map_convert_user_config_to_set(vni_str)
+
+ # since there can be multiple entry of bridge-vlan-vni-map
+ # we could simply check that all vlans and vnis are correctly
+ # set on the vxlan but we would probably miss the case where extra
+ # vlans and vnis were added. So we ned to keep a copy of the cache
+ # entry and pop vlans and svis from the cache copy as we iterate
+ # through the user config. After processing only extra vlans and
+ # vnis should be left.
+ try:
+ for vlan in vlans_list:
+ cached_vlans.remove(vlan)
+ except:
+ ifaceobjcurr.update_config_with_status("bridge-vlan-vni-map", bridge_vlan_vni_map, 1)
+ fail = True
+ continue
+
+ try:
+ for vni in vnis_list:
+ cached_vnis.remove(vni)
+ except:
+ ifaceobjcurr.update_config_with_status("bridge-vlan-vni-map", bridge_vlan_vni_map, 1)
+ fail = True
+ continue
+
+ ifaceobjcurr.update_config_with_status("bridge-vlan-vni-map", bridge_vlan_vni_map, 0)
+
+ if not fail and (cached_vlans or cached_vnis):
+ # cached_vlans and cached_vnis are not empty, it means more
+ # vlans-vni maps were configured on the bridge port
+ ifaceobjcurr.update_config_with_status(
+ "bridge-vlan-vni-map",
+ "%s=%s" % (cached_vlans, cached_vnis),
+ 1
+ )
+
+ @staticmethod
+ def get_vlan_vni_ranges(bridge_vlan_tunnel):
+ vlans = []
+ vnis = []
+
+ tunnel_vlan_range = None
+ tunnel_vni_range = None
+
+ for tunnel_vlan, tunnel_vni, tunnel_flags in bridge_vlan_tunnel:
+
+ if tunnel_flags & Link.BRIDGE_VLAN_INFO_RANGE_BEGIN:
+ tunnel_vlan_range = tunnel_vlan
+ tunnel_vni_range = tunnel_vni
+
+ elif tunnel_flags & Link.BRIDGE_VLAN_INFO_RANGE_END:
+ vlans.extend(range(tunnel_vlan_range, tunnel_vlan + 1))
+ vnis.extend(range(tunnel_vni_range, tunnel_vni + 1))
+
+ else:
+ vlans.append(tunnel_vlan)
+ vnis.append(tunnel_vni)
+
+ return vlans, vnis
+