39
39
BACKEND_ASIC_SUB_ROLE = 'BackEnd'
40
40
BACKEND_ASIC_INTERFACE_NAME_PREFIX = 'Ethernet-BP'
41
41
42
- # Default Virtual Network Index (VNI)
42
+ # Default Virtual Network Index (VNI)
43
43
vni_default = 8000
44
44
45
45
###############################################################################
@@ -554,6 +554,39 @@ def parse_meta(meta, hname):
554
554
region = value
555
555
return syslog_servers , dhcp_servers , ntp_servers , tacacs_servers , mgmt_routes , erspan_dst , deployment_id , region
556
556
557
+
558
+ def parse_linkmeta (meta , hname ):
559
+ link = meta .find (str (QName (ns , "Link" )))
560
+ linkmetas = {}
561
+ for linkmeta in link .findall (str (QName (ns1 , "LinkMetadata" ))):
562
+ port = None
563
+ fec_disabled = None
564
+
565
+ # Sample: ARISTA05T1:Ethernet1/33;switch-t0:fortyGigE0/4
566
+ key = linkmeta .find (str (QName (ns1 , "Key" ))).text
567
+ endpoints = key .split (';' )
568
+ for endpoint in endpoints :
569
+ t = endpoint .split (':' )
570
+ if len (t ) == 2 and t [0 ].lower () == hname .lower ():
571
+ port = t [1 ]
572
+ break
573
+ else :
574
+ # Cannot find a matching hname, something went wrong
575
+ continue
576
+
577
+ properties = linkmeta .find (str (QName (ns1 , "Properties" )))
578
+ for device_property in properties .findall (str (QName (ns1 , "DeviceProperty" ))):
579
+ name = device_property .find (str (QName (ns1 , "Name" ))).text
580
+ value = device_property .find (str (QName (ns1 , "Value" ))).text
581
+ if name == "FECDisabled" :
582
+ fec_disabled = value
583
+
584
+ linkmetas [port ] = {}
585
+ if fec_disabled :
586
+ linkmetas [port ]["FECDisabled" ] = fec_disabled
587
+ return linkmetas
588
+
589
+
557
590
def parse_asic_meta (meta , hname ):
558
591
sub_role = None
559
592
device_metas = meta .find (str (QName (ns , "Devices" )))
@@ -732,7 +765,6 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
732
765
generate asic specific configuration.
733
766
"""
734
767
root = ET .parse (filename ).getroot ()
735
- mini_graph_path = filename
736
768
737
769
u_neighbors = None
738
770
u_devices = None
@@ -766,8 +798,9 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
766
798
deployment_id = None
767
799
region = None
768
800
hostname = None
801
+ linkmetas = {}
769
802
770
- #hostname is the asic_name, get the asic_id from the asic_name
803
+ # hostname is the asic_name, get the asic_id from the asic_name
771
804
if asic_name is not None :
772
805
asic_id = get_npu_id_from_name (asic_name )
773
806
else :
@@ -800,6 +833,8 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
800
833
(u_neighbors , u_devices , _ , _ , _ , _ , _ , _ ) = parse_png (child , hostname )
801
834
elif child .tag == str (QName (ns , "MetadataDeclaration" )):
802
835
(syslog_servers , dhcp_servers , ntp_servers , tacacs_servers , mgmt_routes , erspan_dst , deployment_id , region ) = parse_meta (child , hostname )
836
+ elif child .tag == str (QName (ns , "LinkMetadataDeclaration" )):
837
+ linkmetas = parse_linkmeta (child , hostname )
803
838
elif child .tag == str (QName (ns , "DeviceInfos" )):
804
839
(port_speeds_default , port_descriptions ) = parse_deviceinfo (child , hwsku )
805
840
else :
@@ -811,6 +846,8 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
811
846
(neighbors , devices , port_speed_png ) = parse_asic_png (child , asic_name , hostname )
812
847
elif child .tag == str (QName (ns , "MetadataDeclaration" )):
813
848
(sub_role ) = parse_asic_meta (child , asic_name )
849
+ elif child .tag == str (QName (ns , "LinkMetadataDeclaration" )):
850
+ linkmetas = parse_linkmeta (child , hostname )
814
851
elif child .tag == str (QName (ns , "DeviceInfos" )):
815
852
(port_speeds_default , port_descriptions ) = parse_deviceinfo (child , hwsku )
816
853
@@ -896,7 +933,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
896
933
897
934
for port_name in port_speed_png :
898
935
# not consider port not in port_config.ini
899
- #If no port_config_file is found ports is empty so ignore this error
936
+ # If no port_config_file is found ports is empty so ignore this error
900
937
if port_config_file is not None :
901
938
if port_name not in ports :
902
939
print >> sys .stderr , "Warning: ignore interface '%s' as it is not in the port_config.ini" % port_name
@@ -905,7 +942,14 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
905
942
ports .setdefault (port_name , {})['speed' ] = port_speed_png [port_name ]
906
943
907
944
for port_name , port in ports .items ():
908
- if port .get ('speed' ) == '100000' :
945
+ # get port alias from port_config.ini
946
+ if port_config_file :
947
+ alias = port .get ('alias' )
948
+ else :
949
+ alias = port_name
950
+ # generate default 100G FEC
951
+ # Note: FECDisabled only be effective on 100G port right now
952
+ if port .get ('speed' ) == '100000' and linkmetas .get (alias , {}).get ('FECDisabled' , '' ).lower () != 'true' :
909
953
port ['fec' ] = 'rs'
910
954
911
955
# set port description if parsed from deviceinfo
0 commit comments