blob: ae9dbfbc2996ad32eca59819d1bca4c4b0331204 [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
Dominik Fleischmannb78b3e02020-07-07 13:11:19 +020036class JujuLeaderUnitNotFound(Exception):
37 """The Application cannot be found."""
38
39
40class JujuActionNotFound(Exception):
41 """The Action cannot be found."""
42
43
David Garcia4fee80e2020-05-13 12:18:38 +020044class JujuMachineNotFound(Exception):
45 """The machine cannot be found."""
46
47
Dominik Fleischmannbd808f22020-06-09 11:57:14 +020048class JujuK8sProxycharmNotSupported(Exception):
49 """K8s Proxy Charms not supported in this installation."""
50
51
Adam Israel0cd1c022019-09-03 18:26:08 -040052class N2VCPrimitiveExecutionFailed(Exception):
53 """Something failed while attempting to execute a primitive."""
54
55
56class NetworkServiceDoesNotExist(Exception):
57 """The Network Service being acted against does not exist."""
58
59
60class PrimitiveDoesNotExist(Exception):
61 """The Primitive being executed does not exist."""
62
63
64class NoRouteToHost(Exception):
65 """There was no route to the specified host."""
66
67
68class AuthenticationFailed(Exception):
69 """The authentication for the specified user failed."""
Adam Israel19c5cfc2019-10-03 12:35:38 -040070
Adam Israeld238b032019-11-11 16:42:02 -080071
beierlmf52cb7c2020-04-21 16:36:35 -040072class MethodNotImplemented(Exception):
Adam Israel9e5eddb2019-12-01 12:55:09 -050073 """The method is not implemented."""
74
75
quilesj29114342019-10-29 09:30:44 +010076class N2VCException(Exception):
77 """
78 N2VC exception base class
79 """
80
beierlmf52cb7c2020-04-21 16:36:35 -040081 def __init__(self, message: str = ""):
quilesj29114342019-10-29 09:30:44 +010082 Exception.__init__(self, message)
83 self.message = message
84
85 def __str__(self):
86 return self.message
87
88 def __repr__(self):
beierlmf52cb7c2020-04-21 16:36:35 -040089 return "{}({})".format(type(self), self.message)
quilesj29114342019-10-29 09:30:44 +010090
91
92class N2VCBadArgumentsException(N2VCException):
93 """
94 Bad argument values exception
95 """
96
beierlmf52cb7c2020-04-21 16:36:35 -040097 def __init__(self, message: str = "", bad_args: list = None):
quilesj29114342019-10-29 09:30:44 +010098 N2VCException.__init__(self, message=message)
99 self.bad_args = bad_args
100
101 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400102 return "<{}> Bad arguments: {} -> {}".format(
103 type(self), super().__str__(), self.bad_args
104 )
quilesj29114342019-10-29 09:30:44 +0100105
106
107class N2VCConnectionException(N2VCException):
108 """
109 Error connecting to VCA
110 """
111
beierlmf52cb7c2020-04-21 16:36:35 -0400112 def __init__(self, message: str = "", url: str = None):
quilesj29114342019-10-29 09:30:44 +0100113 N2VCException.__init__(self, message=message)
114 self.url = url
115
116 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400117 return "<{}> Connection to {} failed: {}".format(
118 type(self), self.url, super().__str__()
119 )
quilesj29114342019-10-29 09:30:44 +0100120
121
122class N2VCTimeoutException(N2VCException):
123 """
124 Timeout
125 """
126
beierlmf52cb7c2020-04-21 16:36:35 -0400127 def __init__(self, message: str = "", timeout: str = ""):
quilesj29114342019-10-29 09:30:44 +0100128 N2VCException.__init__(self, message=message)
129 self.timeout = timeout
130
131 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400132 return "<{}> {} timeout: {}".format(type(self), self.timeout, super().__str__())
quilesj29114342019-10-29 09:30:44 +0100133
134
135class N2VCExecutionException(N2VCException):
136 """
137 Error executing primitive
138 """
139
beierlmf52cb7c2020-04-21 16:36:35 -0400140 def __init__(self, message: str = "", primitive_name: str = ""):
quilesj29114342019-10-29 09:30:44 +0100141 N2VCException.__init__(self, message=message)
142 self.primitive_name = primitive_name
143
144 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400145 return "<{}> Error executing primitive {} failed: {}".format(
146 type(self), self.primitive_name, super().__str__()
147 )
quilesj29114342019-10-29 09:30:44 +0100148
Adam Israel9e5eddb2019-12-01 12:55:09 -0500149
quilesj29114342019-10-29 09:30:44 +0100150class N2VCInvalidCertificate(N2VCException):
151 """
152 Invalid certificate
153 """
154
beierlmf52cb7c2020-04-21 16:36:35 -0400155 def __init__(self, message: str = ""):
quilesj29114342019-10-29 09:30:44 +0100156 N2VCException.__init__(self, message=message)
157
158 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400159 return "<{}> Invalid certificate: {}".format(type(self), super().__str__())
quilesja6748412019-12-04 07:51:26 +0000160
161
David Garciac6b19262020-04-08 09:48:21 +0200162class N2VCNotFound(N2VCException):
163 """
164 Not found
165 """
166
beierlmf52cb7c2020-04-21 16:36:35 -0400167 def __init__(self, message: str = ""):
David Garciac6b19262020-04-08 09:48:21 +0200168 N2VCException.__init__(self, message=message)
169
170 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400171 return "<{}> Not found: {}".format(type(self), super().__str__())
David Garciac6b19262020-04-08 09:48:21 +0200172
173
ksaikiranr05ddb452021-01-27 22:07:46 +0530174class JujuError(N2VCException):
175 """
176 Juju Error
177 """
178
179 def __init__(self, message: str = ""):
180 N2VCException.__init__(self, message=message)
181
182 def __str__(self):
183 return "<{}> Juju Error: {}".format(type(self), super().__str__())
184
185
quilesja6748412019-12-04 07:51:26 +0000186class K8sException(Exception):
187 """
188 K8s exception
189 """
190
191 def __init__(self, message: str):
192 Exception.__init__(self, message)
193 self._message = message
194
195 def __str__(self):
196 return self._message
197
198 def __repr__(self):
199 return self._message
David Garcia4fee80e2020-05-13 12:18:38 +0200200
201
202class EntityInvalidException(Exception):
203 """Entity is not valid, the type does not match any EntityType."""