Skip to content

Commit 2e50caf

Browse files
committed
multi-area/level fix plus sid fix
1 parent 85471d8 commit 2e50caf

1 file changed

Lines changed: 29 additions & 11 deletions

File tree

pathman_sr.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
20161204, Niklas - Ver 5.9f - Added BGP-RIB support to retrieve SIDs. Requires XRv 6.1.x, or higher.
5151
20161210, Niklas - ver 5.9g - Added Netconf-modules for users to add their nodes to netconf
5252
- Added static netconf mappings for users ho give up on netconf
53+
20161226, Niklas - ver 5.9h - Multi area/level fix for bgp-ls and sid bug.
5354
"""
5455
__author__ = 'niklas'
5556

@@ -66,7 +67,7 @@
6667

6768

6869
#==============================================================
69-
version = '5.9g'
70+
version = '5.9h'
7071
# Defaults overridden by pathman_ini.py
7172
odl_ip = '127.0.0.1'
7273
odl_port = '8181'
@@ -388,16 +389,16 @@ def get_config(url_list, match):
388389
try:
389390
sid = get_config([get_node_isis_config, get_node_ospf_config], 'prefix-sid')
390391
rid = get_config([get_node_bgp_config], 'router-id')
391-
logging.info('rid: %s, sid: %s' %(rid, sid))
392+
logging.info('rid: %s, sid: %s' % (rid, sid))
392393

393394
if sid != -1:
394-
node_configs.update({node:sid})
395+
node_configs.update({node: sid})
395396
logging.info("got netconf data for: %s" % node)
396-
else:
397-
logging.info("No sid for: %s" % node)
398-
if rid != -1:
399-
rid_dict.update({rid:sid})
400-
logging.info("router-id: %s" % rid)
397+
if rid != -1:
398+
rid_dict.update({rid: sid})
399+
logging.info("router-id: %s" % rid)
400+
else:
401+
logging.info("No sid for: %s" % node)
401402
else:
402403
logging.error("No rid for: %s" % node)
403404
except:
@@ -613,6 +614,22 @@ def find_link2(local, remote, address):
613614
return -1
614615
return(-1)
615616

617+
def add_node(node_list, name, id, loopback, portlist, pcc, pcep_type, prefix, sid):
618+
id_list = [node.id for node in node_list]
619+
if id in id_list:
620+
index = id_list.index(id)
621+
node = node_list[index]
622+
if name != node.name:
623+
logging.error('Name does not match for same ID: {} was {}'.format(name, node.name))
624+
if portlist != node.portlist or prefix != node.prefix:
625+
node = node._replace(portlist=sorted(list(set(node.portlist+portlist))), prefix=sorted(list(set(node.prefix+prefix))))
626+
node_list[index] = node
627+
logging.info("Updated node: %s" % str(node))
628+
else:
629+
node = Node(name, id, loopback, sorted(portlist), pcc, pcep_type, sorted(prefix), sid)
630+
logging.info("New node: %s" % str(node))
631+
node_list.append(node)
632+
616633
def node_structure(my_topology, debug = 2):
617634
""" learn (print out) the topology structure """
618635

@@ -671,9 +688,10 @@ def node_structure(my_topology, debug = 2):
671688
success, hname = name_check(nodes['l3-unicast-igp-topology:igp-node-attributes']['router-id'][0])
672689
if success:
673690
name = hname
674-
node = Node(name,node_dict['router'],router_id,node_ports,pcc, pcep_type, prefix_array, sid)
675-
logging.info("New node: %s" % str(node))
676-
node_list.append(node)
691+
add_node(node_list, name, node_dict['router'], router_id, node_ports, pcc, pcep_type, prefix_array, sid)
692+
# node = Node(name,node_dict['router'],router_id,node_ports,pcc, pcep_type, prefix_array, sid)
693+
# logging.info("New node: %s" % str(node))
694+
# node_list.append(node)
677695
logging.info(node_list)
678696
return node_list
679697

0 commit comments

Comments
 (0)