From 6a2573a15314db781beeda50271b1e13d90baed7 Mon Sep 17 00:00:00 2001 From: Mike Perez Date: Sun, 11 Nov 2012 21:37:14 -0800 Subject: [PATCH] Switching api to use base extension manager progress on blueprint apiv2 Change-Id: I68640a88c7c2b7ee4c6661fa26a4f82d9c63b00f --- cinder/api/extensions.py | 9 ++++- cinder/api/openstack/volume/__init__.py | 2 +- cinder/api/openstack/volume/extensions.py | 33 ------------------- .../volume => }/extensions/__init__.py | 0 .../volume => }/extensions/foxinsocks.py | 0 .../{openstack/volume => }/test_extensions.py | 3 +- cinder/tests/integrated/test_extensions.py | 3 +- 7 files changed, 11 insertions(+), 39 deletions(-) delete mode 100644 cinder/api/openstack/volume/extensions.py rename cinder/tests/api/{openstack/volume => }/extensions/__init__.py (100%) rename cinder/tests/api/{openstack/volume => }/extensions/foxinsocks.py (100%) rename cinder/tests/api/{openstack/volume => }/test_extensions.py (98%) diff --git a/cinder/api/extensions.py b/cinder/api/extensions.py index a6886724e..d558d87a6 100644 --- a/cinder/api/extensions.py +++ b/cinder/api/extensions.py @@ -175,11 +175,18 @@ class ExtensionsResource(wsgi.Resource): class ExtensionManager(object): """Load extensions from the configured extension path. - See cinder/tests/api/openstack/extensions/foxinsocks/extension.py for an + See cinder/tests/api/extensions/foxinsocks/extension.py for an example extension implementation. """ + def __init__(self): + LOG.audit(_('Initializing extension manager.')) + + self.cls_list = FLAGS.osapi_volume_extension + self.extensions = {} + self._load_extensions() + def is_loaded(self, alias): return alias in self.extensions diff --git a/cinder/api/openstack/volume/__init__.py b/cinder/api/openstack/volume/__init__.py index 0f945190d..b82fb8aba 100644 --- a/cinder/api/openstack/volume/__init__.py +++ b/cinder/api/openstack/volume/__init__.py @@ -20,8 +20,8 @@ WSGI middleware for OpenStack Volume API. """ +from cinder.api import extensions import cinder.api.openstack -from cinder.api.openstack.volume import extensions from cinder.api.openstack.volume import limits from cinder.api.openstack.volume import snapshots from cinder.api.openstack.volume import types diff --git a/cinder/api/openstack/volume/extensions.py b/cinder/api/openstack/volume/extensions.py deleted file mode 100644 index 182f58fc3..000000000 --- a/cinder/api/openstack/volume/extensions.py +++ /dev/null @@ -1,33 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2011 OpenStack LLC. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from cinder.api import extensions as base_extensions -from cinder import flags -from cinder.openstack.common import log as logging - - -LOG = logging.getLogger(__name__) -FLAGS = flags.FLAGS - - -class ExtensionManager(base_extensions.ExtensionManager): - def __init__(self): - LOG.audit(_('Initializing extension manager.')) - - self.cls_list = FLAGS.osapi_volume_extension - self.extensions = {} - self._load_extensions() diff --git a/cinder/tests/api/openstack/volume/extensions/__init__.py b/cinder/tests/api/extensions/__init__.py similarity index 100% rename from cinder/tests/api/openstack/volume/extensions/__init__.py rename to cinder/tests/api/extensions/__init__.py diff --git a/cinder/tests/api/openstack/volume/extensions/foxinsocks.py b/cinder/tests/api/extensions/foxinsocks.py similarity index 100% rename from cinder/tests/api/openstack/volume/extensions/foxinsocks.py rename to cinder/tests/api/extensions/foxinsocks.py diff --git a/cinder/tests/api/openstack/volume/test_extensions.py b/cinder/tests/api/test_extensions.py similarity index 98% rename from cinder/tests/api/openstack/volume/test_extensions.py rename to cinder/tests/api/test_extensions.py index 409f8b4ad..7d998633f 100644 --- a/cinder/tests/api/openstack/volume/test_extensions.py +++ b/cinder/tests/api/test_extensions.py @@ -34,8 +34,7 @@ class ExtensionTestCase(test.TestCase): def setUp(self): super(ExtensionTestCase, self).setUp() ext_list = FLAGS.osapi_volume_extension[:] - fox = ('cinder.tests.api.openstack.volume.extensions.' - 'foxinsocks.Foxinsocks') + fox = ('cinder.tests.api.extensions.foxinsocks.Foxinsocks') if fox not in ext_list: ext_list.append(fox) self.flags(osapi_volume_extension=ext_list) diff --git a/cinder/tests/integrated/test_extensions.py b/cinder/tests/integrated/test_extensions.py index 9c5808106..363baed66 100644 --- a/cinder/tests/integrated/test_extensions.py +++ b/cinder/tests/integrated/test_extensions.py @@ -29,8 +29,7 @@ class ExtensionsTest(integrated_helpers._IntegratedTestBase): f = super(ExtensionsTest, self)._get_flags() f['osapi_volume_extension'] = FLAGS.osapi_volume_extension[:] f['osapi_volume_extension'].append( - 'cinder.tests.api.openstack.volume.extensions.' - 'foxinsocks.Foxinsocks') + 'cinder.tests.api.extensions.foxinsocks.Foxinsocks') return f def test_get_foxnsocks(self): -- 2.45.2