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 JujuK8sProxycharmNotSupported(Exception):
41 """K8s Proxy Charms not supported in this installation."""
44 class N2VCPrimitiveExecutionFailed(Exception):
45 """Something failed while attempting to execute a primitive."""
48 class NetworkServiceDoesNotExist(Exception):
49 """The Network Service being acted against does not exist."""
52 class PrimitiveDoesNotExist(Exception):
53 """The Primitive being executed does not exist."""
56 class NoRouteToHost(Exception):
57 """There was no route to the specified host."""
60 class AuthenticationFailed(Exception):
61 """The authentication for the specified user failed."""
64 class MethodNotImplemented(Exception):
65 """The method is not implemented."""
68 class N2VCException(Exception):
70 N2VC exception base class
73 def __init__(self
, message
: str = ""):
74 Exception.__init
__(self
, message
)
75 self
.message
= message
81 return "{}({})".format(type(self
), self
.message
)
84 class N2VCBadArgumentsException(N2VCException
):
86 Bad argument values exception
89 def __init__(self
, message
: str = "", bad_args
: list = None):
90 N2VCException
.__init
__(self
, message
=message
)
91 self
.bad_args
= bad_args
94 return "<{}> Bad arguments: {} -> {}".format(
95 type(self
), super().__str
__(), self
.bad_args
99 class N2VCConnectionException(N2VCException
):
101 Error connecting to VCA
104 def __init__(self
, message
: str = "", url
: str = None):
105 N2VCException
.__init
__(self
, message
=message
)
109 return "<{}> Connection to {} failed: {}".format(
110 type(self
), self
.url
, super().__str
__()
114 class N2VCTimeoutException(N2VCException
):
119 def __init__(self
, message
: str = "", timeout
: str = ""):
120 N2VCException
.__init
__(self
, message
=message
)
121 self
.timeout
= timeout
124 return "<{}> {} timeout: {}".format(type(self
), self
.timeout
, super().__str
__())
127 class N2VCExecutionException(N2VCException
):
129 Error executing primitive
132 def __init__(self
, message
: str = "", primitive_name
: str = ""):
133 N2VCException
.__init
__(self
, message
=message
)
134 self
.primitive_name
= primitive_name
137 return "<{}> Error executing primitive {} failed: {}".format(
138 type(self
), self
.primitive_name
, super().__str
__()
142 class N2VCInvalidCertificate(N2VCException
):
147 def __init__(self
, message
: str = ""):
148 N2VCException
.__init
__(self
, message
=message
)
151 return "<{}> Invalid certificate: {}".format(type(self
), super().__str
__())
154 class N2VCNotFound(N2VCException
):
159 def __init__(self
, message
: str = ""):
160 N2VCException
.__init
__(self
, message
=message
)
163 return "<{}> Not found: {}".format(type(self
), super().__str
__())
166 class K8sException(Exception):
171 def __init__(self
, message
: str):
172 Exception.__init
__(self
, message
)
173 self
._message
= message
182 class EntityInvalidException(Exception):
183 """Entity is not valid, the type does not match any EntityType."""