blob: 815d4eab3dd929315081509a096711fa5f2bff09 [file] [log] [blame]
Adam Israel0cd1c022019-09-03 18:26:08 -04001# Copyright 2019 Canonical Ltd.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
quilesja6748412019-12-04 07:51:26 +000015
Adam Israel0cd1c022019-09-03 18:26:08 -040016class JujuCharmNotFound(Exception):
17 """The Charm can't be found or is not readable."""
18
19
20class JujuApplicationExists(Exception):
21 """The Application already exists."""
22
23
24class N2VCPrimitiveExecutionFailed(Exception):
25 """Something failed while attempting to execute a primitive."""
26
27
28class NetworkServiceDoesNotExist(Exception):
29 """The Network Service being acted against does not exist."""
30
31
32class PrimitiveDoesNotExist(Exception):
33 """The Primitive being executed does not exist."""
34
35
36class NoRouteToHost(Exception):
37 """There was no route to the specified host."""
38
39
40class AuthenticationFailed(Exception):
41 """The authentication for the specified user failed."""
Adam Israel19c5cfc2019-10-03 12:35:38 -040042
Adam Israeld238b032019-11-11 16:42:02 -080043
Adam Israel9e5eddb2019-12-01 12:55:09 -050044class NotImplemented(Exception):
45 """The method is not implemented."""
46
47
quilesj29114342019-10-29 09:30:44 +010048class N2VCException(Exception):
49 """
50 N2VC exception base class
51 """
52
53 def __init__(self, message: str = ''):
54 Exception.__init__(self, message)
55 self.message = message
56
57 def __str__(self):
58 return self.message
59
60 def __repr__(self):
61 return '{}({})'.format(type(self), self.message)
62
63
64class N2VCBadArgumentsException(N2VCException):
65 """
66 Bad argument values exception
67 """
68
69 def __init__(self, message: str = '', bad_args: list = None):
70 N2VCException.__init__(self, message=message)
71 self.bad_args = bad_args
72
73 def __str__(self):
74 return '<{}> Bad arguments: {} -> {}'.format(type(self), super().__str__(), self.bad_args)
75
76
77class N2VCConnectionException(N2VCException):
78 """
79 Error connecting to VCA
80 """
81
82 def __init__(self, message: str = '', url: str = None):
83 N2VCException.__init__(self, message=message)
84 self.url = url
85
86 def __str__(self):
87 return '<{}> Connection to {} failed: {}'.format(type(self), self.url, super().__str__())
88
89
90class N2VCTimeoutException(N2VCException):
91 """
92 Timeout
93 """
94
95 def __init__(self, message: str = '', timeout: str = ''):
96 N2VCException.__init__(self, message=message)
97 self.timeout = timeout
98
99 def __str__(self):
100 return '<{}> {} timeout: {}'.format(type(self), self.timeout, super().__str__())
101
102
103class N2VCExecutionException(N2VCException):
104 """
105 Error executing primitive
106 """
107
108 def __init__(self, message: str = '', primitive_name: str = ''):
109 N2VCException.__init__(self, message=message)
110 self.primitive_name = primitive_name
111
112 def __str__(self):
113 return '<{}> Error executing primitive {} failed: {}'.format(type(self), self.primitive_name, super().__str__())
114
Adam Israel9e5eddb2019-12-01 12:55:09 -0500115
quilesj29114342019-10-29 09:30:44 +0100116class N2VCInvalidCertificate(N2VCException):
117 """
118 Invalid certificate
119 """
120
121 def __init__(self, message: str = ''):
122 N2VCException.__init__(self, message=message)
123
124 def __str__(self):
125 return '<{}> Invalid certificate: {}'.format(type(self), super().__str__())
quilesja6748412019-12-04 07:51:26 +0000126
127
David Garciac6b19262020-04-08 09:48:21 +0200128class N2VCNotFound(N2VCException):
129 """
130 Not found
131 """
132
133 def __init__(self, message: str = ''):
134 N2VCException.__init__(self, message=message)
135
136 def __str__(self):
137 return '<{}> Not found: {}'.format(type(self), super().__str__())
138
139
quilesja6748412019-12-04 07:51:26 +0000140class K8sException(Exception):
141 """
142 K8s exception
143 """
144
145 def __init__(self, message: str):
146 Exception.__init__(self, message)
147 self._message = message
148
149 def __str__(self):
150 return self._message
151
152 def __repr__(self):
153 return self._message