예제 #1
0
    def delete(self, req, id):
        context = _authorize_context(req)

        try:
            id = security_group_api.validate_id(id)
            rule = security_group_api.get_rule(context, id)
            group_id = rule['parent_group_id']
            security_group = security_group_api.get(context, group_id)
            security_group_api.remove_rules(context, security_group,
                                            [rule['id']])
        except exception.SecurityGroupNotFound as exp:
            raise exc.HTTPNotFound(explanation=exp.format_message())
        except exception.NoUniqueMatch as exp:
            raise exc.HTTPConflict(explanation=exp.format_message())
        except exception.Invalid as exp:
            raise exc.HTTPBadRequest(explanation=exp.format_message())
    def delete(self, req, id):
        context = req.environ['nova.context']
        context.can(sg_policies.POLICY_NAME % 'rule:delete',
                    target={'project_id': context.project_id})

        try:
            id = security_group_api.validate_id(id)
            rule = security_group_api.get_rule(context, id)
            group_id = rule['parent_group_id']
            security_group = security_group_api.get(context, group_id)
            security_group_api.remove_rules(context, security_group,
                                            [rule['id']])
        except exception.SecurityGroupNotFound as exp:
            raise exc.HTTPNotFound(explanation=exp.format_message())
        except exception.NoUniqueMatch as exp:
            raise exc.HTTPConflict(explanation=exp.format_message())
        except exception.Invalid as exp:
            raise exc.HTTPBadRequest(explanation=exp.format_message())