[minigraph.py]: Force /32 prefix for mux cable server IPv4 loopbacks (#6418)

Server IPv4 loopbacks do not always arrive with /32 prefix, which is a requirement for the MUX_CABLE table in config DB

Signed-off-by: Lawrence Lee <lawlee@microsoft.com>
This commit is contained in:
Lawrence Lee 2021-01-12 06:04:48 -08:00 committed by Guohan Lu
parent b6de4943fc
commit 063a485982

View File

@ -1505,7 +1505,12 @@ def get_mux_cable_entries(mux_cable_ports, neighbors, devices):
entry = {}
neighbor = neighbors[intf]['name']
entry['state'] = 'auto'
entry['server_ipv4'] = devices[neighbor]['lo_addr']
# Always force a /32 prefix for server IPv4 loopbacks
server_ipv4_lo_addr = devices[neighbor]['lo_addr'].split("/")[0]
server_ipv4_lo_prefix = ipaddress.ip_network(UNICODE_TYPE(server_ipv4_lo_addr))
entry['server_ipv4'] = str(server_ipv4_lo_prefix)
if 'lo_addr_v6' in devices[neighbor]:
entry['server_ipv6'] = devices[neighbor]['lo_addr_v6']
mux_cable_table[intf] = entry