Convert parameter stop to boolean

This patch converts parameter stop to boolean.

Change-Id: I7e9c6f0ebc7a94ddc10332295849b51348d868ed
Closes-Bug: #1732055
This commit is contained in:
miaohb 2017-11-13 18:02:34 -08:00
parent f480a90e4e
commit d37d7f7e7f

View File

@ -560,11 +560,16 @@ class ContainersController(base.Controller):
except ValueError: except ValueError:
msg = _('Valid force values are true, false, 0, 1, yes and no') msg = _('Valid force values are true, false, 0, 1, yes and no')
raise exception.InvalidValue(msg) raise exception.InvalidValue(msg)
stop = kwargs.pop('stop', None) 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)
compute_api = pecan.request.compute_api compute_api = pecan.request.compute_api
if not force and stop is None: if not force and not stop:
utils.validate_container_state(container, 'delete') utils.validate_container_state(container, 'delete')
elif force and stop is None: elif force and not stop:
req_version = pecan.request.version req_version = pecan.request.version
min_version = versions.Version('', '', '', '1.7') min_version = versions.Version('', '', '', '1.7')
if req_version >= min_version: if req_version >= min_version:
@ -576,11 +581,10 @@ class ContainersController(base.Controller):
# raise exception.InvalidParamInVersion(param='force', # raise exception.InvalidParamInVersion(param='force',
# req_version=req_version, # req_version=req_version,
# min_version=min_version) # min_version=min_version)
elif stop is not None: elif stop:
req_version = pecan.request.version req_version = pecan.request.version
min_version = versions.Version('', '', '', '1.12') min_version = versions.Version('', '', '', '1.12')
if req_version >= min_version: if req_version >= min_version:
if stop:
check_policy_on_container(container.as_dict(), check_policy_on_container(container.as_dict(),
"container:stop") "container:stop")
utils.validate_container_state(container, utils.validate_container_state(container,