Update modules/parse.py
This commit is contained in:
parent
7417be581e
commit
3db549d76d
1 changed files with 20 additions and 2 deletions
|
|
@ -9,7 +9,8 @@ VYOS_API_KEY = os.getenv("VYOS_API_KEY")
|
|||
|
||||
def _run_curl(endpoint, data_payload):
|
||||
curl_command = [
|
||||
"curl", "-k", "--location", "--request", "POST", f"{VYOS_API_URL}{endpoint}",
|
||||
"curl", "-s", "-k",
|
||||
"--location", "--request", "POST", f"{VYOS_API_URL}{endpoint}",
|
||||
"--form", f"data={json.dumps(data_payload)}",
|
||||
"--form", f"key={VYOS_API_KEY}"
|
||||
]
|
||||
|
|
@ -30,6 +31,15 @@ def get_bgp_neighbor_config_path(neighbor_ip):
|
|||
else:
|
||||
return ["protocols", "bgp", "neighbor", neighbor_ip]
|
||||
|
||||
def get_route_summary_path(ip_version):
|
||||
vrf_name = os.getenv("BGP_VRF_NAME")
|
||||
path = [ip_version, "route"]
|
||||
if vrf_name:
|
||||
path.extend(["vrf", vrf_name, "summary"])
|
||||
else:
|
||||
path.append("summary")
|
||||
return path
|
||||
|
||||
def run_bgp_curl_command():
|
||||
path = get_bgp_base_path() + ["summ"]
|
||||
return _run_curl("/show", {"op": "show", "path": path})
|
||||
|
|
@ -90,4 +100,12 @@ def run_firewall_ipv4_curl_command():
|
|||
return _run_curl("/show", {"op": "show", "path": ["firewall", "ipv4"]})
|
||||
|
||||
def run_firewall_ipv6_curl_command():
|
||||
return _run_curl("/show", {"op": "show", "path": ["firewall", "ipv6"]})
|
||||
return _run_curl("/show", {"op": "show", "path": ["firewall", "ipv6"]})
|
||||
|
||||
def run_ipv4_route_summary_curl_command():
|
||||
path = get_route_summary_path("ip")
|
||||
return _run_curl("/show", {"op": "show", "path": path})
|
||||
|
||||
def run_ipv6_route_summary_curl_command():
|
||||
path = get_route_summary_path("ipv6")
|
||||
return _run_curl("/show", {"op": "show", "path": path})
|
||||
Loading…
Add table
Add a link
Reference in a new issue