Allow suppression of v1 API.

Fixes bug 1180567

The v1 API is on the deprecation path, so should not require
that distros have all its dependencies available.

Thus we add a new configuration option to allow the v1 app
creation to be suppressed.

Change-Id: Ib5af241a57f54754be534c9acb92a377362571e3
This commit is contained in:
Eoghan Glynn 2013-05-16 11:33:22 +00:00
parent 11e3bcf648
commit e2c1de041a
4 changed files with 23 additions and 11 deletions

View File

@ -16,16 +16,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import flask.helpers
from oslo.config import cfg
from ceilometer.openstack.common import jsonutils
# Replace the json module used by flask with the one from
# openstack.common so we can take advantage of the fact that it knows
# how to serialize more complex objects.
flask.helpers.json = jsonutils
# Register options for the service
API_SERVICE_OPTS = [
cfg.IntOpt('metering_api_port',

View File

@ -23,13 +23,15 @@ from ceilometer.api import acl
from ceilometer.api import config as api_config
from ceilometer.api import hooks
from ceilometer.api import middleware
from ceilometer.api.v1 import app as v1app
auth_opts = [
cfg.StrOpt('auth_strategy',
default='keystone',
help='The strategy to use for auth: noauth or keystone.'),
cfg.BoolOpt('enable_v1_api',
default=True,
help='Deploy the deprecated v1 API.'),
]
CONF = cfg.CONF
@ -77,7 +79,14 @@ class VersionSelectorApplication(object):
pc = get_pecan_config()
pc.app.debug = CONF.debug
pc.app.enable_acl = (CONF.auth_strategy == 'keystone')
self.v1 = v1app.make_app(cfg.CONF, enable_acl=pc.app.enable_acl)
if cfg.CONF.enable_v1_api:
from ceilometer.api.v1 import app as v1app
self.v1 = v1app.make_app(cfg.CONF, enable_acl=pc.app.enable_acl)
else:
def not_found(environ, start_response):
start_response('404 Not Found', [])
return []
self.v1 = not_found
self.v2 = setup_app(pecan_config=pc)
def __call__(self, environ, start_response):

View File

@ -18,6 +18,7 @@
"""Set up the API server application instance."""
import flask
import flask.helpers
from oslo.config import cfg
from ceilometer.api import acl
@ -25,6 +26,10 @@ from ceilometer.api.v1 import blueprint as v1_blueprint
from ceilometer.openstack.common import jsonutils
from ceilometer import storage
# Replace the json module used by flask with the one from
# openstack.common so we can take advantage of the fact that it knows
# how to serialize more complex objects.
flask.helpers.json = jsonutils
storage.register_opts(cfg.CONF)

View File

@ -445,6 +445,12 @@
#cinder_control_exchange=cinder
######## defined in ceilometer.api.app ########
# Deploy the deprecated v1 API. (boolean value)
#enable_v1_api=true
[rpc_notifier2]
######## defined in ceilometer.openstack.common.notifier.rpc_notifier2 ########
@ -479,4 +485,4 @@
#metering_secret=change this or be hacked
# Total option count: 105
# Total option count: 106