summaryrefslogtreecommitdiff
path: root/openstackclient/shell.py
diff options
context:
space:
mode:
authorwanghong <w.wanghong@huawei.com>2014-10-20 15:29:53 +0800
committerwanghong <w.wanghong@huawei.com>2014-10-20 15:29:53 +0800
commitf600c0eafbf9aff23b6efa1c7b94797a25873b99 (patch)
treec292a42c22e18ef296b245e31bea00127972fcab /openstackclient/shell.py
parent2166d7d3afbbdc1659e4cffdb7bcd890cd00ec19 (diff)
downloadpython-openstackclient-f600c0eafbf9aff23b6efa1c7b94797a25873b99.tar.gz
only generate one clientmanager instance in interactive mode
Currently, we repeated to generate clientmanager instance when run command in interactive mode. This should be avoided. Change-Id: I0536a690bc173be38af08a2e4443115532041efd Closes-Bug: #1383083
Diffstat (limited to 'openstackclient/shell.py')
-rw-r--r--openstackclient/shell.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/openstackclient/shell.py b/openstackclient/shell.py
index 1f9eb32b..668e48b5 100644
--- a/openstackclient/shell.py
+++ b/openstackclient/shell.py
@@ -68,6 +68,8 @@ class OpenStackShell(app.App):
# Assume TLS host certificate verification is enabled
self.verify = True
+ self.client_manager = None
+
# NOTE(dtroyer): This hack changes the help action that Cliff
# automatically adds to the parser so we can defer
# its execution until after the api-versioned commands
@@ -204,8 +206,12 @@ class OpenStackShell(app.App):
return clientmanager.build_plugin_option_parser(parser)
- def authenticate_user(self):
- """Verify the required authentication credentials are present"""
+ def initialize_clientmanager(self):
+ """Validating authentication options and generate a clientmanager"""
+
+ if self.client_manager:
+ self.log.debug('The clientmanager has been initialized already')
+ return
self.log.debug("validating authentication options")
@@ -370,11 +376,11 @@ class OpenStackShell(app.App):
return
if cmd.best_effort:
try:
- self.authenticate_user()
+ self.initialize_clientmanager()
except Exception:
pass
else:
- self.authenticate_user()
+ self.initialize_clientmanager()
return
def clean_up(self, cmd, result, err):
@@ -409,7 +415,7 @@ class OpenStackShell(app.App):
def interact(self):
# NOTE(dtroyer): Maintain the old behaviour for interactive use as
# this path does not call prepare_to_run_command()
- self.authenticate_user()
+ self.initialize_clientmanager()
super(OpenStackShell, self).interact()