Skip to content

Commit f503ef7

Browse files
committed
poller_status_codes: Add normalized values, strings
Signed-off-by: Dinesh Dutt <[email protected]>
1 parent 87c02be commit f503ef7

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# List of normalized error codes used in the poller
2+
3+
from enum import IntEnum
4+
5+
# Ensure you never copy backwards compat values
6+
7+
8+
class SqPollerStatusCode(IntEnum):
9+
'''SuzieQ Poller Status Codes and their strings'''
10+
11+
OK = 0, 'OK'
12+
HTTP_OK = 200, 'OK'
13+
PERMISSION_DENIED = 1001, 'Permission Denied'
14+
UNAUTHORIZED = 1002, 'Unauthorized'
15+
LOGIN_FAIL = 1003, 'Login Failed'
16+
PRIV_ESC_FAIL = 1004, 'Privilege Escalation Failed'
17+
NON_FINAL_FAILURES = 1005, 'Dummy to mark boundary, never set'
18+
CMD_NOT_FOUND = 2006, 'Command Not Found'
19+
EMPTY_OUTPUT = 2007, 'Output Empty'
20+
INCOMPLETE_CMD = 2008, 'Command Incomplete'
21+
TIMEOUT = 2009, 'Command Timeout'
22+
DISABLED_FEATURE = 2010, 'Feature Disabled'
23+
CONNECT_FAIL = 2011, 'Connect Failed'
24+
PARSING_ERROR = 2012, 'Parsing Failed'
25+
UNSUPPORTED_SVC = 2013, 'Service Not Supported'
26+
UNSUPPORTED_CMD = 2014, 'Command Not Supported'
27+
NO_RT_TO_HOST = 2015, 'No Route to Host'
28+
VAR_NOT_SET = 2016, 'Variable Not Set'
29+
WAITING_FOR_VAR = 2017, 'Variable Waiting'
30+
ERR_OUTPUT = 2018, 'Command Failed'
31+
GEN_CLS_FAIL = 2019, 'Linux Cmd Failed'
32+
UNREACH_NET = 2020, 'Network Unreachable'
33+
NO_SVC_DEF = 2021, 'Service Not Defined'
34+
UNKNOWN_FAILURE = 2022, 'Unknown Failure'
35+
CONN_REFUSED = 2023, 'Connection Refused'
36+
UNEXPECTED_DISCONNECT = 2024, 'Unexpected Disconnect'
37+
38+
# Everything below this is for backward compat
39+
LINUX_OLD_CMD_NOT_FOUND = 1, 'Command Not Found'
40+
NXOS_CMD_NOT_FOUND = 16, 'Command Not Found'
41+
NXOS_YACNF = 20, 'Command Not Found'
42+
LINUX_CMD_NOT_FOUND = 127, 'Command Not Found'
43+
HTTP_EMPTY_OUTPUT = 204, 'Empty Output'
44+
OLD_EMPTY_OUTPUT = 244, 'Empty Output'
45+
HTTP_INCOMPLETE_CMD = 400, 'Incomplete Command'
46+
HTTP_LOGIN_FAIL = 401, 'Login Failed'
47+
HTTP_BAD_CMD = 404, 'Command Not Found'
48+
HTTP_YAIC = 405, 'Incomplete Command'
49+
HTTP_TIMEOUT = 408, 'Timeout'
50+
OLD_FEATURE_DISABLED = 418, 'Feature Disabled'
51+
OLD_PARSING_ERROR = 502, 'Parsing Error'
52+
OLD_PRIV_ESC_FAIL = -1, 'Privilege Escalation Failed'
53+
54+
def __new__(cls, code: int, errstr: str):
55+
obj = int.__new__(cls, code)
56+
obj._value_ = code
57+
obj.errstr = errstr
58+
59+
return obj
60+
61+
def is_error_code_final(self):
62+
'''is the node in stopped state'''
63+
return (self.value < self.NON_FINAL_FAILURES.value)

0 commit comments

Comments
 (0)