Skip to content

Commit 274e5bc

Browse files
committed
Updated matric selection
1 parent fc2a710 commit 274e5bc

2 files changed

Lines changed: 21 additions & 76 deletions

File tree

pathman_ini.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
"""
2222
#odl_ip = '127.0.0.1'
23-
odl_ip = '198.18.133.1'
23+
odl_ip = '198.18.1.80'
2424
odl_port = '8181'
2525
log_file = '/tmp/pathman.log'
2626
log_size = 2000000

pathman_sr.py

Lines changed: 20 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
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
4848
20160919, Niklas - ver 5.9d - getTopo reply format changed
49+
20160924, Niklas - ver 5.9e - Updated metrics selection
4950
"""
5051
__author__ = 'niklas'
5152

@@ -62,7 +63,7 @@
6263

6364

6465
#==============================================================
65-
version = '5.9d'
66+
version = '5.9e'
6667
# Defaults overridden by pathman_ini.py
6768
odl_ip = '127.0.0.1'
6869
odl_port = '8181'
@@ -298,18 +299,6 @@ def formatTime(self, record, datefmt=None):
298299
},
299300
}
300301

301-
def netconf_list_old():
302-
'''get nodes from netconf'''
303-
result = get_url(get_nodes)
304-
conf_list = []
305-
if True:
306-
try:
307-
for node in result['nodes']['node']:
308-
conf_list.append(node['id'])
309-
except:
310-
logging.error("format error in netconf node-list: %s" % str(result))
311-
pass
312-
return conf_list
313302

314303
def version_check():
315304
"""modified from odl_gateway"""
@@ -671,16 +660,24 @@ def pseudo_net_build(node_list):
671660

672661
def node_links(my_topology, node_list, bgp=False, metric='igp'):
673662
""" Dumps link info """
674-
def metric_test(attributes):
663+
def metric_test(attributes, metric):
675664
""" Pick a metric to return """
665+
temp = {'te-isis':10, 'te-ospf':10}
676666
if 'metric' in attributes.keys():
677-
return attributes['metric']
678-
elif 'ospf-topology:ospf-link-attributes' in attributes.keys() and 'ted' in attributes['ospf-topology:ospf-link-attributes']:
679-
return attributes['ospf-topology:ospf-link-attributes']['ted'].get('te-default-metric', 10)
680-
elif 'isis-topology:isis-link-attributes' in attributes.keys() and 'ted' in attributes['isis-topology:isis-link-attributes']:
681-
return attributes['isis-topology:isis-link-attributes']['ted'].get('te-default-metric', 10)
682-
else:
683-
return 10
667+
temp.update({'metric': attributes['metric']})
668+
if 'ospf-topology:ospf-link-attributes' in attributes.keys() and 'ted' in attributes['ospf-topology:ospf-link-attributes']:
669+
temp.update({'te-ospf': attributes['ospf-topology:ospf-link-attributes']['ted'].get('te-default-metric', 10)})
670+
if 'isis-topology:isis-link-attributes' in attributes.keys() and 'ted' in attributes['isis-topology:isis-link-attributes']:
671+
temp.update({'te-isis': attributes['isis-topology:isis-link-attributes']['ted'].get('te-default-metric', 10)})
672+
673+
if metric == 'igp':
674+
return temp.get('metric', 10)
675+
elif metric == 'te':
676+
if temp['te-isis'] != 10:
677+
return temp['te-isis']
678+
else:
679+
return temp['te-ospf']
680+
684681
net = {}
685682
link_list = []
686683
sr_enabled = [node.id for node in node_list if node.sid != '']
@@ -691,9 +688,9 @@ def metric_test(attributes):
691688

692689
if bgp or set([link_dict['local-router'], link_dict['remote-router']]).issubset(set(sr_enabled)):
693690
if link_dict['local-router'] in net.keys():
694-
net[link_dict['local-router']].update({link_dict['remote-router']: metric_test(link['l3-unicast-igp-topology:igp-link-attributes'])})
691+
net[link_dict['local-router']].update({link_dict['remote-router']: metric_test(link['l3-unicast-igp-topology:igp-link-attributes'], metric)})
695692
else:
696-
net.update({link_dict['local-router']: {link_dict['remote-router']: metric_test(link['l3-unicast-igp-topology:igp-link-attributes'])}})
693+
net.update({link_dict['local-router']: {link_dict['remote-router']: metric_test(link['l3-unicast-igp-topology:igp-link-attributes'], metric)}})
697694

698695
except:
699696
logging.info("We have no links in our BGP-LS topology")
@@ -1450,58 +1447,6 @@ def topoCheck(temp_nodelist):
14501447
return temp_nodelist
14511448

14521449

1453-
def getTopo_old(dict_subcommand, debug):
1454-
""" called from REST Server
1455-
- Get UI a topo to work with """
1456-
#topo_response = {'nodes':[],'links':[]}
1457-
success, cause, num_nodes = build_odl_topology(debug)
1458-
if success:
1459-
temp_nodelist = []
1460-
1461-
for node in node_list:
1462-
sr_enabled = True if node.sid != "" else False
1463-
pcep_enabled = True if node.pcc != "" else False
1464-
node_dict = {'name': node.name,
1465-
'site': node.name,
1466-
'ipaddress': node.loopback,
1467-
'prefix': node.prefix,
1468-
'sid': node.sid,
1469-
'pcc': node.pcc,
1470-
'sr_enabled': sr_enabled,
1471-
'pcep_enabled': pcep_enabled
1472-
}
1473-
copyTopo(node_dict, topologyData['nodes'])
1474-
temp_nodelist.append(node_dict)
1475-
#topo_response['nodes'].append(node_dict)
1476-
1477-
temp_nodelist = topoCheck(temp_nodelist)
1478-
1479-
sorted_nodelist = sorted(temp_nodelist, key=lambda k: k['name'])
1480-
topo_response = {'nodes':sorted_nodelist,'links':[]}
1481-
net_by_name = translate_topo(node_list, bgp_net, debug)
1482-
1483-
for node in net_by_name.keys():
1484-
1485-
for hop in net_by_name[node].keys():
1486-
if hop_not_source(topo_response['links'], hop):
1487-
#link_dict.update({'source':node, 'target':hop})
1488-
link_dict = {'source':None, 'target':None,'sourceTraffic':0, 'targetTraffic':0}
1489-
link_dict["source"]=node
1490-
link_dict["target"]=hop
1491-
try:
1492-
link_dict["sourceTraffic"] = net_by_name[node][hop]
1493-
link_dict["targetTraffic"] = net_by_name[hop][node]
1494-
topo_response['links'].append(link_dict)
1495-
except KeyError:
1496-
logging.error("bgp-ls link missing between {0} and {1}".format(hop, node))
1497-
1498-
logging.info("Topo build with %s nodes" % num_nodes)
1499-
return True, 'another sunny day', topo_response
1500-
else:
1501-
logging.info("Failed to get topo: %s" % cause)
1502-
return False, cause, []
1503-
1504-
15051450
def getTopo(dict_subcommand, debug):
15061451
""" called from REST Server
15071452
- Get UI a topo to work with """

0 commit comments

Comments
 (0)