From: Jenkins Date: Fri, 15 Jan 2016 17:39:16 +0000 (+0000) Subject: Merge "Pecan controller loads service plugins" X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=831c2da94428f34d25316b700b7c83d6feae3f0b;p=openstack-build%2Fneutron-build.git Merge "Pecan controller loads service plugins" --- 831c2da94428f34d25316b700b7c83d6feae3f0b diff --cc neutron/pecan_wsgi/controllers/root.py index 36cc6dc5a,e796112fe..416d60674 --- a/neutron/pecan_wsgi/controllers/root.py +++ b/neutron/pecan_wsgi/controllers/root.py @@@ -93,8 -102,17 +93,17 @@@ class V2Controller(object) def not_supported(self): pecan.abort(405) - @expose() + @utils.expose() def _lookup(self, collection, *remainder): + # if collection exists in the extension to service plugins map then + # we are assuming that collection is the service plugin and + # needs to be remapped. + # Example: https://neutron.endpoint/v2.0/lbaas/loadbalancers + if (remainder and + manager.NeutronManager.get_service_plugin_by_path_prefix( + collection)): + collection = remainder[0] + remainder = remainder[1:] controller = manager.NeutronManager.get_controller_for_resource( collection) if not controller: diff --cc neutron/tests/functional/pecan_wsgi/test_functional.py index ee20ec344,69e68c623..0f0aafc71 --- a/neutron/tests/functional/pecan_wsgi/test_functional.py +++ b/neutron/tests/functional/pecan_wsgi/test_functional.py @@@ -15,11 -15,12 +15,13 @@@ import os + from collections import namedtuple import mock from oslo_config import cfg +from oslo_policy import policy as oslo_policy from oslo_serialization import jsonutils from oslo_utils import uuidutils + import pecan from pecan import request from pecan import set_config from pecan.testing import load_test_app @@@ -31,9 -32,22 +33,23 @@@ from neutron.common import exceptions a from neutron import context from neutron import manager from neutron.pecan_wsgi.controllers import root as controllers +from neutron import policy from neutron.tests.unit import testlib_api + _SERVICE_PLUGIN_RESOURCE = 'serviceplugin' + _SERVICE_PLUGIN_COLLECTION = _SERVICE_PLUGIN_RESOURCE + 's' + _SERVICE_PLUGIN_INDEX_BODY = {_SERVICE_PLUGIN_COLLECTION: []} + + + class FakeServicePluginController(object): + resource = _SERVICE_PLUGIN_RESOURCE + + @pecan.expose(generic=True, + content_type='application/json', + template='json') + def index(self): + return _SERVICE_PLUGIN_INDEX_BODY + class PecanFunctionalTest(testlib_api.SqlTestCase):