I already combine two patches into one. Thanks.

FUJITA Tomonori <[email protected]> 於 2016年9月1日 週四 下午4:14寫道:

> On Mon, 29 Aug 2016 03:31:26 +0000
> 林東岳 <[email protected]> wrote:
>
> > From 8cb2da767e990578ce846e95720a848dac5aff7a Mon Sep 17 00:00:00 2001
> > From: tungyueh <[email protected]>
> > Date: Mon, 29 Aug 2016 11:18:53 +0800
> > Subject: [PATCH 2/2] let default role to be equal
> >
> > Signed-off-by: tungyueh <[email protected]>
> > ---
> >  ryu/lib/ofctl_utils.py | 3 +++
> >  ryu/lib/ofctl_v1_2.py  | 2 +-
> >  ryu/lib/ofctl_v1_3.py  | 2 +-
> >  ryu/lib/ofctl_v1_4.py  | 2 +-
> >  ryu/lib/ofctl_v1_5.py  | 2 +-
> >  5 files changed, 7 insertions(+), 4 deletions(-)
>
> Thanks, please combine two patches and submit one.
>
From 1633af89f6dd5f2b2e42023c62b744362d553546 Mon Sep 17 00:00:00 2001
From: tungyueh <[email protected]>
Date: Thu, 25 Aug 2016 15:53:17 +0800
Subject: [PATCH] add change role API in ofctl_rest

let default role to be equal

Signed-off-by: tungyueh <[email protected]>
---
 ryu/app/ofctl_rest.py  | 12 ++++++++++++
 ryu/lib/ofctl_utils.py |  3 +++
 ryu/lib/ofctl_v1_2.py  |  6 ++++++
 ryu/lib/ofctl_v1_3.py  |  6 ++++++
 ryu/lib/ofctl_v1_4.py  |  6 ++++++
 ryu/lib/ofctl_v1_5.py  |  5 +++++
 6 files changed, 38 insertions(+)

diff --git a/ryu/app/ofctl_rest.py b/ryu/app/ofctl_rest.py
index 9167fbf..0e4555c 100644
--- a/ryu/app/ofctl_rest.py
+++ b/ryu/app/ofctl_rest.py
@@ -177,6 +177,9 @@ supported_ofctl = {
 # modify behavior of the physical port
 # POST /stats/portdesc/modify
 #
+# modify role of controller
+# POST /stats/role
+#
 #
 # send a experimeter message
 # POST /stats/experimenter/<dpid>
@@ -488,6 +491,10 @@ class StatsController(ControllerBase):
     def send_experimenter(self, req, dp, ofctl, exp, **kwargs):
         ofctl.send_experimenter(dp, exp)
 
+    @command_method
+    def set_role(self, req, dp, ofctl, role, **kwargs):
+        ofctl.set_role(dp, role)
+
 
 class RestStatsApi(app_manager.RyuApp):
     OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION,
@@ -698,6 +705,11 @@ class RestStatsApi(app_manager.RyuApp):
                        controller=StatsController, action='send_experimenter',
                        conditions=dict(method=['POST']))
 
+        uri = path + '/role'
+        mapper.connect('stats', uri,
+                       controller=StatsController, action='set_role',
+                       conditions=dict(method=['POST']))
+
     @set_ev_cls([ofp_event.EventOFPStatsReply,
                  ofp_event.EventOFPDescStatsReply,
                  ofp_event.EventOFPFlowStatsReply,
diff --git a/ryu/lib/ofctl_utils.py b/ryu/lib/ofctl_utils.py
index a09517a..9104013 100644
--- a/ryu/lib/ofctl_utils.py
+++ b/ryu/lib/ofctl_utils.py
@@ -424,3 +424,6 @@ class OFCtlUtil(object):
 
     def ofp_queue_to_user(self, queue):
         return self._reserved_num_to_user(queue, 'OFPQ_')
+
+    def ofp_role_from_user(self, role):
+        return self._reserved_num_from_user(role, 'OFPCR_ROLE_')
diff --git a/ryu/lib/ofctl_v1_2.py b/ryu/lib/ofctl_v1_2.py
index f51b0fd..3ba1eb4 100644
--- a/ryu/lib/ofctl_v1_2.py
+++ b/ryu/lib/ofctl_v1_2.py
@@ -926,5 +926,11 @@ def mod_port_behavior(dp, port_config):
     ofctl_utils.send_msg(dp, port_mod, LOG)
 
 
+def set_role(dp, role):
+    r = UTIL.ofp_role_from_user(role.get('role', dp.ofproto.OFPCR_ROLE_EQUAL))
+    role_request = dp.ofproto_parser.OFPRoleRequest(dp, r, 0)
+    ofctl_utils.send_msg(dp, role_request, LOG)
+
+
 # NOTE(jkoelker) Alias common funcitons
 send_experimenter = ofctl_utils.send_experimenter
diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py
index f407e5a..3cac36d 100644
--- a/ryu/lib/ofctl_v1_3.py
+++ b/ryu/lib/ofctl_v1_3.py
@@ -1152,5 +1152,11 @@ def mod_port_behavior(dp, port_config):
     ofctl_utils.send_msg(dp, port_mod, LOG)
 
 
+def set_role(dp, role):
+    r = UTIL.ofp_role_from_user(role.get('role', dp.ofproto.OFPCR_ROLE_EQUAL))
+    role_request = dp.ofproto_parser.OFPRoleRequest(dp, r, 0)
+    ofctl_utils.send_msg(dp, role_request, LOG)
+
+
 # NOTE(jkoelker) Alias common funcitons
 send_experimenter = ofctl_utils.send_experimenter
diff --git a/ryu/lib/ofctl_v1_4.py b/ryu/lib/ofctl_v1_4.py
index 71e33fd..e53cc81 100644
--- a/ryu/lib/ofctl_v1_4.py
+++ b/ryu/lib/ofctl_v1_4.py
@@ -939,5 +939,11 @@ def mod_port_behavior(dp, port_config):
     ofctl_utils.send_msg(dp, port_mod, LOG)
 
 
+def set_role(dp, role):
+    r = UTIL.ofp_role_from_user(role.get('role', dp.ofproto.OFPCR_ROLE_EQUAL))
+    role_request = dp.ofproto_parser.OFPRoleRequest(dp, r, 0)
+    ofctl_utils.send_msg(dp, role_request, LOG)
+
+
 # NOTE(jkoelker) Alias common funcitons
 send_experimenter = ofctl_utils.send_experimenter
diff --git a/ryu/lib/ofctl_v1_5.py b/ryu/lib/ofctl_v1_5.py
index 43ee0fc..867a39e 100644
--- a/ryu/lib/ofctl_v1_5.py
+++ b/ryu/lib/ofctl_v1_5.py
@@ -1084,5 +1084,10 @@ def mod_port_behavior(dp, port_config):
     ofctl_utils.send_msg(dp, port_mod, LOG)
 
 
+def set_role(dp, role):
+    r = UTIL.ofp_role_from_user(role.get('role', dp.ofproto.OFPCR_ROLE_EQUAL))
+    role_request = dp.ofproto_parser.OFPRoleRequest(dp, r, 0)
+    ofctl_utils.send_msg(dp, role_request, LOG)
+
 # NOTE(jkoelker) Alias common funcitons
 send_experimenter = ofctl_utils.send_experimenter
-- 
2.7.4

------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to