-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.py
More file actions
executable file
·33 lines (27 loc) · 1.47 KB
/
Copy pathhandler.py
File metadata and controls
executable file
·33 lines (27 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# plugins/interface_check/handler.py
# ──────────────────────────────────────────────────────────────
# Replace the mock data below with real Netmiko/NAPALM/Nornir
# calls to query your actual network devices.
#
# If you need netmiko: add a requirements.txt in this folder with:
# netmiko==4.3.0
# ──────────────────────────────────────────────────────────────
def get_interface_status(device: str, interface: str) -> str:
"""Return mock interface status for a network device."""
mock_data = {
("router1", "gi0/0"): {"status": "up", "protocol": "up", "speed": "1Gbps", "errors": 0},
("router1", "gi0/1"): {"status": "up", "protocol": "down", "speed": "1Gbps", "errors": 12},
("switch1", "eth0"): {"status": "up", "protocol": "up", "speed": "10Gbps", "errors": 0},
}
key = (device.strip().lower(), interface.strip().lower())
data = mock_data.get(key)
if not data:
return (
f"No data for {interface} on {device}. "
f"Available: {[f'{d}:{i}' for d, i in mock_data.keys()]}"
)
return (
f"Interface {interface} on {device}: "
f"Status={data['status']}/{data['protocol']}, "
f"Speed={data['speed']}, Errors={data['errors']}"
)