'Create a new group.'

@wsgi.Controller.api_version(GROUP_API_VERSION)
@wsgi.response(http_client.ACCEPTED)
def create(self, req, body):

    LOG.debug('Creating    new    group    %s', body)
    self.assert_valid_body(body, 'group')
    context = req.environ['cinder.context']
    group = body['group']
    self.validate_name_and_description(group)
    name = group.get('name')
    description = group.get('description')
    group_type = group.get('group_type')
    if (not group_type):
        msg = (_('group_type    must    be    provided    to    create    group    %(name)s.') % {'name': name})
        raise exc.HTTPBadRequest(explanation=msg)
    if (not uuidutils.is_uuid_like(group_type)):
        req_group_type = group_types.get_group_type_by_name(context, group_type)
        group_type = req_group_type['id']
    self._check_default_cgsnapshot_type(group_type)
    volume_types = group.get('volume_types')
    if (not volume_types):
        msg = (_('volume_types    must    be    provided    to    create    group    %(name)s.') % {'name': name})
        raise exc.HTTPBadRequest(explanation=msg)
    availability_zone = group.get('availability_zone')
    LOG.info('Creating    group    %(name)s.', {'name': name}, context=context)
    try:
        new_group = self.group_api.create(context, name, description, group_type, volume_types, availability_zone=availability_zone)
    except (exception.Invalid, exception.ObjectActionError) as error:
        raise exc.HTTPBadRequest(explanation=error.msg)
    except exception.NotFound:
        raise
    retval = self._view_builder.summary(req, new_group)
    return retval
