#NEWLINE# def _cmp_by_asn( local_asn , path1 , path2 ) : #NEWLINE# #INDENT# 'Select the path based on source (iBGP/eBGP) peer.\n\n    eBGP path is preferred over iBGP. If both paths are from same kind of\n    peers, return None.\n    ' #NEWLINE# def get_path_source_asn( path ) : #NEWLINE# #INDENT# asn = None #NEWLINE# if ( path . source is None ) : #NEWLINE# #INDENT# asn = local_asn #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# asn = path . source . remote_as #NEWLINE# #UNINDENT# return asn #NEWLINE# #UNINDENT# p1_asn = get_path_source_asn ( get_path_source_asn ) #NEWLINE# p2_asn = get_path_source_asn ( path2 ) #NEWLINE# if ( ( p1_asn == local_asn ) and ( p2_asn != local_asn ) ) : #NEWLINE# #INDENT# return path2 #NEWLINE# #UNINDENT# if ( ( p2_asn == local_asn ) and ( p1_asn != local_asn ) ) : #NEWLINE# #INDENT# return path1 #NEWLINE# #UNINDENT# return None