diff --git a/oslo_cache/_opts.py b/oslo_cache/_opts.py index 0787959f..1849b992 100644 --- a/oslo_cache/_opts.py +++ b/oslo_cache/_opts.py @@ -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', diff --git a/oslo_cache/backends/memcache_pool.py b/oslo_cache/backends/memcache_pool.py index cf68a884..0ad36cb5 100644 --- a/oslo_cache/backends/memcache_pool.py +++ b/oslo_cache/backends/memcache_pool.py @@ -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(