Skip to content

Commit ceda81b

Browse files
lolyusonic-build
authored andcommitted
Merged PR 3932212: [minigraph_facts] Fix conflicts
[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 <[email protected]>
1 parent dab2153 commit ceda81b

File tree

2 files changed

+66
-161
lines changed

2 files changed

+66
-161
lines changed

ansible/library/minigraph_facts.py

Lines changed: 1 addition & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -466,156 +466,7 @@ def parse_xml(filename, hostname):
466466

467467
global port_alias_to_name_map
468468

469-
if hwsku == "Force10-S6000":
470-
for i in range(0, 128, 4):
471-
port_alias_to_name_map["fortyGigE0/%d" % i] = "Ethernet%d" % i
472-
elif hwsku == "Force10-S6100":
473-
for i in range(0, 4):
474-
for j in range(0, 16):
475-
port_alias_to_name_map["fortyGigE1/%d/%d" % (i+1, j+1)] = "Ethernet%d" % (i * 16 + j)
476-
elif hwsku in ["Force10-Z9100-C32", "DellEMC-S5232f-C32"]:
477-
for i in range(0, 128, 4):
478-
port_alias_to_name_map["hundredGigE1/%d" % (i/4 + 1)] = "Ethernet%d" % i
479-
elif hwsku == "Arista-7050-QX32":
480-
for i in range(1, 25):
481-
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
482-
for i in range(25, 33):
483-
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % ((i - 1) * 4)
484-
elif hwsku == "Arista-7050-QX-32S":
485-
for i in range(5, 29):
486-
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 5) * 4)
487-
for i in range(29, 37):
488-
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % ((i - 5) * 4)
489-
elif hwsku in ["Arista-7260CX3-C64", "Arista-7170-64C", "Arista-7260CX3-Q64"]:
490-
for i in range(1, 65):
491-
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
492-
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":
493-
for i in range(1, 33):
494-
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
495-
elif hwsku == "Arista-7050CX3-32S-C32":
496-
for i in range(1, 33):
497-
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
498-
for i in range(33, 35):
499-
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % ((i - 1) * 4)
500-
elif hwsku == "Mellanox-SN2700-D48C8":
501-
# 50G ports
502-
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)]
503-
504-
# 100G ports
505-
s100G_ports = [x for x in range(24, 40, 4)] + [x for x in range(88, 104, 4)]
506-
507-
for i in s50G_ports:
508-
alias = "etp%d" % (i / 4 + 1) + ("a" if i % 4 == 0 else "b")
509-
port_alias_to_name_map[alias] = "Ethernet%d" % i
510-
for i in s100G_ports:
511-
alias = "etp%d" % (i / 4 + 1)
512-
port_alias_to_name_map[alias] = "Ethernet%d" % i
513-
elif hwsku == "Mellanox-SN3800-D112C8":
514-
x_ports = [x for x in range(0, 95, 2)]
515-
for i in x_ports:
516-
alias = "etp%d" % (i / 4 + 1) + ("a" if i % 4 == 0 else "b")
517-
# print alias, "Ethernet%d" % i
518-
port_alias_to_name_map[alias] = "Ethernet%d" % i
519-
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)]
520-
i = 0
521-
while i < len(x_ports):
522-
for j in range (0, 2):
523-
alias = "etp%d" % (x_ports[i] / 4 + 1)
524-
port_alias_to_name_map[alias] = "Ethernet%d" % x_ports[i]
525-
# print alias, "Ethernet%d" % ports[i]
526-
i += 1
527-
for j in range (0, 2):
528-
alias = "etp%d" % (x_ports[i] / 4 + 1) + "a"
529-
port_alias_to_name_map[alias] = "Ethernet%d" % x_ports[i]
530-
# print alias, "Ethernet%d" % ports[i]
531-
i += 1
532-
alias = "etp%d" % (x_ports[i] / 4 + 1) + "b"
533-
port_alias_to_name_map[alias] = "Ethernet%d" % x_ports[i]
534-
# print alias, "Ethernet%d" % ports[i]
535-
i += 1
536-
x_ports = [x for x in range(160, 255, 2)]
537-
for i in x_ports:
538-
alias = "etp%d" % (i / 4 + 1) + ("a" if i % 4 == 0 else "b")
539-
# print alias, "Ethernet%d" % i
540-
port_alias_to_name_map[alias] = "Ethernet%d" % i
541-
elif hwsku == "Mellanox-SN2700" or hwsku == "ACS-MSN2700":
542-
for i in range(1, 33):
543-
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1) * 4)
544-
elif hwsku == "ACS-MSN3800":
545-
for i in range(1, 65):
546-
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1) * 4)
547-
elif hwsku in ["Arista-7060CX-32S-D48C8", "Arista-7050CX3-32S-D48C8"]:
548-
# All possible breakout 50G port numbers:
549-
all_ports = [ x for x in range(1, 33)]
550-
551-
# 100G ports
552-
s100G_ports = [ x for x in range(7, 11) ]
553-
s100G_ports += [ x for x in range(23, 27) ]
554-
555-
port_alias_to_name_map = port_alias_to_name_map_50G(all_ports, s100G_ports)
556-
elif hwsku == "Arista-7260CX3-D108C8" or hwsku == "Arista-7260CX3-D108C8-AILAB" or hwsku == "Arista-7260CX3-D108C8-CSI":
557-
# All possible breakout 50G port numbers:
558-
all_ports = [ x for x in range(1, 65)]
559-
560-
# 100G ports
561-
s100G_ports = [ x for x in range(13, 21) ]
562-
563-
if hwsku == "Arista-7260CX3-D108C8-AILAB":
564-
s100G_ports = [ x for x in range(45, 53) ]
565-
elif hwsku == "Arista-7260CX3-D108C8-CSI":
566-
# Treat 40G port as 100G ports
567-
s100G_ports = [ x for x in range(45, 53) ] + [64]
568-
569-
port_alias_to_name_map = port_alias_to_name_map_50G(all_ports, s100G_ports)
570-
elif hwsku == "INGRASYS-S9100-C32":
571-
for i in range(1, 33):
572-
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
573-
elif hwsku == "INGRASYS-S9100-C32" or hwsku == "INGRASYS-S9130-32X" or hwsku == "INGRASYS-S8810-32Q":
574-
for i in range(1, 33):
575-
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
576-
elif hwsku == "INGRASYS-S8900-54XC":
577-
for i in range(1, 49):
578-
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % (i - 1)
579-
for i in range(49, 55):
580-
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 49) * 4 + 48)
581-
elif hwsku == "INGRASYS-S8900-64XC":
582-
for i in range(1, 49):
583-
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % (i - 1)
584-
for i in range(49, 65):
585-
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 49) * 4 + 48)
586-
elif hwsku == "Accton-AS7712-32X":
587-
for i in range(1, 33):
588-
port_alias_to_name_map["hundredGigE%d" % i] = "Ethernet%d" % ((i - 1) * 4)
589-
elif hwsku == "Celestica-DX010-C32":
590-
for i in range(1, 33):
591-
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1) * 4)
592-
elif hwsku == "Seastone-DX010":
593-
for i in range(1, 33):
594-
port_alias_to_name_map["Eth%d" % i] = "Ethernet%d" % ((i - 1) * 4)
595-
elif hwsku == "Celestica-E1031-T48S4":
596-
for i in range(1, 53):
597-
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1))
598-
elif hwsku == "et6448m":
599-
for i in range(0, 52):
600-
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
601-
elif hwsku == "Nokia-7215":
602-
for i in range(0, 52):
603-
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
604-
elif hwsku == "newport":
605-
for i in range(0, 256, 8):
606-
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
607-
elif hwsku in ["Nexus-3132-GE-Q32", "Nexus-3132-GX-Q32"]:
608-
for i in range(1, 33):
609-
port_alias_to_name_map["Ethernet1/%d" % i] = "Ethernet%d" % ((i - 1) * 4)
610-
elif hwsku == "Celestica-DX010-C32":
611-
for i in range(1, 33):
612-
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1) * 4)
613-
elif hwsku == "Celestica-E1031-T48S4":
614-
for i in range(1, 53):
615-
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1))
616-
else:
617-
for i in range(0, 128, 4):
618-
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
469+
port_alias_to_name_map = get_port_alias_to_name_map(hwsku)
619470

620471
for child in root:
621472
if child.tag == str(QName(ns, "DpgDec")):

ansible/module_utils/port_utils.py

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ def get_port_alias_to_name_map(hwsku):
2020
elif hwsku == "Force10-S6100":
2121
for i in range(0, 4):
2222
for j in range(0, 16):
23-
port_alias_to_name_map["fortyGigE1/%d/%d" % (i + 1, j + 1)] = "Ethernet%d" % (i * 16 + j)
24-
elif hwsku == "Force10-Z9100":
23+
port_alias_to_name_map["fortyGigE1/%d/%d" % (i+1, j+1)] = "Ethernet%d" % (i * 16 + j)
24+
elif hwsku in ["Force10-Z9100-C32", "DellEMC-S5232f-C32"]:
2525
for i in range(0, 128, 4):
26-
port_alias_to_name_map["hundredGigE1/%d" % (i / 4 + 1)] = "Ethernet%d" % i
26+
port_alias_to_name_map["hundredGigE1/%d" % (i/4 + 1)] = "Ethernet%d" % i
2727
elif hwsku == "Arista-7050-QX32":
2828
for i in range(1, 25):
2929
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
@@ -34,12 +34,17 @@ def get_port_alias_to_name_map(hwsku):
3434
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 5) * 4)
3535
for i in range(29, 37):
3636
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % ((i - 5) * 4)
37-
elif hwsku == "Arista-7260CX3-C64" or hwsku == "Arista-7170-64C":
37+
elif hwsku in ["Arista-7260CX3-C64", "Arista-7170-64C", "Arista-7260CX3-Q64"]:
3838
for i in range(1, 65):
3939
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
4040
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":
4141
for i in range(1, 33):
4242
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
43+
elif hwsku == "Arista-7050CX3-32S-C32":
44+
for i in range(1, 33):
45+
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
46+
for i in range(33, 35):
47+
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % ((i - 1) * 4)
4348
elif hwsku == "Mellanox-SN2700-D48C8":
4449
# 50G ports
4550
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)]
@@ -53,24 +58,61 @@ def get_port_alias_to_name_map(hwsku):
5358
for i in s100G_ports:
5459
alias = "etp%d" % (i / 4 + 1)
5560
port_alias_to_name_map[alias] = "Ethernet%d" % i
61+
elif hwsku == "Mellanox-SN3800-D112C8":
62+
x_ports = [x for x in range(0, 95, 2)]
63+
for i in x_ports:
64+
alias = "etp%d" % (i / 4 + 1) + ("a" if i % 4 == 0 else "b")
65+
# print alias, "Ethernet%d" % i
66+
port_alias_to_name_map[alias] = "Ethernet%d" % i
67+
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)]
68+
i = 0
69+
while i < len(x_ports):
70+
for j in range (0, 2):
71+
alias = "etp%d" % (x_ports[i] / 4 + 1)
72+
port_alias_to_name_map[alias] = "Ethernet%d" % x_ports[i]
73+
# print alias, "Ethernet%d" % ports[i]
74+
i += 1
75+
for j in range (0, 2):
76+
alias = "etp%d" % (x_ports[i] / 4 + 1) + "a"
77+
port_alias_to_name_map[alias] = "Ethernet%d" % x_ports[i]
78+
# print alias, "Ethernet%d" % ports[i]
79+
i += 1
80+
alias = "etp%d" % (x_ports[i] / 4 + 1) + "b"
81+
port_alias_to_name_map[alias] = "Ethernet%d" % x_ports[i]
82+
# print alias, "Ethernet%d" % ports[i]
83+
i += 1
84+
x_ports = [x for x in range(160, 255, 2)]
85+
for i in x_ports:
86+
alias = "etp%d" % (i / 4 + 1) + ("a" if i % 4 == 0 else "b")
87+
# print alias, "Ethernet%d" % i
88+
port_alias_to_name_map[alias] = "Ethernet%d" % i
5689
elif hwsku == "Mellanox-SN2700" or hwsku == "ACS-MSN2700":
5790
for i in range(1, 33):
5891
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1) * 4)
59-
elif hwsku == "Arista-7060CX-32S-D48C8":
92+
elif hwsku == "ACS-MSN3800":
93+
for i in range(1, 65):
94+
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1) * 4)
95+
elif hwsku in ["Arista-7060CX-32S-D48C8", "Arista-7050CX3-32S-D48C8"]:
6096
# All possible breakout 50G port numbers:
61-
all_ports = [x for x in range(1, 33)]
97+
all_ports = [ x for x in range(1, 33)]
6298

6399
# 100G ports
64-
s100G_ports = [x for x in range(7, 11)]
65-
s100G_ports += [x for x in range(23, 27)]
100+
s100G_ports = [ x for x in range(7, 11) ]
101+
s100G_ports += [ x for x in range(23, 27) ]
66102

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

72108
# 100G ports
73-
s100G_ports = [x for x in range(13, 21)]
109+
s100G_ports = [ x for x in range(13, 21) ]
110+
111+
if hwsku == "Arista-7260CX3-D108C8-AILAB":
112+
s100G_ports = [ x for x in range(45, 53) ]
113+
elif hwsku == "Arista-7260CX3-D108C8-CSI":
114+
# Treat 40G port as 100G ports
115+
s100G_ports = [ x for x in range(45, 53) ] + [64]
74116

75117
port_alias_to_name_map = _port_alias_to_name_map_50G(all_ports, s100G_ports)
76118
elif hwsku == "INGRASYS-S9100-C32":
@@ -104,9 +146,21 @@ def get_port_alias_to_name_map(hwsku):
104146
elif hwsku == "et6448m":
105147
for i in range(0, 52):
106148
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
149+
elif hwsku == "Nokia-7215":
150+
for i in range(0, 52):
151+
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
107152
elif hwsku == "newport":
108153
for i in range(0, 256, 8):
109154
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
155+
elif hwsku in ["Nexus-3132-GE-Q32", "Nexus-3132-GX-Q32"]:
156+
for i in range(1, 33):
157+
port_alias_to_name_map["Ethernet1/%d" % i] = "Ethernet%d" % ((i - 1) * 4)
158+
elif hwsku == "Celestica-DX010-C32":
159+
for i in range(1, 33):
160+
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1) * 4)
161+
elif hwsku == "Celestica-E1031-T48S4":
162+
for i in range(1, 53):
163+
port_alias_to_name_map["etp%d" % i] = "Ethernet%d" % ((i - 1))
110164
else:
111165
for i in range(0, 128, 4):
112166
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i

0 commit comments

Comments
 (0)