Sindbad~EG File Manager

Current Path : /lib/python3.6/site-packages/vdo/vdomgmnt/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/vdo/vdomgmnt/__pycache__/Defaults.cpython-36.pyc

3

x?ag�E�@s�dZddlmZddlmZddlmZddlmZddlmZmZm	Z	m
Z
ddlZddlZddl
Z
ddlZGd	d
�d
e
e�ZGdd�de�ZdS)
zx
  Defaults - manage Albireo/VDO defaults

  $Id: //eng/vdo-releases/aluminum/src/python/vdo/vdomgmnt/Defaults.py#11 $

�)�absolute_import)�division)�print_function)�unicode_literals�)�	Constants�
MgmntUtils�
SizeString�UserExitStatusNcs(eZdZdZ�fdd�Zdd�Z�ZS)�
ArgumentErrorz7Exception raised to indicate an error with an argument.cstt|�j||�||_dS)N)�superr�__init__�_msg)�self�msg�args�kwargs)�	__class__��/usr/lib/python3.6/Defaults.pyr
*szArgumentError.__init__cCs|jS)N)r)rrrr�__str__/szArgumentError.__str__)�__name__�
__module__�__qualname__�__doc__r
r�
__classcell__rr)rrr$src@s`eZdZdZdWZdZdZdZej	Z
dZdZdZ
dZdZdZdZed	�Zed
�Zed	�ZdejZdZdZdZdZejd
d�dZejdd�Z ej	Z!ej	Z"dZ#dZ$dZ%ej&Z'dZ(dZ)dZ*dZ+dZ,dZ-ed�Z.dZ/dZ0dZ1dZ2ed�Z3ed�Z4ed�Z5dZ6dZ7dZ8dZ9dZ:ed�Z;ed�Z<ed	�Z=ej&Z>dZ?dZ@dZAdZBd d!d"d#dd$gZCd%ZDd&ZEd'd(d)d&gZFeGd*d+��ZHeGd,d-��ZIeGd.d/��ZJeGd0d1��ZKeGd2d3��ZLeGd4d5��ZMeGd6d7��ZNeGd8d9��ZOeGd:d;��ZPeGd<d=��ZQeGd>d?��ZReGd@dA��ZSeGdBdC��ZTeGdDdE��ZUeGdFdG��ZVeGdHdI��ZWeGdJdK��ZXeGdLdM��ZYeGdNdO��ZZdPdQ�Z[eGdRdS��Z\eGdTdU��Z]dVS)X�Defaultsz.Defaults manages default values for arguments.r�dr�@i��Z128MZ16T�i�?ZVDO_CONF_DIRz/etcz/vdoconf.ymlZVDO_CONVERSION_UTILITY_DIRz/usr/libexec�g�?Z4096T�	�<Z4KZ4GZon�
Z2GZ32G�i�infoZcritical�errorZwarningZnotice�debugZvdo�auto�asynczasync-unsafe�synccCs tjj|�r|Sttd���dS)z�Checks that an option is an absolute pathname.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The pathname as a string.
    Raises:
      ArgumentError
    zmust be an absolute pathnameN)�os�path�isabsr�_)�valuerrr�checkAbspathvszDefaults.checkAbspathcCs
tj|�S)z�Checks that an option is a valid name for the backing store.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The backing store name as a string.
    Raises:
      ArgumentError
    )rr2)r1rrr�checkBlkDev�szDefaults.checkBlkDevcCstjtjtj|�S)a)Checks that an option is an acceptable value for the block map period.
    The number must be at least 1 and no bigger than 16380.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value converted to an int.
    Raises:
      ArgumentError
    )r�_rangeCheck�blockMapPeriodMin�blockMapPeriodMax)r1rrr�checkBlockMapPeriod�szDefaults.checkBlockMapPeriodcCs$|dk	r tjj|�r tj|�S|S)a@Checks that an option specifies a possible config file path name.

    Currently the only restriction is that the if the path already
    exists, it must be a regular file.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value.
    Raises:
      ArgumentError

    N)r-r.�isfiler�_checkNotBlockFileOrDirectory)r1rrr�
checkConfFile�s
zDefaults.checkConfFilecCs�|jdd�}yH|dks&|dks&|dkr*|St|�}tj|koHtjknrR|SWntk
rhYnXttd�jtjtj���dS)aYChecks that an option is a legitimate index memory setting.

    To handle non-US locales while still supporting the documented
    behavior, we allow either a period or a comma as the decimal
    separator. This will be normalized to the decimal-point
    representation; internally indexMem is always either the string
    representation of an integer or one of the exact strings '0.25',
    '0.5', or '0.75' regardless of locale.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The memory setting as a string.
    Raises:
      ArgumentError

    �,�.z0.25z0.5z0.75zpmust be an integer at least {0} and less than or equal to {1} or one of the special values of 0.25, 0.5, or 0.75N)	�replace�intr�indexMemIntMin�indexMemIntMax�
ValueErrorrr0�format)r1�numberrrr�
checkIndexmem�szDefaults.checkIndexmemcCs
tj|�S)a`Checks that an option specifies a possible log file path name.

    Currently the only restriction is that the path name may not refer
    to an existing block device node or directory in the file system.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value.
    Raises:
      ArgumentError

    )rr9)r1rrr�checkLogFile�szDefaults.checkLogFilecCs,tj|�}|tjks(ttd�jtj���|S)z�Checks that an option is an LVM-style size string.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value converted to a SizeString.
    Raises:
      ArgumentError
    z!must be less than or equal to {0})r�	checkSize�logicalSizeMaxrr0rB)r1�ssrrr�checkLogicalSize�s


zDefaults.checkLogicalSizecCsBtj|�}tj|ko tjkns>ttd�jtjtj���|S)aYChecks that an option is an acceptable value for max discard size.
    Max discard sizes will be rounded to a multiple of 4k, and must be at
    least 4k and less than 4GB.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value converted to a SizeString.
    Raises:
      ArgumentError
    z&must be at least {0} and less than {1})r�checkSiSize�maxDiscardSizeMin�maxDiscardSizeMaxPlusOnerr0rB)r1rHrrr�checkMaxDiscardSizes

zDefaults.checkMaxDiscardSizecCsBtj|�}tj|ko tjkns>ttd�jtjtj���|S)akChecks that an option is an acceptable value for the page cache size.
    Page cache sizes will be rounded up to a multiple of the page size, and
    must be at least 128M and less than 16T.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value converted to a SizeString.
    Raises:
      ArgumentError
    z&must be at least {0} and less than {1})rrJ�blockMapCacheSizeMin�blockMapCacheSizeMaxPlusOnerr0rB)r1rHrrr�checkPageCacheszs

zDefaults.checkPageCacheszcCstjtjtj|�S)z�Checks that an option is a valid "physical" thread count.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value converted to an integer.
    Raises:
      ArgumentError

    )rr4�physicalThreadsMin�physicalThreadsMax)r1rrr�checkPhysicalThreadCount/sz!Defaults.checkPhysicalThreadCountcCstjtjtj|�S)z�Checks that an option is a valid "logical" thread count.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value converted to an integer.
    Raises:
      ArgumentError

    )rr4�logicalThreadsMin�logicalThreadsMax)r1rrr�checkLogicalThreadCount@sz Defaults.checkLogicalThreadCountcCstjtjtj|�S)z�Checks that an option is a valid bio rotation interval.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value converted to an integer.
    Raises:
      ArgumentError

    )rr4�bioRotationIntervalMin�bioRotationIntervalMax)r1rrr�checkRotationIntervalQszDefaults.checkRotationIntervalcCs\|dj�s*|dj�rL|dj�tjkrLyt|�}|Stk
rJYnXttd���dS)z�Checks that an option is an SI unit size string.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value converted to a SizeString.
    Raises:
      ArgumentError
    rzmust be an SI-style size stringN���rZrZ)	�isdigit�isalpha�lowerrZ
lvmSiSuffixesr	rArr0)r1rHrrrrJbszDefaults.checkSiSizecCs2yt|�}|Stk
r YnXttd���dS)z�Checks that an option is an LVM-style size string.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value converted to a SizeString.
    Raises:
      ArgumentError
    z must be an LVM-style size stringN)r	rArr0)r1rHrrrrFxszDefaults.checkSizecCs|yVt|�}|j�}tj|�s<tj|ko4tjknrTttd�j	tjtj���|St
k
rjYnXttd���dS)z�Checks that an option is a valid slab size.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value converted to a SizeString.
    Raises:
      ArgumentError
    z*must be a power of two between {0} and {1}z must be an LVM-style size stringN)r	ZtoBytesrZisPowerOfTwor�slabSizeMin�slabSizeMaxrr0rBrA)r1rH�sizerrr�
checkSlabSize�szDefaults.checkSlabSizecCstjdd|�S)a&Checks that an option is a valid thread count, for worker thread
    types requiring between 0 and 100 threads, inclusive.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value converted to an integer.
    Raises:
      ArgumentError

    rr)rr4)r1rrr�checkThreadCount0_100�s
zDefaults.checkThreadCount0_100cCstjdd|�S)a&Checks that an option is a valid thread count, for worker thread
    types requiring between 1 and 100 threads, inclusive.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value converted to an integer.
    Raises:
      ArgumentError

    rr)rr4)r1rrr�checkThreadCount1_100�s
zDefaults.checkThreadCount1_100cCsL|dks|dkrdSytj|�}t|�Stk
r:YnXttd���dS)z�Checks that an option is a valid UUID.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The uuid as a string.
    Raises:
      ArgumentError

    Nr&z$must be a valid UUID or empty string)�uuidZUUID�strrArr0)r1�valrrr�checkUUIDValue�s
zDefaults.checkUUIDValuecCsPd}tjd|d|�dkr0ttd�j||���|jd�rLttd�j|���|S)a�Checks that an option is a valid VDO device name.

    The "dmsetup create" command will accept a lot of characters that
    could be problematic for udev or for running shell commands
    without careful quoting. For now, we permit only alphanumerics and
    a few other characters.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The device name as a string.
    Raises:
      ArgumentError

    zA-Za-z0-9#+.:@_-z^[z]*$NzFVDO device names may only contain characters in '{0}': bad value '{1}'�-z8VDO device names may not start with '-': bad value '{0}')�re�matchrr0rB�
startswith)r1ZallowedCharsrrr�checkVDOName�s

zDefaults.checkVDONamecCsdS)Nr)rrrrr
szDefaults.__init__cCs^|dk	rZtjj|�rZtj|�}tj|j�r<ttd�j|���tj	|j�rZttd�j|���|S)z�Checks that an option does not specify an existing block device
    or directory.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value.
    Raises:
      ArgumentError

    Nz{0} is a block devicez{0} is a directory)
r-r.�exists�stat�S_ISBLK�st_moderr0rB�S_ISDIR)r1Zpathstatrrrr9s

z&Defaults._checkNotBlockFileOrDirectorycCsVy(t|�}||ko|knr&|SWntk
r<YnXttd�j||���dS)aTChecks that an option is a valid integer within a desired range.

    Arguments:
      minValue (int): The minimum acceptable value.
      maxValue (int): The maximum acceptable value.
      value (str): Value provided as an argument to the option.
    Returns:
      The value converted to an integer.
    Raises:
      ArgumentError

    z=must be an integer at least {0} and less than or equal to {1}N)r>rArr0rB)ZminValueZmaxValuer1rCrrrr4szDefaults._rangeCheckNrZ)^rrrrZNOTSETZ
ackThreadsZ
ackThreadsMaxZ
ackThreadsMinrZenabledZactivateZbioRotationIntervalrXrWZbioThreadOverheadMBZ
bioThreadsZ
bioThreadsMaxZ
bioThreadsMinr	ZblockMapCacheSizerOrNrZMiBZ$blockMapCacheSizeMinPerLogicalThreadZblockMapPeriodr6r5Zcfreqr-�getenvZconfFileZconversionUtilityDirZcompressionZ
deduplicationZ
cpuThreadsZ
cpuThreadsMaxZ
cpuThreadsMinZdisabledZ
emulate512ZhashZoneThreadsZhashZoneThreadsMaxZhashZoneThreadsMinZindexMemr@r?rGZlogicalThreadsZ(logicalThreadsBlockMapCacheSizeThresholdrUrTZmaxDiscardSizerLrKZmdRaid5ModeZphysicalThreadOverheadMBZphysicalThreadsrRrQZslabSizer_r^ZsparseIndexZudsParallelFactorrdZvdoPhysicalBlockSizeZvdoLogLevelZvdoLogLevelChoicesZ
vdoTargetNameZwritePolicyZwritePolicyChoices�staticmethodr2r3r7r:rDrErIrMrPrSrVrYrJrFrarbrcrgrlr
r9r4rrrrr3s�

"%r)rZ
__future__rrrrr&rrr	r
r-rirnrd�	Exceptionr�objectrrrrr�<module>s

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists