Current File : //usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyo
�
.�t_c@s�dZddlmZmZmZmZmZddlZddlZddl	Z	dee
fd��YZdefd��YZ
dS(	sy
  Defaults - manage Albireo/VDO defaults

  $Id: //eng/vdo-releases/magnesium/src/python/vdo/vdomgmnt/Defaults.py#17 $

i(t	ConstantstMgmntLoggert
MgmntUtilst
SizeStringtUserExitStatusi����Nt
ArgumentErrorcBs eZdZd�Zd�ZRS(s7Exception raised to indicate an error with an argument.cOs&tt|�j||�||_dS(N(tsuperRt__init__t_msg(tselftmsgtargstkwargs((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyR%scCs|jS(N(R(R	((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyt__str__*s(t__name__t
__module__t__doc__RR
(((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyRs	tDefaultscBs,eZdZdZdZdZdZejZ	dZ
dZdZdZ
dZd	ZdZdZed
�Zed�Zed
�ZdejZd
Zd
ZdZdZejdd�dZejZ ejZ!dZ"dZ#dZ$ej%Z&dZ'dZ(dZ)dZ*dZ+dZ,e-j.e-j/d�Z0ed�Z1dZ2dZ3dZ4dZ5dZ6dZ7dZ8dZ9dZ:ej%Z;ed�Z<ed�Z=ed�Z>ed�Z?ed�Z@ed
�ZAej%ZBdZCdZDdZEdddd dd!gZFd"ZGd#ZHd$d%d#gZIeJd&��ZKeJd'��ZLeJd(��ZMeJd)��ZNeJd*��ZOeJd+��ZPeJd,��ZQeJd-��ZReJd.��ZSeJd/��ZTeJd0��ZUeJd1��ZVeJd2��ZWeJd3��ZXeJd4��ZYeJd5��ZZeJd6��Z[d7�Z\eJd8��Z]eJd9��Z^RS(:s.Defaults manages default values for arguments.i����iidii@iig�Q����?it128Mt16Tii�?tVDO_CONF_DIRs/etcs/vdoconf.ymlig�?s	.Defaultst4096Ti	toni
t0t2Gt32GitinfotcriticalterrortwarningtnoticetdebugtvdotautotasynctsynccCs,tjj|�r|Sttd���dS(s�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
    smust be an absolute pathnameN(tostpathtisabsRt_(tvalue((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pytcheckAbspathrscCs
tj|�S(s�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
    (RR)(R(((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pytcheckBlkDev�scCstjtjtj|�S(s)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
    (Rt_rangeChecktblockMapPeriodMintblockMapPeriodMax(R(((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pytcheckBlockMapPeriod�scCs0|dk	r,tjj|�r,tj|�S|S(s@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(tNoneR$R%tisfileRt_checkNotBlockFileOrDirectory(R(((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyt
checkConfFile�s
cCs�|jdd�}y^|dks9|dks9|dkr=|St|�}tj|koftjknro|SWntk
r�nXttd�jtjtj���dS(sYChecks 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

    t,t.s0.25s0.5s0.75spmust 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(	treplacetintRtindexMemIntMintindexMemIntMaxt
ValueErrorRR'tformat(R(tnumber((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyt
checkIndexmem�s$"
cCs
tj|�S(s`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

    (RR1(R(((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pytcheckLogFile�scCsCtj|�}|tjks?ttd�jtj���n|S(s�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
    s!must be less than or equal to {0}(Rt	checkSizetlogicalSizeMaxRR'R:(R(tss((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pytcheckLogicalSize�s
cCs\tj|�}tj|ko,tjknsXttd�jtjtj���n|S(skChecks 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
    s&must be at least {0} and less than {1}(RtcheckSiSizetblockMapCacheSizeMintblockMapCacheSizeMaxPlusOneRR'R:(R(R@((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pytcheckPageCachesz�s
cCs\tj|�}tj|ko,tjknsXttd�jtjtj���n|S(sKChecks that an option is an acceptable value for the read cache size.
    Read cache sizes will be rounded to a multiple of 4k, and must be less
    than 16T.

    Arguments:
      value (str): Value provided as an argument to the option.
    Returns:
      The value converted to a SizeString.
    Raises:
      ArgumentError
    s&must be at least {0} and less than {1}(RRBtreadCacheSizeMintreadCacheSizeMaxPlusOneRR'R:(R(R@((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pytcheckReadCacheszs
cCstjtjtj|�S(s�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

    (RR+tphysicalThreadsMintphysicalThreadsMax(R(((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pytcheckPhysicalThreadCount+scCstjtjtj|�S(s�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

    (RR+tbioRotationIntervalMintbioRotationIntervalMax(R(((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pytcheckRotationInterval<scCsz|dj�s9|dj�rd|dj�tjkrdyt|�}|SWqdtk
r`qdXnttd���dS(s�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
    i����smust be an SI-style size stringN(	tisdigittisalphatlowerRt
lvmSiSuffixesRR9RR'(R(R@((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyRBMs
cCs>yt|�}|SWntk
r'nXttd���dS(s�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
    s must be an LVM-style size stringN(RR9RR'(R(R@((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyR>cs
cCs�yzt|�}|j�}tj|�sNtj|koHtjknruttd�j	tjtj���n|SWnt
k
r�nXttd���dS(s�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
    s*must be a power of two between {0} and {1}s must be an LVM-style size stringN(RttoBytesRtisPowerOfTwoRtslabSizeMintslabSizeMaxRR'R:R9(R(R@tsize((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyt
checkSlabSizevs#
cCstjdd|�S(s&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

    iid(RR+(R(((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pytcheckThreadCount0_100�s
cCstjdd|�S(s&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

    iid(RR+(R(((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pytcheckThreadCount1_100�s
cCsxd}tjd|d|�dkrGttd�j||���n|jd�rtttd�j|���n|S(s�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

    sA-Za-z0-9#+.:@_-s^[s]*$sFVDO device names may only contain characters in '{0}': bad value '{1}'t-s8VDO device names may not start with '-': bad value '{0}'N(tretmatchR/RR'R:t
startswith(R(tallowedChars((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pytcheckVDOName�s cCsdS(N((R	((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyR�scCs�|dk	r�tjj|�r�tj|�}tj|j�r]ttd�j	|���ntj
|j�r�ttd�j	|���q�n|S(s�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

    s{0} is a block devices{0} is a directoryN(R/R$R%texistststattS_ISBLKtst_modeRR'R:tS_ISDIR(R(tpathstat((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyR1�s
!cCsfy0t|�}||ko&|knr/|SWntk
rCnXttd�j||���dS(sTChecks 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

    s=must be an integer at least {0} and less than or equal to {1}N(R6R9RR'R:(tminValuetmaxValueR(R;((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyR+�s
(_RRRtNOTSETt
ackThreadst
ackThreadsMaxt
ackThreadsMinRtenabledtactivatetbioRotationIntervalRMRLtbioThreadOverheadMBtbioThreadReadCacheOverheadMBt
bioThreadst
bioThreadsMaxt
bioThreadsMinRtblockMapCacheSizeRDRCRtMiBt$blockMapCacheSizeMinPerLogicalThreadtblockMapPeriodR-R,tcfreqR$tgetenvtconfFiletcompressiont
deduplicationt
cpuThreadst
cpuThreadsMaxt
cpuThreadsMintdisabledt
emulate512thashZoneThreadsthashZoneThreadsMaxthashZoneThreadsMintindexMemR8R7Rt	getLoggertmynametlogR?tlogicalThreadst(logicalThreadsBlockMapCacheSizeThresholdtlogicalThreadsMaxtlogicalThreadsMintmdRaid5ModetphysicalThreadOverheadMBtphysicalThreadsRJRIt	readCachet
readCacheSizeRGRFtslabSizeRVRUtsparseIndextudsParallelFactortvdoPhysicalBlockSizetvdoLogLeveltvdoLogLevelChoicest
vdoTargetNametwritePolicytwritePolicyChoiceststaticmethodR)R*R.R2R<R=RARERHRKRNRBR>RXRYRZR`RR1R+(((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyR.s�	
						"%	(RtRRRRRR$R\Rbt	ExceptionRtobjectR(((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyt<module>s(