1 # Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
2 # Copyright (C) 2011 Isaku Yamahata <yamahata at valinux co jp>
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 class RyuException(Exception):
19 message = 'An unknown exception'
21 def __init__(self, msg=None, **kwargs):
31 super(RyuException, self).__init__(msg)
34 class OFPUnknownVersion(RyuException):
35 message = 'unknown version %(version)x'
38 class OFPMalformedMessage(RyuException):
39 message = 'malformed message'
42 class OFPTruncatedMessage(RyuException):
43 message = 'truncated message: %(orig_ex)s'
45 def __init__(self, ofpmsg, residue, original_exception,
48 self.residue = residue
49 self.original_exception = original_exception
50 kwargs['orig_ex'] = str(original_exception)
52 super(OFPTruncatedMessage, self).__init__(msg, **kwargs)
55 class OFPInvalidActionString(RyuException):
56 message = 'unable to parse: %(action_str)s'
59 class NetworkNotFound(RyuException):
60 message = 'no such network id %(network_id)s'
63 class NetworkAlreadyExist(RyuException):
64 message = 'network id %(network_id)s already exists'
67 class PortNotFound(RyuException):
68 message = 'no such port (%(dpid)s, %(port)s) in network %(network_id)s'
71 class PortAlreadyExist(RyuException):
72 message = 'port (%(dpid)s, %(port)s) in network %(network_id)s ' \
76 class PortUnknown(RyuException):
77 message = 'unknown network id for port (%(dpid)s %(port)s)'
80 class MacAddressDuplicated(RyuException):
81 message = 'MAC address %(mac)s is duplicated'