Move elasticsearch dep to test-requirements.txt
Move experimental feature deps to test-requirements Optional and experimental features should not make glance dependant on the libraries they require. This change moves the python bindings for elasticsearch from the main requirements.txt to test-requirements.txt. semantic_version should potentially also be moved here, but it is currently required to do a db sync and is generally less alarming than an elasticsearch dependency. It is instead moved to the bottom of requirements.txt and marked as being artifacts related. Co-Authored-By: Matt Riedemann <mriedem@us.ibm.com> Change-Id: I7f8dfafdb11dbf7ba258e907fbd17d92319d0f52 Closes-bug: #1441239
This commit is contained in:
parent
6dc5477a12
commit
f53584c268
@ -14,10 +14,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import glance_store
|
||||
from oslo_log import log as logging
|
||||
|
||||
from glance.api import authorization
|
||||
from glance.api import policy
|
||||
from glance.api import property_protections
|
||||
from glance.common import exception
|
||||
from glance.common import property_utils
|
||||
from glance.common import store_utils
|
||||
import glance.db
|
||||
@ -25,7 +27,14 @@ import glance.domain
|
||||
import glance.location
|
||||
import glance.notifier
|
||||
import glance.quota
|
||||
import glance.search
|
||||
try:
|
||||
import glance.search
|
||||
glance_search = glance.search
|
||||
except ImportError:
|
||||
glance_search = None
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Gateway(object):
|
||||
@ -36,7 +45,10 @@ class Gateway(object):
|
||||
self.store_utils = store_utils
|
||||
self.notifier = notifier or glance.notifier.Notifier()
|
||||
self.policy = policy_enforcer or policy.Enforcer()
|
||||
self.es_api = es_api or glance.search.get_api()
|
||||
if es_api:
|
||||
self.es_api = es_api
|
||||
else:
|
||||
self.es_api = glance_search.get_api() if glance_search else None
|
||||
|
||||
def get_image_factory(self, context):
|
||||
image_factory = glance.domain.ImageFactory()
|
||||
@ -235,6 +247,15 @@ class Gateway(object):
|
||||
return authorized_tag_repo
|
||||
|
||||
def get_catalog_search_repo(self, context):
|
||||
if self.es_api is None:
|
||||
# TODO(mriedem): Make this a separate exception or change to
|
||||
# warning/error logging in Liberty once we're past string freeze.
|
||||
# See bug 1441764.
|
||||
LOG.debug('The search and index services are not available. '
|
||||
'Ensure you have the necessary prerequisite '
|
||||
'dependencies installed like elasticsearch to use these '
|
||||
'services.')
|
||||
raise exception.ServiceUnavailable()
|
||||
search_repo = glance.search.CatalogSearchRepo(context, self.es_api)
|
||||
policy_search_repo = policy.CatalogSearchRepoProxy(
|
||||
search_repo, context, self.policy)
|
||||
|
30
glance/tests/unit/test_gateway.py
Normal file
30
glance/tests/unit/test_gateway.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Copyright 2015 IBM Corp.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import mock
|
||||
from oslo_context import context
|
||||
|
||||
from glance.common import exception
|
||||
from glance import gateway
|
||||
from glance.tests import utils as test_utils
|
||||
|
||||
|
||||
class TestGateway(test_utils.BaseTestCase):
|
||||
|
||||
@mock.patch.object(gateway, 'glance_search', None)
|
||||
def test_get_catalog_search_repo_no_es_api(self):
|
||||
gate = gateway.Gateway()
|
||||
self.assertRaises(exception.ServiceUnavailable,
|
||||
gate.get_catalog_search_repo,
|
||||
context.get_admin_context())
|
@ -45,7 +45,6 @@ Paste
|
||||
jsonschema>=2.0.0,<3.0.0
|
||||
python-keystoneclient>=1.1.0
|
||||
pyOpenSSL>=0.11
|
||||
semantic_version>=2.3.1
|
||||
# Required by openstack.common libraries
|
||||
six>=1.9.0
|
||||
|
||||
@ -62,5 +61,5 @@ osprofiler>=0.3.0 # Apache-2.0
|
||||
# Glance Store
|
||||
glance_store>=0.3.0 # Apache-2.0
|
||||
|
||||
# Glance catalog index
|
||||
elasticsearch>=1.3.0
|
||||
# Artifact repository
|
||||
semantic_version>=2.3.1
|
||||
|
@ -29,3 +29,6 @@ xattr>=0.4
|
||||
|
||||
# Documentation
|
||||
oslosphinx>=2.5.0,<2.6.0 # Apache-2.0
|
||||
|
||||
# Glance catalog index
|
||||
elasticsearch>=1.3.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user