From 0719348ba1abd0386fafff882d04720b92ea3631 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Wed, 1 Feb 2017 17:36:13 -0600 Subject: [PATCH] TODO cleanup: osc-lib osc-lib 1.3.0 is released, which contains these functions that still need to be migrated all the way down to os-client-config. Currently osc-lib 1.2.0 is in global-requirements so this can not be merged yet, but is included here for testing and to be ready for when g-r is unfrozen. Change-Id: I7bc8ed6cf78f38bab4a718ed3e2a88641fa23f27 --- openstackclient/common/client_config.py | 68 ------------------------- 1 file changed, 68 deletions(-) diff --git a/openstackclient/common/client_config.py b/openstackclient/common/client_config.py index 5e1395965e..a22dd0cb3c 100644 --- a/openstackclient/common/client_config.py +++ b/openstackclient/common/client_config.py @@ -13,7 +13,6 @@ """OpenStackConfig subclass for argument compatibility""" -from os_client_config import exceptions as occ_exceptions from osc_lib.cli import client_config @@ -70,70 +69,3 @@ class OSC_Config(client_config.OSC_Config): config = self._validate_auth(config, loader) auth_plugin = loader.load_from_options(**config['auth']) return auth_plugin - - # TODO(dtroyer): Remove _validate_auth_ksc when it is in osc-lib 1.3.0 - def _validate_auth_ksc(self, config, cloud, fixed_argparse=None): - """Old compatibility hack for OSC, no longer needed/wanted""" - return config - - # TODO(dtroyer): Remove _validate_auth when it is in osc-lib 1.3.0 - def _validate_auth(self, config, loader, fixed_argparse=None): - """Validate auth plugin arguments""" - # May throw a keystoneauth1.exceptions.NoMatchingPlugin - - plugin_options = loader.get_options() - - msgs = [] - prompt_options = [] - for p_opt in plugin_options: - # if it's in config, win, move it and kill it from config dict - # if it's in config.auth but not in config we're good - # deprecated loses to current - # provided beats default, deprecated or not - winning_value = self._find_winning_auth_value(p_opt, config) - if not winning_value: - winning_value = self._find_winning_auth_value( - p_opt, config['auth']) - - # if the plugin tells us that this value is required - # then error if it's doesn't exist now - if not winning_value and p_opt.required: - msgs.append( - 'Missing value {auth_key}' - ' required for auth plugin {plugin}'.format( - auth_key=p_opt.name, plugin=config.get('auth_type'), - ) - ) - - # Clean up after ourselves - for opt in [p_opt.name] + [o.name for o in p_opt.deprecated]: - opt = opt.replace('-', '_') - config.pop(opt, None) - config['auth'].pop(opt, None) - - if winning_value: - # Prefer the plugin configuration dest value if the value's key - # is marked as depreciated. - if p_opt.dest is None: - config['auth'][p_opt.name.replace('-', '_')] = ( - winning_value) - else: - config['auth'][p_opt.dest] = winning_value - - # See if this needs a prompting - if ( - 'prompt' in vars(p_opt) and - p_opt.prompt is not None and - p_opt.dest not in config['auth'] and - self._pw_callback is not None - ): - # Defer these until we know all required opts are present - prompt_options.append(p_opt) - - if msgs: - raise occ_exceptions.OpenStackConfigException('\n'.join(msgs)) - else: - for p_opt in prompt_options: - config['auth'][p_opt.dest] = self._pw_callback(p_opt.prompt) - - return config