4545 20160906, Giles - ver 5.9 - Fixed TE metric get for ISIS,
4646 20160906, Niklas - ver 5.9b - Added topologies for TE and IGP metrics
4747 20160912, Niklas - ver 5.9c - Fixed Boron version check from false positives
48+ 20160919, Niklas - ver 5.9d - getTopo reply format changed
4849 """
4950__author__ = 'niklas'
5051
6162
6263
6364#==============================================================
64- version = '5.9c '
65+ version = '5.9d '
6566# Defaults overridden by pathman_ini.py
6667odl_ip = '127.0.0.1'
6768odl_port = '8181'
@@ -1500,28 +1501,38 @@ def getTopo_old(dict_subcommand, debug):
15001501 logging .info ("Failed to get topo: %s" % cause )
15011502 return False , cause , []
15021503
1504+
15031505def getTopo (dict_subcommand , debug ):
15041506 """ called from REST Server
15051507 - Get UI a topo to work with """
1506- def get_links (node_list , network ):
1508+ def get_links (node_list , network , type = 'igp' ):
15071509 net_by_name = translate_topo (node_list , network , debug )
15081510 links = []
1509-
15101511 for node in net_by_name .keys ():
15111512 for hop in net_by_name [node ].keys ():
15121513 if hop_not_source (links , hop ):
1513- link_dict = {'source' :None , 'target' :None ,'sourceTraffic' :0 , 'targetTraffic' :0 }
1514+ # link_dict = {'source':None, 'target':None,'sourceTraffic':0, 'targetTraffic':0}
1515+ link_dict = {}
15141516 link_dict ["source" ] = node
15151517 link_dict ["target" ] = hop
15161518 try :
1517- link_dict ["sourceTraffic " ] = net_by_name [node ][hop ]
1518- link_dict ["targetTraffic" ] = net_by_name [hop ][node ]
1519+ link_dict ["metric " ] = { type : { 'tx' : net_by_name [node ][hop ]}}
1520+ link_dict ["metric" ][ type ]. update ({ 'rx' : net_by_name [hop ][node ]})
15191521 links .append (link_dict )
1520- except KeyError :
1522+ except KeyError as e :
1523+ logging .error (e .message )
15211524 logging .error ("Network link missing between {0} and {1}" .format (hop , node ))
15221525 return links
15231526
1524- # New topo_response = {'nodes':[],'links':[], te-links':[]}
1527+ def merge_links (master , extra ):
1528+ """All links exist in master, and only once """
1529+ for item in master :
1530+ for link in extra :
1531+ if item ['source' ] == link ['source' ] and item ['target' ] == link ['target' ]:
1532+ # print "match", item['source'], item['target']
1533+ item ['metric' ].update (link ['metric' ])
1534+ return master
1535+
15251536 success , cause , num_nodes = build_odl_topology (debug )
15261537 if success :
15271538 temp_nodelist = []
@@ -1545,16 +1556,18 @@ def get_links(node_list, network):
15451556 temp_nodelist = topoCheck (temp_nodelist )
15461557
15471558 sorted_nodelist = sorted (temp_nodelist , key = lambda k : k ['name' ])
1559+ links = get_links (node_list , bgp_net )
1560+ te_links = get_links (node_list , te_net , type = 'te' )
15481561 topo_response = {'nodes' : sorted_nodelist ,
1549- 'links' : get_links (node_list , bgp_net ),
1550- 'te-links' : get_links (node_list , te_net )}
1562+ 'links' : merge_links (links , te_links )}
15511563
15521564 logging .info ("Topo build with %s nodes" % num_nodes )
15531565 return True , 'another sunny day' , topo_response
15541566 else :
15551567 logging .info ("Failed to get topo: %s" % cause )
15561568 return False , cause , []
15571569
1570+
15581571def listSRnodes (debug ):
15591572 """Lists existing SR Nodes
15601573 - catching config changes require a refresh """
0 commit comments