Debian Codegraph @

networking_bagpipe/bagpipe_bgp/common/exceptions.py

raw
1 # Copyright 2014 Orange
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
15
16 class RemotePEMACAddressNotFound(Exception):
17
18 def __init__(self, ip_address):
19 super().__init__(
20 "MAC address for %s could not be found. CAUTION:"
21 " Need direct MPLS/Eth connection" % ip_address)
22
23
24 class APIException(Exception):
25 pass
26
27
28 class VPNNotFound(APIException):
29
30 def __init__(self, vrf_id):
31 super().__init__("VPN %s could not be found" % vrf_id)
32
33
34 class MalformedMACAddress(APIException):
35
36 def __init__(self, address):
37 super().__init__(
38 "MAC address %s is not valid" % address)
39
40
41 class MalformedIPAddress(APIException):
42
43 def __init__(self, address):
44 super().__init__(
45 "IP address %s is not valid" % address)
46
47
48 class OVSBridgeNotFound(APIException):
49
50 def __init__(self, bridge):
51 super().__init__(
52 "OVS bridge '%s' doesn't exist" % bridge)
53
54
55 class OVSBridgePortNotFound(APIException):
56
57 def __init__(self, interface, bridge):
58 super().__init__(
59 "OVS Port {} doesn't exist on OVS Bridge {}".format(interface,
60 bridge))
61
62
63 class APIMissingParameterException(APIException):
64 def __init__(self, parameter):
65 super().__init__(
66 "Missing parameter: '%s'" % parameter)
67
68
69 class APIAlreadyUsedVNI(APIException):
70 def __init__(self, vni):
71 super().__init__(
72 "A VPN instance using vni %d already exists." % vni)
73
74
75 class APINotPluggedYet(APIException):
76 def __init__(self, endpoint):
77 super().__init__(
78 "Endpoint {} not plugged yet, can't unplug".format(endpoint))