document ryu.app.ofctl
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
e1f9e1e0a7
commit
a2fc54bd79
12
doc/source/app.rst
Normal file
12
doc/source/app.rst
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
*************************
|
||||||
|
Built-in Ryu applications
|
||||||
|
*************************
|
||||||
|
|
||||||
|
Ryu has some built-in Ryu applications.
|
||||||
|
Some of them are examples.
|
||||||
|
Others provide some functionalities to other Ryu applications.
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
|
||||||
|
app/ofctl.rst
|
30
doc/source/app/ofctl.rst
Normal file
30
doc/source/app/ofctl.rst
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
*************
|
||||||
|
ryu.app.ofctl
|
||||||
|
*************
|
||||||
|
|
||||||
|
ryu.app.ofctl provides a convenient way to use OpenFlow messages
|
||||||
|
synchronously.
|
||||||
|
|
||||||
|
OfctlService ryu application is automatically loaded if your
|
||||||
|
Ryu application imports ofctl.api module.
|
||||||
|
|
||||||
|
Example::
|
||||||
|
|
||||||
|
import ryu.app.ofctl.api
|
||||||
|
|
||||||
|
OfctlService application internally uses OpenFlow barrier messages
|
||||||
|
to ensure message boundaries. As OpenFlow messages are asynchronous
|
||||||
|
and some of messages does not have any replies on success, barriers
|
||||||
|
are necessary for correct error handling.
|
||||||
|
|
||||||
|
api module
|
||||||
|
==========
|
||||||
|
|
||||||
|
.. automodule:: ryu.app.ofctl.api
|
||||||
|
:members:
|
||||||
|
|
||||||
|
exceptions
|
||||||
|
==========
|
||||||
|
|
||||||
|
.. automodule:: ryu.app.ofctl.exception
|
||||||
|
:members:
|
@ -17,6 +17,7 @@ Contents:
|
|||||||
configuration.rst
|
configuration.rst
|
||||||
tests.rst
|
tests.rst
|
||||||
using_with_openstack.rst
|
using_with_openstack.rst
|
||||||
|
app.rst
|
||||||
|
|
||||||
Indices and tables
|
Indices and tables
|
||||||
==================
|
==================
|
||||||
|
@ -23,6 +23,10 @@ import event
|
|||||||
def get_datapath(app, dpid):
|
def get_datapath(app, dpid):
|
||||||
"""
|
"""
|
||||||
Get datapath object by dpid.
|
Get datapath object by dpid.
|
||||||
|
|
||||||
|
:param app: Client RyuApp instance
|
||||||
|
:param dpid: Datapath-id (in integer)
|
||||||
|
|
||||||
Returns None on error.
|
Returns None on error.
|
||||||
"""
|
"""
|
||||||
assert isinstance(dpid, (int, long))
|
assert isinstance(dpid, (int, long))
|
||||||
@ -31,7 +35,30 @@ def get_datapath(app, dpid):
|
|||||||
|
|
||||||
def send_msg(app, msg, reply_cls=None, reply_multi=False):
|
def send_msg(app, msg, reply_cls=None, reply_multi=False):
|
||||||
"""
|
"""
|
||||||
Send an openflow message.
|
Send an OpenFlow message and wait for reply messages.
|
||||||
|
|
||||||
|
:param app: Client RyuApp instance
|
||||||
|
:param msg: An OpenFlow controller-to-switch message to send
|
||||||
|
:param reply_cls: OpenFlow message class for expected replies.
|
||||||
|
None means no replies are expected. The default is None.
|
||||||
|
:param reply_multi: True if multipart replies are expected.
|
||||||
|
The default is False.
|
||||||
|
|
||||||
|
If no replies, returns None.
|
||||||
|
If reply_multi=False, returns OpenFlow switch-to-controller message.
|
||||||
|
If reply_multi=True, returns a list of OpenFlow switch-to-controller
|
||||||
|
messages.
|
||||||
|
|
||||||
|
Raise an exception on error.
|
||||||
|
|
||||||
|
Example::
|
||||||
|
|
||||||
|
import ryu.app.ofctl.api as api
|
||||||
|
|
||||||
|
msg = parser.OFPPortDescStatsRequest(datapath=datapath)
|
||||||
|
result = api.send_msg(self, msg,
|
||||||
|
reply_cls=parser.OFPPortDescStatsReply,
|
||||||
|
reply_multi=True)
|
||||||
"""
|
"""
|
||||||
return app.send_request(event.SendMsgRequest(msg=msg,
|
return app.send_request(event.SendMsgRequest(msg=msg,
|
||||||
reply_cls=reply_cls,
|
reply_cls=reply_cls,
|
||||||
|
@ -26,8 +26,12 @@ class _ExceptionBase(exception.RyuException):
|
|||||||
|
|
||||||
|
|
||||||
class UnexpectedMultiReply(_ExceptionBase):
|
class UnexpectedMultiReply(_ExceptionBase):
|
||||||
|
"""Two or more replies are received for reply_muiti=False request."""
|
||||||
|
|
||||||
message = 'Unexpected Multi replies %(result)s'
|
message = 'Unexpected Multi replies %(result)s'
|
||||||
|
|
||||||
|
|
||||||
class OFError(_ExceptionBase):
|
class OFError(_ExceptionBase):
|
||||||
|
"""OFPErrorMsg is received."""
|
||||||
|
|
||||||
message = 'OpenFlow errors %(result)s'
|
message = 'OpenFlow errors %(result)s'
|
||||||
|
Loading…
Reference in New Issue
Block a user