forked from mirrors/thatmattlove-hyperglass
added port to hyperglass-frr api
This commit is contained in:
parent
d7c336eff2
commit
f6c87eae68
2 changed files with 20 additions and 1 deletions
17
docs/configuration/frr-api.md
Normal file
17
docs/configuration/frr-api.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Add User
|
||||
|
||||
```console
|
||||
# useradd -M hyperglass-frr-api
|
||||
# usermod -L hyerglass-frr-api
|
||||
```
|
||||
|
||||
```console
|
||||
# chown -R hyerglass-frr-api:hyerglass-frr-api /opt/hyperglass-frr
|
||||
```
|
||||
iptables -A INPUT -i loopback1 -s 199.34.92.72 -p tcp --dport 8080 -J ACCEPT
|
||||
|
||||
Add user to fttvty group:
|
||||
|
||||
```console
|
||||
# usermod -a -G <group> <user>
|
||||
```
|
||||
|
|
@ -38,6 +38,7 @@ def execute(lg_data):
|
|||
for r in routers_list:
|
||||
if r["location"] == router:
|
||||
lg_router_address = r["address"]
|
||||
lg_router_port = r["port"]
|
||||
|
||||
# Check blacklist.toml array for prefixes/IPs and return an error upon a match
|
||||
if cmd in ["bgp_route", "ping", "traceroute"]:
|
||||
|
|
@ -99,6 +100,7 @@ def execute(lg_data):
|
|||
return (general_error, code, lg_data)
|
||||
|
||||
def frr_api_direct():
|
||||
"""Sends HTTP POST to router running the hyperglass-frr API"""
|
||||
msg, status, router, query = construct.frr(lg_router_address, cmd, ipprefix)
|
||||
try:
|
||||
headers = {
|
||||
|
|
@ -106,7 +108,7 @@ def execute(lg_data):
|
|||
"X-API-Key": returnCred(findCred(router))[1],
|
||||
}
|
||||
json_query = json.dumps(query)
|
||||
frr_endpoint = f"http://{router}/frr"
|
||||
frr_endpoint = f"http://{router}:{lg_router_port}/frr"
|
||||
frr_output = requests.post(frr_endpoint, headers=headers, data=json_query)
|
||||
return frr_output
|
||||
except:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue