check the security group has been added to the container

Change-Id: I06f60fceb6116d2bb7189426295757b5abe5598c
This commit is contained in:
Feng Shengqin 2018-01-15 17:10:33 +08:00 committed by feng.shengqin
parent 2ed50d1163
commit c0d770a62f

View File

@ -427,6 +427,10 @@ class ContainersController(base.Controller):
context = pecan.request.context context = pecan.request.context
compute_api = pecan.request.compute_api compute_api = pecan.request.compute_api
security_group_id = self._check_security_group(context, security_group) security_group_id = self._check_security_group(context, security_group)
if security_group_id in container.security_groups:
msg = _("Security group %(id)s has been added to container.") % {
'id': security_group_id}
raise exception.InvalidValue(msg)
compute_api.add_security_group(context, container, compute_api.add_security_group(context, container,
security_group_id) security_group_id)
pecan.response.status = 202 pecan.response.status = 202