Repository navigation
Expand file tree
/
Copy pathinterface_check.patch
More file actions
executable file
·47 lines (45 loc) · 2.22 KB
/
Copy pathinterface_check.patch
File metadata and controls
executable file
·47 lines (45 loc) · 2.22 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--- a/run_tgen_server.py
+++ b/run_tgen_server.py
@@ -3419,6 +3419,30 @@ def get_device_arp_status(device_id):
}), 200
+ # Check if the network interface is actually up
+ server_interface = device.get('server_interface')
+ if server_interface:
+ try:
+ import subprocess
+ # Check interface status using ip link show
+ result = subprocess.run(["ip", "link", "show", server_interface],
+ capture_output=True, text=True, timeout=5)
+ if result.returncode == 0:
+ # Check if interface is UP
+ if "state DOWN" in result.stdout:
+ return jsonify({
+ "arp_resolved": False,
+ "arp_ipv4_resolved": False,
+ "arp_ipv6_resolved": False,
+ "arp_gateway_resolved": False,
+ "arp_status": "Interface down",
+ "details": {"error": f"Interface {server_interface} is down"}
+ }), 200
+ else:
+ # Interface doesn't exist
+ return jsonify({
+ "arp_resolved": False,
+ "arp_ipv4_resolved": False,
+ "arp_ipv6_resolved": False,
+ "arp_gateway_resolved": False,
+ "arp_status": "Interface not found",
+ "details": {"error": f"Interface {server_interface} not found"}
+ }), 200
+ except Exception as e:
+ logging.warning(f"[ARP STATUS] Failed to check interface status for {server_interface}: {e}")
+ # Continue with ARP checks even if interface check fails
+
# Get device IP addresses
ipv4_address = device.get('ipv4_address')
ipv6_address = device.get('ipv6_address')
ipv4_gateway = device.get('ipv4_gateway')
ipv6_gateway = device.get('ipv6_gateway')
- server_interface = device.get('server_interface')
if not server_interface:
return jsonify({