ae9dbfbc2996ad32eca59819d1bca4c4b0331204
1 # Copyright 2019 Canonical Ltd.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 class JujuCharmNotFound(Exception):
17 """The Charm can't be found or is not readable."""
20 class JujuControllerFailedConnecting(Exception):
21 """Failed connecting to juju controller."""
24 class JujuModelAlreadyExists(Exception):
25 """The model already exists."""
28 class JujuApplicationExists(Exception):
29 """The Application already exists."""
32 class JujuApplicationNotFound(Exception):
33 """The Application cannot be found."""
36 class JujuLeaderUnitNotFound(Exception):
37 """The Application cannot be found."""
40 class JujuActionNotFound(Exception):
41 """The Action cannot be found."""
44 class JujuMachineNotFound(Exception):
45 """The machine cannot be found."""
48 class JujuK8sProxycharmNotSupported(Exception):
49 """K8s Proxy Charms not supported in this installation."""
52 class N2VCPrimitiveExecutionFailed(Exception):
53 """Something failed while attempting to execute a primitive."""
56 class NetworkServiceDoesNotExist(Exception):
57 """The Network Service being acted against does not exist."""
60 class PrimitiveDoesNotExist(Exception):
61 """The Primitive being executed does not exist."""
64 class NoRouteToHost(Exception):
65 """There was no route to the specified host."""
68 class AuthenticationFailed(Exception):
69 """The authentication for the specified user failed."""
72 class MethodNotImplemented(Exception):
73 """The method is not implemented."""
76 class N2VCException(Exception):
78 N2VC exception base class
81 def __init__(self
, message
: str = ""):
82 Exception.__init
__(self
, message
)
83 self
.message
= message
89 return "{}({})".format(type(self
), self
.message
)
92 class N2VCBadArgumentsException(N2VCException
):
94 Bad argument values exception
97 def __init__(self
, message
: str = "", bad_args
: list = None):
98 N2VCException
.__init
__(self
, message
=message
)
99 self
.bad_args
= bad_args
102 return "<{}> Bad arguments: {} -> {}".format(
103 type(self
), super().__str
__(), self
.bad_args
107 class N2VCConnectionException(N2VCException
):
109 Error connecting to VCA
112 def __init__(self
, message
: str = "", url
: str = None):
113 N2VCException
.__init
__(self
, message
=message
)
117 return "<{}> Connection to {} failed: {}".format(
118 type(self
), self
.url
, super().__str
__()
122 class N2VCTimeoutException(N2VCException
):
127 def __init__(self
, message
: str = "", timeout
: str = ""):
128 N2VCException
.__init
__(self
, message
=message
)
129 self
.timeout
= timeout
132 return "<{}> {} timeout: {}".format(type(self
), self
.timeout
, super().__str
__())
135 class N2VCExecutionException(N2VCException
):
137 Error executing primitive
140 def __init__(self
, message
: str = "", primitive_name
: str = ""):
141 N2VCException
.__init
__(self
, message
=message
)
142 self
.primitive_name
= primitive_name
145 return "<{}> Error executing primitive {} failed: {}".format(
146 type(self
), self
.primitive_name
, super().__str
__()
150 class N2VCInvalidCertificate(N2VCException
):
155 def __init__(self
, message
: str = ""):
156 N2VCException
.__init
__(self
, message
=message
)
159 return "<{}> Invalid certificate: {}".format(type(self
), super().__str
__())
162 class N2VCNotFound(N2VCException
):
167 def __init__(self
, message
: str = ""):
168 N2VCException
.__init
__(self
, message
=message
)
171 return "<{}> Not found: {}".format(type(self
), super().__str
__())
174 class JujuError(N2VCException
):
179 def __init__(self
, message
: str = ""):
180 N2VCException
.__init
__(self
, message
=message
)
183 return "<{}> Juju Error: {}".format(type(self
), super().__str
__())
186 class K8sException(Exception):
191 def __init__(self
, message
: str):
192 Exception.__init
__(self
, message
)
193 self
._message
= message
202 class EntityInvalidException(Exception):
203 """Entity is not valid, the type does not match any EntityType."""