From a25c256ef5b57b13126a1264843aa954c3ccefff Mon Sep 17 00:00:00 2001 From: Chris Yeoh Date: Fri, 31 May 2013 16:23:33 +0930 Subject: Adds v3 API disable config option Adds the ability to disable the v3 API and it is disabled by default for now. The API is explictly enabled when running the unittests though. Change-Id: I34597d35b9739e06561579651f7ec72afa357919 --- nova/api/openstack/__init__.py | 13 +++++++++++++ nova/test.py | 1 + 2 files changed, 14 insertions(+) (limited to 'nova') diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index 51a8785e2..c5181dd0b 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -20,6 +20,7 @@ WSGI middleware for OpenStack API controllers. """ +from oslo.config import cfg import routes import stevedore import webob.dec @@ -33,7 +34,15 @@ from nova import utils from nova import wsgi as base_wsgi +api_opts = [ + cfg.BoolOpt('osapi_v3_enabled', + default=False, + help='Whether the V3 API is enabled or not') +] + LOG = logging.getLogger(__name__) +CONF = cfg.CONF +CONF.register_opts(api_opts) class FaultWrapper(base_wsgi.Middleware): @@ -234,6 +243,10 @@ class APIRouterV3(base_wsgi.Router): else: return False + if not CONF.osapi_v3_enabled: + LOG.warning("V3 API has been disabled by configuration") + return + self.init_only = init_only self.api_extension_manager = stevedore.enabled.EnabledExtensionManager( namespace=self.API_EXTENSION_NAMESPACE, diff --git a/nova/test.py b/nova/test.py index 6dad0784a..ac056ad1c 100644 --- a/nova/test.py +++ b/nova/test.py @@ -227,6 +227,7 @@ class TestCase(testtools.TestCase): self.useFixture(fixtures.EnvironmentVariable('http_proxy')) self.policy = self.useFixture(policy_fixture.PolicyFixture()) CONF.set_override('fatal_exception_format_errors', True) + CONF.set_override('osapi_v3_enabled', True) def _clear_attrs(self): # Delete attributes that don't start with _ so they don't pin -- cgit