Finish removing legacy credentials
Change I8c24cd17f643083dde71ab2bd2a38417c54aeccb removed deprecated legacy configured credentials, but a couple of dependencies were overlooked. Removing them to complete the clean-up. Note that this breaks stress for tests not marked as 'use_admin', but since the stress test is going be depreacted, this should be acceptable. Change-Id: Ie814de56d588e438c375ee87e8b5994c6c364c19
This commit is contained in:
parent
b02fa114b8
commit
bc0a7a6d80
@ -73,8 +73,8 @@ def get_credentials_provider(name, network_resources=None,
|
||||
# the test should be skipped else it would fail.
|
||||
identity_version = identity_version or CONF.identity.auth_version
|
||||
if CONF.auth.use_dynamic_credentials or force_tenant_isolation:
|
||||
admin_creds = get_configured_credentials(
|
||||
'identity_admin', fill_in=True, identity_version=identity_version)
|
||||
admin_creds = get_configured_admin_credentials(
|
||||
fill_in=True, identity_version=identity_version)
|
||||
return dynamic_creds.DynamicCredentialProvider(
|
||||
name=name,
|
||||
network_resources=network_resources,
|
||||
@ -111,7 +111,7 @@ def is_admin_available(identity_version):
|
||||
is_admin = False
|
||||
else:
|
||||
try:
|
||||
get_configured_credentials('identity_admin', fill_in=False,
|
||||
get_configured_admin_credentials(fill_in=False,
|
||||
identity_version=identity_version)
|
||||
except exceptions.InvalidConfiguration:
|
||||
is_admin = False
|
||||
@ -163,39 +163,32 @@ DEFAULT_PARAMS = {
|
||||
|
||||
# Read credentials from configuration, builds a Credentials object
|
||||
# based on the specified or configured version
|
||||
def get_configured_credentials(credential_type, fill_in=True,
|
||||
identity_version=None):
|
||||
def get_configured_admin_credentials(fill_in=True, identity_version=None):
|
||||
identity_version = identity_version or CONF.identity.auth_version
|
||||
|
||||
if identity_version not in ('v2', 'v3'):
|
||||
raise exceptions.InvalidConfiguration(
|
||||
'Unsupported auth version: %s' % identity_version)
|
||||
|
||||
if credential_type not in CREDENTIAL_TYPES:
|
||||
raise exceptions.InvalidCredentials()
|
||||
conf_attributes = ['username', 'password', 'project_name']
|
||||
conf_attributes = ['username', 'password',
|
||||
'project_name']
|
||||
|
||||
if identity_version == 'v3':
|
||||
conf_attributes.append('domain_name')
|
||||
# Read the parts of credentials from config
|
||||
params = DEFAULT_PARAMS.copy()
|
||||
section, prefix = CREDENTIAL_TYPES[credential_type]
|
||||
for attr in conf_attributes:
|
||||
_section = getattr(CONF, section)
|
||||
if prefix is None:
|
||||
params[attr] = getattr(_section, attr)
|
||||
else:
|
||||
params[attr] = getattr(_section, prefix + "_" + attr)
|
||||
params[attr] = getattr(CONF.auth, 'admin_' + attr)
|
||||
# Build and validate credentials. We are reading configured credentials,
|
||||
# so validate them even if fill_in is False
|
||||
credentials = get_credentials(fill_in=fill_in,
|
||||
identity_version=identity_version, **params)
|
||||
if not fill_in:
|
||||
if not credentials.is_valid():
|
||||
msg = ("The %s credentials are incorrectly set in the config file."
|
||||
" Double check that all required values are assigned" %
|
||||
credential_type)
|
||||
raise exceptions.InvalidConfiguration(msg)
|
||||
msg = ("The admin credentials are incorrectly set in the config "
|
||||
"file for identity version %s. Double check that all "
|
||||
"required values are assigned.")
|
||||
raise exceptions.InvalidConfiguration(msg % identity_version)
|
||||
return credentials
|
||||
|
||||
|
||||
@ -223,19 +216,10 @@ def get_credentials(fill_in=True, identity_version=None, **kwargs):
|
||||
# === Credential / client managers
|
||||
|
||||
|
||||
class ConfiguredUserManager(clients.Manager):
|
||||
"""Manager that uses user credentials for its managed client objects"""
|
||||
|
||||
def __init__(self, service=None):
|
||||
super(ConfiguredUserManager, self).__init__(
|
||||
credentials=get_configured_credentials('user'),
|
||||
service=service)
|
||||
|
||||
|
||||
class AdminManager(clients.Manager):
|
||||
"""Manager that uses admin credentials for its managed client objects"""
|
||||
|
||||
def __init__(self, service=None):
|
||||
super(AdminManager, self).__init__(
|
||||
credentials=get_configured_credentials('identity_admin'),
|
||||
credentials=get_configured_admin_credentials(),
|
||||
service=service)
|
||||
|
@ -135,10 +135,13 @@ def stress_openstack(tests, duration, max_runs=None, stop_on_error=False):
|
||||
break
|
||||
if skip:
|
||||
break
|
||||
# TODO(andreaf) This has to be reworked to use the credential
|
||||
# provider interface. For now only tests marked as 'use_admin' will
|
||||
# work.
|
||||
if test.get('use_admin', False):
|
||||
manager = admin_manager
|
||||
else:
|
||||
manager = credentials.ConfiguredUserManager()
|
||||
raise NotImplemented('Non admin tests are not supported')
|
||||
for p_number in moves.xrange(test.get('threads', default_thread_num)):
|
||||
if test.get('use_isolated_tenants', False):
|
||||
username = data_utils.rand_name("stress_user")
|
||||
|
Loading…
Reference in New Issue
Block a user