summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYong Sheng Gong <gongysh@cn.ibm.com>2012-05-11 10:18:01 +0800
committerYong Sheng Gong <gongysh@cn.ibm.com>2012-05-23 07:00:53 +0800
commitbc2d6a66f0fbcb23b2e9782352b9477a85950ef2 (patch)
tree322b48952b6d627c54f58457c8ded20908d840e3
parent1fb4540bfa8abb8fbba710c5037ec31a35884d9f (diff)
downloadpython-neutronclient-folsom-1.tar.gz
Use --debug to enable printing HTTP message(s) between client andfolsom-1
server, besides logging verbosely. fix Bug #993859 change --verbose into --debug, which is a practice by other clients (nova and glance). note: httplib prints message by print. Patch 2: fix pep8, modify according to some comments Change-Id: Ibc959cca7d89c18b6d5c902f2e98bb856102c51c
-rw-r--r--quantumclient/__init__.py7
-rwxr-xr-xquantumclient/cli.py13
2 files changed, 14 insertions, 6 deletions
diff --git a/quantumclient/__init__.py b/quantumclient/__init__.py
index 056e0dc..461f9b8 100644
--- a/quantumclient/__init__.py
+++ b/quantumclient/__init__.py
@@ -216,6 +216,8 @@ class Client(object):
self.key_file = key_file
self.cert_file = cert_file
self.logger = logger
+ if not self.logger:
+ self.logger = LOG
self.auth_token = auth_token
self.version = version
self.action_prefix = "/v%s%s" % (version, uri_prefix)
@@ -301,6 +303,11 @@ class Client(object):
conn = connection_type(self.host, self.port, **certs)
else:
conn = connection_type(self.host, self.port)
+ # besides HTTP(s)Connection, we still have testConnection
+ if (LOG.isEnabledFor(logging.DEBUG) and
+ isinstance(conn, httplib.HTTPConnection)):
+ conn.set_debuglevel(1)
+
res = self._send_request(conn, method, action, body, headers)
status_code = self.get_status_code(res)
data = res.read()
diff --git a/quantumclient/cli.py b/quantumclient/cli.py
index a1a5b1d..1636639 100755
--- a/quantumclient/cli.py
+++ b/quantumclient/cli.py
@@ -31,9 +31,10 @@ from quantumclient.common import exceptions
from quantumclient.common import utils
-#Configure logger for client - cli logger is a child of it
-#NOTE(salvatore-orlando): logger name does not map to package
-#this is deliberate. Simplifies logger configuration
+# Configure logger for client - cli logger is a child of it
+# NOTE(salvatore-orlando): logger name does not map to package
+# this is deliberate. Simplifies logger configuration
+logging.basicConfig()
LOG = logging.getLogger('quantumclient')
@@ -251,9 +252,9 @@ def main():
type="int", default=9696, help="api poort")
parser.add_option("-s", "--ssl", dest="ssl",
action="store_true", default=False, help="use ssl")
- parser.add_option("-v", "--verbose", dest="verbose",
+ parser.add_option("--debug", dest="debug",
action="store_true", default=False,
- help="turn on verbose logging")
+ help="print debugging output")
parser.add_option("-f", "--logfile", dest="logfile",
type="string", default="syslog", help="log file path")
parser.add_option("-t", "--token", dest="token",
@@ -264,7 +265,7 @@ def main():
help='Accepts 1.1 and 1.0, defaults to env[QUANTUM_VERSION].')
options, args = parser.parse_args()
- if options.verbose:
+ if options.debug:
LOG.setLevel(logging.DEBUG)
else:
LOG.setLevel(logging.WARN)