Merge "Make baremetal --debug actually work"

This commit is contained in:
Zuul 2021-03-25 04:22:14 +00:00 committed by Gerrit Code Review
commit d8d1269f8f
2 changed files with 23 additions and 0 deletions

View File

@ -19,6 +19,7 @@ try:
import ironic_inspector_client import ironic_inspector_client
except ImportError: except ImportError:
ironic_inspector_client = None ironic_inspector_client = None
import openstack
from openstack import config as os_config from openstack import config as os_config
from osc_lib import utils from osc_lib import utils
import pbr.version import pbr.version
@ -168,8 +169,25 @@ class App(app.App):
) )
return parser 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): def initialize_app(self, argv):
super(App, self).initialize_app(argv) super(App, self).initialize_app(argv)
self._configure_ironic_logging()
self.cloud_region = self.config.get_one(argparse=self.options) self.cloud_region = self.config.get_one(argparse=self.options)
# Compatibility with OSC # Compatibility with OSC
self.client_manager = ClientManager(self.cloud_region, self.options) self.client_manager = ClientManager(self.cloud_region, self.options)

View File

@ -0,0 +1,5 @@
---
fixes:
- |
The ``--debug`` option now works correctly with the built-in ``baremetal``
command line tool.