From f0837dbb272d8c9cb623ad859a8cec4f58203b2c Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sun, 8 Jul 2018 23:32:40 -0400 Subject: [PATCH] Fix exception in log warning when no cloud config exists A recent patch added a more descriptive log message, which is great. Unfortunately, config is not guaranteed in this case to have a cloud key, so just accessing it with config['cloud'] throws an exception, which in turn breaks a test in python-openstackclient. Expand the code a little bit to log the warning differently depending on whether or not cloud exists and has a value. Change-Id: I6b058b3c48a6018b1fe8084344f370530d730d25 --- osc_lib/cli/client_config.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/osc_lib/cli/client_config.py b/osc_lib/cli/client_config.py index 61260fc..cc855f7 100644 --- a/osc_lib/cli/client_config.py +++ b/osc_lib/cli/client_config.py @@ -94,9 +94,15 @@ class OSC_Config(config.OpenStackConfig): ] for prop in domain_props: if config['auth'].pop(prop, None) is not None: - LOG.warning("Ignoring domain related config %s for %s" - "because identity API version is 2.0" % - (prop, config['cloud'])) + if config.get('cloud'): + LOG.warning( + "Ignoring domain related config %s for %s" + "because identity API version is 2.0" % ( + prop, config['cloud'])) + else: + LOG.warning( + "Ignoring domain related config %s because" + " identity API version is 2.0" % prop) return config def _auth_default_domain(self, config):