diff options
| author | Jenkins <jenkins@review.openstack.org> | 2017-01-24 15:35:33 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2017-01-24 15:35:33 +0000 |
| commit | bfad2abf23de1689a28d0377b0498db0feccdf3a (patch) | |
| tree | 7c8e211282ea4758da7358985d2e3c8a434f2898 /openstackclient/common | |
| parent | 1ef0dae8b1347d78cecec8007031679e7315f77b (diff) | |
| parent | 4d9da2c40ae02086258cfde852b297754d8085fa (diff) | |
| download | python-openstackclient-bfad2abf23de1689a28d0377b0498db0feccdf3a.tar.gz | |
Merge "Fix OSC networking commands help errors"
Diffstat (limited to 'openstackclient/common')
| -rw-r--r-- | openstackclient/common/clientmanager.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py index 23c35a3b..3e1a50e3 100644 --- a/openstackclient/common/clientmanager.py +++ b/openstackclient/common/clientmanager.py @@ -59,6 +59,8 @@ class ClientManager(clientmanager.ClientManager): self._interface = self.interface self._cacert = self.cacert self._insecure = not self.verify + # store original auth_type + self._original_auth_type = cli_options.auth_type def setup_auth(self): """Set up authentication""" @@ -73,12 +75,33 @@ class ClientManager(clientmanager.ClientManager): if self._cli_options._openstack_config is not None: self._cli_options._openstack_config._pw_callback = \ shell.prompt_for_password + try: + self._cli_options._auth = \ + self._cli_options._openstack_config.load_auth_plugin( + self._cli_options.config, + ) + except TypeError as e: + self._fallback_load_auth_plugin(e) + + return super(ClientManager, self).setup_auth() + + def _fallback_load_auth_plugin(self, e): + # NOTES(RuiChen): Hack to avoid auth plugins choking on data they don't + # expect, delete fake token and endpoint, then try to + # load auth plugin again with user specified options. + # We know it looks ugly, but it's necessary. + if self._cli_options.config['auth']['token'] == 'x': + # restore original auth_type + self._cli_options.config['auth_type'] = \ + self._original_auth_type + del self._cli_options.config['auth']['token'] + del self._cli_options.config['auth']['endpoint'] self._cli_options._auth = \ self._cli_options._openstack_config.load_auth_plugin( self._cli_options.config, ) - - return super(ClientManager, self).setup_auth() + else: + raise e def is_network_endpoint_enabled(self): """Check if the network endpoint is enabled""" |
