Makes possible to enable Registry API v1 and v2

This change will make possible to enable/disable both v1 and v2 Registry APIs
either individually or together from glance-registry.conf.

DocImpact
Closes bug: #1290432
Change-Id: Ib2458b3312bdb552975b1e42485086a1c3aa6d3f
This commit is contained in:
Erno Kuvaja 2014-03-12 13:51:56 +00:00
parent 697db03ed6
commit c6365cc4f5
7 changed files with 82 additions and 16 deletions

View File

@ -1029,6 +1029,22 @@ Can only be specified in configuration files.
Sets the number of seconds after which SQLAlchemy should reconnect to the Sets the number of seconds after which SQLAlchemy should reconnect to the
datastore if no activity has been made on the connection. datastore if no activity has been made on the connection.
* ``enable_v1_registry=<True|False>``
Optional. Default: ``True``
* ``enable_v2_registry=<True|False>``
Optional. Default: ``True``
Defines which version(s) of the Registry API will be enabled.
If the Glance API server parameter ``enable_v1_api`` has been set to ``True`` the
``enable_v1_registry`` has to be ``True`` as well.
If the Glance API server parameter ``enable_v2_api`` has been set to ``True`` and
the parameter ``data_api`` has been set to ``glance.db.registry.api`` the
``enable_v2_registry`` has to be set to ``True``
Configuring Notifications Configuring Notifications
------------------------- -------------------------

View File

@ -13,7 +13,7 @@ pipeline = authtoken context registryapp
pipeline = context registryapp pipeline = context registryapp
[app:registryapp] [app:registryapp]
paste.app_factory = glance.registry.api.v1:API.factory paste.app_factory = glance.registry.api:API.factory
[filter:context] [filter:context]
paste.filter_factory = glance.api.middleware.context:ContextMiddleware.factory paste.filter_factory = glance.api.middleware.context:ContextMiddleware.factory

View File

@ -29,6 +29,10 @@ backlog = 4096
# package. # package.
# data_api = glance.db.sqlalchemy.api # data_api = glance.db.sqlalchemy.api
# Enable Registry API versions individually or simultaneously
#enable_v1_registry = True
#enable_v2_registry = True
# SQLAlchemy connection string for the reference implementation # SQLAlchemy connection string for the reference implementation
# registry server. Any valid SQLAlchemy connection string is fine. # registry server. Any valid SQLAlchemy connection string is fine.
# See: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/connections.html#sqlalchemy.create_engine # See: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/connections.html#sqlalchemy.create_engine

View File

@ -107,6 +107,10 @@ common_opts = [
help=_("Deploy the v1 OpenStack Images API.")), help=_("Deploy the v1 OpenStack Images API.")),
cfg.BoolOpt('enable_v2_api', default=True, cfg.BoolOpt('enable_v2_api', default=True,
help=_("Deploy the v2 OpenStack Images API.")), help=_("Deploy the v2 OpenStack Images API.")),
cfg.BoolOpt('enable_v1_registry', default=True,
help=_("Deploy the v1 OpenStack Registry API.")),
cfg.BoolOpt('enable_v2_registry', default=True,
help=_("Deploy the v2 OpenStack Registry API.")),
cfg.StrOpt('pydev_worker_debug_host', default=None, cfg.StrOpt('pydev_worker_debug_host', default=None,
help=_('The hostname/IP of the pydev process listening for ' help=_('The hostname/IP of the pydev process listening for '
'debug connections')), 'debug connections')),

View File

@ -0,0 +1,37 @@
# Copyright 2014 Hewlett-Packard Development Company, L.P.
# 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 oslo.config import cfg
from glance.common import wsgi
from glance.registry.api import v1
from glance.registry.api import v2
CONF = cfg.CONF
CONF.import_opt('enable_v1_registry', 'glance.common.config')
CONF.import_opt('enable_v2_registry', 'glance.common.config')
class API(wsgi.Router):
"""WSGI entry point for all Registry requests."""
def __init__(self, mapper):
mapper = mapper or wsgi.APIMapper()
if CONF.enable_v1_registry:
v1.init(mapper)
if CONF.enable_v2_registry:
v2.init(mapper)
super(API, self).__init__(mapper)

View File

@ -13,19 +13,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import routes
from glance.common import wsgi from glance.common import wsgi
from glance.registry.api.v1 import images from glance.registry.api.v1 import images
from glance.registry.api.v1 import members from glance.registry.api.v1 import members
class API(wsgi.Router): def init(mapper):
"""WSGI entry point for all Registry requests."""
def __init__(self, mapper):
mapper = routes.Mapper()
images_resource = images.create_resource() images_resource = images.create_resource()
mapper.connect("/", mapper.connect("/",
@ -86,4 +79,13 @@ class API(wsgi.Router):
controller=members_resource, controller=members_resource,
action="index_shared_images") action="index_shared_images")
class API(wsgi.Router):
"""WSGI entry point for all Registry requests."""
def __init__(self, mapper):
mapper = mapper or wsgi.APIMapper()
init(mapper)
super(API, self).__init__(mapper) super(API, self).__init__(mapper)

View File

@ -13,20 +13,23 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import routes
from glance.common import wsgi from glance.common import wsgi
from glance.registry.api.v2 import rpc from glance.registry.api.v2 import rpc
def init(mapper):
rpc_resource = rpc.create_resource()
mapper.connect("/rpc", controller=rpc_resource,
conditions=dict(method=["POST"]),
action="__call__")
class API(wsgi.Router): class API(wsgi.Router):
"""WSGI entry point for all Registry requests.""" """WSGI entry point for all Registry requests."""
def __init__(self, mapper): def __init__(self, mapper):
mapper = mapper or routes.Mapper() mapper = mapper or wsgi.APIMapper()
init(mapper)
rpc_resource = rpc.create_resource()
mapper.connect("/rpc", controller=rpc_resource,
conditions=dict(method=["POST"]),
action="__call__")
super(API, self).__init__(mapper) super(API, self).__init__(mapper)