@@ -62,6 +62,7 @@ def parse_png(png, hname):
62
62
console_port = ''
63
63
mgmt_dev = ''
64
64
mgmt_port = ''
65
+ port_speeds = {}
65
66
for child in png :
66
67
if child .tag == str (QName (ns , "DeviceInterfaceLinks" )):
67
68
for link in child .findall (str (QName (ns , "DeviceLinkBase" ))):
@@ -73,15 +74,21 @@ def parse_png(png, hname):
73
74
endport = link .find (str (QName (ns , "EndPort" ))).text
74
75
startdevice = link .find (str (QName (ns , "StartDevice" ))).text
75
76
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
76
79
77
80
if enddevice == hname :
78
81
if port_alias_map .has_key (endport ):
79
82
endport = port_alias_map [endport ]
80
83
neighbors [endport ] = {'name' : startdevice , 'port' : startport }
84
+ if bandwidth :
85
+ port_speeds [endport ] = bandwidth
81
86
else :
82
87
if port_alias_map .has_key (startport ):
83
88
startport = port_alias_map [startport ]
84
89
neighbors [startport ] = {'name' : enddevice , 'port' : endport }
90
+ if bandwidth :
91
+ port_speeds [startport ] = bandwidth
85
92
86
93
if child .tag == str (QName (ns , "Devices" )):
87
94
for device in child .findall (str (QName (ns , "Device" ))):
@@ -106,7 +113,7 @@ def parse_png(png, hname):
106
113
elif node .tag == str (QName (ns , "EndDevice" )):
107
114
mgmt_dev = node .text
108
115
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 )
110
117
111
118
112
119
def parse_dpg (dpg , hname ):
@@ -368,7 +375,8 @@ def parse_xml(filename, platform=None, port_config_file=None):
368
375
neighbors = None
369
376
devices = None
370
377
hostname = None
371
- port_speeds = {}
378
+ port_speeds_default = {}
379
+ port_speed_png = {}
372
380
port_descriptions = {}
373
381
syslog_servers = []
374
382
dhcp_servers = []
@@ -395,13 +403,13 @@ def parse_xml(filename, platform=None, port_config_file=None):
395
403
elif child .tag == str (QName (ns , "CpgDec" )):
396
404
(bgp_sessions , bgp_asn , bgp_peers_with_range ) = parse_cpg (child , hostname )
397
405
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 )
399
407
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 )
401
409
elif child .tag == str (QName (ns , "MetadataDeclaration" )):
402
410
(syslog_servers , dhcp_servers , ntp_servers , tacacs_servers , mgmt_routes , erspan_dst , deployment_id ) = parse_meta (child , hostname )
403
411
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 )
405
413
406
414
results = {}
407
415
results ['DEVICE_METADATA' ] = {'localhost' : {
@@ -438,14 +446,23 @@ def parse_xml(filename, platform=None, port_config_file=None):
438
446
results ['VLAN_INTERFACE' ] = vlan_intfs
439
447
results ['PORTCHANNEL_INTERFACE' ] = pc_intfs
440
448
441
- for port_name in port_speeds :
449
+ for port_name in port_speeds_default :
442
450
# ignore port not in port_config.ini
443
451
if not ports .has_key (port_name ):
444
452
continue
445
453
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
+
449
466
for port_name in port_descriptions :
450
467
# ignore port not in port_config.ini
451
468
if not ports .has_key (port_name ):
0 commit comments