backing up
[vsorcdistro/.git] / ryu / build / lib.linux-armv7l-2.7 / ryu / exception.py
1 # Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
2 # Copyright (C) 2011 Isaku Yamahata <yamahata at valinux co jp>
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #    http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17
18 class RyuException(Exception):
19     message = 'An unknown exception'
20
21     def __init__(self, msg=None, **kwargs):
22         self.kwargs = kwargs
23         if msg is None:
24             msg = self.message
25
26         try:
27             msg = msg % kwargs
28         except Exception:
29             msg = self.message
30
31         super(RyuException, self).__init__(msg)
32
33
34 class OFPUnknownVersion(RyuException):
35     message = 'unknown version %(version)x'
36
37
38 class OFPMalformedMessage(RyuException):
39     message = 'malformed message'
40
41
42 class OFPTruncatedMessage(RyuException):
43     message = 'truncated message: %(orig_ex)s'
44
45     def __init__(self, ofpmsg, residue, original_exception,
46                  msg=None, **kwargs):
47         self.ofpmsg = ofpmsg
48         self.residue = residue
49         self.original_exception = original_exception
50         kwargs['orig_ex'] = str(original_exception)
51
52         super(OFPTruncatedMessage, self).__init__(msg, **kwargs)
53
54
55 class OFPInvalidActionString(RyuException):
56     message = 'unable to parse: %(action_str)s'
57
58
59 class NetworkNotFound(RyuException):
60     message = 'no such network id %(network_id)s'
61
62
63 class NetworkAlreadyExist(RyuException):
64     message = 'network id %(network_id)s already exists'
65
66
67 class PortNotFound(RyuException):
68     message = 'no such port (%(dpid)s, %(port)s) in network %(network_id)s'
69
70
71 class PortAlreadyExist(RyuException):
72     message = 'port (%(dpid)s, %(port)s) in network %(network_id)s ' \
73               'already exists'
74
75
76 class PortUnknown(RyuException):
77     message = 'unknown network id for port (%(dpid)s %(port)s)'
78
79
80 class MacAddressDuplicated(RyuException):
81     message = 'MAC address %(mac)s is duplicated'