Simulate Unicast Path Lookup In IP Fabric 4.3
A quick tutorial about how to use IP Fabric’s API with python-ipfabric-diagrams Python module.
Prerequisites
-
we strongly recommend using a virtual environment for development testing
-
install the Python package in your environment:
pip install ipfabric-diagrams
Code Snippet
There are more examples in our Git, but we will test unicast path simulation with the following code snippet:
"""
Unicast path simulation with IP Fabric's Python package (valid for version 4.3 and later
"""
from ipfabric_diagrams import IPFDiagram, PathLookupSettings, Unicast, Algorithm, EntryPoint, OtherOptions
if __name__ == '__main__':
ipf = IPFDiagram(base_url='https://ipfabric_fqdn/', token='api_token', verify=False, timeout=15)
print(' \nStarting with path simulation..')
uni = Unicast(
startingPoint='10.38.115.1',
destinationPoint='10.66.126.1',
protocol='tcp',
srcPorts='10000',
dstPorts='80',
ttl=64,
fragmentOffset=0
)
json_data = ipf.diagram_json(uni)
path_result = json_data['pathlookup']['passingTraffic']
print("""
Simulation finished. Legend:
- all = all traffic is reaching destination
- part = some traffic is reaching destination
- none = some traffic is reaching destination
""")
print(' Result is : {}'.format(path_result))
print()
ipf.close()
More examples at this link