|
47 | 47 | 20160912, Niklas - ver 5.9c - Fixed Boron version check from false positives |
48 | 48 | 20160919, Niklas - ver 5.9d - getTopo reply format changed |
49 | 49 | 20160924, Niklas - ver 5.9e - Updated metrics selection |
| 50 | + 20161226, Niklas - ver 5.9f - Updates from branches; multi-area/level and sid fix |
50 | 51 | """ |
51 | 52 | __author__ = 'niklas' |
52 | 53 |
|
|
63 | 64 |
|
64 | 65 |
|
65 | 66 | #============================================================== |
66 | | -version = '5.9e' |
| 67 | +version = '5.9f' |
67 | 68 | # Defaults overridden by pathman_ini.py |
68 | 69 | odl_ip = '127.0.0.1' |
69 | 70 | odl_port = '8181' |
@@ -372,13 +373,13 @@ def get_config(url_list, match): |
372 | 373 | if sid != -1: |
373 | 374 | node_configs.update({node:sid}) |
374 | 375 | logging.info("got netconf data for: %s" % node) |
| 376 | + if rid != -1: |
| 377 | + rid_dict.update({rid:sid}) |
| 378 | + logging.info("router-id: %s" % rid) |
| 379 | + else: |
| 380 | + logging.error("No rid for: %s" % node) |
375 | 381 | else: |
376 | 382 | logging.info("No sid for: %s" % node) |
377 | | - if rid != -1: |
378 | | - rid_dict.update({rid:sid}) |
379 | | - logging.info("router-id: %s" % rid) |
380 | | - else: |
381 | | - logging.error("No rid for: %s" % node) |
382 | 383 | except: |
383 | 384 | logging.error("failure to get netconf data for: %s" % node) |
384 | 385 | return node_configs, rid_dict |
@@ -576,6 +577,22 @@ def find_link2(local, remote, address): |
576 | 577 | return -1 |
577 | 578 | return(-1) |
578 | 579 |
|
| 580 | +def add_node(node_list, name, id, loopback, portlist, pcc, pcep_type, prefix, sid): |
| 581 | + id_list = [node.id for node in node_list] |
| 582 | + if id in id_list: |
| 583 | + index = id_list.index(id) |
| 584 | + node = node_list[index] |
| 585 | + if name != node.name: |
| 586 | + logging.error('Name does not match for same ID: {} was {}'.format(name, node.name)) |
| 587 | + if portlist != node.portlist or prefix != node.prefix: |
| 588 | + node = node._replace(portlist=sorted(list(set(node.portlist+portlist))), prefix=sorted(list(set(node.prefix+prefix)))) |
| 589 | + node_list[index] = node |
| 590 | + logging.info("Updated node: %s" % str(node)) |
| 591 | + else: |
| 592 | + node = Node(name, id, loopback, sorted(portlist), pcc, pcep_type, sorted(prefix), sid) |
| 593 | + logging.info("New node: %s" % str(node)) |
| 594 | + node_list.append(node) |
| 595 | + |
579 | 596 | def node_structure(my_topology, debug = 2): |
580 | 597 | """ learn (print out) the topology structure """ |
581 | 598 |
|
@@ -634,9 +651,10 @@ def node_structure(my_topology, debug = 2): |
634 | 651 | success, hname = name_check(nodes['l3-unicast-igp-topology:igp-node-attributes']['router-id'][0]) |
635 | 652 | if success: |
636 | 653 | name = hname |
637 | | - node = Node(name,node_dict['router'],router_id,node_ports,pcc, pcep_type, prefix_array, sid) |
638 | | - logging.info("New node: %s" % str(node)) |
639 | | - node_list.append(node) |
| 654 | + add_node(node_list, name, node_dict['router'], router_id, node_ports, pcc, pcep_type, prefix_array, sid) |
| 655 | + # node = Node(name,node_dict['router'],router_id,node_ports,pcc, pcep_type, prefix_array, sid) |
| 656 | + # logging.info("New node: %s" % str(node)) |
| 657 | + # node_list.append(node) |
640 | 658 | logging.info(node_list) |
641 | 659 | return node_list |
642 | 660 |
|
|
0 commit comments