Optimize error log for bool_from_string
Change-Id: I4cc8ec79bde26b941074153cdf74471fd1c70ad8
This commit is contained in:
parent
51aeb8d447
commit
e5f911c0ef
|
@ -325,8 +325,9 @@ class ContainersController(base.Controller):
|
||||||
container_dict['interactive'] = strutils.bool_from_string(
|
container_dict['interactive'] = strutils.bool_from_string(
|
||||||
container_dict.get('interactive', False), strict=True)
|
container_dict.get('interactive', False), strict=True)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise exception.InvalidValue(_('Valid run or interactive values '
|
bools = ', '.join(strutils.TRUE_STRINGS + strutils.FALSE_STRINGS)
|
||||||
'are: true, false, True, False'))
|
raise exception.InvalidValue(_('Valid run or interactive '
|
||||||
|
'values are: %s') % bools)
|
||||||
|
|
||||||
auto_remove = container_dict.pop('auto_remove', None)
|
auto_remove = container_dict.pop('auto_remove', None)
|
||||||
if auto_remove is not None:
|
if auto_remove is not None:
|
||||||
|
@ -335,8 +336,10 @@ class ContainersController(base.Controller):
|
||||||
container_dict['auto_remove'] = strutils.bool_from_string(
|
container_dict['auto_remove'] = strutils.bool_from_string(
|
||||||
auto_remove, strict=True)
|
auto_remove, strict=True)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise exception.InvalidValue(_('Auto_remove values are: '
|
bools = ', '.join(strutils.TRUE_STRINGS +
|
||||||
'true, false, True, False'))
|
strutils.FALSE_STRINGS)
|
||||||
|
raise exception.InvalidValue(_('Valid auto_remove '
|
||||||
|
'values are: %s') % bools)
|
||||||
|
|
||||||
runtime = container_dict.pop('runtime', None)
|
runtime = container_dict.pop('runtime', None)
|
||||||
if runtime is not None:
|
if runtime is not None:
|
||||||
|
@ -376,8 +379,10 @@ class ContainersController(base.Controller):
|
||||||
container_dict['privileged'] = strutils.bool_from_string(
|
container_dict['privileged'] = strutils.bool_from_string(
|
||||||
privileged, strict=True)
|
privileged, strict=True)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise exception.InvalidValue(_('privileged values are: '
|
bools = ', '.join(strutils.TRUE_STRINGS +
|
||||||
'true, false, True, False'))
|
strutils.FALSE_STRINGS)
|
||||||
|
raise exception.InvalidValue(_('Valid privileged values '
|
||||||
|
'are: %s') % bools)
|
||||||
|
|
||||||
# Valiadtion accepts 'None' so need to convert it to None
|
# Valiadtion accepts 'None' so need to convert it to None
|
||||||
if container_dict.get('image_driver'):
|
if container_dict.get('image_driver'):
|
||||||
|
@ -713,8 +718,7 @@ class ContainersController(base.Controller):
|
||||||
'delete_after_stop')
|
'delete_after_stop')
|
||||||
if container.status == consts.RUNNING:
|
if container.status == consts.RUNNING:
|
||||||
LOG.debug('Calling compute.container_stop with %s '
|
LOG.debug('Calling compute.container_stop with %s '
|
||||||
'before delete',
|
'before delete', container.uuid)
|
||||||
container.uuid)
|
|
||||||
compute_api.container_stop(context, container, 10)
|
compute_api.container_stop(context, container, 10)
|
||||||
container.status = consts.DELETING
|
container.status = consts.DELETING
|
||||||
if container.host:
|
if container.host:
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
import pecan
|
import pecan
|
||||||
import six
|
|
||||||
|
|
||||||
from zun.api.controllers import base
|
from zun.api.controllers import base
|
||||||
from zun.api.controllers.v1 import collection
|
from zun.api.controllers.v1 import collection
|
||||||
|
@ -111,8 +110,10 @@ class ZunServiceController(base.Controller):
|
||||||
"""Set or unset forced_down flag for the service"""
|
"""Set or unset forced_down flag for the service"""
|
||||||
try:
|
try:
|
||||||
forced_down = strutils.bool_from_string(body['forced_down'], True)
|
forced_down = strutils.bool_from_string(body['forced_down'], True)
|
||||||
except ValueError as err:
|
except ValueError:
|
||||||
raise exception.InvalidValue(six.text_type(err))
|
bools = ', '.join(strutils.TRUE_STRINGS + strutils.FALSE_STRINGS)
|
||||||
|
raise exception.InvalidValue(_('Valid forced_down values are: %s')
|
||||||
|
% bools)
|
||||||
self._update(context, body['host'], body['binary'],
|
self._update(context, body['host'], body['binary'],
|
||||||
{"forced_down": forced_down})
|
{"forced_down": forced_down})
|
||||||
res = {
|
res = {
|
||||||
|
|
|
@ -439,8 +439,10 @@ def is_all_projects(search_opts):
|
||||||
if all_projects:
|
if all_projects:
|
||||||
try:
|
try:
|
||||||
all_projects = strutils.bool_from_string(all_projects, True)
|
all_projects = strutils.bool_from_string(all_projects, True)
|
||||||
except ValueError as err:
|
except ValueError:
|
||||||
raise exception.InvalidValue(six.text_type(err))
|
bools = ', '.join(strutils.TRUE_STRINGS + strutils.FALSE_STRINGS)
|
||||||
|
raise exception.InvalidValue(_('Valid all_projects values are: %s')
|
||||||
|
% bools)
|
||||||
else:
|
else:
|
||||||
all_projects = False
|
all_projects = False
|
||||||
return all_projects
|
return all_projects
|
||||||
|
|
Loading…
Reference in New Issue