Interface and Layer 2 link O&M (interface/aggregation/VLAN/MAC/STP), executing show/display commands via the local NOC API.
Used for troubleshooting device interface physical status, description information, link aggregation (Eth-Trunk/EtherChannel), VLAN, MAC address table, and STP status.
device_name (required): Device namevendor (required): Huawei | Cisco | H3Cquestion_number (required): Number representing the current question/problem ID being solvedaction (required):
int_brief: Interface brief statusint_desc: Interface descriptionlink_agg: Link aggregation informationvlan: VLAN statusmac: MAC address tablestp_brief: STP summarystp_interface: Interface STP status (Cisco requires interface_id)interface_idGi1/0/1Eth-Trunk1http://127.0.0.1:5000/api/agent/executePOST{ "device_name": "...", "command": "...", "question_number": 1 }Huawei:
int_brief: display interface brief
int_desc: display interface description
link_agg: display eth-trunk
vlan: display vlan
mac: display mac-address
stp_brief: display stp brief
stp_interface: display stp interface brief
Cisco:
int_brief: show ip int brief
int_desc: show interface description
link_agg: show etherchannel summary
vlan: show vlan brief
mac: show mac address-table
stp_brief: show spanning-tree brief
stp_interface: show spanning-tree interface <interface_id>
H3C:
int_brief: display interface brief
int_desc: display interface description
link_agg: display link-aggregation summary
vlan: display vlan
mac: display mac-address
stp_brief: display stp brief
stp_interface: display stp interface brief
Note: In Windows/enterprise environments, system proxies may interfere with local
127.0.0.1calls;s.trust_env = Falseis used here to disable environment proxies.
import os
import requests
# Remove proxy environment variables to prevent interference with local API calls
for key in ["http_proxy", "https_proxy", "HTTP_PROXY", "HTTPS_PROXY"]:
os.environ.pop(key, None)
s = requests.Session()
s.trust_env = False # Do not read system/environment proxies
url = "http://127.0.0.1:5000/api/agent/execute"
body = {
"device_name": "SW-01",
"command": "display interface brief",
"question_number": 1,
}
r = s.post(url, json=body, timeout=30)
r.raise_for_status()
print(r.text)