nautobot/nautobot-plugin-chatops-ipfabric

End-to-end path simulation fails when path data isn't in snapshot

chipn opened this issue · 1 comments

chipn commented

If a snapshot doesn't contain data for the requested path, the user will see the following error in chat:

image

This issue occurs when the e2e path data returned is incomplete and doesn't contain a forwarding key:

>>> response = ipfabric_api.get_path_simulation("10.0.10.5", "10.0.20.7", "1000", "80", "tcp", 'a8aa600d-e2e8-497b-809a-8a3c93fc805f')
>>> response
{'graph': {'nodes': [{'id': '10.0.10.5', 'hostname': '10.0.10.5', 'devType': 'host'}, {'id': '10.0.20.7', 'hostname': '10.0.20.7', 'devType': 'host'}], 'lookup': {'state': 'ok', 'id': None}, 'edges': [{'tlabel': '', 'inAcl': None, 'source': '10.0.10.5', 'id': '10.0.10.510.0.20.7l3', 'target': '10.0.20.7', 'linkType': 'cef', 'outAcl': None, 'slabel': ''}], 'type': 'e2e'}, 'ad': []}
>>> ipfabric_api.get_parsed_path_simulation("10.0.10.5", "10.0.20.7", "1000", "80", "tcp", "$last")
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/source/ipfabric/ipfabric.py", line 169, in get_parsed_path_simulation
    edge_id = node["forwarding"][0]["dstIntList"][0]["id"]
KeyError: 'forwarding'

Currently, both get_parsed_path_simulation and get_src_dst_endpoint rely on the forwarding key to exist.

We need to handle the case when this key doesn't exist and/or the # of edges == 1 (meaning the path can't be determined).

Fixed in #43