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 JujuApplicationExists(Exception):
21 """The Application already exists."""
24 class N2VCPrimitiveExecutionFailed(Exception):
25 """Something failed while attempting to execute a primitive."""
28 class NetworkServiceDoesNotExist(Exception):
29 """The Network Service being acted against does not exist."""
32 class PrimitiveDoesNotExist(Exception):
33 """The Primitive being executed does not exist."""
36 class NoRouteToHost(Exception):
37 """There was no route to the specified host."""
40 class AuthenticationFailed(Exception):
41 """The authentication for the specified user failed."""
44 class MethodNotImplemented(Exception):
45 """The method is not implemented."""
48 class N2VCException(Exception):
50 N2VC exception base class
53 def __init__(self
, message
: str = ""):
54 Exception.__init
__(self
, message
)
55 self
.message
= message
61 return "{}({})".format(type(self
), self
.message
)
64 class N2VCBadArgumentsException(N2VCException
):
66 Bad argument values exception
69 def __init__(self
, message
: str = "", bad_args
: list = None):
70 N2VCException
.__init
__(self
, message
=message
)
71 self
.bad_args
= bad_args
74 return "<{}> Bad arguments: {} -> {}".format(
75 type(self
), super().__str
__(), self
.bad_args
79 class N2VCConnectionException(N2VCException
):
81 Error connecting to VCA
84 def __init__(self
, message
: str = "", url
: str = None):
85 N2VCException
.__init
__(self
, message
=message
)
89 return "<{}> Connection to {} failed: {}".format(
90 type(self
), self
.url
, super().__str
__()
94 class N2VCTimeoutException(N2VCException
):
99 def __init__(self
, message
: str = "", timeout
: str = ""):
100 N2VCException
.__init
__(self
, message
=message
)
101 self
.timeout
= timeout
104 return "<{}> {} timeout: {}".format(type(self
), self
.timeout
, super().__str
__())
107 class N2VCExecutionException(N2VCException
):
109 Error executing primitive
112 def __init__(self
, message
: str = "", primitive_name
: str = ""):
113 N2VCException
.__init
__(self
, message
=message
)
114 self
.primitive_name
= primitive_name
117 return "<{}> Error executing primitive {} failed: {}".format(
118 type(self
), self
.primitive_name
, super().__str
__()
122 class N2VCInvalidCertificate(N2VCException
):
127 def __init__(self
, message
: str = ""):
128 N2VCException
.__init
__(self
, message
=message
)
131 return "<{}> Invalid certificate: {}".format(type(self
), super().__str
__())
134 class N2VCNotFound(N2VCException
):
139 def __init__(self
, message
: str = ""):
140 N2VCException
.__init
__(self
, message
=message
)
143 return "<{}> Not found: {}".format(type(self
), super().__str
__())
146 class K8sException(Exception):
151 def __init__(self
, message
: str):
152 Exception.__init
__(self
, message
)
153 self
._message
= message