Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 32 additions & 16 deletions docs/automation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,17 @@ with open('cisco_lsdb_output.txt') as f:

### Shortest path

`/api/path` accepts OSPF RIDs, IP addresses or IP subnets as source and destination and returns the path cost, the shortest path and the unbackuped parts of the path (if these links go down, connectivity between the source and destination is lost).
`GET /api/graph/{graph_time}/path/{node_a}/{node_b}` returns the path cost, the shortest paths and the unbackuped parts of the path (if these links go down, connectivity between the source and destination is lost). Nodes are given by router ID, hostname or IS-IS System ID.

```python
r_post = requests.post('https://topolograph.com/api/path', auth=('', ''),
json={'graph_time': '27Dec2022_22h46m01s_7_hosts_ospfwatcher', 'src_node': '192.168.100.100', 'dst_node': '10.1.123.23'})
r = requests.get('https://topolograph.com/api/graph/27Dec2022_22h46m01s_7_hosts_ospfwatcher/path/192.168.100.100/10.1.123.23',
auth=('', ''))
```

Reply:

```python
r_post.json()
r.json()
{'cost': 30,
'spt_path_nodes_name_as_ll_in_ll': [['192.168.100.100', '10.1.1.4', '10.1.1.2', '10.1.123.23']],
'unbackup_paths_nodes_name_as_ll_in_ll': [['192.168.100.100', '10.1.1.4']]}
Expand All @@ -113,38 +113,54 @@ The `'192.168.100.100' - '10.1.1.4'` link is shown as nonbackuped.

### Backup path

`removedEdgesAsNodePairsFromSptPath_ll_in_ll` accepts a list of edges which are treated as down links.
`POST /api/graph/{graph_time}/analyse/spt_edge_failure` returns the shortest path when links or routers are down. A link is named by its `edge_key`; ask the edges list for it:

```python
r_post = requests.post('https://topolograph.com/api/path', auth=('', ''),
json={'graph_time': '27Dec2022_22h46m01s_7_hosts_ospfwatcher', 'src_node': '192.168.100.100', 'dst_node': '10.1.123.23',
'removedEdgesAsNodePairsFromSptPath_ll_in_ll': [['10.1.1.4', '10.1.1.2']]})
graph = 'https://topolograph.com/api/graph/27Dec2022_22h46m01s_7_hosts_ospfwatcher'
r = requests.get(f'{graph}/edges', auth=('', ''),
params={'src_node': '10.1.1.4', 'dst_node': '10.1.1.2', 'include': 'edge_key'})
edge_key = r.json()['items'][0]['edge_key'] # '10.1.1.4|10.1.1.2|ip:10.1.24.4'

r = requests.post(f'{graph}/analyse/spt_edge_failure', auth=('', ''),
json={'from': '192.168.100.100', 'to': '10.1.123.23', 'failed_edges': [edge_key]})
```

A failed link is down in both directions; parallel links between the same routers stay up. `failed_nodes` takes routers down, `changed_costs` sets a new cost on one direction of a link.

Reply:

```python
r_post.json()
{'cost': 40,
'spt_path_nodes_name_as_ll_in_ll': [['192.168.100.100', '10.1.1.4', '10.1.1.3', '10.1.1.2', '10.1.123.23']],
'unbackup_paths_nodes_name_as_ll_in_ll': [['192.168.100.100', '10.1.1.4']]}
r.json()
{'result': {'cost': 40, 'paths': 1, 'reason': ''},
'nodes': {'192.168.100.100': {'name': '192.168.100.100', 'role': ['from']},
'10.1.1.4': {'name': '10.1.1.4', 'role': ['via']},
'10.1.1.3': {'name': '10.1.1.3', 'role': ['via']},
'10.1.1.2': {'name': '10.1.1.2', 'role': ['via']},
'10.1.123.23': {'name': '10.1.123.23', 'role': ['to']}},
'edges': {'192.168.100.100|10.1.1.4|ip:172.17.0.100': {'role': 'on_path', 'hops': [{'path': 0, 'hop': 0, 'traffic_share': 1.0}]},
'10.1.1.4|10.1.1.3|ip:10.1.34.4': {'role': 'on_path', 'hops': [{'path': 0, 'hop': 1, 'traffic_share': 1.0}]},
'10.1.1.3|10.1.1.2|ip:10.1.23.3': {'role': 'on_path', 'hops': [{'path': 0, 'hop': 2, 'traffic_share': 1.0}]},
'10.1.1.2|10.1.123.23|ip:10.1.123.1': {'role': 'on_path', 'hops': [{'path': 0, 'hop': 3, 'traffic_share': 1.0}]},
'10.1.1.4|10.1.1.2|ip:10.1.24.4': {'role': 'failed'}}}
```

`hops` orders the links of each path; with several equal-cost paths, `path` tells them apart.

![Backup path on the graph](../static/ui/seven-routers-backup.png)

### Shortest path between networks

`/api/path/network` accepts IP addresses and IP networks. Example: a path between `192.1.113.99` and `192.1.213.0/24`.
`GET /api/graph/{graph_time}/path/network` accepts IP addresses and IP networks. Example: a path between `192.1.113.99` and `192.1.213.0/24`.

```python
r_post = requests.post('https://topolograph.com/api/path/network', auth=('', ''),
json={'graph_time': '27Dec2022_22h46m01s_7_hosts_ospfwatcher', 'src_ip_or_network': '192.1.113.99', 'dst_ip_or_network': '192.1.213.0/24'})
r = requests.get('https://topolograph.com/api/graph/27Dec2022_22h46m01s_7_hosts_ospfwatcher/path/network', auth=('', ''),
params={'src_ip_or_network': '192.1.113.99', 'dst_ip_or_network': '192.1.213.0/24'})
```

Reply:

```python
r_post.json()
r.json()
{'cost': 20,
'spt_path_nodes_name_as_ll_in_ll': [['10.1.1.1', '10.1.1.4', '10.1.1.2'], ['10.1.1.1', '10.1.1.3', '10.1.1.2']],
'unbackup_paths_nodes_name_as_ll_in_ll': []}
Expand Down
Loading