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 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'nova/api') 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, -- cgit