'Creates a new security group.'

@wsgi.Controller.api_version('2.1', MAX_PROXY_API_SUPPORT_VERSION)
@extensions.expected_errors((400, 403))
def create(self, req, body):

    context = _authorize_context(req)
    security_group = self._from_body(body, 'security_group')
    group_name = security_group.get('name', None)
    group_description = security_group.get('description', None)
    try:
        self.security_group_api.validate_property(group_name, 'name', None)
        self.security_group_api.validate_property(group_description, 'description', None)
        group_ref = self.security_group_api.create_security_group(context, group_name, group_description)
    except exception.Invalid as exp:
        raise exc.HTTPBadRequest(explanation=exp.format_message())
    except exception.SecurityGroupLimitExceeded as exp:
        raise exc.HTTPForbidden(explanation=exp.format_message())
    return {'security_group': self._format_security_group(context, group_ref)}
