Combine alias_map.json with port_config.ini (#304)

* Combine alias_map.json with port_config.ini
This commit is contained in:
Taoyu Li 2017-02-17 13:03:42 -08:00 committed by GitHub
parent f9f31ed296
commit 2d0b41a340
12 changed files with 180 additions and 314 deletions

View File

@ -285,18 +285,33 @@ def get_mgmt_info(devices, dev, port):
return ret_val return ret_val
def get_alias_map_list(hwsku): def get_alias_map_list(hwsku, platform=None):
alias_map_json = os.path.join('/usr/share/sonic', hwsku, 'alias_map.json') port_config_candidates = []
if not os.path.isfile(alias_map_json): 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 return None
with open(alias_map_json) as data:
alias_map_dict = json.load(data)
alias_map_list = [] alias_map_list = []
for k,v in alias_map_dict.items(): with open(port_config) as data:
alias_map_list.append({'sonic': k, 'origin': v}) 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 return alias_map_list
def parse_xml(filename): def parse_xml(filename, platform=None):
root = ET.parse(filename).getroot() root = ET.parse(filename).getroot()
mini_graph_path = filename mini_graph_path = filename
@ -322,8 +337,7 @@ def parse_xml(filename):
if child.tag == str(hostname_qn): if child.tag == str(hostname_qn):
hostname = child.text hostname = child.text
# port_alias_map maps ngs port name to sonic port name alias_map_list = get_alias_map_list(hwsku, platform)
alias_map_list = get_alias_map_list(hwsku)
if alias_map_list != None: if alias_map_list != None:
for item in alias_map_list: for item in alias_map_list:
port_alias_map[item['origin']] = item['sonic'] port_alias_map[item['origin']] = item['sonic']
@ -373,6 +387,7 @@ def parse_xml(filename):
results['minigraph_as_xml'] = mini_graph_path results['minigraph_as_xml'] = mini_graph_path
results['minigraph_console'] = get_console_info(devices, console_dev, console_port) results['minigraph_console'] = get_console_info(devices, console_dev, console_port)
results['minigraph_mgmt'] = get_mgmt_info(devices, mgmt_dev, mgmt_port) results['minigraph_mgmt'] = get_mgmt_info(devices, mgmt_dev, mgmt_port)
results['minigraph_hostname'] = hostname
results['inventory_hostname'] = hostname results['inventory_hostname'] = hostname
results['alias_map'] = alias_map_list results['alias_map'] = alias_map_list

View File

@ -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"
}

View File

@ -1,4 +1,4 @@
# alias lanes # name lanes
Ethernet0 0,1,2,3 Ethernet0 0,1,2,3
Ethernet4 4,5,6,7 Ethernet4 4,5,6,7
Ethernet8 8,9,10,11 Ethernet8 8,9,10,11

View File

@ -1,4 +1,4 @@
# alias lanes # name lanes
Ethernet0 16,17,18,19 Ethernet0 16,17,18,19
Ethernet4 20,21,22,23 Ethernet4 20,21,22,23
Ethernet8 24,25,26,27 Ethernet8 24,25,26,27

View File

@ -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"
}

View File

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

View File

@ -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"
}

View File

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

View File

@ -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"
}

View File

@ -1,65 +1,65 @@
# alias lanes # name lanes alias
Ethernet0 101,102 Ethernet0 101,102 fortyGigE1/1/1
Ethernet1 103,104 Ethernet1 103,104 fortyGigE1/1/2
Ethernet2 97,98 Ethernet2 97,98 fortyGigE1/1/3
Ethernet3 99,100 Ethernet3 99,100 fortyGigE1/1/4
Ethernet4 69,70 Ethernet4 69,70 fortyGigE1/1/5
Ethernet5 71,72 Ethernet5 71,72 fortyGigE1/1/6
Ethernet6 65,66 Ethernet6 65,66 fortyGigE1/1/7
Ethernet7 67,68 Ethernet7 67,68 fortyGigE1/1/8
Ethernet8 53,54 Ethernet8 53,54 fortyGigE1/1/9
Ethernet9 55,56 Ethernet9 55,56 fortyGigE1/1/10
Ethernet10 49,50 Ethernet10 49,50 fortyGigE1/1/11
Ethernet11 51,52 Ethernet11 51,52 fortyGigE1/1/12
Ethernet12 21,22 Ethernet12 21,22 fortyGigE1/1/13
Ethernet13 23,24 Ethernet13 23,24 fortyGigE1/1/14
Ethernet14 17,18 Ethernet14 17,18 fortyGigE1/1/15
Ethernet15 19,20 Ethernet15 19,20 fortyGigE1/1/16
Ethernet16 25,26 Ethernet16 25,26 fortyGigE1/2/1
Ethernet17 27,28 Ethernet17 27,28 fortyGigE1/2/2
Ethernet18 29,30 Ethernet18 29,30 fortyGigE1/2/3
Ethernet19 31,32 Ethernet19 31,32 fortyGigE1/2/4
Ethernet20 57,58 Ethernet20 57,58 fortyGigE1/2/5
Ethernet21 59,60 Ethernet21 59,60 fortyGigE1/2/6
Ethernet22 61,62 Ethernet22 61,62 fortyGigE1/2/7
Ethernet23 63,64 Ethernet23 63,64 fortyGigE1/2/8
Ethernet24 73,74 Ethernet24 73,74 fortyGigE1/2/9
Ethernet25 75,76 Ethernet25 75,76 fortyGigE1/2/10
Ethernet26 77,78 Ethernet26 77,78 fortyGigE1/2/11
Ethernet27 79,80 Ethernet27 79,80 fortyGigE1/2/12
Ethernet28 105,106 Ethernet28 105,106 fortyGigE1/2/13
Ethernet29 107,108 Ethernet29 107,108 fortyGigE1/2/14
Ethernet30 109,110 Ethernet30 109,110 fortyGigE1/2/15
Ethernet31 111,112 Ethernet31 111,112 fortyGigE1/2/16
Ethernet32 13,14 Ethernet32 13,14 fortyGigE1/3/1
Ethernet33 15,16 Ethernet33 15,16 fortyGigE1/3/2
Ethernet34 9,10 Ethernet34 9,10 fortyGigE1/3/3
Ethernet35 11,12 Ethernet35 11,12 fortyGigE1/3/4
Ethernet36 125,126 Ethernet36 125,126 fortyGigE1/3/5
Ethernet37 127,128 Ethernet37 127,128 fortyGigE1/3/6
Ethernet38 121,122 Ethernet38 121,122 fortyGigE1/3/7
Ethernet39 123,124 Ethernet39 123,124 fortyGigE1/3/8
Ethernet40 93,94 Ethernet40 93,94 fortyGigE1/3/9
Ethernet41 95,96 Ethernet41 95,96 fortyGigE1/3/10
Ethernet42 89,90 Ethernet42 89,90 fortyGigE1/3/11
Ethernet43 91,92 Ethernet43 91,92 fortyGigE1/3/12
Ethernet44 45,46 Ethernet44 45,46 fortyGigE1/3/13
Ethernet45 47,48 Ethernet45 47,48 fortyGigE1/3/14
Ethernet46 41,42 Ethernet46 41,42 fortyGigE1/3/15
Ethernet47 43,44 Ethernet47 43,44 fortyGigE1/3/16
Ethernet48 113,114 Ethernet48 113,114 fortyGigE1/4/1
Ethernet49 115,116 Ethernet49 115,116 fortyGigE1/4/2
Ethernet50 117,118 Ethernet50 117,118 fortyGigE1/4/3
Ethernet51 119,120 Ethernet51 119,120 fortyGigE1/4/4
Ethernet52 1,2 Ethernet52 1,2 fortyGigE1/4/5
Ethernet53 3,4 Ethernet53 3,4 fortyGigE1/4/6
Ethernet54 5,6 Ethernet54 5,6 fortyGigE1/4/7
Ethernet55 7,8 Ethernet55 7,8 fortyGigE1/4/8
Ethernet56 33,34 Ethernet56 33,34 fortyGigE1/4/9
Ethernet57 35,36 Ethernet57 35,36 fortyGigE1/4/10
Ethernet58 37,38 Ethernet58 37,38 fortyGigE1/4/11
Ethernet59 39,40 Ethernet59 39,40 fortyGigE1/4/12
Ethernet60 81,82 Ethernet60 81,82 fortyGigE1/4/13
Ethernet61 83,84 Ethernet61 83,84 fortyGigE1/4/14
Ethernet62 85,86 Ethernet62 85,86 fortyGigE1/4/15
Ethernet63 87,88 Ethernet63 87,88 fortyGigE1/4/16

View File

@ -10,8 +10,6 @@ def get_platform_file_list():
platforms = os.listdir(data_path) platforms = os.listdir(data_path)
for platform in platforms: for platform in platforms:
files = ['platform/' + platform + '/port_config.ini'] 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') ): 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 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) ) data_files.append( (os.path.join('/usr/share/sonic', platform), files) )

View File

@ -34,6 +34,18 @@ def is_ipv6(value):
return False return False
return addr.version == 6 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(): def main():
parser=argparse.ArgumentParser(description="Render configuration file from minigraph data and jinja2 template.") parser=argparse.ArgumentParser(description="Render configuration file from minigraph data and jinja2 template.")
@ -49,10 +61,19 @@ def main():
args = parser.parse_args() args = parser.parse_args()
data = {} 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: if args.minigraph != None:
minigraph = args.minigraph minigraph = args.minigraph
data.update(parse_xml(minigraph)) if data.has_key('platform'):
data.update(parse_xml(minigraph, data['platform']))
else:
data.update(parse_xml(minigraph))
if args.yaml != None: if args.yaml != None:
with open(args.yaml, 'r') as stream: with open(args.yaml, 'r') as stream: