Skip to content

Commit 2d0b41a

Browse files
authored
Combine alias_map.json with port_config.ini (#304)
* Combine alias_map.json with port_config.ini
1 parent f9f31ed commit 2d0b41a

12 files changed

Lines changed: 180 additions & 314 deletions

File tree

src/sonic-config-engine/minigraph.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,18 +285,33 @@ def get_mgmt_info(devices, dev, port):
285285

286286
return ret_val
287287

288-
def get_alias_map_list(hwsku):
289-
alias_map_json = os.path.join('/usr/share/sonic', hwsku, 'alias_map.json')
290-
if not os.path.isfile(alias_map_json):
288+
def get_alias_map_list(hwsku, platform=None):
289+
port_config_candidates = []
290+
port_config_candidates.append('/usr/share/sonic/sku/port_config.ini')
291+
if platform != None:
292+
port_config_candidates.append(os.path.join('/usr/share/sonic/device', platform, hwsku, 'port_config.ini'))
293+
port_config_candidates.append(os.path.join('/usr/share/sonic/device', hwsku, 'port_config.ini'))
294+
port_config_candidates.append(os.path.join('/usr/share/sonic', hwsku, 'port_config.ini'))
295+
port_config = None
296+
for candidate in port_config_candidates:
297+
if os.path.isfile(candidate):
298+
port_config = candidate
299+
break
300+
if port_config == None:
291301
return None
292-
with open(alias_map_json) as data:
293-
alias_map_dict = json.load(data)
302+
294303
alias_map_list = []
295-
for k,v in alias_map_dict.items():
296-
alias_map_list.append({'sonic': k, 'origin': v})
304+
with open(port_config) as data:
305+
for line in data:
306+
if line.startswith('#'):
307+
continue
308+
tokens = line.split()
309+
if len(tokens) < 3:
310+
continue
311+
alias_map_list.append({'sonic': tokens[0], 'origin': tokens[2].strip()})
297312
return alias_map_list
298313

299-
def parse_xml(filename):
314+
def parse_xml(filename, platform=None):
300315
root = ET.parse(filename).getroot()
301316
mini_graph_path = filename
302317

@@ -322,8 +337,7 @@ def parse_xml(filename):
322337
if child.tag == str(hostname_qn):
323338
hostname = child.text
324339

325-
# port_alias_map maps ngs port name to sonic port name
326-
alias_map_list = get_alias_map_list(hwsku)
340+
alias_map_list = get_alias_map_list(hwsku, platform)
327341
if alias_map_list != None:
328342
for item in alias_map_list:
329343
port_alias_map[item['origin']] = item['sonic']
@@ -373,6 +387,7 @@ def parse_xml(filename):
373387
results['minigraph_as_xml'] = mini_graph_path
374388
results['minigraph_console'] = get_console_info(devices, console_dev, console_port)
375389
results['minigraph_mgmt'] = get_mgmt_info(devices, mgmt_dev, mgmt_port)
390+
results['minigraph_hostname'] = hostname
376391
results['inventory_hostname'] = hostname
377392
results['alias_map'] = alias_map_list
378393

src/sonic-config-engine/platform/ACS-MSN2700/alias_map.json

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/sonic-config-engine/platform/ACS-MSN2700/port_config.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# alias lanes
1+
# name lanes
22
Ethernet0 0,1,2,3
33
Ethernet4 4,5,6,7
44
Ethernet8 8,9,10,11

src/sonic-config-engine/platform/AS7512/port_config.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# alias lanes
1+
# name lanes
22
Ethernet0 16,17,18,19
33
Ethernet4 20,21,22,23
44
Ethernet8 24,25,26,27

src/sonic-config-engine/platform/Arista-7050-QX32/alias_map.json

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
# alias lanes
2-
Ethernet0 125,126,127,128
3-
Ethernet4 121,122,123,124
4-
Ethernet8 13,14,15,16
5-
Ethernet12 9,10,11,12
6-
Ethernet16 17,18,19,20
7-
Ethernet20 21,22,23,24
8-
Ethernet24 25,26,27,28
9-
Ethernet28 29,30,31,32
10-
Ethernet32 37,38,39,40
11-
Ethernet36 33,34,35,36
12-
Ethernet40 45,46,47,48
13-
Ethernet44 41,42,43,44
14-
Ethernet48 53,54,55,56
15-
Ethernet52 49,50,51,52
16-
Ethernet56 69,70,71,72
17-
Ethernet60 65,66,67,68
18-
Ethernet64 77,78,79,80
19-
Ethernet68 73,74,75,76
20-
Ethernet72 93,94,95,96
21-
Ethernet76 89,90,91,92
22-
Ethernet80 101,102,103,104
23-
Ethernet84 97,98,99,100
24-
Ethernet88 109,110,111,112
25-
Ethernet92 105,106,107,108
26-
Ethernet96 61,62,63,64
27-
Ethernet100 57,58,59,60
28-
Ethernet104 81,82,83,84
29-
Ethernet108 85,86,87,88
30-
Ethernet112 117,118,119,120
31-
Ethernet116 113,114,115,116
32-
Ethernet120 5,6,7,8
33-
Ethernet124 1,2,3,4
1+
# name lanes alias
2+
Ethernet0 125,126,127,128 Ethernet1/1
3+
Ethernet4 121,122,123,124 Ethernet2/1
4+
Ethernet8 13,14,15,16 Ethernet3/1
5+
Ethernet12 9,10,11,12 Ethernet4/1
6+
Ethernet16 17,18,19,20 Ethernet5/1
7+
Ethernet20 21,22,23,24 Ethernet6/1
8+
Ethernet24 25,26,27,28 Ethernet7/1
9+
Ethernet28 29,30,31,32 Ethernet8/1
10+
Ethernet32 37,38,39,40 Ethernet9/1
11+
Ethernet36 33,34,35,36 Ethernet10/1
12+
Ethernet40 45,46,47,48 Ethernet11/1
13+
Ethernet44 41,42,43,44 Ethernet12/1
14+
Ethernet48 53,54,55,56 Ethernet13/1
15+
Ethernet52 49,50,51,52 Ethernet14/1
16+
Ethernet56 69,70,71,72 Ethernet15/1
17+
Ethernet60 65,66,67,68 Ethernet16/1
18+
Ethernet64 77,78,79,80 Ethernet17/1
19+
Ethernet68 73,74,75,76 Ethernet18/1
20+
Ethernet72 93,94,95,96 Ethernet19/1
21+
Ethernet76 89,90,91,92 Ethernet20/1
22+
Ethernet80 101,102,103,104 Ethernet21/1
23+
Ethernet84 97,98,99,100 Ethernet22/1
24+
Ethernet88 109,110,111,112 Ethernet23/1
25+
Ethernet92 105,106,107,108 Ethernet24/1
26+
Ethernet96 61,62,63,64 Ethernet25
27+
Ethernet100 57,58,59,60 Ethernet26
28+
Ethernet104 81,82,83,84 Ethernet27
29+
Ethernet108 85,86,87,88 Ethernet28
30+
Ethernet112 117,118,119,120 Ethernet29
31+
Ethernet116 113,114,115,116 Ethernet30
32+
Ethernet120 5,6,7,8 Ethernet31
33+
Ethernet124 1,2,3,4 Ethernet32

src/sonic-config-engine/platform/Force10-S6000/alias_map.json

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
# alias lanes
2-
Ethernet0 29,30,31,32
3-
Ethernet4 25,26,27,28
4-
Ethernet8 37,38,39,40
5-
Ethernet12 33,34,35,36
6-
Ethernet16 41,42,43,44
7-
Ethernet20 45,46,47,48
8-
Ethernet24 5,6,7,8
9-
Ethernet28 1,2,3,4
10-
Ethernet32 9,10,11,12
11-
Ethernet36 13,14,15,16
12-
Ethernet40 21,22,23,24
13-
Ethernet44 17,18,19,20
14-
Ethernet48 49,50,51,52
15-
Ethernet52 53,54,55,56
16-
Ethernet56 61,62,63,64
17-
Ethernet60 57,58,59,60
18-
Ethernet64 65,66,67,68
19-
Ethernet68 69,70,71,72
20-
Ethernet72 77,78,79,80
21-
Ethernet76 73,74,75,76
22-
Ethernet80 105,106,107,108
23-
Ethernet84 109,110,111,112
24-
Ethernet88 117,118,119,120
25-
Ethernet92 113,114,115,116
26-
Ethernet96 121,122,123,124
27-
Ethernet100 125,126,127,128
28-
Ethernet104 85,86,87,88
29-
Ethernet108 81,82,83,84
30-
Ethernet112 89,90,91,92
31-
Ethernet116 93,94,95,96
32-
Ethernet120 97,98,99,100
33-
Ethernet124 101,102,103,104
1+
# name lanes alias
2+
Ethernet0 29,30,31,32 fortyGigE0/0
3+
Ethernet4 25,26,27,28 fortyGigE0/4
4+
Ethernet8 37,38,39,40 fortyGigE0/8
5+
Ethernet12 33,34,35,36 fortyGigE0/12
6+
Ethernet16 41,42,43,44 fortyGigE0/16
7+
Ethernet20 45,46,47,48 fortyGigE0/20
8+
Ethernet24 5,6,7,8 fortyGigE0/24
9+
Ethernet28 1,2,3,4 fortyGigE0/28
10+
Ethernet32 9,10,11,12 fortyGigE0/32
11+
Ethernet36 13,14,15,16 fortyGigE0/36
12+
Ethernet40 21,22,23,24 fortyGigE0/40
13+
Ethernet44 17,18,19,20 fortyGigE0/44
14+
Ethernet48 49,50,51,52 fortyGigE0/48
15+
Ethernet52 53,54,55,56 fortyGigE0/52
16+
Ethernet56 61,62,63,64 fortyGigE0/56
17+
Ethernet60 57,58,59,60 fortyGigE0/60
18+
Ethernet64 65,66,67,68 fortyGigE0/64
19+
Ethernet68 69,70,71,72 fortyGigE0/68
20+
Ethernet72 77,78,79,80 fortyGigE0/72
21+
Ethernet76 73,74,75,76 fortyGigE0/76
22+
Ethernet80 105,106,107,108 fortyGigE0/80
23+
Ethernet84 109,110,111,112 fortyGigE0/84
24+
Ethernet88 117,118,119,120 fortyGigE0/88
25+
Ethernet92 113,114,115,116 fortyGigE0/92
26+
Ethernet96 121,122,123,124 fortyGigE0/96
27+
Ethernet100 125,126,127,128 fortyGigE0/100
28+
Ethernet104 85,86,87,88 fortyGigE0/104
29+
Ethernet108 81,82,83,84 fortyGigE0/108
30+
Ethernet112 89,90,91,92 fortyGigE0/112
31+
Ethernet116 93,94,95,96 fortyGigE0/116
32+
Ethernet120 97,98,99,100 fortyGigE0/120
33+
Ethernet124 101,102,103,104 fortyGigE0/124

src/sonic-config-engine/platform/Force10-S6100/alias_map.json

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)