.t_c@sdZddlmZmZmZmZmZddlZddlZddl Z dee fdYZ de fdYZ dS( sy Defaults - manage Albireo/VDO defaults $Id: //eng/vdo-releases/magnesium/src/python/vdo/vdomgmnt/Defaults.py#17 $ i(t Constantst MgmntLoggert MgmntUtilst SizeStringtUserExitStatusiNt ArgumentErrorcBs eZdZdZdZRS(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 dZ dZ dZ dZd ZdZdZed Zed Zed Zd ejZd Zd ZdZdZejdddZejZ ejZ!dZ"dZ#dZ$ej%Z&dZ'dZ(dZ)dZ*dZ+dZ,e-j.e-j/dZ0edZ1dZ2dZ3dZ4dZ5dZ6dZ7dZ8d Z9dZ:ej%Z;edZ<ed Z=edZ>edZ?edZ@ed ZAej%ZBdZCdZDdZEdddd dd!gZFd"ZGd#ZHd$d%d#gZIeJd&ZKeJd'ZLeJd(ZMeJd)ZNeJd*ZOeJd+ZPeJd,ZQeJd-ZReJd.ZSeJd/ZTeJd0ZUeJd1ZVeJd2ZWeJd3ZXeJd4ZYeJd5ZZeJd6Z[d7Z\eJd8Z]eJd9Z^RS(:s.Defaults manages default values for arguments.iiidii@iigQ?it128Mt16Tii?t VDO_CONF_DIRs/etcs /vdoconf.ymlig?s .Defaultst4096Ti toni t0t2Gt32GitinfotcriticalterrortwarningtnoticetdebugtvdotautotasynctsynccCs,tjj|r|SttddS(sChecks 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 checkAbspathrs cCs tj|S(sChecks 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.pyt checkBlkDevs cCstjtjtj|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.pytcheckBlockMapPeriods 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 checkConfFiles cCs|jdd}y^|dks9|dks9|dkr=|St|}tj|koftjknro|SWntk rnXttdjtjtjdS(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 checkIndexmems$ "  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 checkLogFilescCsCtj|}|tjks?ttdjtjn|S(sChecks 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.pytcheckLogicalSizes cCs\tj|}tj|ko,tjknsXttdjtjtjn|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}(Rt checkSiSizetblockMapCacheSizeMintblockMapCacheSizeMaxPlusOneRR'R:(R(R@((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pytcheckPageCacheszs  cCs\tj|}tj|ko,tjknsXttdjtjtjn|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(sChecks 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(sChecks 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|djs9|djrd|djtjkrdyt|}|SWqdtk r`qdXnttddS(sChecks 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 ismust 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'nXttddS(sChecks 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   cCsyzt|}|j}tj| sNtj|koHtjkn ruttdj tjtjn|SWnt k rnXttddS(sChecks 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 isPowerOfTwoRt slabSizeMint slabSizeMaxRR'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_100s 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_100s cCsxd}tjd|d|dkrGttdj||n|jdrtttdj|n|S(sChecks 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 checkVDONames   cCsdS(N((R ((s9/usr/lib/python2.7/site-packages/vdo/vdomgmnt/Defaults.pyRscCs|dk rtjj|rtj|}tj|jr]ttdj |ntj |jrttdj |qn|S(sChecks 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.pyR1s !cCsfy0t|}||ko&|knr/|SWntk rCnXttdj||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$tgetenvtconfFilet compressiont deduplicationt cpuThreadst cpuThreadsMaxt cpuThreadsMintdisabledt emulate512thashZoneThreadsthashZoneThreadsMaxthashZoneThreadsMintindexMemR8R7Rt getLoggertmynametlogR?tlogicalThreadst(logicalThreadsBlockMapCacheSizeThresholdtlogicalThreadsMaxtlogicalThreadsMint mdRaid5ModetphysicalThreadOverheadMBtphysicalThreadsRJRIt readCachet readCacheSizeRGRFtslabSizeRVRUt sparseIndextudsParallelFactortvdoPhysicalBlockSizet vdoLogLeveltvdoLogLevelChoicest vdoTargetNamet writePolicytwritePolicyChoicest 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.pyts (