From 78cc024c05481474fedc8f7faa615748d37a6a0f Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Fri, 17 Feb 2017 02:49:11 +0000 Subject: [PATCH 1/3] Combine alias_map.json with port_config.ini --- src/sonic-config-engine/minigraph.py | 35 +++-- .../platform/ACS-MSN2700/alias_map.json | 34 ----- .../platform/Arista-7050-QX32/alias_map.json | 34 ----- .../platform/Arista-7050-QX32/port_config.ini | 66 ++++----- .../platform/Force10-S6000/alias_map.json | 34 ----- .../platform/Force10-S6000/port_config.ini | 66 ++++----- .../platform/Force10-S6100/alias_map.json | 66 --------- .../platform/Force10-S6100/port_config.ini | 130 +++++++++--------- src/sonic-config-engine/setup.py | 2 - src/sonic-config-engine/sonic-cfggen | 19 ++- 10 files changed, 174 insertions(+), 312 deletions(-) delete mode 100644 src/sonic-config-engine/platform/ACS-MSN2700/alias_map.json delete mode 100644 src/sonic-config-engine/platform/Arista-7050-QX32/alias_map.json delete mode 100644 src/sonic-config-engine/platform/Force10-S6000/alias_map.json delete mode 100644 src/sonic-config-engine/platform/Force10-S6100/alias_map.json diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 8560b850c179..317d9c963a33 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -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: + 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')) + 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 diff --git a/src/sonic-config-engine/platform/ACS-MSN2700/alias_map.json b/src/sonic-config-engine/platform/ACS-MSN2700/alias_map.json deleted file mode 100644 index dd1324ae4360..000000000000 --- a/src/sonic-config-engine/platform/ACS-MSN2700/alias_map.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "Ethernet8": "Ethernet8", - "Ethernet0": "Ethernet0", - "Ethernet4": "Ethernet4", - "Ethernet108": "Ethernet108", - "Ethernet100": "Ethernet100", - "Ethernet104": "Ethernet104", - "Ethernet96": "Ethernet96", - "Ethernet124": "Ethernet124", - "Ethernet120": "Ethernet120", - "Ethernet92": "Ethernet92", - "Ethernet28": "Ethernet28", - "Ethernet52": "Ethernet52", - "Ethernet56": "Ethernet56", - "Ethernet76": "Ethernet76", - "Ethernet72": "Ethernet72", - "Ethernet32": "Ethernet32", - "Ethernet16": "Ethernet16", - "Ethernet36": "Ethernet36", - "Ethernet12": "Ethernet12", - "Ethernet88": "Ethernet88", - "Ethernet24": "Ethernet24", - "Ethernet116": "Ethernet116", - "Ethernet80": "Ethernet80", - "Ethernet112": "Ethernet112", - "Ethernet84": "Ethernet84", - "Ethernet48": "Ethernet48", - "Ethernet44": "Ethernet44", - "Ethernet40": "Ethernet40", - "Ethernet64": "Ethernet64", - "Ethernet60": "Ethernet60", - "Ethernet20": "Ethernet20", - "Ethernet68": "Ethernet68" -} \ No newline at end of file diff --git a/src/sonic-config-engine/platform/Arista-7050-QX32/alias_map.json b/src/sonic-config-engine/platform/Arista-7050-QX32/alias_map.json deleted file mode 100644 index 90b35011e2c5..000000000000 --- a/src/sonic-config-engine/platform/Arista-7050-QX32/alias_map.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "Ethernet8": "Ethernet3/1", - "Ethernet0": "Ethernet1/1", - "Ethernet4": "Ethernet2/1", - "Ethernet108": "Ethernet28", - "Ethernet100": "Ethernet26", - "Ethernet104": "Ethernet27", - "Ethernet96": "Ethernet25", - "Ethernet124": "Ethernet32", - "Ethernet120": "Ethernet31", - "Ethernet92": "Ethernet24/1", - "Ethernet28": "Ethernet8/1", - "Ethernet52": "Ethernet14/1", - "Ethernet56": "Ethernet15/1", - "Ethernet76": "Ethernet20/1", - "Ethernet72": "Ethernet19/1", - "Ethernet32": "Ethernet9/1", - "Ethernet16": "Ethernet5/1", - "Ethernet36": "Ethernet10/1", - "Ethernet12": "Ethernet4/1", - "Ethernet88": "Ethernet23/1", - "Ethernet24": "Ethernet7/1", - "Ethernet116": "Ethernet30", - "Ethernet80": "Ethernet21/1", - "Ethernet112": "Ethernet29", - "Ethernet84": "Ethernet22/1", - "Ethernet48": "Ethernet13/1", - "Ethernet44": "Ethernet12/1", - "Ethernet40": "Ethernet11/1", - "Ethernet64": "Ethernet17/1", - "Ethernet60": "Ethernet16/1", - "Ethernet20": "Ethernet6/1", - "Ethernet68": "Ethernet18/1" -} \ No newline at end of file diff --git a/src/sonic-config-engine/platform/Arista-7050-QX32/port_config.ini b/src/sonic-config-engine/platform/Arista-7050-QX32/port_config.ini index ec12639d72bf..8c8042a6e6c5 100644 --- a/src/sonic-config-engine/platform/Arista-7050-QX32/port_config.ini +++ b/src/sonic-config-engine/platform/Arista-7050-QX32/port_config.ini @@ -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 +# alias 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 diff --git a/src/sonic-config-engine/platform/Force10-S6000/alias_map.json b/src/sonic-config-engine/platform/Force10-S6000/alias_map.json deleted file mode 100644 index b58d147f70c3..000000000000 --- a/src/sonic-config-engine/platform/Force10-S6000/alias_map.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "Ethernet8": "fortyGigE0/8", - "Ethernet0": "fortyGigE0/0", - "Ethernet4": "fortyGigE0/4", - "Ethernet108": "fortyGigE0/108", - "Ethernet100": "fortyGigE0/100", - "Ethernet104": "fortyGigE0/104", - "Ethernet96": "fortyGigE0/96", - "Ethernet124": "fortyGigE0/124", - "Ethernet120": "fortyGigE0/120", - "Ethernet92": "fortyGigE0/92", - "Ethernet28": "fortyGigE0/28", - "Ethernet52": "fortyGigE0/52", - "Ethernet56": "fortyGigE0/56", - "Ethernet76": "fortyGigE0/76", - "Ethernet72": "fortyGigE0/72", - "Ethernet32": "fortyGigE0/32", - "Ethernet16": "fortyGigE0/16", - "Ethernet36": "fortyGigE0/36", - "Ethernet12": "fortyGigE0/12", - "Ethernet88": "fortyGigE0/88", - "Ethernet24": "fortyGigE0/24", - "Ethernet116": "fortyGigE0/116", - "Ethernet80": "fortyGigE0/80", - "Ethernet112": "fortyGigE0/112", - "Ethernet84": "fortyGigE0/84", - "Ethernet48": "fortyGigE0/48", - "Ethernet44": "fortyGigE0/44", - "Ethernet40": "fortyGigE0/40", - "Ethernet64": "fortyGigE0/64", - "Ethernet60": "fortyGigE0/60", - "Ethernet20": "fortyGigE0/20", - "Ethernet68": "fortyGigE0/68" -} \ No newline at end of file diff --git a/src/sonic-config-engine/platform/Force10-S6000/port_config.ini b/src/sonic-config-engine/platform/Force10-S6000/port_config.ini index 7161416e4d4c..71430c526302 100644 --- a/src/sonic-config-engine/platform/Force10-S6000/port_config.ini +++ b/src/sonic-config-engine/platform/Force10-S6000/port_config.ini @@ -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 +# alias 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 diff --git a/src/sonic-config-engine/platform/Force10-S6100/alias_map.json b/src/sonic-config-engine/platform/Force10-S6100/alias_map.json deleted file mode 100644 index 19a1ef662d37..000000000000 --- a/src/sonic-config-engine/platform/Force10-S6100/alias_map.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "Ethernet0": "fortyGigE1/1/1", - "Ethernet1": "fortyGigE1/1/2", - "Ethernet2": "fortyGigE1/1/3", - "Ethernet3": "fortyGigE1/1/4", - "Ethernet4": "fortyGigE1/1/5", - "Ethernet5": "fortyGigE1/1/6", - "Ethernet6": "fortyGigE1/1/7", - "Ethernet7": "fortyGigE1/1/8", - "Ethernet8": "fortyGigE1/1/9", - "Ethernet9": "fortyGigE1/1/10", - "Ethernet10": "fortyGigE1/1/11", - "Ethernet11": "fortyGigE1/1/12", - "Ethernet12": "fortyGigE1/1/13", - "Ethernet13": "fortyGigE1/1/14", - "Ethernet14": "fortyGigE1/1/15", - "Ethernet15": "fortyGigE1/1/16", - "Ethernet16": "fortyGigE1/2/1", - "Ethernet17": "fortyGigE1/2/2", - "Ethernet18": "fortyGigE1/2/3", - "Ethernet19": "fortyGigE1/2/4", - "Ethernet20": "fortyGigE1/2/5", - "Ethernet21": "fortyGigE1/2/6", - "Ethernet22": "fortyGigE1/2/7", - "Ethernet23": "fortyGigE1/2/8", - "Ethernet24": "fortyGigE1/2/9", - "Ethernet25": "fortyGigE1/2/10", - "Ethernet26": "fortyGigE1/2/11", - "Ethernet27": "fortyGigE1/2/12", - "Ethernet28": "fortyGigE1/2/13", - "Ethernet29": "fortyGigE1/2/14", - "Ethernet30": "fortyGigE1/2/15", - "Ethernet31": "fortyGigE1/2/16", - "Ethernet32": "fortyGigE1/3/1", - "Ethernet33": "fortyGigE1/3/2", - "Ethernet34": "fortyGigE1/3/3", - "Ethernet34": "fortyGigE1/3/4", - "Ethernet36": "fortyGigE1/3/5", - "Ethernet37": "fortyGigE1/3/6", - "Ethernet38": "fortyGigE1/3/7", - "Ethernet39": "fortyGigE1/3/8", - "Ethernet40": "fortyGigE1/3/9", - "Ethernet41": "fortyGigE1/3/10", - "Ethernet42": "fortyGigE1/3/11", - "Ethernet43": "fortyGigE1/3/12", - "Ethernet44": "fortyGigE1/3/13", - "Ethernet45": "fortyGigE1/3/14", - "Ethernet46": "fortyGigE1/3/15", - "Ethernet47": "fortyGigE1/3/16", - "Ethernet48": "fortyGigE1/4/1", - "Ethernet49": "fortyGigE1/4/2", - "Ethernet50": "fortyGigE1/4/3", - "Ethernet51": "fortyGigE1/4/4", - "Ethernet52": "fortyGigE1/4/5", - "Ethernet53": "fortyGigE1/4/6", - "Ethernet54": "fortyGigE1/4/7", - "Ethernet55": "fortyGigE1/4/8", - "Ethernet56": "fortyGigE1/4/9", - "Ethernet57": "fortyGigE1/4/10", - "Ethernet58": "fortyGigE1/4/11", - "Ethernet59": "fortyGigE1/4/12", - "Ethernet60": "fortyGigE1/4/13", - "Ethernet61": "fortyGigE1/4/14", - "Ethernet62": "fortyGigE1/4/15", - "Ethernet63": "fortyGigE1/4/16" -} diff --git a/src/sonic-config-engine/platform/Force10-S6100/port_config.ini b/src/sonic-config-engine/platform/Force10-S6100/port_config.ini index 67e558963f36..eb268882b782 100644 --- a/src/sonic-config-engine/platform/Force10-S6100/port_config.ini +++ b/src/sonic-config-engine/platform/Force10-S6100/port_config.ini @@ -1,65 +1,65 @@ -# alias lanes -Ethernet0 101,102 -Ethernet1 103,104 -Ethernet2 97,98 -Ethernet3 99,100 -Ethernet4 69,70 -Ethernet5 71,72 -Ethernet6 65,66 -Ethernet7 67,68 -Ethernet8 53,54 -Ethernet9 55,56 -Ethernet10 49,50 -Ethernet11 51,52 -Ethernet12 21,22 -Ethernet13 23,24 -Ethernet14 17,18 -Ethernet15 19,20 -Ethernet16 25,26 -Ethernet17 27,28 -Ethernet18 29,30 -Ethernet19 31,32 -Ethernet20 57,58 -Ethernet21 59,60 -Ethernet22 61,62 -Ethernet23 63,64 -Ethernet24 73,74 -Ethernet25 75,76 -Ethernet26 77,78 -Ethernet27 79,80 -Ethernet28 105,106 -Ethernet29 107,108 -Ethernet30 109,110 -Ethernet31 111,112 -Ethernet32 13,14 -Ethernet33 15,16 -Ethernet34 9,10 -Ethernet35 11,12 -Ethernet36 125,126 -Ethernet37 127,128 -Ethernet38 121,122 -Ethernet39 123,124 -Ethernet40 93,94 -Ethernet41 95,96 -Ethernet42 89,90 -Ethernet43 91,92 -Ethernet44 45,46 -Ethernet45 47,48 -Ethernet46 41,42 -Ethernet47 43,44 -Ethernet48 113,114 -Ethernet49 115,116 -Ethernet50 117,118 -Ethernet51 119,120 -Ethernet52 1,2 -Ethernet53 3,4 -Ethernet54 5,6 -Ethernet55 7,8 -Ethernet56 33,34 -Ethernet57 35,36 -Ethernet58 37,38 -Ethernet59 39,40 -Ethernet60 81,82 -Ethernet61 83,84 -Ethernet62 85,86 -Ethernet63 87,88 +# alias lanes alias +Ethernet0 101,102 fortyGigE1/1/1 +Ethernet1 103,104 fortyGigE1/1/2 +Ethernet2 97,98 fortyGigE1/1/3 +Ethernet3 99,100 fortyGigE1/1/4 +Ethernet4 69,70 fortyGigE1/1/5 +Ethernet5 71,72 fortyGigE1/1/6 +Ethernet6 65,66 fortyGigE1/1/7 +Ethernet7 67,68 fortyGigE1/1/8 +Ethernet8 53,54 fortyGigE1/1/9 +Ethernet9 55,56 fortyGigE1/1/10 +Ethernet10 49,50 fortyGigE1/1/11 +Ethernet11 51,52 fortyGigE1/1/12 +Ethernet12 21,22 fortyGigE1/1/13 +Ethernet13 23,24 fortyGigE1/1/14 +Ethernet14 17,18 fortyGigE1/1/15 +Ethernet15 19,20 fortyGigE1/1/16 +Ethernet16 25,26 fortyGigE1/2/1 +Ethernet17 27,28 fortyGigE1/2/2 +Ethernet18 29,30 fortyGigE1/2/3 +Ethernet19 31,32 fortyGigE1/2/4 +Ethernet20 57,58 fortyGigE1/2/5 +Ethernet21 59,60 fortyGigE1/2/6 +Ethernet22 61,62 fortyGigE1/2/7 +Ethernet23 63,64 fortyGigE1/2/8 +Ethernet24 73,74 fortyGigE1/2/9 +Ethernet25 75,76 fortyGigE1/2/10 +Ethernet26 77,78 fortyGigE1/2/11 +Ethernet27 79,80 fortyGigE1/2/12 +Ethernet28 105,106 fortyGigE1/2/13 +Ethernet29 107,108 fortyGigE1/2/14 +Ethernet30 109,110 fortyGigE1/2/15 +Ethernet31 111,112 fortyGigE1/2/16 +Ethernet32 13,14 fortyGigE1/3/1 +Ethernet33 15,16 fortyGigE1/3/2 +Ethernet34 9,10 fortyGigE1/3/3 +Ethernet35 11,12 fortyGigE1/3/4 +Ethernet36 125,126 fortyGigE1/3/5 +Ethernet37 127,128 fortyGigE1/3/6 +Ethernet38 121,122 fortyGigE1/3/7 +Ethernet39 123,124 fortyGigE1/3/8 +Ethernet40 93,94 fortyGigE1/3/9 +Ethernet41 95,96 fortyGigE1/3/10 +Ethernet42 89,90 fortyGigE1/3/11 +Ethernet43 91,92 fortyGigE1/3/12 +Ethernet44 45,46 fortyGigE1/3/13 +Ethernet45 47,48 fortyGigE1/3/14 +Ethernet46 41,42 fortyGigE1/3/15 +Ethernet47 43,44 fortyGigE1/3/16 +Ethernet48 113,114 fortyGigE1/4/1 +Ethernet49 115,116 fortyGigE1/4/2 +Ethernet50 117,118 fortyGigE1/4/3 +Ethernet51 119,120 fortyGigE1/4/4 +Ethernet52 1,2 fortyGigE1/4/5 +Ethernet53 3,4 fortyGigE1/4/6 +Ethernet54 5,6 fortyGigE1/4/7 +Ethernet55 7,8 fortyGigE1/4/8 +Ethernet56 33,34 fortyGigE1/4/9 +Ethernet57 35,36 fortyGigE1/4/10 +Ethernet58 37,38 fortyGigE1/4/11 +Ethernet59 39,40 fortyGigE1/4/12 +Ethernet60 81,82 fortyGigE1/4/13 +Ethernet61 83,84 fortyGigE1/4/14 +Ethernet62 85,86 fortyGigE1/4/15 +Ethernet63 87,88 fortyGigE1/4/16 diff --git a/src/sonic-config-engine/setup.py b/src/sonic-config-engine/setup.py index 92f1b2f84869..37c61b84ae5f 100644 --- a/src/sonic-config-engine/setup.py +++ b/src/sonic-config-engine/setup.py @@ -10,8 +10,6 @@ def get_platform_file_list(): platforms = os.listdir(data_path) for platform in platforms: files = ['platform/' + platform + '/port_config.ini'] - if os.path.isfile( os.path.join(data_path, platform, 'alias_map.json') ): - files.append('platform/' + platform + '/alias_map.json') #If a platform doesnot have alias_map.json minigraph.py will fall back to no alias mapping if os.path.isfile( os.path.join(data_path, platform, 'sensors.conf') ): files.append('platform/' + platform + '/sensors.conf') #Not all platforms need to have a sensors.conf file data_files.append( (os.path.join('/usr/share/sonic', platform), files) ) diff --git a/src/sonic-config-engine/sonic-cfggen b/src/sonic-config-engine/sonic-cfggen index 01774885b578..bdff7f18e033 100755 --- a/src/sonic-config-engine/sonic-cfggen +++ b/src/sonic-config-engine/sonic-cfggen @@ -34,6 +34,18 @@ def is_ipv6(value): return False return addr.version == 6 +def get_machine_info(): + if not os.path.isfile('/host/machine.conf'): + return None + machine_vars = {} + with open('/host/machine.conf') as machine_file: + for line in machine_file: + tokens = line.split('=') + if len(tokens) < 2: + continue + machine_vars[tokens[0]] = tokens[1].strip() + return machine_vars + def main(): parser=argparse.ArgumentParser(description="Render configuration file from minigraph data and jinja2 template.") @@ -49,10 +61,15 @@ def main(): args = parser.parse_args() data = {} + machine_info = get_machine_info() + data.update(machine_info) if args.minigraph != None: minigraph = args.minigraph - data.update(parse_xml(minigraph)) + if machine_info == None: + data.update(parse_xml(minigraph)) + else: + data.update(parse_xml(minigraph, machine_info['onie_platform'])) if args.yaml != None: with open(args.yaml, 'r') as stream: From b1c9905dedeeb40e9332b8db99e35eb13cd65436 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Fri, 17 Feb 2017 20:43:12 +0000 Subject: [PATCH 2/3] Rename first column in port_config.ini to 'name' --- src/sonic-config-engine/platform/ACS-MSN2700/port_config.ini | 2 +- src/sonic-config-engine/platform/AS7512/port_config.ini | 2 +- .../platform/Arista-7050-QX32/port_config.ini | 2 +- src/sonic-config-engine/platform/Force10-S6000/port_config.ini | 2 +- src/sonic-config-engine/platform/Force10-S6100/port_config.ini | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sonic-config-engine/platform/ACS-MSN2700/port_config.ini b/src/sonic-config-engine/platform/ACS-MSN2700/port_config.ini index ae703f020de6..816bb0e94a70 100644 --- a/src/sonic-config-engine/platform/ACS-MSN2700/port_config.ini +++ b/src/sonic-config-engine/platform/ACS-MSN2700/port_config.ini @@ -1,4 +1,4 @@ -# alias lanes +# name lanes Ethernet0 0,1,2,3 Ethernet4 4,5,6,7 Ethernet8 8,9,10,11 diff --git a/src/sonic-config-engine/platform/AS7512/port_config.ini b/src/sonic-config-engine/platform/AS7512/port_config.ini index c35776dcfcc5..c10cd2786941 100644 --- a/src/sonic-config-engine/platform/AS7512/port_config.ini +++ b/src/sonic-config-engine/platform/AS7512/port_config.ini @@ -1,4 +1,4 @@ -# alias lanes +# name lanes Ethernet0 16,17,18,19 Ethernet4 20,21,22,23 Ethernet8 24,25,26,27 diff --git a/src/sonic-config-engine/platform/Arista-7050-QX32/port_config.ini b/src/sonic-config-engine/platform/Arista-7050-QX32/port_config.ini index 8c8042a6e6c5..b9ab8854a2ec 100644 --- a/src/sonic-config-engine/platform/Arista-7050-QX32/port_config.ini +++ b/src/sonic-config-engine/platform/Arista-7050-QX32/port_config.ini @@ -1,4 +1,4 @@ -# alias lanes alias +# name lanes alias Ethernet0 125,126,127,128 Ethernet1/1 Ethernet4 121,122,123,124 Ethernet2/1 Ethernet8 13,14,15,16 Ethernet3/1 diff --git a/src/sonic-config-engine/platform/Force10-S6000/port_config.ini b/src/sonic-config-engine/platform/Force10-S6000/port_config.ini index 71430c526302..06898f1d7964 100644 --- a/src/sonic-config-engine/platform/Force10-S6000/port_config.ini +++ b/src/sonic-config-engine/platform/Force10-S6000/port_config.ini @@ -1,4 +1,4 @@ -# alias lanes alias +# name lanes alias Ethernet0 29,30,31,32 fortyGigE0/0 Ethernet4 25,26,27,28 fortyGigE0/4 Ethernet8 37,38,39,40 fortyGigE0/8 diff --git a/src/sonic-config-engine/platform/Force10-S6100/port_config.ini b/src/sonic-config-engine/platform/Force10-S6100/port_config.ini index eb268882b782..dcdd6548c198 100644 --- a/src/sonic-config-engine/platform/Force10-S6100/port_config.ini +++ b/src/sonic-config-engine/platform/Force10-S6100/port_config.ini @@ -1,4 +1,4 @@ -# alias lanes alias +# name lanes alias Ethernet0 101,102 fortyGigE1/1/1 Ethernet1 103,104 fortyGigE1/1/2 Ethernet2 97,98 fortyGigE1/1/3 From 4da47f5ecea180e24094c7da33859697c084a70b Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Fri, 17 Feb 2017 20:52:09 +0000 Subject: [PATCH 3/3] Support querying aboot-platform --- src/sonic-config-engine/sonic-cfggen | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sonic-config-engine/sonic-cfggen b/src/sonic-config-engine/sonic-cfggen index bdff7f18e033..18540a548338 100755 --- a/src/sonic-config-engine/sonic-cfggen +++ b/src/sonic-config-engine/sonic-cfggen @@ -63,13 +63,17 @@ def main(): data = {} machine_info = get_machine_info() data.update(machine_info) + if machine_info.has_key('onie_platform'): + data['platform'] = machine_info['onie_platform'] + elif machine_info.has_key('aboot_platform'): + data['platform'] = machine_info['aboot_platform'] if args.minigraph != None: minigraph = args.minigraph - if machine_info == None: - data.update(parse_xml(minigraph)) + if data.has_key('platform'): + data.update(parse_xml(minigraph, data['platform'])) else: - data.update(parse_xml(minigraph, machine_info['onie_platform'])) + data.update(parse_xml(minigraph)) if args.yaml != None: with open(args.yaml, 'r') as stream: