ryu/app: Use Request/Response wrappers in REST Apps

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
IWASE Yusuke 2016-12-26 15:44:24 +09:00 committed by FUJITA Tomonori
parent 40178c92b2
commit 49461e84ec
10 changed files with 32 additions and 30 deletions

View File

@ -14,10 +14,8 @@
# limitations under the License.
import logging
import json
import ast
from webob import Response
from ryu.base import app_manager
from ryu.controller import ofp_event
@ -35,8 +33,9 @@ from ryu.lib import ofctl_v1_2
from ryu.lib import ofctl_v1_3
from ryu.lib import ofctl_v1_4
from ryu.lib import ofctl_v1_5
from ryu.app.wsgi import ControllerBase, WSGIApplication
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import Response
from ryu.app.wsgi import WSGIApplication
LOG = logging.getLogger('ryu.app.ofctl_rest')

View File

@ -21,12 +21,12 @@ This module provides a set of REST API for switch configuration.
Used by OpenStack Ryu agent.
"""
from six.moves import http_client
import json
import logging
from webob import Response
from six.moves import http_client
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import Response
from ryu.base import app_manager
from ryu.controller import conf_switch
from ryu.lib import dpid as dpid_lib

View File

@ -17,9 +17,8 @@
import logging
import json
from webob import Response
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import Response
from ryu.app.wsgi import WSGIApplication
from ryu.base import app_manager
from ryu.controller import ofp_event

View File

@ -18,10 +18,11 @@ import logging
import json
import re
from webob import Response
from ryu.app import conf_switch_key as cs_key
from ryu.app.wsgi import ControllerBase, WSGIApplication, route
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import Response
from ryu.app.wsgi import route
from ryu.app.wsgi import WSGIApplication
from ryu.base import app_manager
from ryu.controller import conf_switch
from ryu.controller import ofp_event

View File

@ -20,9 +20,9 @@ import socket
import struct
import json
from webob import Response
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import Response
from ryu.app.wsgi import WSGIApplication
from ryu.base import app_manager
from ryu.controller import dpset

View File

@ -14,9 +14,11 @@
# limitations under the License.
import json
from webob import Response
from ryu.app.wsgi import ControllerBase, WSGIApplication, route
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import Response
from ryu.app.wsgi import route
from ryu.app.wsgi import WSGIApplication
from ryu.base import app_manager
from ryu.lib import dpid as dpid_lib
from ryu.topology.api import get_switch, get_link, get_host

View File

@ -16,11 +16,13 @@
import json
from ryu.app import simple_switch_13
from webob import Response
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.app.wsgi import ControllerBase, WSGIApplication, route
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import Response
from ryu.app.wsgi import route
from ryu.app.wsgi import WSGIApplication
from ryu.lib import dpid as dpid_lib
simple_switch_instance_name = 'simple_switch_api_app'

View File

@ -42,15 +42,14 @@ Get arp table:
15:0c:de:49": 2}}}
"""
import json
from webob import Response
from ryu.app import simple_switch_13
from ryu.app.wsgi import route, websocket, ControllerBase, WSGIApplication
from ryu.app.wsgi import rpc_public, WebSocketRPCServer
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import rpc_public
from ryu.app.wsgi import websocket
from ryu.app.wsgi import WebSocketRPCServer
from ryu.app.wsgi import WSGIApplication
from ryu.controller import ofp_event
from ryu.controller.handler import set_ev_cls
from ryu.lib import hub
from ryu.lib.packet import packet

View File

@ -18,17 +18,17 @@
import functools
import json
import logging
from nose.tools import eq_
import os
import sys
import unittest
from webob.request import Request
try:
import mock # Python 2
except ImportError:
from unittest import mock # Python 3
from nose.tools import eq_
from ryu.app import ofctl_rest
from ryu.app.wsgi import Request
from ryu.app.wsgi import WSGIApplication
from ryu.controller.dpset import DPSet
from ryu.ofproto import ofproto_protocol
@ -71,7 +71,7 @@ class DummyDatapath(ofproto_protocol.ProtocolDesc):
class Test_ofctl_rest(unittest.TestCase):
def _test(self, name, dp, method, path, body):
print('processing %s ...' % name)
# print('processing %s ...' % name)
dpset = DPSet()
dpset._register(dp)
@ -104,13 +104,13 @@ def _add_tests():
this_dir = os.path.dirname(sys.modules[__name__].__file__)
ofctl_rest_json_dir = os.path.join(this_dir, 'ofctl_rest_json/')
for ofp_ver in _ofp_vers.keys():
for ofp_ver in _ofp_vers:
# read a json file
json_path = os.path.join(ofctl_rest_json_dir, ofp_ver + '.json')
if os.path.exists(json_path):
_test_cases = json.load(open(json_path))
else:
print("Skip to load test cases for %s" % ofp_ver)
# print("Skip to load test cases for %s" % ofp_ver)
continue
# add test
@ -120,7 +120,7 @@ def _add_tests():
body = test.get('body', {})
name = 'test_ofctl_rest_' + method + '_' + ofp_ver + '_' + path
print('adding %s ...' % name)
# print('adding %s ...' % name)
f = functools.partial(
Test_ofctl_rest._test,
name=name,

View File

@ -20,10 +20,10 @@ import logging
import nose
from nose.tools import eq_
from webob.response import Response
from ryu.app.wsgi import ControllerBase
from ryu.app.wsgi import WSGIApplication
from ryu.app.wsgi import Response
from ryu.app.wsgi import route
from ryu.lib import dpid as dpidlib