Fix --debug CLI option

The --debug argument has been ignored since httplib2 was replaced
with httplib. This re-enables the --debug flag as an equivalent
to the env var GLANCECLIENT_DEBUG.

Fixes bug 1030700

Change-Id: Ib653049eea2f18c4cc2f8f8aac7884245afd0f04
This commit is contained in:
Brian Waldon 2012-07-29 21:08:26 -07:00
parent 1e744f162e
commit 158f7ccd74
2 changed files with 7 additions and 10 deletions
glanceclient

@ -5,7 +5,6 @@ OpenStack Client interface. Handles the REST calls and responses.
import copy
import httplib
import logging
import os
import urlparse
@ -48,13 +47,6 @@ class HTTPClient(object):
return self.connection_class(*self.endpoint)
def http_log(self, args, kwargs, resp):
if os.environ.get('GLANCECLIENT_DEBUG', False):
ch = logging.StreamHandler()
logger.setLevel(logging.DEBUG)
logger.addHandler(ch)
elif not logger.isEnabledFor(logging.DEBUG):
return
string_parts = ['curl -i']
for element in args:
if element in ('GET', 'POST'):

@ -18,6 +18,7 @@ Command-line interface to the OpenStack Images API.
"""
import argparse
import logging
import re
import sys
@ -47,9 +48,9 @@ class OpenStackImagesShell(object):
)
parser.add_argument('--debug',
default=False,
default=bool(utils.env('GLANCECLIENT_DEBUG')),
action='store_true',
help=argparse.SUPPRESS)
help='Defaults to env[GLANCECLIENT_DEBUG]')
parser.add_argument('--insecure',
default=False,
@ -238,6 +239,10 @@ class OpenStackImagesShell(object):
self.do_help(args)
return 0
LOG = logging.getLogger('glanceclient')
LOG.addHandler(logging.StreamHandler())
LOG.setLevel(logging.DEBUG if args.debug else logging.INFO)
auth_reqd = (utils.is_authentication_required(args.func) and
not (args.os_auth_token and args.os_image_url))