%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/xfs.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZddl	Z
ddlZ
ddlZ
ddl
Z
ddlmZddlmZddlmZeje�Zd�Zdd�Zd	�Zd
�Zd�Zd�Zdddd
�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'ddddddddddd�
Z(dddd�Z)d�Z*d�Z+dS(u'
Module for managing XFS file systems.
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionError(tsix(trangecC@s&tjjj�o%tjd�dkS(u)
    Only work on POSIX-like systems
    ukerneluLinux(tsalttutilstplatformt
is_windowst
__grains__tget(((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt__virtual__1scC@s�|jdd�r}|dr}|r5tjd|�ntjd|jd��tjd|jdd��t|d��ndS(	uC
    Crash to the log if command execution was not successful.
    uretcodeiustderru
Command: "%s"uReturn code: %suError output:
%suN/AN(RtlogtdebugR(touttcmd((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt_verify_run9scC@s�|jd�r"|dj�}n|jdd�jdd�}g}xd|jd�D]S}|sod|kr|j|�qV|t|�dd||t|�d<qVWg|D]}t|jd��^q�S(u0
    Parse one line of the XFS info output.
    u=iu = u=*** u =u (t
startswithtstriptreplacetsplittappendtlenttuple(t
serializedtoptttkntitems((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt_xfs_info_get_kvGs.cC@s�i}tjd�}d
}x�g|jd�D]*}|jd|�j�jdd�^q.D]�}|snq\nt|�}|jd�s�|j	d�}i||ddkr�dp�dd	6||d<n||dj
t|��q\W|S(u:
    Parse output from "xfs_info" or "xfs_growfs -n".
    u\s+u
u u, u=iiu***usectionN(tretcompiletNoneRtsubRRRRtpoptupdatetdict(tdatatrettsprtentrytltlinetnfo((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt_parse_xfs_info]sG2cC@s[tddj|��}|jd�rMt|djdd�j���nt|d�S(u
    Get filesystem geometry information.

    CLI Example:

    .. code-block:: bash

        salt '*' xfs.info /dev/sda1
    ucmd.run_alluxfs_info {0}ustderru	xfs_info:uustdout(t__salt__tformatRRRRR,(tdeviceR((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pytinfops
%cC@s�i}g}t}x�g|jd�D]}|j�r%|j�^q%D]U}tjdd|�}|jd�r�|jd�d|d<n�|jd�r�tjd	d|�|d
<n�|jd�r�tjdd|�|d
<nq|jd�rtjdd|�|d<nF|jd�r7tjdd|�|d<n|jd�rRt}qGn|jd�r}|r}|j|j��qG|jd�rG|rGt}qGqGW|r�dj|�|d<n|S(u2
    Parse CLI output of the xfsdump utility.
    u
u
^xfsdump: uusession id:u i����u
Session IDusession label:u^session label: u
Session labelumedia file sizeu^media file size\s+u
Media sizeudump complete:u^dump complete:\s+u
Dump completeuDump Status:u^Dump Status:\s+uStatusu
Dump Summary:uSummary(	tFalseRRRR!RtTrueRtjoin(R%Rtsummaryt
summary_blockR)R*((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt_xfsdump_output�s2;
cC@stjjjd�s$td��n|r0|pZtjdj|�tj��j	dd�}dg}|j
d�|s�|j
d�n|j
dj|��|j
d	j|��|j
d
j|��|j
|�dj|�}td|�}t
|d
|�t|d�S(uh
    Dump filesystem device to the media (file, tape etc).

    Required parameters:

    * **device**: XFS device, content of which to be dumped.
    * **destination**: Specifies a dump destination.

    Valid options are:

    * **label**: Label of the dump. Otherwise automatically generated label is used.
    * **level**: Specifies a dump level of 0 to 9.
    * **noerase**: Pre-erase media.

    Other options are not used in order to let ``xfsdump`` use its default
    values, as they are most optimal. See the ``xfsdump(8)`` manpage for
    a more complete description of these options.

    CLI Example:

    .. code-block:: bash

        salt '*' xfs.dump /dev/sda1 /detination/on/the/client
        salt '*' xfs.dump /dev/sda1 /detination/on/the/client label='Company accountancy'
        salt '*' xfs.dump /dev/sda1 /detination/on/the/client noerase=True
    uxfsdumpu1Utility "xfsdump" has to be installed or missing.u%XFS dump for "{0}" of %Y.%m.%d, %H:%Mu'u"u-Fu-Eu-L '{0}'u-l {0}u-f {0}u ucmd.run_allRustdout(RRtpathtwhichRttimetstrftimeR.t	localtimeRRR3R-RR6(R/tdestinationtleveltlabeltnoeraseRR((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pytdump�s 	

cC@s�g|j�jdd�D]}|r|^q}t|�dkrTdj|d�S|\}}dj|j�|j��SdS(u2
    Parse xfsrestore output keyset elements.
    u:iu'{0}': iu
'{0}': '{1}',N(RRRR.(R*telmttknstkeytval((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt
_xr_to_keyset�s
1cC@s�g}g|jd�D]}|j�r|^q}t|�dkrkd|dj�krki|dd6Sd}|jd�x�|d D]�}tg|j�jd�D]}|r�|^q��dkr@ttjd	d
|��}||krx$t|�D]}|jd�q�Wn|}|jt|��|jd�q�|jt|��q�Wx%t|d�D]}|jd�qhW|jd�t	dj
|��d}|d|d<|S(u]
    Transform xfsrestore inventory data output to a Python dict source and evaluate it.
    u
iurestore statusiurestore_statusu{i����u:u[^	]uu},(RRRtlowerRRR!RREtevalR3(RR%R*tidentRAtn_identtstep((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt_xfs_inventory_output�s,.(
:
cC@s(tdd�}t|�t|d�S(u�
    Display XFS dump inventory without restoration.

    CLI Example:

    .. code-block:: bash

        salt '*' xfs.inventory
    ucmd.run_allu
xfsrestore -Iustdout(R-RRK(R((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt	inventorys

cC@s&i}g}t}xqg|jd�D]}|r%|j�^q%D]A}|jd�rl|r`Pqlt}qAn|rA|j|�qAqAWx~g|dD]}d|kr�|^q�D]S}g|jdd�D]}	|	j�^q�\}
}|||
j�jdd�<q�W|jd�|kr"|p%iS(u
    Parse prune output.
    u
u-iu:u u_uuuid(	R1RRRR2RRFRR(RtuuidR%tcnttcutpointR)R*tetksetttRCRD((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt_xfs_prune_outputs501 cC@sYtddj|��}t|�t|d|�}|r@|Stdj|���dS(u�
    Prunes the dump session identified by the given session id.

    CLI Example:

    .. code-block:: bash

        salt '*' xfs.prune_dump b74a3586-e52e-4a4a-8775-c3334fa8ea2c

    ucmd.run_alluxfsinvutil -s {0} -Fustdoutu!Session UUID "{0}" was not found.N(R-R.RRSR(t	sessionidRR%((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt
prune_dump,s
c
C@sd�}i}x�||jd��D]�}i}xK||j�jd��D].}|jdd�\}}|||j�<qMW|jd�dkr%|jd�|d<|||jd	�<q%q%Wt�}x>tj|�D]-}	|j|	�r�||	j||	�q�q�W|S(
u
    Parse blkid output.
    cS@s#g|D]}|j�r|^qS(N(R(R%tel((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt<lambda>Esu

u
u=iutypeuxfsulabeludevname(	RRRFR"Rt_get_mountsRtiterkeysR#(
RtfltR%tdev_metatdevRRCRDtmountsR/((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt
_blkid_outputAs	"	cC@s(tdd�}t|�t|d�S(u�
    Get known XFS formatted devices on the system.

    CLI Example:

    .. code-block:: bash

        salt '*' xfs.devices
    ucmd.run_allublkid -o exportustdout(R-RR^(R((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pytdevicesXs

c
C@s�tjd�}i}x�g|jd�D]}|j�r(|^q(dD]V}|jd|�jd�\}}}}}	i|d6|d6|d6|	d6||<qHW|S(	u$
    Parse xfs_estimate output.
    u\s+u
iu ublock _sizeublocksu	megabytesulogsize(RRRRR!(
RtspcR%R)R*t	directorytbsizetblockst	megabytestlogsize((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt_xfs_estimate_outpuths9*cC@s[tjj|�s*tdj|���ntddj|��}t|�t|d�S(u`
    Estimate the space that an XFS filesystem will take.
    For each directory estimate the space that directory would take
    if it were copied to an XFS filesystem.
    Estimation does not cross mount points.

    CLI Example:

    .. code-block:: bash

        salt '*' xfs.estimate /path/to/file
        salt '*' xfs.estimate /path/to/dir/*
    uPath "{0}" was not found.ucmd.run_alluxfs_estimate -v {0}ustdout(tosR7texistsRR.R-RRf(R7R((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pytestimatezs

cC@spd�}dg}|r>|jd�|jdj|��n|ra|jd�|j|�nx�d|fd|fd|	fd	|fd
|
fd|fd|fgD]e\}
}y-||�r�|j|
�|j|�nWq�tk
rtd
j||
���q�Xq�W|s&|jd�n|j|�dj|�}td|�}t|d|�t|d�S(ul
    Create a file system on the specified device. By default wipes out with force.

    General options:

    * **label**: Specify volume label.
    * **ssize**: Specify the fundamental sector size of the filesystem.
    * **noforce**: Do not force create filesystem, if disk is already formatted.

    Filesystem geometry options:

    * **bso**: Block size options.
    * **gmo**: Global metadata options.
    * **dso**: Data section options. These options specify the location, size,
               and other parameters of the data section of the filesystem.
    * **ino**: Inode options to specify the inode size of the filesystem, and other inode allocation parameters.
    * **lso**: Log section options.
    * **nmo**: Naming options.
    * **rso**: Realtime section options.

    See the ``mkfs.xfs(8)`` manpage for a more complete description of corresponding options description.

    CLI Example:

    .. code-block:: bash

        salt '*' xfs.mkfs /dev/sda1
        salt '*' xfs.mkfs /dev/sda1 dso='su=32k,sw=6' noforce=True
        salt '*' xfs.mkfs /dev/sda1 dso='su=32k,sw=6' lso='logdev=/dev/sda2,size=10000b'
    c	S@sSt|rd|kr|s!drLg|jd�D]}|jd�^q1pOg�S(Nu=u,(R$R R(targstkw((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyRW�sumkfs.xfsu-Lu'{0}'u-su-bu-mu-nu-iu-du-lu-ru'Wrong parameters "{0}" for option "{1}"u-fu ucmd.run_allRustdout(RR.t	ExceptionRR3R-RR,(R/R>tssizetnoforcetbsotgmotinotlsotrsotnmotdsotgetoptsRtswitchtoptsR((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pytmkfs�s.!		

'+

 
cC@sk|r7|dkr7|dkr7tdj|���ndg}|rl|jd�|jdj|��n|tkr�|jd�|jd�n#|r�|jd�|jd�n|tkr�|jd�|jd	�n#|r|jd�|jd
�n|j|�dj|�}ttd|�d
|�tddj|��}t|�t|d�S(u
    Modify parameters of an XFS filesystem.

    CLI Example:

    .. code-block:: bash

        salt '*' xfs.modify /dev/sda1 label='My backup' lazy_counting=False
        salt '*' xfs.modify /dev/sda1 uuid=False
        salt '*' xfs.modify /dev/sda1 uuid=True
    u3Nothing specified for modification for "{0}" deviceu	xfs_adminu-Lu'{0}'u-cu0u1u-Uunilugenerateu ucmd.run_allRublkid -o export {0}ustdoutN(	R RR.RR1R3RR-R^(R/R>t
lazy_countingRMRR((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pytmodify�s0	






c	C@s�i}tjjjd���}x}tjjj|j��D]`}|j�jd�\}}}}}}|dkryq:ni|d6|jd�d6||<q:WWdQX|S(u#
    List mounted filesystems.
    u/proc/mountsu uxfsumount_pointu,uoptionsN(	RRtfilestfopenR%tdecodet	readlinesRR(	R]tfhrR*R/tmntpnttfstypetoptionstfs_freqt	fs_passno((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyRX�s"'!cC@sw|dkrtd��nt�j|�sEtdj|���ntddj|��}t|�i|dd6S(u�
    Defragment mounted XFS filesystem.
    In order to mount a filesystem, device should be properly mounted and writable.

    CLI Example:

    .. code-block:: bash

        salt '*' xfs.defragment /dev/sda1
    u/uRoot is not a device.uDevice "{0}" is not mounteducmd.run_alluxfs_fsr {0}ustdoutulog(RRXRR.R-R(R/R((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt
defragments
(,t__doc__t
__future__RRRRgRR9tloggingtsalt.utils.filesRtsalt.utils.pathtsalt.utils.platformtsalt.utils.datatsalt.exceptionsRtsalt.extRtsalt.ext.six.movesRt	getLoggert__name__R
RR RRR,R0R6R@RERKRLRSRUR^R_RfRiRyR{RXR�(((s4/usr/lib/python2.7/site-packages/salt/modules/xfs.pyt<module>sD					#0		$								?,	

Zerion Mini Shell 1.0