diff --git a/keystoneclient/shell.py b/keystoneclient/shell.py index 88d8317e2..62b7c68b2 100644 --- a/keystoneclient/shell.py +++ b/keystoneclient/shell.py @@ -26,6 +26,7 @@ from __future__ import print_function import argparse import getpass +import logging import os import six import sys @@ -379,6 +380,9 @@ class OpenStackIdentityShell(object): self.do_bash_completion(args) return 0 + if args.debug: + logging.basicConfig(level=logging.DEBUG) + # TODO(heckj): supporting backwards compatibility with environment # variables. To be removed after DEVSTACK is updated, ideally in # the Grizzly release cycle. diff --git a/keystoneclient/tests/test_shell.py b/keystoneclient/tests/test_shell.py index 93935ed20..2a80c9db0 100644 --- a/keystoneclient/tests/test_shell.py +++ b/keystoneclient/tests/test_shell.py @@ -14,6 +14,7 @@ import argparse import json +import logging import os import sys import uuid @@ -117,6 +118,15 @@ class ShellTest(utils.TestCase): exceptions.CommandError, 'Expecting'): self.shell('user-list') + def test_debug(self): + logging_mock = mock.MagicMock() + with mock.patch('logging.basicConfig', logging_mock): + self.assertRaises(exceptions.CommandError, + self.shell, '--debug user-list') + self.assertTrue(logging_mock.called) + self.assertEqual([(), {'level': logging.DEBUG}], + list(logging_mock.call_args)) + def test_auth_password_authurl_no_username(self): with testtools.ExpectedException( exceptions.CommandError,