-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combine alias_map.json with port_config.ini #304
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,18 +285,33 @@ def get_mgmt_info(devices, dev, port): | |
|
||
return ret_val | ||
|
||
def get_alias_map_list(hwsku): | ||
alias_map_json = os.path.join('/usr/share/sonic', hwsku, 'alias_map.json') | ||
if not os.path.isfile(alias_map_json): | ||
def get_alias_map_list(hwsku, platform=None): | ||
port_config_candidates = [] | ||
port_config_candidates.append('/usr/share/sonic/sku/port_config.ini') | ||
if platform != None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. platform must not be none #ByDesign There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When called in the container, actually you won't need to know the platform. In reply to: 101695783 [](ancestors = 101695783) |
||
port_config_candidates.append(os.path.join('/usr/share/sonic/device', platform, hwsku, 'port_config.ini')) | ||
port_config_candidates.append(os.path.join('/usr/share/sonic/device', hwsku, 'port_config.ini')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need these candidate? #ByDesign There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For supporting usage in both base os and docker container, and for backward compatibility In reply to: 101695827 [](ancestors = 101695827) |
||
port_config_candidates.append(os.path.join('/usr/share/sonic', hwsku, 'port_config.ini')) | ||
port_config = None | ||
for candidate in port_config_candidates: | ||
if os.path.isfile(candidate): | ||
port_config = candidate | ||
break | ||
if port_config == None: | ||
return None | ||
with open(alias_map_json) as data: | ||
alias_map_dict = json.load(data) | ||
|
||
alias_map_list = [] | ||
for k,v in alias_map_dict.items(): | ||
alias_map_list.append({'sonic': k, 'origin': v}) | ||
with open(port_config) as data: | ||
for line in data: | ||
if line.startswith('#'): | ||
continue | ||
tokens = line.split() | ||
if len(tokens) < 3: | ||
continue | ||
alias_map_list.append({'sonic': tokens[0], 'origin': tokens[2].strip()}) | ||
return alias_map_list | ||
|
||
def parse_xml(filename): | ||
def parse_xml(filename, platform=None): | ||
root = ET.parse(filename).getroot() | ||
mini_graph_path = filename | ||
|
||
|
@@ -322,8 +337,7 @@ def parse_xml(filename): | |
if child.tag == str(hostname_qn): | ||
hostname = child.text | ||
|
||
# port_alias_map maps ngs port name to sonic port name | ||
alias_map_list = get_alias_map_list(hwsku) | ||
alias_map_list = get_alias_map_list(hwsku, platform) | ||
if alias_map_list != None: | ||
for item in alias_map_list: | ||
port_alias_map[item['origin']] = item['sonic'] | ||
|
@@ -373,6 +387,7 @@ def parse_xml(filename): | |
results['minigraph_as_xml'] = mini_graph_path | ||
results['minigraph_console'] = get_console_info(devices, console_dev, console_port) | ||
results['minigraph_mgmt'] = get_mgmt_info(devices, mgmt_dev, mgmt_port) | ||
results['minigraph_hostname'] = hostname | ||
results['inventory_hostname'] = hostname | ||
results['alias_map'] = alias_map_list | ||
|
||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# alias lanes | ||
# name lanes | ||
Ethernet0 0,1,2,3 | ||
Ethernet4 4,5,6,7 | ||
Ethernet8 8,9,10,11 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# alias lanes | ||
# name lanes | ||
Ethernet0 16,17,18,19 | ||
Ethernet4 20,21,22,23 | ||
Ethernet8 24,25,26,27 | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
# alias lanes | ||
Ethernet0 125,126,127,128 | ||
Ethernet4 121,122,123,124 | ||
Ethernet8 13,14,15,16 | ||
Ethernet12 9,10,11,12 | ||
Ethernet16 17,18,19,20 | ||
Ethernet20 21,22,23,24 | ||
Ethernet24 25,26,27,28 | ||
Ethernet28 29,30,31,32 | ||
Ethernet32 37,38,39,40 | ||
Ethernet36 33,34,35,36 | ||
Ethernet40 45,46,47,48 | ||
Ethernet44 41,42,43,44 | ||
Ethernet48 53,54,55,56 | ||
Ethernet52 49,50,51,52 | ||
Ethernet56 69,70,71,72 | ||
Ethernet60 65,66,67,68 | ||
Ethernet64 77,78,79,80 | ||
Ethernet68 73,74,75,76 | ||
Ethernet72 93,94,95,96 | ||
Ethernet76 89,90,91,92 | ||
Ethernet80 101,102,103,104 | ||
Ethernet84 97,98,99,100 | ||
Ethernet88 109,110,111,112 | ||
Ethernet92 105,106,107,108 | ||
Ethernet96 61,62,63,64 | ||
Ethernet100 57,58,59,60 | ||
Ethernet104 81,82,83,84 | ||
Ethernet108 85,86,87,88 | ||
Ethernet112 117,118,119,120 | ||
Ethernet116 113,114,115,116 | ||
Ethernet120 5,6,7,8 | ||
Ethernet124 1,2,3,4 | ||
# name lanes alias | ||
Ethernet0 125,126,127,128 Ethernet1/1 | ||
Ethernet4 121,122,123,124 Ethernet2/1 | ||
Ethernet8 13,14,15,16 Ethernet3/1 | ||
Ethernet12 9,10,11,12 Ethernet4/1 | ||
Ethernet16 17,18,19,20 Ethernet5/1 | ||
Ethernet20 21,22,23,24 Ethernet6/1 | ||
Ethernet24 25,26,27,28 Ethernet7/1 | ||
Ethernet28 29,30,31,32 Ethernet8/1 | ||
Ethernet32 37,38,39,40 Ethernet9/1 | ||
Ethernet36 33,34,35,36 Ethernet10/1 | ||
Ethernet40 45,46,47,48 Ethernet11/1 | ||
Ethernet44 41,42,43,44 Ethernet12/1 | ||
Ethernet48 53,54,55,56 Ethernet13/1 | ||
Ethernet52 49,50,51,52 Ethernet14/1 | ||
Ethernet56 69,70,71,72 Ethernet15/1 | ||
Ethernet60 65,66,67,68 Ethernet16/1 | ||
Ethernet64 77,78,79,80 Ethernet17/1 | ||
Ethernet68 73,74,75,76 Ethernet18/1 | ||
Ethernet72 93,94,95,96 Ethernet19/1 | ||
Ethernet76 89,90,91,92 Ethernet20/1 | ||
Ethernet80 101,102,103,104 Ethernet21/1 | ||
Ethernet84 97,98,99,100 Ethernet22/1 | ||
Ethernet88 109,110,111,112 Ethernet23/1 | ||
Ethernet92 105,106,107,108 Ethernet24/1 | ||
Ethernet96 61,62,63,64 Ethernet25 | ||
Ethernet100 57,58,59,60 Ethernet26 | ||
Ethernet104 81,82,83,84 Ethernet27 | ||
Ethernet108 85,86,87,88 Ethernet28 | ||
Ethernet112 117,118,119,120 Ethernet29 | ||
Ethernet116 113,114,115,116 Ethernet30 | ||
Ethernet120 5,6,7,8 Ethernet31 | ||
Ethernet124 1,2,3,4 Ethernet32 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
# alias lanes | ||
Ethernet0 29,30,31,32 | ||
Ethernet4 25,26,27,28 | ||
Ethernet8 37,38,39,40 | ||
Ethernet12 33,34,35,36 | ||
Ethernet16 41,42,43,44 | ||
Ethernet20 45,46,47,48 | ||
Ethernet24 5,6,7,8 | ||
Ethernet28 1,2,3,4 | ||
Ethernet32 9,10,11,12 | ||
Ethernet36 13,14,15,16 | ||
Ethernet40 21,22,23,24 | ||
Ethernet44 17,18,19,20 | ||
Ethernet48 49,50,51,52 | ||
Ethernet52 53,54,55,56 | ||
Ethernet56 61,62,63,64 | ||
Ethernet60 57,58,59,60 | ||
Ethernet64 65,66,67,68 | ||
Ethernet68 69,70,71,72 | ||
Ethernet72 77,78,79,80 | ||
Ethernet76 73,74,75,76 | ||
Ethernet80 105,106,107,108 | ||
Ethernet84 109,110,111,112 | ||
Ethernet88 117,118,119,120 | ||
Ethernet92 113,114,115,116 | ||
Ethernet96 121,122,123,124 | ||
Ethernet100 125,126,127,128 | ||
Ethernet104 85,86,87,88 | ||
Ethernet108 81,82,83,84 | ||
Ethernet112 89,90,91,92 | ||
Ethernet116 93,94,95,96 | ||
Ethernet120 97,98,99,100 | ||
Ethernet124 101,102,103,104 | ||
# name lanes alias | ||
Ethernet0 29,30,31,32 fortyGigE0/0 | ||
Ethernet4 25,26,27,28 fortyGigE0/4 | ||
Ethernet8 37,38,39,40 fortyGigE0/8 | ||
Ethernet12 33,34,35,36 fortyGigE0/12 | ||
Ethernet16 41,42,43,44 fortyGigE0/16 | ||
Ethernet20 45,46,47,48 fortyGigE0/20 | ||
Ethernet24 5,6,7,8 fortyGigE0/24 | ||
Ethernet28 1,2,3,4 fortyGigE0/28 | ||
Ethernet32 9,10,11,12 fortyGigE0/32 | ||
Ethernet36 13,14,15,16 fortyGigE0/36 | ||
Ethernet40 21,22,23,24 fortyGigE0/40 | ||
Ethernet44 17,18,19,20 fortyGigE0/44 | ||
Ethernet48 49,50,51,52 fortyGigE0/48 | ||
Ethernet52 53,54,55,56 fortyGigE0/52 | ||
Ethernet56 61,62,63,64 fortyGigE0/56 | ||
Ethernet60 57,58,59,60 fortyGigE0/60 | ||
Ethernet64 65,66,67,68 fortyGigE0/64 | ||
Ethernet68 69,70,71,72 fortyGigE0/68 | ||
Ethernet72 77,78,79,80 fortyGigE0/72 | ||
Ethernet76 73,74,75,76 fortyGigE0/76 | ||
Ethernet80 105,106,107,108 fortyGigE0/80 | ||
Ethernet84 109,110,111,112 fortyGigE0/84 | ||
Ethernet88 117,118,119,120 fortyGigE0/88 | ||
Ethernet92 113,114,115,116 fortyGigE0/92 | ||
Ethernet96 121,122,123,124 fortyGigE0/96 | ||
Ethernet100 125,126,127,128 fortyGigE0/100 | ||
Ethernet104 85,86,87,88 fortyGigE0/104 | ||
Ethernet108 81,82,83,84 fortyGigE0/108 | ||
Ethernet112 89,90,91,92 fortyGigE0/112 | ||
Ethernet116 93,94,95,96 fortyGigE0/116 | ||
Ethernet120 97,98,99,100 fortyGigE0/120 | ||
Ethernet124 101,102,103,104 fortyGigE0/124 |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to this? #Pending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't get your question.
In reply to: 101696721 [](ancestors = 101696721)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now, I understand.