blob: 061cd7a335e94f5b0f5772c982b8182480418474 [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
Adam Israel0cd1c022019-09-03 18:26:08 -040040class N2VCPrimitiveExecutionFailed(Exception):
41 """Something failed while attempting to execute a primitive."""
42
43
44class NetworkServiceDoesNotExist(Exception):
45 """The Network Service being acted against does not exist."""
46
47
48class PrimitiveDoesNotExist(Exception):
49 """The Primitive being executed does not exist."""
50
51
52class NoRouteToHost(Exception):
53 """There was no route to the specified host."""
54
55
56class AuthenticationFailed(Exception):
57 """The authentication for the specified user failed."""
Adam Israel19c5cfc2019-10-03 12:35:38 -040058
Adam Israeld238b032019-11-11 16:42:02 -080059
beierlmf52cb7c2020-04-21 16:36:35 -040060class MethodNotImplemented(Exception):
Adam Israel9e5eddb2019-12-01 12:55:09 -050061 """The method is not implemented."""
62
63
quilesj29114342019-10-29 09:30:44 +010064class N2VCException(Exception):
65 """
66 N2VC exception base class
67 """
68
beierlmf52cb7c2020-04-21 16:36:35 -040069 def __init__(self, message: str = ""):
quilesj29114342019-10-29 09:30:44 +010070 Exception.__init__(self, message)
71 self.message = message
72
73 def __str__(self):
74 return self.message
75
76 def __repr__(self):
beierlmf52cb7c2020-04-21 16:36:35 -040077 return "{}({})".format(type(self), self.message)
quilesj29114342019-10-29 09:30:44 +010078
79
80class N2VCBadArgumentsException(N2VCException):
81 """
82 Bad argument values exception
83 """
84
beierlmf52cb7c2020-04-21 16:36:35 -040085 def __init__(self, message: str = "", bad_args: list = None):
quilesj29114342019-10-29 09:30:44 +010086 N2VCException.__init__(self, message=message)
87 self.bad_args = bad_args
88
89 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -040090 return "<{}> Bad arguments: {} -> {}".format(
91 type(self), super().__str__(), self.bad_args
92 )
quilesj29114342019-10-29 09:30:44 +010093
94
95class N2VCConnectionException(N2VCException):
96 """
97 Error connecting to VCA
98 """
99
beierlmf52cb7c2020-04-21 16:36:35 -0400100 def __init__(self, message: str = "", url: str = None):
quilesj29114342019-10-29 09:30:44 +0100101 N2VCException.__init__(self, message=message)
102 self.url = url
103
104 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400105 return "<{}> Connection to {} failed: {}".format(
106 type(self), self.url, super().__str__()
107 )
quilesj29114342019-10-29 09:30:44 +0100108
109
110class N2VCTimeoutException(N2VCException):
111 """
112 Timeout
113 """
114
beierlmf52cb7c2020-04-21 16:36:35 -0400115 def __init__(self, message: str = "", timeout: str = ""):
quilesj29114342019-10-29 09:30:44 +0100116 N2VCException.__init__(self, message=message)
117 self.timeout = timeout
118
119 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400120 return "<{}> {} timeout: {}".format(type(self), self.timeout, super().__str__())
quilesj29114342019-10-29 09:30:44 +0100121
122
123class N2VCExecutionException(N2VCException):
124 """
125 Error executing primitive
126 """
127
beierlmf52cb7c2020-04-21 16:36:35 -0400128 def __init__(self, message: str = "", primitive_name: str = ""):
quilesj29114342019-10-29 09:30:44 +0100129 N2VCException.__init__(self, message=message)
130 self.primitive_name = primitive_name
131
132 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400133 return "<{}> Error executing primitive {} failed: {}".format(
134 type(self), self.primitive_name, super().__str__()
135 )
quilesj29114342019-10-29 09:30:44 +0100136
Adam Israel9e5eddb2019-12-01 12:55:09 -0500137
quilesj29114342019-10-29 09:30:44 +0100138class N2VCInvalidCertificate(N2VCException):
139 """
140 Invalid certificate
141 """
142
beierlmf52cb7c2020-04-21 16:36:35 -0400143 def __init__(self, message: str = ""):
quilesj29114342019-10-29 09:30:44 +0100144 N2VCException.__init__(self, message=message)
145
146 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400147 return "<{}> Invalid certificate: {}".format(type(self), super().__str__())
quilesja6748412019-12-04 07:51:26 +0000148
149
David Garciac6b19262020-04-08 09:48:21 +0200150class N2VCNotFound(N2VCException):
151 """
152 Not found
153 """
154
beierlmf52cb7c2020-04-21 16:36:35 -0400155 def __init__(self, message: str = ""):
David Garciac6b19262020-04-08 09:48:21 +0200156 N2VCException.__init__(self, message=message)
157
158 def __str__(self):
beierlmf52cb7c2020-04-21 16:36:35 -0400159 return "<{}> Not found: {}".format(type(self), super().__str__())
David Garciac6b19262020-04-08 09:48:21 +0200160
161
quilesja6748412019-12-04 07:51:26 +0000162class K8sException(Exception):
163 """
164 K8s exception
165 """
166
167 def __init__(self, message: str):
168 Exception.__init__(self, message)
169 self._message = message
170
171 def __str__(self):
172 return self._message
173
174 def __repr__(self):
175 return self._message
David Garcia4fee80e2020-05-13 12:18:38 +0200176
177
178class EntityInvalidException(Exception):
179 """Entity is not valid, the type does not match any EntityType."""