summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Tantsur <dtantsur@protonmail.com>2021-03-17 14:38:46 +0100
committerDmitry Tantsur <dtantsur@protonmail.com>2021-03-25 11:56:19 +0000
commit2e6778fe6d795783fb71a8910c202ca32cd70c39 (patch)
tree74465a6cf7dbe944f677dc3ea44f76cfb45635ec
parent0187ffb581656527e64b838414016e9305735f25 (diff)
downloadpython-ironicclient-stable/victoria.tar.gz
Make baremetal --debug actually workvictoria-em4.4.1stable/victoria
The --debug option exists but does nothing. Wire in openstacksdk logging and make sure ironicclient can log as well. Change-Id: I136503f546be2ecbd3203ee07597df59a40a594e (cherry picked from commit 4a22f29f1e439d20b66a5f20de1d501b11a4d385)
-rw-r--r--ironicclient/shell.py18
-rw-r--r--releasenotes/notes/debug-e9dd680d783fa4b6.yaml5
2 files changed, 23 insertions, 0 deletions
diff --git a/ironicclient/shell.py b/ironicclient/shell.py
index fcb358f..0edc585 100644
--- a/ironicclient/shell.py
+++ b/ironicclient/shell.py
@@ -19,6 +19,7 @@ try:
import ironic_inspector_client
except ImportError:
ironic_inspector_client = None
+import openstack
from openstack import config as os_config
from osc_lib import utils
import pbr.version
@@ -168,8 +169,25 @@ class App(app.App):
)
return parser
+ def _configure_ironic_logging(self):
+ openstack.enable_logging(debug=self.options.debug)
+ # NOTE(dtantsur): I wish logging.basicConfig worked.. but it does not.
+ for name in ('ironicclient', 'ironic_inspector_client'):
+ logger = logging.getLogger(name)
+ logger.setLevel(
+ logging.DEBUG if self.options.debug else logging.WARNING)
+ # warnings are already configured by something else, only configure
+ # debug logging for ironic.
+ if not logger.handlers and self.options.debug:
+ handler = logging.StreamHandler()
+ handler.setFormatter(logging.Formatter(
+ # This is the openstacksdk default value
+ '%(asctime)s %(levelname)s: %(name)s %(message)s'))
+ logger.addHandler(handler)
+
def initialize_app(self, argv):
super(App, self).initialize_app(argv)
+ self._configure_ironic_logging()
self.cloud_region = self.config.get_one(argparse=self.options)
# Compatibility with OSC
self.client_manager = ClientManager(self.cloud_region, self.options)
diff --git a/releasenotes/notes/debug-e9dd680d783fa4b6.yaml b/releasenotes/notes/debug-e9dd680d783fa4b6.yaml
new file mode 100644
index 0000000..9bc8c66
--- /dev/null
+++ b/releasenotes/notes/debug-e9dd680d783fa4b6.yaml
@@ -0,0 +1,5 @@
+---
+fixes:
+ - |
+ The ``--debug`` option now works correctly with the built-in ``baremetal``
+ command line tool.