mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
added port to hyperglass-frr api
This commit is contained in:
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:
|
for r in routers_list:
|
||||||
if r["location"] == router:
|
if r["location"] == router:
|
||||||
lg_router_address = r["address"]
|
lg_router_address = r["address"]
|
||||||
|
lg_router_port = r["port"]
|
||||||
|
|
||||||
# Check blacklist.toml array for prefixes/IPs and return an error upon a match
|
# Check blacklist.toml array for prefixes/IPs and return an error upon a match
|
||||||
if cmd in ["bgp_route", "ping", "traceroute"]:
|
if cmd in ["bgp_route", "ping", "traceroute"]:
|
||||||
@@ -99,6 +100,7 @@ def execute(lg_data):
|
|||||||
return (general_error, code, lg_data)
|
return (general_error, code, lg_data)
|
||||||
|
|
||||||
def frr_api_direct():
|
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)
|
msg, status, router, query = construct.frr(lg_router_address, cmd, ipprefix)
|
||||||
try:
|
try:
|
||||||
headers = {
|
headers = {
|
||||||
@@ -106,7 +108,7 @@ def execute(lg_data):
|
|||||||
"X-API-Key": returnCred(findCred(router))[1],
|
"X-API-Key": returnCred(findCred(router))[1],
|
||||||
}
|
}
|
||||||
json_query = json.dumps(query)
|
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)
|
frr_output = requests.post(frr_endpoint, headers=headers, data=json_query)
|
||||||
return frr_output
|
return frr_output
|
||||||
except:
|
except:
|
||||||
|
Reference in New Issue
Block a user