Skip to content

Commit

Permalink
Merged PR 3932212: [minigraph_facts] Fix conflicts
Browse files Browse the repository at this point in the history
[minigraph_facts] Fix conflicts

Move the port alias to name mapping parsing to
ansible/module_utils/port_utils.py that is introduced by the following
patch:
sonic-net#2517

Signed-off-by: Longxiang Lyu <lolv@microsoft.com>
  • Loading branch information
lolyu authored and sonic-build committed Jan 7, 2021
1 parent dab2153 commit ceda81b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 161 deletions.
151 changes: 1 addition & 150 deletions ansible/library/minigraph_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,156 +466,7 @@ def parse_xml(filename, hostname):

global port_alias_to_name_map

if hwsku == "Force10-S6000":
for i in range(0, 128, 4):
port_alias_to_name_map["fortyGigE0/%d" % i] = "Ethernet%d" % i
elif hwsku == "Force10-S6100":
for i in range(0, 4):
for j in range(0, 16):
port_alias_to_name_map["fortyGigE1/%d/%d" % (i+1, j+1)] = "Ethernet%d" % (i * 16 + j)
elif hwsku in ["Force10-Z9100-C32", "DellEMC-S5232f-C32"]:
for i in range(0, 128, 4):
port_alias_to_name_map["hundredGigE1/%d" % (i/4 + 1)] = "Ethernet%d" % i
elif hwsku == "Arista-7050-QX32":
for i in range(1, 25):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
for i in range(25, 33):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Arista-7050-QX-32S":
for i in range(5, 29):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 5) * 4)
for i in range(29, 37):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % ((i - 5) * 4)
elif hwsku in ["Arista-7260CX3-C64", "Arista-7170-64C", "Arista-7260CX3-Q64"]:
for i in range(1, 65):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Arista-7060CX-32S-C32" or hwsku == "Arista-7060CX-32S-Q32" or hwsku == "Arista-7060CX-32S-C32-T1" or hwsku == "Arista-7170-32CD-C32":
for i in range(1, 33):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Arista-7050CX3-32S-C32":
for i in range(1, 33):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
for i in range(33, 35):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Mellanox-SN2700-D48C8":
# 50G ports
s50G_ports = [x for x in range(0, 24, 2)] + [x for x in range(40, 88, 2)] + [x for x in range(104, 128, 2)]

# 100G ports
s100G_ports = [x for x in range(24, 40, 4)] + [x for x in range(88, 104, 4)]

for i in s50G_ports:
alias = "etp%d" % (i / 4 + 1) + ("a" if i % 4 == 0 else "b")
port_alias_to_name_map[alias] = "Ethernet%d" % i
for i in s100G_ports:
alias = "etp%d" % (i / 4 + 1)
port_alias_to_name_map[alias] = "Ethernet%d" % i
elif hwsku == "Mellanox-SN3800-D112C8":
x_ports = [x for x in range(0, 95, 2)]
for i in x_ports:
alias = "etp%d" % (i / 4 + 1) + ("a" if i % 4 == 0 else "b")
# print alias, "Ethernet%d" % i
port_alias_to_name_map[alias] = "Ethernet%d" % i
x_ports = [x for x in range(96, 101, 4)] + [x for x in range(104, 111, 2)] + [x for x in range(112, 117, 4)] + [x for x in range(120, 127, 2)] + [x for x in range(128, 133, 4)] + [x for x in range(136, 143, 2)] + [x for x in range(144, 149, 4)] + [x for x in range(152, 159, 2)]
i = 0
while i < len(x_ports):
for j in range (0, 2):
alias = "etp%d" % (x_ports[i] / 4 + 1)
port_alias_to_name_map[alias] = "Ethernet%d" % x_ports[i]
# print alias, "Ethernet%d" % ports[i]
i += 1
for j in range (0, 2):
alias = "etp%d" % (x_ports[i] / 4 + 1) + "a"
port_alias_to_name_map[alias] = "Ethernet%d" % x_ports[i]
# print alias, "Ethernet%d" % ports[i]
i += 1
alias = "etp%d" % (x_ports[i] / 4 + 1) + "b"
port_alias_to_name_map[alias] = "Ethernet%d" % x_ports[i]
# print alias, "Ethernet%d" % ports[i]
i += 1
x_ports = [x for x in range(160, 255, 2)]
for i in x_ports:
alias = "etp%d" % (i / 4 + 1) + ("a" if i % 4 == 0 else "b")
# print alias, "Ethernet%d" % i
port_alias_to_name_map[alias] = "Ethernet%d" % i
elif hwsku == "Mellanox-SN2700" or hwsku == "ACS-MSN2700":
for i in range(1, 33):
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "ACS-MSN3800":
for i in range(1, 65):
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku in ["Arista-7060CX-32S-D48C8", "Arista-7050CX3-32S-D48C8"]:
# All possible breakout 50G port numbers:
all_ports = [ x for x in range(1, 33)]

# 100G ports
s100G_ports = [ x for x in range(7, 11) ]
s100G_ports += [ x for x in range(23, 27) ]

port_alias_to_name_map = port_alias_to_name_map_50G(all_ports, s100G_ports)
elif hwsku == "Arista-7260CX3-D108C8" or hwsku == "Arista-7260CX3-D108C8-AILAB" or hwsku == "Arista-7260CX3-D108C8-CSI":
# All possible breakout 50G port numbers:
all_ports = [ x for x in range(1, 65)]

# 100G ports
s100G_ports = [ x for x in range(13, 21) ]

if hwsku == "Arista-7260CX3-D108C8-AILAB":
s100G_ports = [ x for x in range(45, 53) ]
elif hwsku == "Arista-7260CX3-D108C8-CSI":
# Treat 40G port as 100G ports
s100G_ports = [ x for x in range(45, 53) ] + [64]

port_alias_to_name_map = port_alias_to_name_map_50G(all_ports, s100G_ports)
elif hwsku == "INGRASYS-S9100-C32":
for i in range(1, 33):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "INGRASYS-S9100-C32" or hwsku == "INGRASYS-S9130-32X" or hwsku == "INGRASYS-S8810-32Q":
for i in range(1, 33):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "INGRASYS-S8900-54XC":
for i in range(1, 49):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % (i - 1)
for i in range(49, 55):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 49) * 4 + 48)
elif hwsku == "INGRASYS-S8900-64XC":
for i in range(1, 49):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % (i - 1)
for i in range(49, 65):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 49) * 4 + 48)
elif hwsku == "Accton-AS7712-32X":
for i in range(1, 33):
port_alias_to_name_map["hundredGigE%d" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Celestica-DX010-C32":
for i in range(1, 33):
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Seastone-DX010":
for i in range(1, 33):
port_alias_to_name_map["Eth%d" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Celestica-E1031-T48S4":
for i in range(1, 53):
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1))
elif hwsku == "et6448m":
for i in range(0, 52):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
elif hwsku == "Nokia-7215":
for i in range(0, 52):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
elif hwsku == "newport":
for i in range(0, 256, 8):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
elif hwsku in ["Nexus-3132-GE-Q32", "Nexus-3132-GX-Q32"]:
for i in range(1, 33):
port_alias_to_name_map["Ethernet1/%d" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Celestica-DX010-C32":
for i in range(1, 33):
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Celestica-E1031-T48S4":
for i in range(1, 53):
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1))
else:
for i in range(0, 128, 4):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
port_alias_to_name_map = get_port_alias_to_name_map(hwsku)

for child in root:
if child.tag == str(QName(ns, "DpgDec")):
Expand Down
76 changes: 65 additions & 11 deletions ansible/module_utils/port_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def get_port_alias_to_name_map(hwsku):
elif hwsku == "Force10-S6100":
for i in range(0, 4):
for j in range(0, 16):
port_alias_to_name_map["fortyGigE1/%d/%d" % (i + 1, j + 1)] = "Ethernet%d" % (i * 16 + j)
elif hwsku == "Force10-Z9100":
port_alias_to_name_map["fortyGigE1/%d/%d" % (i+1, j+1)] = "Ethernet%d" % (i * 16 + j)
elif hwsku in ["Force10-Z9100-C32", "DellEMC-S5232f-C32"]:
for i in range(0, 128, 4):
port_alias_to_name_map["hundredGigE1/%d" % (i / 4 + 1)] = "Ethernet%d" % i
port_alias_to_name_map["hundredGigE1/%d" % (i/4 + 1)] = "Ethernet%d" % i
elif hwsku == "Arista-7050-QX32":
for i in range(1, 25):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
Expand All @@ -34,12 +34,17 @@ def get_port_alias_to_name_map(hwsku):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 5) * 4)
for i in range(29, 37):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % ((i - 5) * 4)
elif hwsku == "Arista-7260CX3-C64" or hwsku == "Arista-7170-64C":
elif hwsku in ["Arista-7260CX3-C64", "Arista-7170-64C", "Arista-7260CX3-Q64"]:
for i in range(1, 65):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Arista-7060CX-32S-C32" or hwsku == "Arista-7060CX-32S-Q32" or hwsku == "Arista-7060CX-32S-C32-T1" or hwsku == "Arista-7170-32CD-C32":
for i in range(1, 33):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Arista-7050CX3-32S-C32":
for i in range(1, 33):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
for i in range(33, 35):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Mellanox-SN2700-D48C8":
# 50G ports
s50G_ports = [x for x in range(0, 24, 2)] + [x for x in range(40, 88, 2)] + [x for x in range(104, 128, 2)]
Expand All @@ -53,24 +58,61 @@ def get_port_alias_to_name_map(hwsku):
for i in s100G_ports:
alias = "etp%d" % (i / 4 + 1)
port_alias_to_name_map[alias] = "Ethernet%d" % i
elif hwsku == "Mellanox-SN3800-D112C8":
x_ports = [x for x in range(0, 95, 2)]
for i in x_ports:
alias = "etp%d" % (i / 4 + 1) + ("a" if i % 4 == 0 else "b")
# print alias, "Ethernet%d" % i
port_alias_to_name_map[alias] = "Ethernet%d" % i
x_ports = [x for x in range(96, 101, 4)] + [x for x in range(104, 111, 2)] + [x for x in range(112, 117, 4)] + [x for x in range(120, 127, 2)] + [x for x in range(128, 133, 4)] + [x for x in range(136, 143, 2)] + [x for x in range(144, 149, 4)] + [x for x in range(152, 159, 2)]
i = 0
while i < len(x_ports):
for j in range (0, 2):
alias = "etp%d" % (x_ports[i] / 4 + 1)
port_alias_to_name_map[alias] = "Ethernet%d" % x_ports[i]
# print alias, "Ethernet%d" % ports[i]
i += 1
for j in range (0, 2):
alias = "etp%d" % (x_ports[i] / 4 + 1) + "a"
port_alias_to_name_map[alias] = "Ethernet%d" % x_ports[i]
# print alias, "Ethernet%d" % ports[i]
i += 1
alias = "etp%d" % (x_ports[i] / 4 + 1) + "b"
port_alias_to_name_map[alias] = "Ethernet%d" % x_ports[i]
# print alias, "Ethernet%d" % ports[i]
i += 1
x_ports = [x for x in range(160, 255, 2)]
for i in x_ports:
alias = "etp%d" % (i / 4 + 1) + ("a" if i % 4 == 0 else "b")
# print alias, "Ethernet%d" % i
port_alias_to_name_map[alias] = "Ethernet%d" % i
elif hwsku == "Mellanox-SN2700" or hwsku == "ACS-MSN2700":
for i in range(1, 33):
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Arista-7060CX-32S-D48C8":
elif hwsku == "ACS-MSN3800":
for i in range(1, 65):
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku in ["Arista-7060CX-32S-D48C8", "Arista-7050CX3-32S-D48C8"]:
# All possible breakout 50G port numbers:
all_ports = [x for x in range(1, 33)]
all_ports = [ x for x in range(1, 33)]

# 100G ports
s100G_ports = [x for x in range(7, 11)]
s100G_ports += [x for x in range(23, 27)]
s100G_ports = [ x for x in range(7, 11) ]
s100G_ports += [ x for x in range(23, 27) ]

port_alias_to_name_map = _port_alias_to_name_map_50G(all_ports, s100G_ports)
elif hwsku == "Arista-7260CX3-D108C8":
elif hwsku == "Arista-7260CX3-D108C8" or hwsku == "Arista-7260CX3-D108C8-AILAB" or hwsku == "Arista-7260CX3-D108C8-CSI":
# All possible breakout 50G port numbers:
all_ports = [x for x in range(1, 65)]
all_ports = [ x for x in range(1, 65)]

# 100G ports
s100G_ports = [x for x in range(13, 21)]
s100G_ports = [ x for x in range(13, 21) ]

if hwsku == "Arista-7260CX3-D108C8-AILAB":
s100G_ports = [ x for x in range(45, 53) ]
elif hwsku == "Arista-7260CX3-D108C8-CSI":
# Treat 40G port as 100G ports
s100G_ports = [ x for x in range(45, 53) ] + [64]

port_alias_to_name_map = _port_alias_to_name_map_50G(all_ports, s100G_ports)
elif hwsku == "INGRASYS-S9100-C32":
Expand Down Expand Up @@ -104,9 +146,21 @@ def get_port_alias_to_name_map(hwsku):
elif hwsku == "et6448m":
for i in range(0, 52):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
elif hwsku == "Nokia-7215":
for i in range(0, 52):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
elif hwsku == "newport":
for i in range(0, 256, 8):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
elif hwsku in ["Nexus-3132-GE-Q32", "Nexus-3132-GX-Q32"]:
for i in range(1, 33):
port_alias_to_name_map["Ethernet1/%d" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Celestica-DX010-C32":
for i in range(1, 33):
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Celestica-E1031-T48S4":
for i in range(1, 53):
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1))
else:
for i in range(0, 128, 4):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
Expand Down

0 comments on commit ceda81b

Please sign in to comment.