Deprecation cleanout Registry and related

This patch removes majority of the registry and it's related
endpoints and config options that has been deprecated for
removal in various releases.

Change-Id: I75014bd50bf382efebe56bd89c20ffefbdde25f5
This commit is contained in:
Erno Kuvaja 2020-06-30 15:13:54 +01:00
parent e6db0b10a7
commit 673666cbf4
28 changed files with 48 additions and 567 deletions

View File

@ -1,22 +0,0 @@
# Glance Registry has been removed, this file can be removed once devstack doesn't need it.
# Use this pipeline for no auth - DEFAULT
[pipeline:glance-registry]
pipeline = healthcheck registryapp
# Use this pipeline for keystone auth
[pipeline:glance-registry-keystone]
pipeline = healthcheck registryapp
# Use this pipeline for authZ only. This means that the registry will treat a
# user as authenticated without making requests to keystone to reauthenticate
# the user.
[pipeline:glance-registry-trusted-auth]
pipeline = healthcheck registryapp
[app:registryapp]
paste.app_factory = glance.registry.api:API.factory
[filter:healthcheck]
paste.filter_factory = oslo_middleware:Healthcheck.factory
backends = disable_by_file
disable_by_file_path = /etc/glance/healthcheck_disable

View File

@ -1,2 +0,0 @@
# NOTE(jokke): Glance registry has been removed after deprecation.
# This file can be deleted once devstack doesn't need it anymore.

View File

@ -1,4 +0,0 @@
[DEFAULT]
wrap_width = 80
output_file = etc/glance-registry.conf.sample
namespace = glance.registry

View File

@ -38,7 +38,6 @@ import glance.db
from glance.i18n import _LE, _LI
from glance import image_cache
from glance import notifier
import glance.registry.client.v1.api as registry
LOG = logging.getLogger(__name__)
@ -106,19 +105,6 @@ class CacheFilter(wsgi.Middleware):
LOG.debug("User not permitted to perform '%s' action", action)
raise webob.exc.HTTPForbidden(explanation=e.msg, request=req)
def _get_v1_image_metadata(self, request, image_id):
"""
Retrieves image metadata using registry for v1 api and creates
dictionary-like mash-up of image core and custom properties.
"""
try:
image_metadata = registry.get_image_metadata(request.context,
image_id)
return utils.create_mashup_dict(image_metadata)
except exception.NotFound as e:
LOG.debug("No metadata found for image '%s'", image_id)
raise webob.exc.HTTPNotFound(explanation=e.msg, request=request)
def _get_v2_image_metadata(self, request, image_id):
"""
Retrieves image and for v2 api and creates adapter like object
@ -183,7 +169,7 @@ class CacheFilter(wsgi.Middleware):
return method(request, image_id, image_iterator, image_metadata)
except exception.ImageNotFound:
msg = _LE("Image cache contained image file for image '%s', "
"however the registry did not contain metadata for "
"however the database did not contain metadata for "
"that image!") % image_id
LOG.error(msg)
self.cache.delete_cached_image(image_id)

View File

@ -141,24 +141,23 @@ class ImageDataController(object):
image = image_repo.get(image_id)
image.status = 'saving'
try:
if CONF.data_api == 'glance.db.registry.api':
# create a trust if backend is registry
try:
# request user plugin for current token
user_plugin = req.environ.get('keystone.token_auth')
roles = []
# use roles from request environment because they
# are not transformed to lower-case unlike cxt.roles
for role_info in req.environ.get(
'keystone.token_info')['token']['roles']:
roles.append(role_info['name'])
refresher = trust_auth.TokenRefresher(user_plugin,
cxt.project_id,
roles)
except Exception as e:
LOG.info(_LI("Unable to create trust: %s "
"Use the existing user token."),
encodeutils.exception_to_unicode(e))
# create a trust if backend is registry
try:
# request user plugin for current token
user_plugin = req.environ.get('keystone.token_auth')
roles = []
# use roles from request environment because they
# are not transformed to lower-case unlike cxt.roles
for role_info in req.environ.get(
'keystone.token_info')['token']['roles']:
roles.append(role_info['name'])
refresher = trust_auth.TokenRefresher(user_plugin,
cxt.project_id,
roles)
except Exception as e:
LOG.info(_LI("Unable to create trust: %s "
"Use the existing user token."),
encodeutils.exception_to_unicode(e))
image_repo.save(image, from_state='queued')
image.set_data(data, size, backend=backend)

View File

@ -51,10 +51,9 @@ CONF = cfg.CONF
ALL_COMMANDS = ['start', 'status', 'stop', 'shutdown', 'restart',
'reload', 'force-reload']
ALL_SERVERS = ['api', 'registry', 'scrubber']
RELOAD_SERVERS = ['glance-api', 'glance-registry']
GRACEFUL_SHUTDOWN_SERVERS = ['glance-api', 'glance-registry',
'glance-scrubber']
ALL_SERVERS = ['api', 'scrubber']
RELOAD_SERVERS = ['glance-api']
GRACEFUL_SHUTDOWN_SERVERS = ['glance-api', 'glance-scrubber']
MAX_DESCRIPTORS = 32768
MAX_MEMORY = 2 * units.Gi # 2 GB
USAGE = """%(prog)s [options] <SERVER> <COMMAND> [CONFPATH]

View File

@ -547,9 +547,7 @@ def main():
logging.register_options(CONF)
CONF.set_default(name='use_stderr', default=True)
cfg_files = cfg.find_config_files(project='glance',
prog='glance-registry')
cfg_files.extend(cfg.find_config_files(project='glance',
prog='glance-api'))
prog='glance-api')
cfg_files.extend(cfg.find_config_files(project='glance',
prog='glance-manage'))
config.parse_args(default_config_files=cfg_files)

View File

@ -1,51 +0,0 @@
#!/usr/bin/env python
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# Copyright 2011 OpenStack Foundation
# 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.
"""
Glance Registry has been removed after deprecation
Delete after devstack does not need this anymore.
"""
import os
import sys
import time
# If ../glance/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
os.pardir,
os.pardir))
if os.path.exists(os.path.join(possible_topdir, 'glance', '__init__.py')):
sys.path.insert(0, possible_topdir)
def main():
try:
print("Glance Registry has been removed after deprecation")
# NOTE(jokke): Service is started and running for any init tooling
# purposes. Just being no-op.
while True:
time.sleep(5)
except Exception:
sys.exit("ERROR: Glance Registry has been removed after deprecation")
if __name__ == '__main__':
main()

View File

@ -278,59 +278,6 @@ Any negative value is interpreted as unlimited.
Related options:
* None
""")),
# TODO(abashmak): Add choices parameter to this option:
# choices('glance.db.sqlalchemy.api',
# 'glance.db.registry.api',
# 'glance.db.simple.api')
# This will require a fix to the functional tests which
# set this option to a test version of the registry api module:
# (glance.tests.functional.v2.registry_data_api), in order to
# bypass keystone authentication for the Registry service.
# All such tests are contained in:
# glance/tests/functional/v2/test_images.py
cfg.StrOpt('data_api',
default='glance.db.sqlalchemy.api',
deprecated_for_removal=True,
deprecated_since="Queens",
deprecated_reason=_("""
Glance registry service is deprecated for removal.
More information can be found from the spec:
http://specs.openstack.org/openstack/glance-specs/specs/queens/approved/glance/deprecate-registry.html
"""),
help=_("""
Python module path of data access API.
Specifies the path to the API to use for accessing the data model.
This option determines how the image catalog data will be accessed.
Possible values:
* glance.db.sqlalchemy.api
* glance.db.registry.api
* glance.db.simple.api
If this option is set to ``glance.db.sqlalchemy.api`` then the image
catalog data is stored in and read from the database via the
SQLAlchemy Core and ORM APIs.
Setting this option to ``glance.db.registry.api`` will force all
database access requests to be routed through the Registry service.
This avoids data access from the Glance API nodes for an added layer
of security, scalability and manageability.
NOTE: In v2 OpenStack Images API, the registry service is optional.
In order to use the Registry API in v2, the option
``enable_v2_registry`` must be set to ``True``.
Finally, when this configuration option is set to
``glance.db.simple.api``, image catalog data is stored in and read
from an in-memory data structure. This is primarily used for testing.
Related options:
* enable_v2_api
* enable_v2_registry
""")),
cfg.IntOpt('limit_param_default', default=25, min=1,
help=_("""
@ -530,59 +477,10 @@ When this option is set to ``True``, Glance service will respond
to requests on registered endpoints conforming to the v2 OpenStack
Images API.
NOTES:
* If this option is disabled, then the ``enable_v2_registry``
option, which is enabled by default, is also recommended
to be disabled.
Possible values:
* True
* False
Related options:
* enable_v2_registry
""")),
cfg.BoolOpt('enable_v1_registry',
default=True,
deprecated_reason=_DEPRECATE_GLANCE_V1_MSG,
deprecated_since='Newton',
help=_("""
DEPRECATED FOR REMOVAL
""")),
cfg.BoolOpt('enable_v2_registry',
default=True,
deprecated_for_removal=True,
deprecated_since="Queens",
deprecated_reason=_("""
Glance registry service is deprecated for removal.
More information can be found from the spec:
http://specs.openstack.org/openstack/glance-specs/specs/queens/approved/glance/deprecate-registry.html
"""),
help=_("""
Deploy the v2 API Registry service.
When this option is set to ``True``, the Registry service
will be enabled in Glance for v2 API requests.
NOTES:
* Use of Registry is optional in v2 API, so this option
must only be enabled if both ``enable_v2_api`` is set to
``True`` and the ``data_api`` option is set to
``glance.db.registry.api``.
* If deploying only the v1 OpenStack Images API, this option,
which is enabled by default, should be disabled.
Possible values:
* True
* False
Related options:
* enable_v2_api
* data_api
""")),
cfg.HostAddressOpt('pydev_worker_debug_host',
sample_default='localhost',

View File

@ -27,7 +27,6 @@ from glance import scrubber
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
CONF.import_opt('use_user_token', 'glance.registry.client')
RESTRICTED_URI_SCHEMAS = frozenset(['file', 'filesystem', 'swift+config'])
@ -93,8 +92,7 @@ def schedule_delayed_delete_from_backend(context, image_id, location):
db_queue = scrubber.get_scrub_queue()
if not CONF.use_user_token:
context = None
context = None
ret = db_queue.add_location(image_id, location)
if ret:

View File

@ -34,22 +34,8 @@ CONF.import_opt('image_size_cap', 'glance.common.config')
CONF.import_opt('metadata_encryption_key', 'glance.common.config')
def get_api(v1_mode=False):
"""
When using v2_registry with v2_api or alone, it is essential that the opt
'data_api' be set to 'glance.db.registry.api'. This requires us to
differentiate what this method returns as the db api. i.e., we do not want
to return 'glance.db.registry.api' for a call from v1 api.
Reference bug #1516706
"""
if v1_mode:
# prevent v1_api from talking to v2_registry.
if CONF.data_api == 'glance.db.simple.api':
api = importutils.import_module(CONF.data_api)
else:
api = importutils.import_module('glance.db.sqlalchemy.api')
else:
api = importutils.import_module(CONF.data_api)
def get_api():
api = importutils.import_module('glance.db.sqlalchemy.api')
if hasattr(api, 'configure'):
api.configure()

View File

@ -0,0 +1,4 @@
# flake8: noqa
# Note(jokke): SimpleDB is only used for unittests and #noqa
# has not been supported in production since moving
# to alembic migrations.

View File

@ -14,7 +14,6 @@
__all__ = [
'list_api_opts',
'list_registry_opts',
'list_scrubber_opts',
'list_cache_opts',
'list_manage_opts',
@ -42,9 +41,6 @@ import glance.common.wsgi
import glance.image_cache
import glance.image_cache.drivers.sqlite
import glance.notifier
import glance.registry
import glance.registry.client
import glance.registry.client.v1.api
import glance.scrubber
@ -64,10 +60,6 @@ _api_opts = [
glance.image_cache.drivers.sqlite.sqlite_opts,
glance.image_cache.image_cache_opts,
glance.notifier.notifier_opts,
glance.registry.registry_addr_opts,
glance.registry.client.registry_client_ctx_opts,
glance.registry.client.registry_client_opts,
glance.registry.client.v1.api.registry_client_ctx_opts,
glance.scrubber.scrubber_opts))),
('image_format', glance.common.config.image_format_opts),
('task', glance.common.config.task_opts),
@ -79,9 +71,6 @@ _api_opts = [
profiler.list_opts()[0],
('paste_deploy', glance.common.config.paste_deploy_opts)
]
_registry_opts = [
(None, []),
]
_scrubber_opts = [
(None, list(itertools.chain(
glance.common.config.common_opts,
@ -93,10 +82,7 @@ _cache_opts = [
(None, list(itertools.chain(
glance.common.config.common_opts,
glance.image_cache.drivers.sqlite.sqlite_opts,
glance.image_cache.image_cache_opts,
glance.registry.registry_addr_opts,
glance.registry.client.registry_client_opts,
glance.registry.client.registry_client_ctx_opts))),
glance.image_cache.image_cache_opts))),
]
_manage_opts = [
(None, [])
@ -129,13 +115,6 @@ def list_api_opts():
return [(g, copy.deepcopy(o)) for g, o in _api_opts]
def list_registry_opts():
"""Return a list of oslo_config options available in Glance Registry
service.
"""
return [(g, copy.deepcopy(o)) for g, o in _registry_opts]
def list_scrubber_opts():
"""Return a list of oslo_config options available in Glance Scrubber
service.

View File

@ -1,37 +0,0 @@
# 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.
"""
Glance Registry has been removed after deprecation
Delete after devstack doesn't require anymore
"""
from oslo_config import cfg
from glance.common import wsgi
from glance.registry.api import v2
CONF = cfg.CONF
class API(wsgi.Router):
"""WSGI entry point for all Registry requests."""
def __init__(self, mapper):
mapper = wsgi.APIMapper()
v2.init(mapper)
super(API, self).__init__(mapper)

View File

@ -1,33 +0,0 @@
# Copyright 2013 Red Hat, Inc.
# 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 glance.common import wsgi
def init(mapper):
reject_method_resource = wsgi.Resource(wsgi.RejectMethodController())
mapper.connect("/rpc", controller=reject_method_resource,
action="reject")
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)

View File

@ -96,7 +96,6 @@ class BaseServer(object):
self.process_pid = None
self.server_module = None
self.stop_kill = False
self.use_user_token = True
self.send_identity_credentials = False
def write_conf(self, **kwargs):
@ -401,8 +400,6 @@ class ApiServer(Server):
default_sql_connection = SQLITE_CONN_TEMPLATE % self.test_dir
self.sql_connection = os.environ.get('GLANCE_TEST_SQL_CONNECTION',
default_sql_connection)
self.data_api = kwargs.get("data_api",
"glance.db.sqlalchemy.api")
self.user_storage_quota = '0'
self.lock_path = self.test_dir
@ -417,7 +414,6 @@ default_log_levels = eventlet.wsgi.server=DEBUG
bind_host = %(bind_host)s
bind_port = %(bind_port)s
metadata_encryption_key = %(metadata_encryption_key)s
use_user_token = %(use_user_token)s
send_identity_credentials = %(send_identity_credentials)s
log_file = %(log_file)s
image_size_cap = %(image_size_cap)d
@ -428,7 +424,6 @@ scrub_time = %(scrub_time)s
send_identity_headers = %(send_identity_headers)s
image_cache_dir = %(image_cache_dir)s
image_cache_driver = %(image_cache_driver)s
data_api = %(data_api)s
sql_connection = %(sql_connection)s
show_image_direct_url = %(show_image_direct_url)s
show_multiple_locations = %(show_multiple_locations)s
@ -579,8 +574,6 @@ class ApiServerForMultipleBackend(Server):
default_sql_connection = SQLITE_CONN_TEMPLATE % self.test_dir
self.sql_connection = os.environ.get('GLANCE_TEST_SQL_CONNECTION',
default_sql_connection)
self.data_api = kwargs.get("data_api",
"glance.db.sqlalchemy.api")
self.user_storage_quota = '0'
self.lock_path = self.test_dir
@ -595,7 +588,6 @@ default_log_levels = eventlet.wsgi.server=DEBUG
bind_host = %(bind_host)s
bind_port = %(bind_port)s
metadata_encryption_key = %(metadata_encryption_key)s
use_user_token = %(use_user_token)s
send_identity_credentials = %(send_identity_credentials)s
log_file = %(log_file)s
image_size_cap = %(image_size_cap)d
@ -606,7 +598,6 @@ scrub_time = %(scrub_time)s
send_identity_headers = %(send_identity_headers)s
image_cache_dir = %(image_cache_dir)s
image_cache_driver = %(image_cache_driver)s
data_api = %(data_api)s
sql_connection = %(sql_connection)s
show_image_direct_url = %(show_image_direct_url)s
show_multiple_locations = %(show_multiple_locations)s

View File

@ -1,91 +0,0 @@
# Copyright 2012 OpenStack Foundation
# Copyright 2013 IBM Corp.
# 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 glance.api import CONF
import glance.db.simple.api
import glance.tests.functional.db as db_tests
from glance.tests.functional.db import base
def get_db(config, workers=1):
CONF.set_override('data_api', 'glance.db.simple.api')
CONF.set_override('workers', workers)
db_api = glance.db.get_api()
return db_api
def reset_db(db_api):
db_api.reset()
class TestSimpleDriver(base.TestDriver,
base.DriverTests,
base.FunctionalInitWrapper):
def setUp(self):
db_tests.load(get_db, reset_db)
super(TestSimpleDriver, self).setUp()
self.addCleanup(db_tests.reset)
class TestSimpleQuota(base.DriverQuotaTests,
base.FunctionalInitWrapper):
def setUp(self):
db_tests.load(get_db, reset_db)
super(TestSimpleQuota, self).setUp()
self.addCleanup(db_tests.reset)
class TestSimpleVisibility(base.TestVisibility,
base.VisibilityTests,
base.FunctionalInitWrapper):
def setUp(self):
db_tests.load(get_db, reset_db)
super(TestSimpleVisibility, self).setUp()
self.addCleanup(db_tests.reset)
class TestSimpleMembershipVisibility(base.TestMembershipVisibility,
base.MembershipVisibilityTests,
base.FunctionalInitWrapper):
def setUp(self):
db_tests.load(get_db, reset_db)
super(TestSimpleMembershipVisibility, self).setUp()
self.addCleanup(db_tests.reset)
class TestSimpleTask(base.TaskTests,
base.FunctionalInitWrapper):
def setUp(self):
db_tests.load(get_db, reset_db)
super(TestSimpleTask, self).setUp()
self.addCleanup(db_tests.reset)
class TestTooManyWorkers(base.TaskTests):
def setUp(self):
def get_db_too_many_workers(config):
self.assertRaises(SystemExit, get_db, config, 2)
return get_db(config)
db_tests.load(get_db_too_many_workers, reset_db)
super(TestTooManyWorkers, self).setUp()
self.addCleanup(db_tests.reset)

View File

@ -79,7 +79,6 @@ class TestScrubber(functional.FunctionalTest):
"""
self.cleanup()
kwargs = self.__dict__.copy()
kwargs['use_user_token'] = True
self.start_servers(delayed_delete=True, daemon=True,
metadata_encryption_key='', **kwargs)
path = "http://%s:%d/v2/images" % ("127.0.0.1", self.api_port)
@ -115,7 +114,6 @@ class TestScrubber(functional.FunctionalTest):
"""
self.cleanup()
kwargs = self.__dict__.copy()
kwargs['use_user_token'] = True
self.start_servers(delayed_delete=True, daemon=False,
metadata_encryption_key='', **kwargs)
path = "http://%s:%d/v2/images" % ("127.0.0.1", self.api_port)
@ -164,7 +162,6 @@ class TestScrubber(functional.FunctionalTest):
# Start servers.
self.cleanup()
kwargs = self.__dict__.copy()
kwargs['use_user_token'] = True
self.start_servers(delayed_delete=True, daemon=False,
default_store='file', **kwargs)
@ -242,7 +239,6 @@ class TestScrubber(functional.FunctionalTest):
def test_scrubber_restore_image(self):
self.cleanup()
kwargs = self.__dict__.copy()
kwargs['use_user_token'] = True
self.start_servers(delayed_delete=True, daemon=False,
metadata_encryption_key='', **kwargs)
path = "http://%s:%d/v2/images" % ("127.0.0.1", self.api_port)

View File

@ -43,13 +43,11 @@ class TestImages(functional.FunctionalTest):
self.cleanup()
self.include_scrubber = False
self.api_server.deployment_flavor = 'noauth'
self.api_server.data_api = 'glance.db.sqlalchemy.api'
for i in range(3):
ret = test_utils.start_http_server("foo_image_id%d" % i,
"foo_image%d" % i)
setattr(self, 'http_server%d' % i, ret[1])
setattr(self, 'http_port%d' % i, ret[2])
self.api_server.use_user_token = True
self.api_server.send_identity_credentials = True
def tearDown(self):
@ -3341,7 +3339,6 @@ class TestImages(functional.FunctionalTest):
self.api_server.deployment_flavor = 'fakeauth'
kwargs = self.__dict__.copy()
kwargs['use_user_token'] = True
self.start_servers(**kwargs)
owners = ['admin', 'tenant1', 'tenant2', 'none']
@ -4361,7 +4358,6 @@ class TestImagesMultipleBackend(functional.MultipleBackendFunctionalTest):
self.cleanup()
self.include_scrubber = False
self.api_server_multiple_backend.deployment_flavor = 'noauth'
self.api_server_multiple_backend.data_api = 'glance.db.sqlalchemy.api'
for i in range(3):
ret = test_utils.start_http_server("foo_image_id%d" % i,
"foo_image%d" % i)
@ -6151,7 +6147,6 @@ class TestMultiStoreImageMembers(functional.MultipleBackendFunctionalTest):
self.cleanup()
self.include_scrubber = False
self.api_server_multiple_backend.deployment_flavor = 'noauth'
self.api_server_multiple_backend.data_api = 'glance.db.sqlalchemy.api'
for i in range(3):
ret = test_utils.start_http_server("foo_image_id%d" % i,
"foo_image%d" % i)

View File

@ -26,7 +26,6 @@ from oslo_db import options
import glance.common.client
from glance.common import config
import glance.db.sqlalchemy.api
import glance.registry.client.v1.client
from glance import tests as glance_tests
from glance.tests import utils as test_utils
@ -93,27 +92,6 @@ paste.filter_factory =
paste.filter_factory = glance.tests.utils:FakeAuthMiddleware.factory
"""
TESTING_REGISTRY_PASTE_CONF = """
[pipeline:glance-registry]
pipeline = unauthenticated-context registryapp
[pipeline:glance-registry-fakeauth]
pipeline = fakeauth context registryapp
[app:registryapp]
paste.app_factory = glance.registry.api.v1:API.factory
[filter:context]
paste.filter_factory = glance.api.middleware.context:ContextMiddleware.factory
[filter:unauthenticated-context]
paste.filter_factory =
glance.api.middleware.context:UnauthenticatedContextMiddleware.factory
[filter:fakeauth]
paste.filter_factory = glance.tests.utils:FakeAuthMiddleware.factory
"""
CONF = cfg.CONF
@ -126,13 +104,6 @@ class ApiTest(test_utils.BaseTestCase):
self._setup_database()
self._setup_stores()
self._setup_property_protection()
self.glance_registry_app = self._load_paste_app(
'glance-registry',
flavor=getattr(self, 'registry_flavor', ''),
conf=getattr(self, 'registry_paste_conf',
TESTING_REGISTRY_PASTE_CONF),
)
self._connect_registry_client()
self.glance_api_app = self._load_paste_app(
'glance-api',
flavor=getattr(self, 'api_flavor', ''),
@ -203,15 +174,6 @@ class ApiTest(test_utils.BaseTestCase):
return config.load_paste_app(name, flavor=flavor,
conf_file=conf_file_path)
def _connect_registry_client(self):
def get_connection_type(self2):
def wrapped(*args, **kwargs):
return test_utils.HttplibWsgiAdapter(self.glance_registry_app)
return wrapped
self.mock_object(glance.common.client.BaseClient,
'get_connection_type', get_connection_type)
def tearDown(self):
glance.db.sqlalchemy.api.clear_db_env()
super(ApiTest, self).tearDown()

View File

@ -27,57 +27,15 @@ import routes
import webob
from glance.api.middleware import context
from glance.api.v1 import router
from glance.api.v2 import router
import glance.common.client
from glance.registry.api import v1 as rserver
from glance.tests import utils
DEBUG = False
class FakeRegistryConnection(object):
def __init__(self, registry=None):
self.registry = registry or rserver
def __call__(self, *args, **kwargs):
# NOTE(flaper87): This method takes
# __init__'s place in the chain.
return self
def connect(self):
return True
def close(self):
return True
def request(self, method, url, body=None, headers=None):
self.req = webob.Request.blank("/" + url.lstrip("/"))
self.req.method = method
if headers:
self.req.headers = headers
if body:
self.req.body = body
def getresponse(self):
mapper = routes.Mapper()
server = self.registry.API(mapper)
# NOTE(markwash): we need to pass through context auth information if
# we have it.
if 'X-Auth-Token' in self.req.headers:
api = utils.FakeAuthMiddleware(server)
else:
api = context.UnauthenticatedContextMiddleware(server)
webob_res = self.req.get_response(api)
return utils.FakeHTTPResponse(status=webob_res.status_int,
headers=webob_res.headers,
data=webob_res.body)
def stub_out_registry_and_store_server(stubs, base_dir, **kwargs):
"""Mocks calls to 127.0.0.1 on 9191 and 9292 for testing.
def stub_out_store_server(stubs, base_dir, **kwargs):
"""Mocks calls to 127.0.0.1 on 9292 for testing.
Done so that a real Glance server does not need to be up and
running

View File

@ -102,14 +102,6 @@ class TestCacheMiddlewareChecksumVerification(base.IsolatedUnitTest):
self.request = webob.Request.blank('')
self.request.context = self.context
def test_checksum_v1_header(self):
cache_filter = ChecksumTestCacheFilter()
headers = {"x-image-meta-checksum": "1234567890"}
resp = webob.Response(request=self.request, headers=headers)
cache_filter._process_GET_response(resp, None)
self.assertEqual("1234567890", cache_filter.cache.image_checksum)
def test_checksum_v2_header(self):
cache_filter = ChecksumTestCacheFilter()
headers = {
@ -276,15 +268,15 @@ class TestCacheMiddlewareProcessRequest(base.IsolatedUnitTest):
context has not 'download_image' role.
"""
def fake_get_v1_image_metadata(*args, **kwargs):
def fake_get_v2_image_metadata(*args, **kwargs):
return {'status': 'active', 'properties': {}}
image_id = 'test1'
request = webob.Request.blank('/v1/images/%s' % image_id)
request = webob.Request.blank('/v2/images/%s/file' % image_id)
request.context = context.RequestContext()
cache_filter = ProcessRequestTestCacheFilter()
cache_filter._get_v1_image_metadata = fake_get_v1_image_metadata
cache_filter._get_v2_image_metadata = fake_get_v2_image_metadata
enforcer = self._enforcer_from_rules({'download_image': '!'})
cache_filter.policy = enforcer

View File

@ -35,33 +35,6 @@ CONF = cfg.CONF
CONF.import_opt('metadata_encryption_key', 'glance.common.config')
@mock.patch('oslo_utils.importutils.import_module')
class TestDbUtilities(test_utils.BaseTestCase):
def setUp(self):
super(TestDbUtilities, self).setUp()
self.config(data_api='silly pants')
self.api = mock.Mock()
def test_get_api_calls_configure_if_present(self, import_module):
import_module.return_value = self.api
self.assertEqual(glance.db.get_api(), self.api)
import_module.assert_called_once_with('silly pants')
self.api.configure.assert_called_once_with()
def test_get_api_skips_configure_if_missing(self, import_module):
import_module.return_value = self.api
del self.api.configure
self.assertEqual(glance.db.get_api(), self.api)
import_module.assert_called_once_with('silly pants')
self.assertFalse(hasattr(self.api, 'configure'))
def test_get_api_calls_for_v1_api(self, import_module):
api = glance.db.get_api(v1_mode=True)
self.assertNotEqual(api, self.api)
import_module.assert_called_once_with('glance.db.sqlalchemy.api')
api.configure.assert_called_once_with()
UUID1 = 'c80a1a6c-bd1f-41c5-90ee-81afedb1d58d'
UUID2 = 'a85abd86-55b3-4d5b-b0b4-5d0a6e6042fc'
UUID3 = '971ec09a-8067-4bc8-a91f-ae3557f1c4c7'

View File

@ -5,6 +5,7 @@ appdirs==1.4.3
asn1crypto==0.24.0
automaton==1.14.0
Babel==2.3.4
boto3==1.9.199
cachetools==2.0.1
castellan==0.17.0
certifi==2018.1.18

View File

@ -0,0 +1,10 @@
---
deprecations:
- |
This release removes endpoints and config options related
to glance-registry. Including but not limited to config
option 'data-api' which has no production supported
options left. SimpleDB has not been supported since
moving DB migrations to alembic and registry is removed.
All registry specific options and config files have been
removed. 'glance-registry' command has been removed.

View File

@ -25,10 +25,8 @@ data_files =
etc/glance-api.conf
etc/glance-cache.conf
etc/glance-manage.conf
etc/glance-registry.conf
etc/glance-scrubber.conf
etc/glance-api-paste.ini
etc/glance-registry-paste.ini
etc/glance/metadefs = etc/metadefs/*
packages =
glance
@ -42,7 +40,6 @@ console_scripts =
glance-cache-cleaner = glance.cmd.cache_cleaner:main
glance-control = glance.cmd.control:main
glance-manage = glance.cmd.manage:main
glance-registry = glance.cmd.registry:main
glance-replicator = glance.cmd.replicator:main
glance-scrubber = glance.cmd.scrubber:main
glance-status = glance.cmd.status:main
@ -53,7 +50,6 @@ glance.common.image_location_strategy.modules =
store_type_strategy = glance.common.location_strategy.store_type
oslo.config.opts =
glance.api = glance.opts:list_api_opts
glance.registry = glance.opts:list_registry_opts
glance.scrubber = glance.opts:list_scrubber_opts
glance.cache= glance.opts:list_cache_opts
glance.manage = glance.opts:list_manage_opts

View File

@ -22,6 +22,7 @@ oslotest>=3.2.0 # Apache-2.0
stestr>=2.0.0 # Apache-2.0
doc8>=0.6.0 # Apache-2.0
Pygments>=2.2.0 # BSD license
boto3>=1.9.199 # Apache-2.0
# Optional packages that should be installed when testing
PyMySQL>=0.7.6 # MIT License

View File

@ -86,7 +86,6 @@ commands =
[testenv:genconfig]
commands =
oslo-config-generator --config-file etc/oslo-config-generator/glance-api.conf
oslo-config-generator --config-file etc/oslo-config-generator/glance-registry.conf
oslo-config-generator --config-file etc/oslo-config-generator/glance-scrubber.conf
oslo-config-generator --config-file etc/oslo-config-generator/glance-cache.conf
oslo-config-generator --config-file etc/oslo-config-generator/glance-manage.conf