From 3db549d76da768ef4d28fde1a30d2e7d0b79027a Mon Sep 17 00:00:00 2001 From: Blackwhitebear8 Date: Wed, 17 Sep 2025 20:05:46 +0200 Subject: [PATCH] Update modules/parse.py --- modules/parse.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/parse.py b/modules/parse.py index 48e2546..dcba0d9 100644 --- a/modules/parse.py +++ b/modules/parse.py @@ -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"]}) \ No newline at end of file + 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}) \ No newline at end of file