Hi,

If you want to use the method of class DPSet, please refer to the 
following source.
The following is an example that is to use the get_all() at 
ryu/app/simple_switch_13.py.

$ git diff
diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py
index 3e7c598..a47e27c 100644
--- a/ryu/app/simple_switch_13.py
+++ b/ryu/app/simple_switch_13.py
@@ -15,6 +15,7 @@

  from ryu.base import app_manager
  from ryu.controller import ofp_event
+from ryu.controller import dpset
  from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
  from ryu.controller.handler import set_ev_cls
  from ryu.ofproto import ofproto_v1_3
@@ -26,9 +27,12 @@ from ryu.lib.packet import ether_types
  class SimpleSwitch13(app_manager.RyuApp):
      OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]

+    _CONTEXTS = {'dpset': dpset.DPSet}
+
      def __init__(self, *args, **kwargs):
          super(SimpleSwitch13, self).__init__(*args, **kwargs)
          self.mac_to_port = {}
+        self.dpset = kwargs['dpset']

@@ -76,6 +82,10 @@ class SimpleSwitch13(app_manager.RyuApp):
          parser = datapath.ofproto_parser
          in_port = msg.match['in_port']

+        print "-----------------------"
+        print self.dpset.get_all()
+        print "-----------------------"
+
          pkt = packet.Packet(msg.data)
          eth = pkt.get_protocols(ethernet.ethernet)[0]


The following is the output result.

-----------------------
[(1, <ryu.controller.controller.Datapath object at 0x7fe0ee45e950>)]
-----------------------


Please refer to the following for _CONTEXTS.

http://ryu-zhdoc.readthedocs.org/en/latest/api_ref.html#ryu.base.app_manager.RyuApp._CONTEXTS



Thanks,

On 2016年03月23日 01:27, Sergio Andrés Rivera Polanco wrote:
> Hi, I cannot find how can I get the list of datapaths connected to the
> controller and their ports.
>
> http://ryu-zhdoc.readthedocs.org/en/latest/api_ref.html
>
> Shows on the bottom the class DPSet however I have no success using it.
> For example if I write:
>
>     self.logger.info <http://self.logger.info>("ALL: %s " %
>     (DPSet().get_all())
>
>
> I get an empty list. If on the other hand I use:
>
>     self.logger.info <http://self.logger.info>("ALL: %s " %
>     (DPSet.get_all())
>
>
> I get TypeError: unbound method get_all() must be called with DPSet
> instance as first argument.
>
> Kindly appreciate your help
>
> Sergio
>
>
> ------------------------------------------------------------------------------
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
>
>
>
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to