Skip to content

Commit 3c3f212

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Make bash comple command best effort to authorize"
2 parents 398dc6c + 211cd31 commit 3c3f212

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎openstackclient/shell.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
from cliff import app
2626
from cliff import command
27+
from cliff import complete
2728
from cliff import help
2829

2930
import openstackclient
@@ -64,8 +65,10 @@ class OpenStackShell(app.App):
6465
def __init__(self):
6566
# Patch command.Command to add a default auth_required = True
6667
command.Command.auth_required = True
68+
command.Command.best_effort = False
6769
# But not help
6870
help.HelpCommand.auth_required = False
71+
complete.CompleteCommand.best_effort = True
6972

7073
super(OpenStackShell, self).__init__(
7174
description=__doc__.strip(),
@@ -465,7 +468,15 @@ def prepare_to_run_command(self, cmd):
465468
"""Set up auth and API versions"""
466469
self.log.debug('prepare_to_run_command %s', cmd.__class__.__name__)
467470

468-
if cmd.auth_required:
471+
if not cmd.auth_required:
472+
return
473+
if cmd.best_effort:
474+
try:
475+
self.authenticate_user()
476+
self.restapi.set_auth(self.client_manager.identity.auth_token)
477+
except Exception:
478+
pass
479+
else:
469480
self.authenticate_user()
470481
self.restapi.set_auth(self.client_manager.identity.auth_token)
471482
return

0 commit comments

Comments
 (0)