summaryrefslogtreecommitdiff
path: root/openstackclient/shell.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/shell.py')
-rw-r--r--openstackclient/shell.py42
1 files changed, 32 insertions, 10 deletions
diff --git a/openstackclient/shell.py b/openstackclient/shell.py
index f7704efc..16ba1aab 100644
--- a/openstackclient/shell.py
+++ b/openstackclient/shell.py
@@ -25,6 +25,7 @@ from cliff import app
from cliff import command
from cliff import complete
from cliff import help
+from oslo_utils import strutils
import openstackclient
from openstackclient.common import clientmanager
@@ -79,6 +80,10 @@ class OpenStackShell(app.App):
help.HelpCommand.auth_required = False
complete.CompleteCommand.auth_required = False
+ # Slight change to the meaning of --debug
+ self.DEFAULT_DEBUG_VALUE = None
+ self.DEFAULT_DEBUG_HELP = 'Set debug logging and traceback on errors.'
+
super(OpenStackShell, self).__init__(
description=__doc__.strip(),
version=openstackclient.__version__,
@@ -197,13 +202,17 @@ class OpenStackShell(app.App):
# Parent __init__ parses argv into self.options
super(OpenStackShell, self).initialize_app(argv)
+ self.log.info("START with options: %s",
+ strutils.mask_password(self.command_options))
+ self.log.debug("options: %s",
+ strutils.mask_password(self.options))
# Set the default plugin to token_endpoint if url and token are given
if (self.options.url and self.options.token):
# Use service token authentication
auth_type = 'token_endpoint'
else:
- auth_type = 'osc_password'
+ auth_type = 'password'
project_id = getattr(self.options, 'project_id', None)
project_name = getattr(self.options, 'project_name', None)
@@ -245,10 +254,9 @@ class OpenStackShell(app.App):
self.log_configurator.configure(self.cloud)
self.dump_stack_trace = self.log_configurator.dump_trace
- self.log.info("START with options: %s", self.command_options)
- self.log.debug("options: %s", self.options)
self.log.debug("defaults: %s", cc.defaults)
- self.log.debug("cloud cfg: %s", self.cloud.config)
+ self.log.debug("cloud cfg: %s",
+ strutils.mask_password(self.cloud.config))
# Set up client TLS
# NOTE(dtroyer): --insecure is the non-default condition that
@@ -272,15 +280,29 @@ class OpenStackShell(app.App):
# Loop through extensions to get API versions
for mod in clientmanager.PLUGIN_MODULES:
- version_opt = getattr(self.options, mod.API_VERSION_OPTION, None)
+ default_version = getattr(mod, 'DEFAULT_API_VERSION', None)
+ option = mod.API_VERSION_OPTION.replace('os_', '')
+ version_opt = self.cloud.config.get(option, default_version)
if version_opt:
api = mod.API_NAME
self.api_version[api] = version_opt
- if version_opt not in mod.API_VERSIONS:
- self.log.warning(
- "The %s version <%s> is not in supported versions <%s>"
- % (api, version_opt,
- ', '.join(mod.API_VERSIONS.keys())))
+
+ # Add a plugin interface to let the module validate the version
+ # requested by the user
+ skip_old_check = False
+ mod_check_api_version = getattr(mod, 'check_api_version', None)
+ if mod_check_api_version:
+ # this throws an exception if invalid
+ skip_old_check = mod_check_api_version(version_opt)
+
+ mod_versions = getattr(mod, 'API_VERSIONS', None)
+ if not skip_old_check and mod_versions:
+ if version_opt not in mod_versions:
+ self.log.warning(
+ "%s version %s is not in supported versions %s"
+ % (api, version_opt,
+ ', '.join(mod.API_VERSIONS.keys())))
+
# Command groups deal only with major versions
version = '.v' + version_opt.replace('.', '_').split('_')[0]
cmd_group = 'openstack.' + api.replace('-', '_') + version