diff --git a/zun/api/controllers/v1/containers.py b/zun/api/controllers/v1/containers.py index 344b46aa8..51ca5de46 100644 --- a/zun/api/controllers/v1/containers.py +++ b/zun/api/controllers/v1/containers.py @@ -195,9 +195,8 @@ class ContainersController(base.Controller): container_dict['interactive'] = strutils.bool_from_string( container_dict.get('interactive', False), strict=True) except ValueError: - msg = _('Valid run or interactive value is ''true'', ' - '"false", True, False, "True" and "False"') - raise exception.InvalidValue(msg) + raise exception.InvalidValue(_('Valid run or interactive values ' + 'are: true, false, True, False')) auto_remove = container_dict.pop('auto_remove', None) if auto_remove is not None: @@ -208,8 +207,8 @@ class ContainersController(base.Controller): container_dict['auto_remove'] = strutils.bool_from_string( auto_remove, strict=True) except ValueError: - msg = _('Auto_remove value are true or false') - raise exception.InvalidValue(msg) + raise exception.InvalidValue(_('Auto_remove values are: ' + 'true, false, True, False')) else: raise exception.InvalidParamInVersion(param='auto_remove', req_version=req_version, @@ -494,14 +493,16 @@ class ContainersController(base.Controller): try: force = strutils.bool_from_string(force, strict=True) except ValueError: - msg = _('Valid force values are true, false, 0, 1, yes and no') - raise exception.InvalidValue(msg) + bools = ', '.join(strutils.TRUE_STRINGS + strutils.FALSE_STRINGS) + raise exception.InvalidValue(_('Valid force values are: %s') + % bools) stop = kwargs.pop('stop', False) try: stop = strutils.bool_from_string(stop, strict=True) except ValueError: - msg = _('Valid stop values are true, false, 0, 1, yes and no') - raise exception.InvalidValue(msg) + bools = ', '.join(strutils.TRUE_STRINGS + strutils.FALSE_STRINGS) + raise exception.InvalidValue(_('Valid stop values are: %s') + % bools) compute_api = pecan.request.compute_api if not force and not stop: utils.validate_container_state(container, 'delete') @@ -648,9 +649,10 @@ class ContainersController(base.Controller): stderr = strutils.bool_from_string(stderr, strict=True) timestamps = strutils.bool_from_string(timestamps, strict=True) except ValueError: - msg = _('Valid stdout, stderr and timestamps values are ''true'', ' - '"false", True, False, 0 and 1, yes and no') - raise exception.InvalidValue(msg) + bools = ', '.join(strutils.TRUE_STRINGS + strutils.FALSE_STRINGS) + raise exception.InvalidValue(_('Valid stdout, stderr and ' + 'timestamps values are: %s') + % bools) LOG.debug('Calling compute.container_logs with %s', container.uuid) context = pecan.request.context compute_api = pecan.request.compute_api @@ -676,8 +678,9 @@ class ContainersController(base.Controller): run = strutils.bool_from_string(run, strict=True) interactive = strutils.bool_from_string(interactive, strict=True) except ValueError: - msg = _('Valid run values are true, false, 0, 1, yes and no') - raise exception.InvalidValue(msg) + bools = ', '.join(strutils.TRUE_STRINGS + strutils.FALSE_STRINGS) + raise exception.InvalidValue(_('Valid run or interactive ' + 'values are: %s') % bools) LOG.debug('Calling compute.container_exec with %(uuid)s command ' '%(command)s', {'uuid': container.uuid, 'command': kwargs['command']}) diff --git a/zun/api/controllers/v1/images.py b/zun/api/controllers/v1/images.py index d9f613850..09b3bc486 100644 --- a/zun/api/controllers/v1/images.py +++ b/zun/api/controllers/v1/images.py @@ -145,9 +145,9 @@ class ImagesController(base.Controller): try: exact_match = strutils.bool_from_string(exact_match, strict=True) except ValueError: - msg = _("Valid exact_match values are true," - " false, 0, 1, yes and no") - raise exception.InvalidValue(msg) + bools = ', '.join(strutils.TRUE_STRINGS + strutils.FALSE_STRINGS) + raise exception.InvalidValue(_('Valid exact_match values are: %s') + % bools) # Valiadtion accepts 'None' so need to convert it to None if image_driver: image_driver = api_utils.string_or_none(image_driver)