061cd7a335e94f5b0f5772c982b8182480418474
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 JujuMachineNotFound(Exception):
37 """The machine cannot be found."""
40 class N2VCPrimitiveExecutionFailed(Exception):
41 """Something failed while attempting to execute a primitive."""
44 class NetworkServiceDoesNotExist(Exception):
45 """The Network Service being acted against does not exist."""
48 class PrimitiveDoesNotExist(Exception):
49 """The Primitive being executed does not exist."""
52 class NoRouteToHost(Exception):
53 """There was no route to the specified host."""
56 class AuthenticationFailed(Exception):
57 """The authentication for the specified user failed."""
60 class MethodNotImplemented(Exception):
61 """The method is not implemented."""
64 class N2VCException(Exception):
66 N2VC exception base class
69 def __init__(self
, message
: str = ""):
70 Exception.__init
__(self
, message
)
71 self
.message
= message
77 return "{}({})".format(type(self
), self
.message
)
80 class N2VCBadArgumentsException(N2VCException
):
82 Bad argument values exception
85 def __init__(self
, message
: str = "", bad_args
: list = None):
86 N2VCException
.__init
__(self
, message
=message
)
87 self
.bad_args
= bad_args
90 return "<{}> Bad arguments: {} -> {}".format(
91 type(self
), super().__str
__(), self
.bad_args
95 class N2VCConnectionException(N2VCException
):
97 Error connecting to VCA
100 def __init__(self
, message
: str = "", url
: str = None):
101 N2VCException
.__init
__(self
, message
=message
)
105 return "<{}> Connection to {} failed: {}".format(
106 type(self
), self
.url
, super().__str
__()
110 class N2VCTimeoutException(N2VCException
):
115 def __init__(self
, message
: str = "", timeout
: str = ""):
116 N2VCException
.__init
__(self
, message
=message
)
117 self
.timeout
= timeout
120 return "<{}> {} timeout: {}".format(type(self
), self
.timeout
, super().__str
__())
123 class N2VCExecutionException(N2VCException
):
125 Error executing primitive
128 def __init__(self
, message
: str = "", primitive_name
: str = ""):
129 N2VCException
.__init
__(self
, message
=message
)
130 self
.primitive_name
= primitive_name
133 return "<{}> Error executing primitive {} failed: {}".format(
134 type(self
), self
.primitive_name
, super().__str
__()
138 class N2VCInvalidCertificate(N2VCException
):
143 def __init__(self
, message
: str = ""):
144 N2VCException
.__init
__(self
, message
=message
)
147 return "<{}> Invalid certificate: {}".format(type(self
), super().__str
__())
150 class N2VCNotFound(N2VCException
):
155 def __init__(self
, message
: str = ""):
156 N2VCException
.__init
__(self
, message
=message
)
159 return "<{}> Not found: {}".format(type(self
), super().__str
__())
162 class K8sException(Exception):
167 def __init__(self
, message
: str):
168 Exception.__init
__(self
, message
)
169 self
._message
= message
178 class EntityInvalidException(Exception):
179 """Entity is not valid, the type does not match any EntityType."""