Skip to content

Commit

Permalink
Merge "Disable v3 API by default"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Sep 4, 2015
2 parents 032daa9 + 6fe3626 commit 8fa349c
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
23 changes: 12 additions & 11 deletions doc/source/configuring.rst
Expand Up @@ -1344,9 +1344,9 @@ 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``
If the Glance API server parameter ``enable_v2_api`` or ``enable_v3_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
Expand Down Expand Up @@ -1401,9 +1401,9 @@ Optional. Default: ``roles``.
Configuring Glance APIs
-----------------------

The glance-api service implements versions 1 and 2 of the OpenStack
Images API. Disable either version of the Images API using the
following options:
The glance-api service implements versions 1, 2 and 3 of
the OpenStack Images API. Disable any version of
the Images API using the following options:

* ``enable_v1_api=<True|False>``

Expand All @@ -1413,11 +1413,12 @@ Optional. Default: ``True``

Optional. Default: ``True``

**IMPORTANT NOTE**: The v1 API is implemented on top of the
glance-registry service while the v2 API is not. This means that
in order to use the v2 API, you must copy the necessary sql
configuration from your glance-registry service to your
glance-api configuration file.
* ``enable_v3_api=<True|False>``

Optional. Default: ``False``

**IMPORTANT NOTE**: To use v2 registry in v2 or v3 API, you must set
``data_api`` to glance.db.registry.api in glance-api.conf.

Configuring Glance Tasks
------------------------
Expand Down
3 changes: 3 additions & 0 deletions etc/glance-api.conf
Expand Up @@ -64,6 +64,9 @@ backlog = 4096
# Allow access to version 2 of glance api
#enable_v2_api = True

# Allow access to version 3 of glance api
#enable_v3_api = False

# Return the URL that references where the data is stored on
# the backend storage system. For example, if using the
# file system store a URL of 'file:///path/to/image' will
Expand Down
6 changes: 3 additions & 3 deletions glance/api/__init__.py
Expand Up @@ -20,10 +20,10 @@


def root_app_factory(loader, global_conf, **local_conf):
if not CONF.enable_v1_api:
if not CONF.enable_v1_api and '/v1' in local_conf:
del local_conf['/v1']
if not CONF.enable_v2_api:
if not CONF.enable_v2_api and '/v2' in local_conf:
del local_conf['/v2']
if not CONF.enable_v3_api:
if not CONF.enable_v3_api and '/v3' in local_conf:
del local_conf['/v3']
return paste.urlmap.urlmap_factory(loader, global_conf, **local_conf)
2 changes: 1 addition & 1 deletion glance/common/config.py
Expand Up @@ -150,7 +150,7 @@
help=_("Deploy the v1 OpenStack Images API.")),
cfg.BoolOpt('enable_v2_api', default=True,
help=_("Deploy the v2 OpenStack Images API.")),
cfg.BoolOpt('enable_v3_api', default=True,
cfg.BoolOpt('enable_v3_api', default=False,
help=_("Deploy the v3 OpenStack Objects API.")),
cfg.BoolOpt('enable_v1_registry', default=True,
help=_("Deploy the v1 OpenStack Registry API.")),
Expand Down
4 changes: 4 additions & 0 deletions glance/tests/integration/legacy_functional/base.py
Expand Up @@ -55,6 +55,7 @@
/: apiversions
/v1: apiv1app
/v2: apiv2app
/v3: apiv3app
[app:apiversions]
paste.app_factory = glance.api.versions:create_resource
Expand All @@ -65,6 +66,9 @@
[app:apiv2app]
paste.app_factory = glance.api.v2.router:API.factory
[app:apiv3app]
paste.app_factory = glance.api.v3.router:API.factory
[filter:versionnegotiation]
paste.filter_factory =
glance.api.middleware.version_negotiation:VersionNegotiationFilter.factory
Expand Down
4 changes: 4 additions & 0 deletions glance/tests/integration/v2/base.py
Expand Up @@ -58,6 +58,7 @@
/: apiversions
/v1: apiv1app
/v2: apiv2app
/v3: apiv3app
[app:apiversions]
paste.app_factory = glance.api.versions:create_resource
Expand All @@ -68,6 +69,9 @@
[app:apiv2app]
paste.app_factory = glance.api.v2.router:API.factory
[app:apiv3app]
paste.app_factory = glance.api.v3.router:API.factory
[filter:versionnegotiation]
paste.filter_factory =
glance.api.middleware.version_negotiation:VersionNegotiationFilter.factory
Expand Down
20 changes: 4 additions & 16 deletions glance/tests/unit/test_versions.py
Expand Up @@ -34,12 +34,6 @@ def test_get_version_list(self):
self.assertEqual('application/json', res.content_type)
results = jsonutils.loads(res.body)['versions']
expected = [
{
'status': 'EXPERIMENTAL',
'id': 'v3.0',
'links': [{'href': 'http://127.0.0.1:9292/v3/',
'rel': 'self'}],
},
{
'id': 'v2.3',
'status': 'CURRENT',
Expand Down Expand Up @@ -89,12 +83,6 @@ def test_get_version_list_public_endpoint(self):
self.assertEqual('application/json', res.content_type)
results = jsonutils.loads(res.body)['versions']
expected = [
{
'status': 'EXPERIMENTAL',
'id': 'v3.0',
'links': [{'href': 'https://example.com:9292/v3/',
'rel': 'self'}],
},
{
'id': 'v2.3',
'status': 'CURRENT',
Expand Down Expand Up @@ -184,13 +172,13 @@ def test_request_url_v2_2(self):

def test_request_url_v3(self):
request = webob.Request.blank('/v3/artifacts')
self.middleware.process_request(request)
self.assertEqual('/v3/artifacts', request.path_info)
resp = self.middleware.process_request(request)
self.assertIsInstance(resp, versions.Controller)

def test_request_url_v3_0(self):
request = webob.Request.blank('/v3.0/artifacts')
self.middleware.process_request(request)
self.assertEqual('/v3/artifacts', request.path_info)
resp = self.middleware.process_request(request)
self.assertIsInstance(resp, versions.Controller)

def test_request_url_v2_3_unsupported(self):
request = webob.Request.blank('/v2.3/images')
Expand Down

0 comments on commit 8fa349c

Please sign in to comment.