@wsgi.Controller.api_version("2.1")
    @extensions.expected_errors((400, 403))
    @validation.schema(schema.create, "2.1", "2.14")
    @validation.schema(schema.create_v215, "2.15")
    def create(self, req, body):
        """Creates a new server group."""
        context = _authorize_context(req)

        quotas = objects.Quotas(context=context)
        try:
            quotas.reserve(project_id=context.project_id,
                           user_id=context.user_id, server_groups=1)
        except nova.exception.OverQuota:
            msg = _("Quota exceeded, too many server groups.")
            raise exc.HTTPForbidden(explanation=msg)

        vals = body['server_group']
        sg = objects.InstanceGroup(context)
        sg.project_id = context.project_id
        sg.user_id = context.user_id
        try:
            sg.name = vals.get('name')
            sg.policies = vals.get('policies')
            sg.create()
        except __HOLE__ as e:
            quotas.rollback()
            raise exc.HTTPBadRequest(explanation=e)

        quotas.commit()
        return {'server_group': self._format_server_group(context, sg, req)}
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/server_groups.py/ServerGroupController.create