]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Merge "Pecan controller loads service plugins"
authorJenkins <jenkins@review.openstack.org>
Fri, 15 Jan 2016 17:39:16 +0000 (17:39 +0000)
committerGerrit Code Review <review@openstack.org>
Fri, 15 Jan 2016 17:39:16 +0000 (17:39 +0000)
1  2 
neutron/pecan_wsgi/controllers/root.py
neutron/tests/functional/pecan_wsgi/test_functional.py

index 36cc6dc5adbfd6f3c4faf6c36d21fa2dac62a065,e796112febde6986ff958ba4426b3fa573473b2a..416d60674c3ae6892536ddee9a84c5803baeb691
@@@ -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:
index ee20ec34473a0bff1cb1adcd37dde371a7aac7da,69e68c6239152fed31f43c90013eee7dbb7a0488..0f0aafc7193833e0d0d2222d7ba00554bb3bcb78
  
  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):