示例#1
0
def validate_long_type_length(cls, field_name, value):
    """Makes sure the value does not exceeds the maximum size."""
    if value:
        # Get the configured limit.
        size_limit_kb = cfg.CONF.engine.execution_field_size_limit_kb

        # If the size is unlimited.
        if size_limit_kb < 0:
            return

        size_kb = int(sys.getsizeof(str(value)) / 1024)

        if size_kb > size_limit_kb:
            msg = (
                "Field size limit exceeded"
                " [class={}, field={}, size={}KB, limit={}KB]"
            ).format(
                cls.__name__,
                field_name,
                size_kb,
                size_limit_kb
            )

            LOG.error(msg)

            raise exc.SizeLimitExceededException(msg)
示例#2
0
def validate_long_type_length(cls, field_name, value):
    """Makes sure the value does not exceeds the maximum size."""
    if value:
        # Get the configured limit.
        size_limit_kb = cfg.CONF.engine.execution_field_size_limit_kb

        # If the size is unlimited.
        if (size_limit_kb < 0):
            return

        size_kb = sys.getsizeof(str(value)) / 1024
        if (size_kb > size_limit_kb):
            LOG.error(
                "Size limit %dKB exceed for class [%s], "
                "field %s of size %dKB.", size_limit_kb, str(cls), field_name,
                size_kb)
            raise exc.SizeLimitExceededException(field_name, size_kb,
                                                 size_limit_kb)