Merge "memcache: Remove "default" username and password"

This commit is contained in:
Zuul 2024-02-13 11:27:54 +00:00 committed by Gerrit Code Review
commit 50345eb5b6
2 changed files with 6 additions and 2 deletions

View File

@ -122,10 +122,8 @@ FILE_OPTIONS = {
help='Enable the SASL(Simple Authentication and Security'
'Layer) if the SASL_enable is true, else disable.'),
cfg.StrOpt('memcache_username',
default='',
help='the user name for the memcached which SASL enabled'),
cfg.StrOpt('memcache_password',
default='',
secret=True,
help='the password for the memcached which SASL enabled'),
cfg.BoolOpt('tls_enabled',

View File

@ -27,6 +27,7 @@ except ImportError as e:
else:
raise
from oslo_cache import _memcache_pool
from oslo_cache import exception
# Helper to ease backend refactoring
@ -63,6 +64,11 @@ class PooledMemcachedBackend(memcached_backend.MemcachedBackend):
def __init__(self, arguments):
super(PooledMemcachedBackend, self).__init__(arguments)
if arguments.get('sasl_enabled', False):
if (arguments.get('username') is None or
arguments.get('password') is None):
raise exception.ConfigurationError(
'username and password should be configured to use SASL '
'authentication.')
if not _bmemcache_pool:
raise ImportError("python-binary-memcached package is missing")
self.client_pool = _bmemcache_pool.BMemcacheClientPool(