diff --git a/interfaces.py b/interfaces.py deleted file mode 100644 index 3ef5015..0000000 --- a/interfaces.py +++ /dev/null @@ -1,172 +0,0 @@ -import json -import subprocess -from jinja2 import Template -from flask import Flask, render_template_string, jsonify - -app = Flask(__name__) - -def run_curl_command(): - curl_command = [ - "curl", "-k", "--location", "--request", "POST", "https://ip:port/show", - "--form", "data={\"op\": \"show\", \"path\": [\"interfaces\"]}", - "--form", "key=key" - ] - response = subprocess.check_output(curl_command, text=True) - return json.loads(response) - -def parse_interface_data(data): - interface_table = [] - - if "data" in data: - raw_data = data["data"] - - for line in raw_data.split("\n"): - if line.startswith("Interface") and "IP Address" in line: - continue - - if line.startswith("Codes:"): - continue - - if line.strip().startswith('-'): - continue - - if line.strip(): - interface_info = line.split() - if len(interface_info) >= 6: - interface_table.append({ - "interface": interface_info[0], - "ip_address": interface_info[1] if interface_info[1] != '-' else 'N/A', - "mac_address": interface_info[2], - "vrf": interface_info[3], - "mtu": interface_info[4], - "status": interface_info[5], - "description": " ".join(interface_info[6:]) - }) - - return interface_table - -def generate_html_table(interface_table): - html_template = """ - - -
- - -Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
-| Interface | -IP Address | -MAC Address | -VRF | -MTU | -Status | -Description | -
|---|---|---|---|---|---|---|
| {{ entry.interface }} | -{{ entry.ip_address }} | -{{ entry.mac_address }} | -{{ entry.vrf }} | -{{ entry.mtu }} | -{{ entry.status }} | -{{ entry.description }} | -