- rename push_flow_entry to mod_flow_entry
- add OFPFC_{MODIFY, DELETE} support
- remove debug message

Signed-off-by: OHMURA Kei <[email protected]>
---
 ryu/app/ofctl_rest.py |   31 +++++++++++++++++++++++--------
 ryu/lib/ofctl_v1_0.py |    4 ++--
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/ryu/app/ofctl_rest.py b/ryu/app/ofctl_rest.py
index 2a0818e..5a5223a 100644
--- a/ryu/app/ofctl_rest.py
+++ b/ryu/app/ofctl_rest.py
@@ -49,9 +49,15 @@ LOG = logging.getLogger('ryu.app.ofctl_rest')
 ## Update the switch stats
 #
 # add a flow entry
-# POST /stats/flowentry
+# POST /stats/flowentry/add
 #
-# delete flows of the switch
+# modify all matching flow entries
+# POST /stats/flowentry/modify
+#
+# delete all matching flow entries
+# POST /stats/flowentry/delete
+#
+# delete all flow entries of the switch
 # DELETE /stats/flowentry/clear/<dpid>
 #
 
@@ -109,7 +115,7 @@ class StatsController(ControllerBase):
         body = json.dumps(ports)
         return (Response(content_type='application/json', body=body))
 
-    def push_flow_entry(self, req, **_kwargs):
+    def mod_flow_entry(self, req, cmd, **_kwargs):
         try:
             flow = eval(req.body)
         except SyntaxError:
@@ -121,8 +127,17 @@ class StatsController(ControllerBase):
         if dp is None:
             return Response(status=404)
 
+        if cmd == 'add':
+            cmd = dp.ofproto.OFPFC_ADD
+        elif cmd == 'modify':
+            cmd = dp.ofproto.OFPFC_MODIFY
+        elif cmd == 'delete':
+            cmd = dp.ofproto.OFPFC_DELETE
+        else:
+            return Response(status=404)
+
         if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
-            ofctl_v1_0.push_flow_entry(dp, flow)
+            ofctl_v1_0.mod_flow_entry(dp, flow, cmd)
         else:
             LOG.debug('Unsupported OF protocol')
             return Response(status=501)
@@ -182,11 +197,12 @@ class RestStatsApi(app_manager.RyuApp):
                        controller=StatsController, action='get_port_stats',
                        conditions=dict(method=['GET']))
 
-        uri = path + '/flowentry'
+        uri = path + '/flowentry/{cmd}'
         mapper.connect('stats', uri,
-                       controller=StatsController, action='push_flow_entry',
+                       controller=StatsController, action='mod_flow_entry',
                        conditions=dict(method=['POST']))
-        uri = uri + '/clear/{dpid}'
+
+        uri = path + '/flowentry/clear/{dpid}'
         mapper.connect('stats', uri,
                        controller=StatsController, action='delete_flow_entry',
                        conditions=dict(method=['DELETE']))
@@ -201,7 +217,6 @@ class RestStatsApi(app_manager.RyuApp):
             return
         lock, msgs = self.waiters[dp.id][msg.xid]
         msgs.append(msg)
-        print 'stats_reply_handler:', msgs
 
         if msg.flags & dp.ofproto.OFPSF_REPLY_MORE:
             return
diff --git a/ryu/lib/ofctl_v1_0.py b/ryu/lib/ofctl_v1_0.py
index 0da0262..8553c9a 100644
--- a/ryu/lib/ofctl_v1_0.py
+++ b/ryu/lib/ofctl_v1_0.py
@@ -256,7 +256,7 @@ def get_port_stats(dp, waiters):
     return ports
 
 
-def push_flow_entry(dp, flow):
+def mod_flow_entry(dp, flow, cmd):
     cookie = int(flow.get('cookie', 0))
     priority = int(flow.get('priority',
                             dp.ofproto.OFP_DEFAULT_PRIORITY))
@@ -268,7 +268,7 @@ def push_flow_entry(dp, flow):
 
     flow_mod = dp.ofproto_parser.OFPFlowMod(
         datapath=dp, match=match, cookie=cookie,
-        command=dp.ofproto.OFPFC_ADD, idle_timeout=idle_timeout,
+        command=cmd, idle_timeout=idle_timeout,
         hard_timeout=hard_timeout, priority=priority, flags=flags,
         actions=actions)
 
-- 
1.7.9.5


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to