diff options
| author | Jenkins <jenkins@review.openstack.org> | 2014-04-17 02:06:11 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2014-04-17 02:06:11 +0000 |
| commit | 3c3f212d8b3646e4cd05c4ac6051636fa3a8a671 (patch) | |
| tree | 259619beba31454b72c94940a13b80c297e6192d /openstackclient | |
| parent | 398dc6c0bdb1ceb3211a748e0c076930fb81a7d1 (diff) | |
| parent | 211cd31d7ac2c7768cc871ac7c9228f7713b8dfc (diff) | |
| download | python-openstackclient-3c3f212d8b3646e4cd05c4ac6051636fa3a8a671.tar.gz | |
Merge "Make bash comple command best effort to authorize"
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/shell.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/openstackclient/shell.py b/openstackclient/shell.py index 49307992..cc4570a1 100644 --- a/openstackclient/shell.py +++ b/openstackclient/shell.py @@ -24,6 +24,7 @@ import traceback from cliff import app from cliff import command +from cliff import complete from cliff import help import openstackclient @@ -64,8 +65,10 @@ class OpenStackShell(app.App): def __init__(self): # Patch command.Command to add a default auth_required = True command.Command.auth_required = True + command.Command.best_effort = False # But not help help.HelpCommand.auth_required = False + complete.CompleteCommand.best_effort = True super(OpenStackShell, self).__init__( description=__doc__.strip(), @@ -465,7 +468,15 @@ class OpenStackShell(app.App): """Set up auth and API versions""" self.log.debug('prepare_to_run_command %s', cmd.__class__.__name__) - if cmd.auth_required: + if not cmd.auth_required: + return + if cmd.best_effort: + try: + self.authenticate_user() + self.restapi.set_auth(self.client_manager.identity.auth_token) + except Exception: + pass + else: self.authenticate_user() self.restapi.set_auth(self.client_manager.identity.auth_token) return |
