Batfish wrapper for MDDO Project
Install required packages
pip3 install -r requirements_prod.txt
python3 src/app.py
It will up at http://localhost:5000/
BATFISH_HOST
: specify batfish service (hostname)MDDO_CONFIGS_DIR
: batfish snapshot directory (default:./configs
)MDDO_QUERIES_DIR
: query result directory (default:./queries
)
APIs to control batfish.
Parameters in examples:
- network name :
pushed_configs
- snapshot name:
mddo_network
Get all networks and snapshots
- GET
/batfish/snapshots
curl -X GET http://localhost:5000/batfish/snapshots
Get networks
- GET
/batfish/networks
curl -X GET http://localhost:5000/batfish/networks
Get snapshots in a network
- GET
/batfish/<network>/snapshots
simulated
: [optional] returns all logical (simulated) snapshots defined in the network even if these snapshots are not registered in batfish. (default: false)
curl -X GET http://localhost:5000/batfish/pushed_configs/snapshots
curl -X GET http://localhost:5000/batfish/pushed_configs/snapshots?simulated=true
Get nodes in a snapshot
- GET
/batfish/<network>/<snapshot>/nodes
curl -X GET http://localhost:5000/batfish/pushed_configs/mddo_network/nodes
Get interfaces in a node
- GET
/batfish/<network>/<snapshot>/<node>/interfaces
curl -X GET http://localhost:5000/batfish/pushed_configs/mddo_network/regiona-svr01/interfaces
Get interfaces in a snapshots
- GET
/batfish/<network>/<snapshot>/interfaces
curl -X GET http://localhost:5000/batfish/pushed_configs/mddo_network/interfaces
L3 Reachability (traceroute) simulation
- GET
/batfish/<network>/<snapshot>/<source-node>/traceroute
interface
: source interfacedestination
: destination IP address
curl -X GET "http://localhost:5000/batfish/pushed_configs/mddo_network/regiona-svr01/traceroute?interface=enp1s4&destination=172.31.10.1"
Register snapshot
- POST
/batfish/<network>/<snapshot>/register
overwrite
: [optional] Overwrite (reload) snapshot
curl -X POST -H "Content-Type: application/json" -d {} \
http://localhost:5000/batfish/pushed_configs/mddo_network/register
# if overwrite (reload)
curl -X POST -H "Content-Type: application/json" -d '{"overwrite": true}'\
http://localhost:5000/batfish/pushed_configs/mddo_network/register
APIs to operate configs/snapshots.
Make snapshot patterns
- POST
/configs/<network>/<snapshot>/snapshot_patterns
node
: [optional] draw-off (deactivate) target nodeinterface_regexp
: [optional] draw-off (deactivate) interface name (regexp match)
# without draw-off
curl -X POST -H "Content-Type: application/json" -d '{}'\
http://localhost:5000/configs/pushed_configs/mddo_network/snapshot_patterns
# draw-off regiona-pe01[ge-0/0/0]
curl -X POST -H "Content-Type: application/json" \
-d '{"node": "regiona-pe01", "interface_regexp": "ge-0/0/0"}' \
http://localhost:5000/configs/pushed_configs/mddo_network/snapshot_patterns
CLI
python3 src/cli_make_snapshot_patterns.py -n pushed_configs -s mddo_network -d regiona-pe01 -l "ge-0/0/0"
Fetch snapshot patterns
- GET
/configs/<network>/<snapshot>/snapshot_patterns
curl http://localhost:5000/configs/pushed_configs/mddo_network/snapshot_patterns
Remove snapshot patterns
- DELETE
/configs/<network>/<snapshot>/snapshot_patterns
curl -X DELETE http://localhost:5000/configs/pushed_configs/mddo_network/snapshot_patterns
Change current branch
- POST
/configs/<network>/branch
name
: [optional] branch name (default "main")
curl -X POST -H "Content-Type: application/json" -d '{"name": "202202demo"}' \
http://localhost:5000/configs/pushed_configs/branch
Fetch current branch
- GET
/configs/<network>/branch
curl http://localhost:5000/configs/pushed_configs/branch
Save (upload) config file
- POST
/configs/<network>/<snapshot>
filename
: file nametext
: file body
Fetch (download) config file
- GET
/configs/<network>/<snapshot>/<filename>
Fetch all config files
- GET
/configs/<network>/<snapshot>
APIs to operate batfish query (query results)
Make query data
- POST
/queries/<network>
(for all snapshots in the network) - POST
/queries/<network>/<snapshot>
(for a snapshot)
# all snapshots
curl -X POST -H "Content-Type: application/json" -d '{}'\
http://localhost:5000/queries/pushed_configs
# single snapshot
curl -X POST -H "Content-Type: application/json" -d '{}'\
http://localhost:5000/queries/pushed_configs/mddo_network
CLI
-n
/--network
: target network (query for all snapshots in the network without-s
)-s
/--snapshot
: [optional] target snapshot (query for single snapshot)
# all snapshots
python3 src/cli_exec_queries.py -n pushed_configs
# single snapshot
python3 src/cli_exec_queries.py -n pushed_configs -s mddo_network
Delete query data
- DELETE
/queries/<network>
(for all snapshots in the network)
curl -XX DELETE http://localhost:5000/queries/pushed_configs
Calculate asis/tobe model diff and generate configurations using it.
- POST
/model-merge
asis
: asis topologytobe
: tobe topology
pip3 install -r requirements_dev.txt
black src/*.py src/**/*.py
flake8 --statistics --config .config/flake8 src/
pylint --rcfile .config/pylintrc src/*.py src/**/*.py
mkdocs serve
and access http://localhost:8000