blob: 59bcc1adbaf262040ea6b6d7dd4d5f860b370554 [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
David Garcia4fee80e2020-05-13 12:18:38 +020020class JujuControllerFailedConnecting(Exception):
21 """Failed connecting to juju controller."""
22
23
24class JujuModelAlreadyExists(Exception):
25 """The model already exists."""
26
27
Adam Israel0cd1c022019-09-03 18:26:08 -040028class JujuApplicationExists(Exception):
29 """The Application already exists."""
30
31
David Garcia4fee80e2020-05-13 12:18:38 +020032class JujuApplicationNotFound(Exception):
33 """The Application cannot be found."""
34
35
36class JujuMachineNotFound(Exception):
37 """The machine cannot be found."""
38
39
Dominik Fleischmannbd808f22020-06-09 11:57:14 +020040class JujuK8sProxycharmNotSupported(Exception):
41 """K8s Proxy Charms not supported in this installation."""
42
43
Adam Israel0cd1c022019-09-03 18:26:08 -040044class N2VCPrimitiveExecutionFailed(Exception):
45 """Something failed while attempting to execute a primitive."""
46
47
48class NetworkServiceDoesNotExist(Exception):
49 """The Network Service being acted against does not exist."""
50
51
52class PrimitiveDoesNotExist(Exception):
53 """The Primitive being executed does not exist."""
54
55
56class NoRouteToHost(Exception):
57 """There was no route to the specified host."""
58
59
60class AuthenticationFailed(Exception):
61 """The authentication for the specified user failed."""
Adam Israel19c5cfc2019-10-03 12:35:38 -040062
Adam Israeld238b032019-11-11 16:42:02 -080063
beierlmf52cb7c2020-04-21 16:36:35 -040064class MethodNotImplemented(Exception):
Adam Israel9e5eddb2019-12-01 12:55:09 -050065 """The method is not implemented."""
66
67
quilesj29114342019-10-29 09:30:44 +010068class N2VCException(Exception):
69 """
70 N2VC exception base class
71 """
72
beierlmf52cb7c2020-04-21 16:36:35 -040073 def __init__(self, message: str = ""):
quilesj29114342019-10-29 09:30:44 +010074 Exception.__init__(self, message)
75 self.message = message
76
77 def __str__(self):
78 return self.message
79
80 def __repr__(self):
beierlmf52cb7c2020-04-21 16:36:35 -040081 return "{}({})".format(type(self), self.message)
quilesj29114342019-10-29 09:30:44 +010082
83
84class N2VCBadArgumentsException(N2VCException):
85 """
86 Bad argument values exception
87 """
88
beierlmf52cb7c2020-04-21 16:36:35 -040089 def __init__(self, message: str = "", bad_args: list = None):
quilesj29114342019-10-29 09:30:44 +010090 N2VCException.__init__(self, message=message)
91 self.bad_args = bad_args
92
93 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -040094 return "<{}> Bad arguments: {} -> {}".format(
95 type(self), super().__str__(), self.bad_args
96 )
quilesj29114342019-10-29 09:30:44 +010097
98
99class N2VCConnectionException(N2VCException):
100 """
101 Error connecting to VCA
102 """
103
beierlmf52cb7c2020-04-21 16:36:35 -0400104 def __init__(self, message: str = "", url: str = None):
quilesj29114342019-10-29 09:30:44 +0100105 N2VCException.__init__(self, message=message)
106 self.url = url
107
108 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400109 return "<{}> Connection to {} failed: {}".format(
110 type(self), self.url, super().__str__()
111 )
quilesj29114342019-10-29 09:30:44 +0100112
113
114class N2VCTimeoutException(N2VCException):
115 """
116 Timeout
117 """
118
beierlmf52cb7c2020-04-21 16:36:35 -0400119 def __init__(self, message: str = "", timeout: str = ""):
quilesj29114342019-10-29 09:30:44 +0100120 N2VCException.__init__(self, message=message)
121 self.timeout = timeout
122
123 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400124 return "<{}> {} timeout: {}".format(type(self), self.timeout, super().__str__())
quilesj29114342019-10-29 09:30:44 +0100125
126
127class N2VCExecutionException(N2VCException):
128 """
129 Error executing primitive
130 """
131
beierlmf52cb7c2020-04-21 16:36:35 -0400132 def __init__(self, message: str = "", primitive_name: str = ""):
quilesj29114342019-10-29 09:30:44 +0100133 N2VCException.__init__(self, message=message)
134 self.primitive_name = primitive_name
135
136 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400137 return "<{}> Error executing primitive {} failed: {}".format(
138 type(self), self.primitive_name, super().__str__()
139 )
quilesj29114342019-10-29 09:30:44 +0100140
Adam Israel9e5eddb2019-12-01 12:55:09 -0500141
quilesj29114342019-10-29 09:30:44 +0100142class N2VCInvalidCertificate(N2VCException):
143 """
144 Invalid certificate
145 """
146
beierlmf52cb7c2020-04-21 16:36:35 -0400147 def __init__(self, message: str = ""):
quilesj29114342019-10-29 09:30:44 +0100148 N2VCException.__init__(self, message=message)
149
150 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400151 return "<{}> Invalid certificate: {}".format(type(self), super().__str__())
quilesja6748412019-12-04 07:51:26 +0000152
153
David Garciac6b19262020-04-08 09:48:21 +0200154class N2VCNotFound(N2VCException):
155 """
156 Not found
157 """
158
beierlmf52cb7c2020-04-21 16:36:35 -0400159 def __init__(self, message: str = ""):
David Garciac6b19262020-04-08 09:48:21 +0200160 N2VCException.__init__(self, message=message)
161
162 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400163 return "<{}> Not found: {}".format(type(self), super().__str__())
David Garciac6b19262020-04-08 09:48:21 +0200164
165
quilesja6748412019-12-04 07:51:26 +0000166class K8sException(Exception):
167 """
168 K8s exception
169 """
170
171 def __init__(self, message: str):
172 Exception.__init__(self, message)
173 self._message = message
174
175 def __str__(self):
176 return self._message
177
178 def __repr__(self):
179 return self._message
David Garcia4fee80e2020-05-13 12:18:38 +0200180
181
182class EntityInvalidException(Exception):
183 """Entity is not valid, the type does not match any EntityType."""