Set MPLS for loopback and interface. Allow for --novpp and VPP changes
This commit is contained in:
@ -108,6 +108,8 @@ class Dumper(VPPApi):
|
|||||||
loop["addresses"] = self.cache["interface_addresses"][
|
loop["addresses"] = self.cache["interface_addresses"][
|
||||||
iface.sw_if_index
|
iface.sw_if_index
|
||||||
]
|
]
|
||||||
|
if iface.sw_if_index in self.cache["interface_mpls"]:
|
||||||
|
loop["mpls"] = self.cache["interface_mpls"][iface.sw_if_index]
|
||||||
config["loopbacks"][iface.interface_name] = loop
|
config["loopbacks"][iface.interface_name] = loop
|
||||||
elif iface.interface_dev_type in [
|
elif iface.interface_dev_type in [
|
||||||
"bond",
|
"bond",
|
||||||
|
@ -947,6 +947,9 @@ class Reconciler:
|
|||||||
if not self.__sync_phys():
|
if not self.__sync_phys():
|
||||||
self.logger.warning("Could not sync PHYs in VPP")
|
self.logger.warning("Could not sync PHYs in VPP")
|
||||||
ret = False
|
ret = False
|
||||||
|
if not self.__sync_mpls_state():
|
||||||
|
self.logger.warning("Could not sync interface MPLS state in VPP")
|
||||||
|
ret = False
|
||||||
if not self.__sync_admin_state():
|
if not self.__sync_admin_state():
|
||||||
self.logger.warning("Could not sync interface adminstate in VPP")
|
self.logger.warning("Could not sync interface adminstate in VPP")
|
||||||
ret = False
|
ret = False
|
||||||
@ -1291,6 +1294,36 @@ class Reconciler:
|
|||||||
ret = False
|
ret = False
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def __sync_mpls_state(self):
|
||||||
|
"""Synchronize the VPP Dataplane configuration for interface and loopback MPLS state"""
|
||||||
|
for ifname in interface.get_interfaces(self.cfg) + loopback.get_loopbacks(
|
||||||
|
self.cfg
|
||||||
|
):
|
||||||
|
if ifname.startswith("loop"):
|
||||||
|
vpp_ifname, config_iface = loopback.get_by_name(self.cfg, ifname)
|
||||||
|
else:
|
||||||
|
vpp_ifname, config_iface = interface.get_by_name(self.cfg, ifname)
|
||||||
|
|
||||||
|
try:
|
||||||
|
config_mpls = config_iface["mpls"]
|
||||||
|
except KeyError:
|
||||||
|
config_mpls = False
|
||||||
|
|
||||||
|
vpp_mpls = False
|
||||||
|
if vpp_ifname in self.vpp.cache["interface_names"]:
|
||||||
|
sw_if_index = self.vpp.cache["interface_names"][vpp_ifname]
|
||||||
|
try:
|
||||||
|
vpp_mpls = self.vpp.cache["interface_mpls"][sw_if_index]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
if vpp_mpls != config_mpls:
|
||||||
|
state = "disable"
|
||||||
|
if config_mpls:
|
||||||
|
state = "enable"
|
||||||
|
cli = f"set interface mpls {vpp_ifname} {state}"
|
||||||
|
self.cli["sync"].append(cli)
|
||||||
|
return True
|
||||||
|
|
||||||
def __sync_addresses(self):
|
def __sync_addresses(self):
|
||||||
"""Synchronize the VPP Dataplane configuration for interface addresses"""
|
"""Synchronize the VPP Dataplane configuration for interface addresses"""
|
||||||
for ifname in interface.get_interfaces(self.cfg) + loopback.get_loopbacks(
|
for ifname in interface.get_interfaces(self.cfg) + loopback.get_loopbacks(
|
||||||
|
@ -119,6 +119,7 @@ class VPPApi:
|
|||||||
"interface_names": {},
|
"interface_names": {},
|
||||||
"interfaces": {},
|
"interfaces": {},
|
||||||
"interface_addresses": {},
|
"interface_addresses": {},
|
||||||
|
"interface_mpls": {},
|
||||||
"bondethernets": {},
|
"bondethernets": {},
|
||||||
"bondethernet_members": {},
|
"bondethernet_members": {},
|
||||||
"bridgedomains": {},
|
"bridgedomains": {},
|
||||||
@ -215,7 +216,7 @@ class VPPApi:
|
|||||||
enumerating the 'interfaces' scope from yaml_config"""
|
enumerating the 'interfaces' scope from yaml_config"""
|
||||||
|
|
||||||
if not "interfaces" in yaml_config:
|
if not "interfaces" in yaml_config:
|
||||||
self.logger.error(f"YAML config does not contain any interfaces")
|
self.logger.error("YAML config does not contain any interfaces")
|
||||||
return False
|
return False
|
||||||
self.logger.debug(f"config: {yaml_config['interfaces']}")
|
self.logger.debug(f"config: {yaml_config['interfaces']}")
|
||||||
|
|
||||||
@ -332,6 +333,11 @@ class VPPApi:
|
|||||||
str(addr.prefix)
|
str(addr.prefix)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.logger.debug("Retrieving interface MPLS state")
|
||||||
|
api_response = self.vpp.api.mpls_interface_dump()
|
||||||
|
for iface in api_response:
|
||||||
|
self.cache["interface_mpls"][iface.sw_if_index] = True
|
||||||
|
|
||||||
self.logger.debug("Retrieving bondethernets")
|
self.logger.debug("Retrieving bondethernets")
|
||||||
api_response = self.vpp.api.sw_bond_interface_dump()
|
api_response = self.vpp.api.sw_bond_interface_dump()
|
||||||
for iface in api_response:
|
for iface in api_response:
|
||||||
|
Reference in New Issue
Block a user