Upload files to "modules"
This commit is contained in:
parent
8b7378ebaa
commit
7ce1184719
4 changed files with 331 additions and 0 deletions
58
modules/parse.py
Normal file
58
modules/parse.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import subprocess
|
||||
import json
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
VYOS_API_URL = os.getenv("VYOS_API_URL")
|
||||
VYOS_API_KEY = os.getenv("VYOS_API_KEY")
|
||||
|
||||
def run_bgp_curl_command():
|
||||
curl_command = [
|
||||
"curl", "-k", "--location", "--request", "POST", f"{VYOS_API_URL}/show",
|
||||
"--form", "data={\"op\": \"show\", \"path\": [\"bgp\", \"vrf\", \"bgp\", \"summ\"]}",
|
||||
"--form", f"key={VYOS_API_KEY}"
|
||||
]
|
||||
response = subprocess.check_output(curl_command, text=True)
|
||||
return json.loads(response)
|
||||
|
||||
def run_arp_curl_command():
|
||||
curl_command = [
|
||||
"curl", "-k", "--location", "--request", "POST", f"{VYOS_API_URL}/show",
|
||||
"--form", "data={\"op\": \"show\", \"path\": [\"arp\"]}",
|
||||
"--form", f"key={VYOS_API_KEY}"
|
||||
]
|
||||
response = subprocess.check_output(curl_command, text=True)
|
||||
return json.loads(response)
|
||||
|
||||
def run_neighbors_curl_command():
|
||||
curl_command = [
|
||||
"curl", "-k", "--location", "--request", "POST", f"{VYOS_API_URL}/show",
|
||||
"--form", "data={\"op\": \"show\", \"path\": [\"ipv6\", \"neighbors\"]}",
|
||||
"--form", f"key={VYOS_API_KEY}"
|
||||
]
|
||||
response = subprocess.check_output(curl_command, text=True)
|
||||
return json.loads(response)
|
||||
|
||||
def run_interfaces_curl_command():
|
||||
curl_command = [
|
||||
"curl", "-k", "--location", "--request", "POST", f"{VYOS_API_URL}/show",
|
||||
"--form", "data={\"op\": \"show\", \"path\": [\"interfaces\"]}",
|
||||
"--form", f"key={VYOS_API_KEY}"
|
||||
]
|
||||
response = subprocess.check_output(curl_command, text=True)
|
||||
return json.loads(response)
|
||||
|
||||
def run_bgp_route_curl_command(ip_version, bgprouteprefix):
|
||||
data_json = {
|
||||
"op": "show",
|
||||
"path": ["bgp", "vrf", "bgp", ip_version, bgprouteprefix]
|
||||
}
|
||||
curl_command = [
|
||||
"curl", "-k", "--location", "--request", "POST", f"{VYOS_API_URL}/show",
|
||||
"--form", f"data={json.dumps(data_json)}",
|
||||
"--form", f"key={VYOS_API_KEY}"
|
||||
]
|
||||
response = subprocess.check_output(curl_command, text=True)
|
||||
return json.loads(response)
|
||||
Loading…
Add table
Add a link
Reference in a new issue