Created
November 11, 2022 19:02
-
-
Save renatoalmeidaoliveira/454e785dba8b19db69699a01f4856c09 to your computer and use it in GitHub Desktop.
Netbox Webhoocks integration with exaBGP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process http-api { | |
run /home/renato/rtbh/venv/bin/python /home/renato/rtbh/http_api.py; | |
encoder text; | |
} | |
template { | |
neighbor AS_65000 { | |
router-id 192.168.194.132; | |
local-as 65000; | |
local-address 192.168.194.132; | |
peer-as 65000; | |
api listening { | |
processes [ http-api ]; | |
} | |
} | |
} | |
neighbor 192.168.194.136 { | |
inherit AS_65000; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request | |
from sys import stdout | |
app = Flask(__name__) | |
# Setup a command route to listen for prefix advertisements | |
@app.route('/', methods=['POST']) | |
def command(): | |
data = request.get_json() | |
if data['action'] == 'create': | |
command = f"command=announce route {data['prefix']} next-hop self" | |
elif data['action'] == 'delete': | |
command = f"command=withdraw route {data['prefix']} next-hop self" | |
print(data['action']) | |
print(command) | |
stdout.write('%s\n' % command) | |
stdout.flush() | |
return '%s\n' % command | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment