Alex | 0989ecf | 2022-03-29 13:43:21 -0500 | [diff] [blame] | 1 | # Author: Alex Savatieiev (osavatieiev@mirantis.com; a.savex@gmail.com) |
| 2 | # Copyright 2019-2022 Mirantis, Inc. |
Alex Savatieiev | 5118de0 | 2019-02-20 15:50:42 -0600 | [diff] [blame] | 3 | class CheckerBaseExceptions(Exception): |
Alex Savatieiev | d48994d | 2018-12-13 12:13:00 +0100 | [diff] [blame] | 4 | pass |
| 5 | |
| 6 | |
Alex Savatieiev | 5118de0 | 2019-02-20 15:50:42 -0600 | [diff] [blame] | 7 | class CheckerException(CheckerBaseExceptions): |
Alex Savatieiev | d48994d | 2018-12-13 12:13:00 +0100 | [diff] [blame] | 8 | def __init__(self, message, *args, **kwargs): |
| 9 | super(CheckerException, self).__init__(message, *args, **kwargs) |
| 10 | # get the trace |
| 11 | # TODO: get and log traceback |
| 12 | |
| 13 | # prettify message |
Alex Savatieiev | f808cd2 | 2019-03-01 13:17:59 -0600 | [diff] [blame] | 14 | self.message = "# CheckerException: {}".format(message) |
Alex Savatieiev | d48994d | 2018-12-13 12:13:00 +0100 | [diff] [blame] | 15 | |
| 16 | |
| 17 | class ConfigException(CheckerException): |
| 18 | def __init__(self, message, *args, **kwargs): |
| 19 | super(ConfigException, self).__init__(message, *args, **kwargs) |
Alex Savatieiev | f808cd2 | 2019-03-01 13:17:59 -0600 | [diff] [blame] | 20 | self.message = "# Configuration error: {}".format(message) |
Alex Savatieiev | 6357683 | 2019-02-27 15:46:26 -0600 | [diff] [blame] | 21 | |
| 22 | |
Alex | 9a4ad21 | 2020-10-01 18:04:25 -0500 | [diff] [blame] | 23 | class CommandNotSupportedException(CheckerException): |
| 24 | def __init__(self, message, *args, **kwargs): |
| 25 | super(CommandNotSupportedException, self).__init__( |
| 26 | message, |
| 27 | *args, |
| 28 | **kwargs |
| 29 | ) |
| 30 | self.message = "# Command not supported: {}".format(message) |
| 31 | |
| 32 | |
| 33 | class CommandTypeNotSupportedException(CheckerException): |
| 34 | def __init__(self, message, *args, **kwargs): |
| 35 | super(CommandTypeNotSupportedException, self).__init__( |
| 36 | message, |
| 37 | *args, |
| 38 | **kwargs |
| 39 | ) |
| 40 | self.message = "# Command type not supported: {}".format(message) |
| 41 | |
| 42 | |
Alex Savatieiev | 6357683 | 2019-02-27 15:46:26 -0600 | [diff] [blame] | 43 | class SaltException(CheckerException): |
| 44 | def __init__(self, message, *args, **kwargs): |
| 45 | super(SaltException, self).__init__(message, *args, **kwargs) |
Alex Savatieiev | f808cd2 | 2019-03-01 13:17:59 -0600 | [diff] [blame] | 46 | self.message = "# Salt error: {}".format(message) |
Alex Savatieiev | 6357683 | 2019-02-27 15:46:26 -0600 | [diff] [blame] | 47 | |
| 48 | |
Alex | 9a4ad21 | 2020-10-01 18:04:25 -0500 | [diff] [blame] | 49 | class KubeException(CheckerException): |
| 50 | def __init__(self, message, *args, **kwargs): |
| 51 | super(KubeException, self).__init__(message, *args, **kwargs) |
| 52 | self.message = "# Kube client error: {}".format(message) |
| 53 | |
| 54 | |
Alex Savatieiev | 6357683 | 2019-02-27 15:46:26 -0600 | [diff] [blame] | 55 | class InvalidReturnException(CheckerException): |
| 56 | def __init__(self, message, *args, **kwargs): |
| 57 | super(InvalidReturnException, self).__init__(message, *args, **kwargs) |
Alex Savatieiev | f808cd2 | 2019-03-01 13:17:59 -0600 | [diff] [blame] | 58 | self.message = "# Unexpected return value: {}".format(message) |
Alex | 3ebc563 | 2019-04-18 16:47:18 -0500 | [diff] [blame] | 59 | |
| 60 | |
Alex | 9a4ad21 | 2020-10-01 18:04:25 -0500 | [diff] [blame] | 61 | class TimeoutException(CheckerException): |
| 62 | def __init__(self, message, *args, **kwargs): |
| 63 | super(TimeoutException, self).__init__(message, *args, **kwargs) |
| 64 | self.message = "# Timed out waiting: {}".format(message) |
| 65 | |
| 66 | |
Alex | 3ebc563 | 2019-04-18 16:47:18 -0500 | [diff] [blame] | 67 | class ErrorMappingException(CheckerException): |
| 68 | def __init__(self, message, *args, **kwargs): |
| 69 | super(ErrorMappingException, self).__init__(message, *args, **kwargs) |
| 70 | self.message = "# Unexpected error mapping/type: {}".format(message) |