Signed-off-by: IWASE Yusuke <[email protected]>
---
 ryu/app/ofctl_rest.py | 31 ++++++++++++-------------------
 ryu/lib/ofctl_v1_2.py |  5 +----
 ryu/lib/ofctl_v1_3.py |  5 +----
 3 files changed, 14 insertions(+), 27 deletions(-)

diff --git a/ryu/app/ofctl_rest.py b/ryu/app/ofctl_rest.py
index c398d94..38301ca 100644
--- a/ryu/app/ofctl_rest.py
+++ b/ryu/app/ofctl_rest.py
@@ -140,7 +140,7 @@ class StatsController(ControllerBase):
     def get_dpids(self, req, **_kwargs):
         dps = self.dpset.dps.keys()
         body = json.dumps(dps)
-        return (Response(content_type='application/json', body=body))
+        return Response(content_type='application/json', body=body)
 
     def get_desc_stats(self, req, dpid, **_kwargs):
         dp = self.dpset.get(int(dpid))
@@ -158,7 +158,7 @@ class StatsController(ControllerBase):
             return Response(status=501)
 
         body = json.dumps(desc)
-        return (Response(content_type='application/json', body=body))
+        return Response(content_type='application/json', body=body)
 
     def get_flow_stats(self, req, dpid, **_kwargs):
         if req.body == '':
@@ -185,7 +185,7 @@ class StatsController(ControllerBase):
             return Response(status=501)
 
         body = json.dumps(flows)
-        return (Response(content_type='application/json', body=body))
+        return Response(content_type='application/json', body=body)
 
     def get_aggregate_flow_stats(self, req, dpid, **_kwargs):
         if req.body == '':
@@ -230,7 +230,7 @@ class StatsController(ControllerBase):
             return Response(status=501)
 
         body = json.dumps(ports)
-        return (Response(content_type='application/json', body=body))
+        return Response(content_type='application/json', body=body)
 
     def get_queue_stats(self, req, dpid, **_kwargs):
         dp = self.dpset.get(int(dpid))
@@ -266,7 +266,7 @@ class StatsController(ControllerBase):
             return Response(status=501)
 
         body = json.dumps(meters)
-        return (Response(content_type='application/json', body=body))
+        return Response(content_type='application/json', body=body)
 
     def get_meter_config(self, req, dpid, **_kwargs):
         dp = self.dpset.get(int(dpid))
@@ -284,7 +284,7 @@ class StatsController(ControllerBase):
             return Response(status=501)
 
         body = json.dumps(meters)
-        return (Response(content_type='application/json', body=body))
+        return Response(content_type='application/json', body=body)
 
     def get_meter_stats(self, req, dpid, **_kwargs):
         dp = self.dpset.get(int(dpid))
@@ -302,7 +302,7 @@ class StatsController(ControllerBase):
             return Response(status=501)
 
         body = json.dumps(meters)
-        return (Response(content_type='application/json', body=body))
+        return Response(content_type='application/json', body=body)
 
     def get_group_features(self, req, dpid, **_kwargs):
         dp = self.dpset.get(int(dpid))
@@ -514,18 +514,11 @@ class StatsController(ControllerBase):
 
         port_no = int(port_config.get('port_no', 0))
         port_info = self.dpset.port_state[int(dpid)].get(port_no)
-
-        if 'hw_addr' not in port_config:
-            if port_info is not None:
-                port_config['hw_addr'] = port_info.hw_addr
-            else:
-                return Response(status=404)
-
-        if 'advertise' not in port_config:
-            if port_info is not None:
-                port_config['advertise'] = port_info.advertised
-            else:
-                return Response(status=404)
+        if port_info:
+            port_config.setdefault('hw_addr', port_info.hw_addr)
+            port_config.setdefault('advertise', port_info.advertised)
+        else:
+            return Response(status=404)
 
         dp = self.dpset.get(int(dpid))
         if dp is None:
diff --git a/ryu/lib/ofctl_v1_2.py b/ryu/lib/ofctl_v1_2.py
index bbc5b27..1c1ff5d 100644
--- a/ryu/lib/ofctl_v1_2.py
+++ b/ryu/lib/ofctl_v1_2.py
@@ -14,8 +14,6 @@
 # limitations under the License.
 
 import base64
-import struct
-import socket
 import logging
 import netaddr
 
@@ -24,7 +22,6 @@ from ryu.ofproto import inet
 from ryu.ofproto import ofproto_v1_2
 from ryu.ofproto import ofproto_v1_2_parser
 from ryu.lib import hub
-from ryu.lib import mac
 
 
 LOG = logging.getLogger('ryu.lib.ofctl_v1_2')
@@ -365,7 +362,7 @@ def match_to_str(ofmatch):
 
 
 def match_metadata_to_str(value, mask):
-    return ('%d/%d' % (value, mask) if mask else '%d' % value)
+    return '%d/%d' % (value, mask) if mask else '%d' % value
 
 
 def match_vid_to_str(value, mask):
diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py
index 1bdb217..04bf76d 100644
--- a/ryu/lib/ofctl_v1_3.py
+++ b/ryu/lib/ofctl_v1_3.py
@@ -14,8 +14,6 @@
 # limitations under the License.
 
 import base64
-import struct
-import socket
 import logging
 import netaddr
 
@@ -24,7 +22,6 @@ from ryu.ofproto import inet
 from ryu.ofproto import ofproto_v1_3
 from ryu.ofproto import ofproto_v1_3_parser
 from ryu.lib import hub
-from ryu.lib import mac
 
 
 LOG = logging.getLogger('ryu.lib.ofctl_v1_3')
@@ -387,7 +384,7 @@ def match_to_str(ofmatch):
 
 
 def match_masked_int_to_str(value, mask):
-    return ('%d/%d' % (value, mask) if mask else '%d' % value)
+    return '%d/%d' % (value, mask) if mask else '%d' % value
 
 
 def match_vid_to_str(value, mask):
-- 
1.9.1


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to