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