Displaying curl commands for nova and cinder calls
When using the -v option, displays curl equivalent commands and http messages exchanged with the nova and cinder API servers. Displays the same messages as those displayed with the --debug option of python-novaclient and python-cinderclient. Implements: blueprint curl-commands-in-debugging-messages for nova and cinder related calls Change-Id: Ibc8ef79d874334585b81d652b9c7df9e874fffa9
This commit is contained in:
parent
de27c1b455
commit
a5e087e7a9
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
"""Common client utilities"""
|
"""Common client utilities"""
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import six
|
import six
|
||||||
import sys
|
import sys
|
||||||
@ -215,3 +216,16 @@ def wait_for_status(status_f,
|
|||||||
callback(progress)
|
callback(progress)
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
|
||||||
|
def get_effective_log_level():
|
||||||
|
"""Returns the lowest logging level considered by logging handlers
|
||||||
|
|
||||||
|
Retrieve an return the smallest log level set among the root
|
||||||
|
logger's handlers (in case of multiple handlers).
|
||||||
|
"""
|
||||||
|
root_log = logging.getLogger()
|
||||||
|
min_log_lvl = logging.CRITICAL
|
||||||
|
for handler in root_log.handlers:
|
||||||
|
min_log_lvl = min(min_log_lvl, handler.level)
|
||||||
|
return min_log_lvl
|
||||||
|
@ -35,6 +35,10 @@ def make_client(instance):
|
|||||||
instance._api_version[API_NAME],
|
instance._api_version[API_NAME],
|
||||||
API_VERSIONS)
|
API_VERSIONS)
|
||||||
LOG.debug('instantiating compute client: %s' % compute_client)
|
LOG.debug('instantiating compute client: %s' % compute_client)
|
||||||
|
|
||||||
|
# Set client http_log_debug to True if verbosity level is high enough
|
||||||
|
http_log_debug = utils.get_effective_log_level() <= logging.DEBUG
|
||||||
|
|
||||||
client = compute_client(
|
client = compute_client(
|
||||||
username=instance._username,
|
username=instance._username,
|
||||||
api_key=instance._password,
|
api_key=instance._password,
|
||||||
@ -49,7 +53,8 @@ def make_client(instance):
|
|||||||
extensions=[],
|
extensions=[],
|
||||||
service_type=API_NAME,
|
service_type=API_NAME,
|
||||||
# FIXME(dhellmann): what is service_name?
|
# FIXME(dhellmann): what is service_name?
|
||||||
service_name='')
|
service_name='',
|
||||||
|
http_log_debug=http_log_debug)
|
||||||
|
|
||||||
# Populate the Nova client to skip another auth query to Identity
|
# Populate the Nova client to skip another auth query to Identity
|
||||||
if instance._url:
|
if instance._url:
|
||||||
|
@ -37,6 +37,10 @@ def make_client(instance):
|
|||||||
)
|
)
|
||||||
|
|
||||||
LOG.debug('instantiating volume client')
|
LOG.debug('instantiating volume client')
|
||||||
|
|
||||||
|
# Set client http_log_debug to True if verbosity level is high enough
|
||||||
|
http_log_debug = utils.get_effective_log_level() <= logging.DEBUG
|
||||||
|
|
||||||
client = volume_client(
|
client = volume_client(
|
||||||
username=instance._username,
|
username=instance._username,
|
||||||
api_key=instance._password,
|
api_key=instance._password,
|
||||||
@ -44,6 +48,7 @@ def make_client(instance):
|
|||||||
auth_url=instance._auth_url,
|
auth_url=instance._auth_url,
|
||||||
cacert=instance._cacert,
|
cacert=instance._cacert,
|
||||||
insecure=instance._insecure,
|
insecure=instance._insecure,
|
||||||
|
http_log_debug=http_log_debug
|
||||||
)
|
)
|
||||||
|
|
||||||
return client
|
return client
|
||||||
|
Loading…
x
Reference in New Issue
Block a user