Fix "Message object do not support addition".
In the 7.0.0 Novaclient release we added some warning log about user should using "endpoint_type" rather than "interface" when init novaclient: https://github.com/openstack/python-novaclient/blob/master/novaclient/client.py#L312-L327 https://github.com/openstack/python-novaclient/blob/master/novaclient/client.py#L249-L272 This is now causing a lot jenkins failures acroos projects that is using novaclient with enable_lazy set to False. As in this kind of scenario the warning message is a message object instead of unicode sting and it cannot be added: http://git.openstack.org/cgit/openstack/oslo.i18n/tree/oslo_i18n/_message.py#n227 and "Message object do not support addition" will raise. Related Jenkins Error: Ceilometer: http://logs.openstack.org/29/333129/3/check/gate-ceilometer-python27-ubuntu-xenial/bd125e7/ Closes-bug: #1652414 Change-Id: I11a490f759fdac9707c1321c9659da2605196a94
This commit is contained in:
parent
5e5835de67
commit
aeec4d11b2
@ -253,19 +253,28 @@ def _check_arguments(kwargs, release, deprecated_name, right_name=None):
|
||||
message, renames key to right one it needed.
|
||||
"""
|
||||
if deprecated_name in kwargs:
|
||||
msg = _LW("The '%(old)s' argument is deprecated in %(release)s and "
|
||||
"its use may result in errors in future releases.") % {
|
||||
"old": deprecated_name, "release": release}
|
||||
if right_name:
|
||||
if right_name in kwargs:
|
||||
msg += _LW(" As '%(new)s' is provided, the '%(old)s' argument "
|
||||
"will be ignored.") % {"old": deprecated_name,
|
||||
msg = _LW("The '%(old)s' argument is deprecated in "
|
||||
"%(release)s and its use may result in errors "
|
||||
"in future releases. As '%(new)s' is provided, "
|
||||
"the '%(old)s' argument will be ignored.") % {
|
||||
"old": deprecated_name, "release": release,
|
||||
"new": right_name}
|
||||
kwargs.pop(deprecated_name)
|
||||
else:
|
||||
msg += _LW(" Use '%s' instead.") % right_name
|
||||
msg = _LW("The '%(old)s' argument is deprecated in "
|
||||
"%(release)s and its use may result in errors in "
|
||||
"future releases. Use '%(right)s' instead.") % {
|
||||
"old": deprecated_name, "release": release,
|
||||
"right": right_name}
|
||||
kwargs[right_name] = kwargs.pop(deprecated_name)
|
||||
|
||||
else:
|
||||
msg = _LW("The '%(old)s' argument is deprecated in %(release)s "
|
||||
"and its use may result in errors in future "
|
||||
"releases.") % {
|
||||
"old": deprecated_name, "release": release}
|
||||
# just ignore it
|
||||
kwargs.pop(deprecated_name)
|
||||
|
||||
|
@ -35,17 +35,17 @@ def warn(alternative=True):
|
||||
frm = inspect.stack()[1]
|
||||
module_name = inspect.getmodule(frm[0]).__name__
|
||||
if module_name.startswith("novaclient.v2.contrib."):
|
||||
msg = (_LW("Module `%s` is deprecated as of OpenStack Ocata") %
|
||||
module_name)
|
||||
if alternative:
|
||||
new_module_name = module_name.replace("contrib.", "")
|
||||
msg += _LW(" in favor of `%s`") % new_module_name
|
||||
|
||||
msg += (_LW(" and will be removed after OpenStack Pike."))
|
||||
msg = _LW("Module `%(module)s` is deprecated as of OpenStack "
|
||||
"Ocata in favor of `%(new_module)s` and will be "
|
||||
"removed after OpenStack Pike.") % {
|
||||
"module": module_name, "new_module": new_module_name}
|
||||
|
||||
if not alternative:
|
||||
msg += _LW(" All shell commands were moved to "
|
||||
msg = _LW("Module `%s` is deprecated as of OpenStack Ocata "
|
||||
"All shell commands were moved to "
|
||||
"`novaclient.v2.shell` and will be automatically "
|
||||
"loaded.")
|
||||
"loaded.") % module_name
|
||||
|
||||
warnings.warn(msg)
|
||||
|
Loading…
Reference in New Issue
Block a user