-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbpdu.py
More file actions
61 lines (51 loc) · 1.85 KB
/
Copy pathbpdu.py
File metadata and controls
61 lines (51 loc) · 1.85 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
--------------------------------------------------------------------------------
------------------------- Mist API Python CLI Session --------------------------
Written by: Thomas Munzer (tmunzer@juniper.net)
Github : https://github.com/tmunzer/mistapi_python
This package is licensed under the MIT License.
--------------------------------------------------------------------------------
"""
from mistapi import APISession as _APISession
from mistapi.__logger import logger as LOGGER
from mistapi.api.v1.sites import devices
from mistapi.device_utils.__tools.__ws_wrapper import UtilResponse
def clear_error(
apissession: _APISession,
site_id: str,
device_id: str,
port_ids: list[str],
) -> UtilResponse:
"""
DEVICES: EX
Clears BPDU error state on the specified ports of a switch.
PARAMS
-----------
site_id : str
UUID of the site where the switch is located.
device_id : str
UUID of the switch to clear BPDU errors on.
port_ids : list[str]
List of port IDs to clear BPDU errors on.
RETURNS
-----------
UtilResponse
A UtilResponse object containing the API response and a list of raw messages received
from the WebSocket stream.
"""
body: dict[str, str | list | int] = {"ports": port_ids}
trigger = devices.clearBpduErrorsFromPortsOnSwitch(
apissession,
site_id=site_id,
device_id=device_id,
body=body,
)
util_response = UtilResponse(trigger)
if trigger.status_code == 200:
LOGGER.info(trigger.data)
print(f"Clear BPDU error command triggered for device {device_id}")
else:
LOGGER.error(
f"Failed to trigger clear BPDU error command: {trigger.status_code} - {trigger.data}"
) # Give the clear BPDU error command a moment to take effect
return util_response