@@ -62,6 +62,7 @@ def parse_png(png, hname):
6262 console_port = ''
6363 mgmt_dev = ''
6464 mgmt_port = ''
65+ port_speeds = {}
6566 for child in png :
6667 if child .tag == str (QName (ns , "DeviceInterfaceLinks" )):
6768 for link in child .findall (str (QName (ns , "DeviceLinkBase" ))):
@@ -73,15 +74,21 @@ def parse_png(png, hname):
7374 endport = link .find (str (QName (ns , "EndPort" ))).text
7475 startdevice = link .find (str (QName (ns , "StartDevice" ))).text
7576 startport = link .find (str (QName (ns , "StartPort" ))).text
77+ bandwidth_node = link .find (str (QName (ns , "Bandwidth" )))
78+ bandwidth = bandwidth_node .text if bandwidth_node is not None else None
7679
7780 if enddevice == hname :
7881 if port_alias_map .has_key (endport ):
7982 endport = port_alias_map [endport ]
8083 neighbors [endport ] = {'name' : startdevice , 'port' : startport }
84+ if bandwidth :
85+ port_speeds [endport ] = bandwidth
8186 else :
8287 if port_alias_map .has_key (startport ):
8388 startport = port_alias_map [startport ]
8489 neighbors [startport ] = {'name' : enddevice , 'port' : endport }
90+ if bandwidth :
91+ port_speeds [startport ] = bandwidth
8592
8693 if child .tag == str (QName (ns , "Devices" )):
8794 for device in child .findall (str (QName (ns , "Device" ))):
@@ -106,7 +113,7 @@ def parse_png(png, hname):
106113 elif node .tag == str (QName (ns , "EndDevice" )):
107114 mgmt_dev = node .text
108115
109- return (neighbors , devices , console_dev , console_port , mgmt_dev , mgmt_port )
116+ return (neighbors , devices , console_dev , console_port , mgmt_dev , mgmt_port , port_speeds )
110117
111118
112119def parse_dpg (dpg , hname ):
@@ -368,7 +375,8 @@ def parse_xml(filename, platform=None, port_config_file=None):
368375 neighbors = None
369376 devices = None
370377 hostname = None
371- port_speeds = {}
378+ port_speeds_default = {}
379+ port_speed_png = {}
372380 port_descriptions = {}
373381 syslog_servers = []
374382 dhcp_servers = []
@@ -395,13 +403,13 @@ def parse_xml(filename, platform=None, port_config_file=None):
395403 elif child .tag == str (QName (ns , "CpgDec" )):
396404 (bgp_sessions , bgp_asn , bgp_peers_with_range ) = parse_cpg (child , hostname )
397405 elif child .tag == str (QName (ns , "PngDec" )):
398- (neighbors , devices , console_dev , console_port , mgmt_dev , mgmt_port ) = parse_png (child , hostname )
406+ (neighbors , devices , console_dev , console_port , mgmt_dev , mgmt_port , port_speed_png ) = parse_png (child , hostname )
399407 elif child .tag == str (QName (ns , "UngDec" )):
400- (u_neighbors , u_devices , _ , _ , _ , _ ) = parse_png (child , hostname )
408+ (u_neighbors , u_devices , _ , _ , _ , _ , _ ) = parse_png (child , hostname )
401409 elif child .tag == str (QName (ns , "MetadataDeclaration" )):
402410 (syslog_servers , dhcp_servers , ntp_servers , tacacs_servers , mgmt_routes , erspan_dst , deployment_id ) = parse_meta (child , hostname )
403411 elif child .tag == str (QName (ns , "DeviceInfos" )):
404- (port_speeds , port_descriptions ) = parse_deviceinfo (child , hwsku )
412+ (port_speeds_default , port_descriptions ) = parse_deviceinfo (child , hwsku )
405413
406414 results = {}
407415 results ['DEVICE_METADATA' ] = {'localhost' : {
@@ -438,14 +446,23 @@ def parse_xml(filename, platform=None, port_config_file=None):
438446 results ['VLAN_INTERFACE' ] = vlan_intfs
439447 results ['PORTCHANNEL_INTERFACE' ] = pc_intfs
440448
441- for port_name in port_speeds :
449+ for port_name in port_speeds_default :
442450 # ignore port not in port_config.ini
443451 if not ports .has_key (port_name ):
444452 continue
445453
446- ports .setdefault (port_name , {})['speed' ] = port_speeds [port_name ]
447- if port_speeds [port_name ] == '100000' :
448- ports .setdefault (port_name , {})['fec' ] = 'rs'
454+ ports .setdefault (port_name , {})['speed' ] = port_speeds_default [port_name ]
455+
456+ for port_name in port_speed_png :
457+ # if port_name is not in port_config.ini, still consider it.
458+ # and later swss will pick up and behave on-demand port break-up.
459+ # if on-deman port break-up is not supported on a specific platform, swss will return error.
460+ ports .setdefault (port_name , {})['speed' ] = port_speed_png [port_name ]
461+
462+ for port_name , port in ports .items ():
463+ if port .get ('speed' ) == '100000' :
464+ port ['fec' ] = 'rs'
465+
449466 for port_name in port_descriptions :
450467 # ignore port not in port_config.ini
451468 if not ports .has_key (port_name ):
0 commit comments