Convert parameter stop to boolean
This patch converts parameter stop to boolean. Change-Id: I7e9c6f0ebc7a94ddc10332295849b51348d868ed Closes-Bug: #1732055
This commit is contained in:
parent
f480a90e4e
commit
d37d7f7e7f
@ -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,19 +581,18 @@ 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,
|
'delete_after_stop')
|
||||||
'delete_after_stop')
|
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)
|
|
||||||
else:
|
else:
|
||||||
raise exception.InvalidParamInVersion(param='stop',
|
raise exception.InvalidParamInVersion(param='stop',
|
||||||
req_version=req_version,
|
req_version=req_version,
|
||||||
|
Loading…
Reference in New Issue
Block a user