diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py index 2ed77501..02ea0e04 100644 --- a/glanceclient/common/http.py +++ b/glanceclient/common/http.py @@ -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'): diff --git a/glanceclient/shell.py b/glanceclient/shell.py index cbc61cea..fe7a285c 100644 --- a/glanceclient/shell.py +++ b/glanceclient/shell.py @@ -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))