%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/linux_lvm.pyo

�
���^c@@s0dZddlmZmZmZddlZddlZddlZ	ddl
mZddlm
Z
eje�ZdZd�Zd�Zd	�Zd
ed�Zd
d�Zd
ed
�Zed�Zed�Zd�Zd�Zddddeeed�Zd�Z d�Z!dddd�Z"dS(u
Support for Linux LVM2
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tCommandExecutionErrorulvmcC@s#tjjjd�rtStdfS(u2
    Only load the module if lvm is installed
    ulvmuSThe linux_lvm execution module cannot be loaded: the lvm binary is not in the path.(tsalttutilstpathtwhicht__virtualname__tFalse(((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pyt__virtual__scC@s=d}td|�j�}|djd�}|dj�S(uw
    Return LVM version from lvm version

    CLI Example:

    .. code-block:: bash

        salt '*' lvm.version
    ulvm versionucmd.runiu: i(t__salt__t
splitlinestsplittstrip(tcmdtouttret((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pytversion s
cC@sdi}d}td|�j�}x;|D]3}|jd�}|dj�||dj�<q)W|S(u�
    Return all version info from lvm version

    CLI Example:

    .. code-block:: bash

        salt '*' lvm.fullversion
    ulvm versionucmd.runu:ii(RR
RR(RRRtlinetcomps((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pytfullversion0s

"uc	C@s^i}ddg}|r(|j|�ntd|dt�}|ddkrRiS|dj�}x�|D]�}d|kri|j�jd	�}|r�tjj|d�}n
|d}i|dd
6|dd6|d
d6|dd6|dd6|dd6|dd6|dd6|dd6|dd6|dd6||<|rV|||d<qVqiqiW|S( uA
    Return information about the physical volume(s)

    pvname
        physical device name
    real
        dereference any symlinks and report the real device

        .. versionadded:: 2015.8.7


    CLI Examples:

    .. code-block:: bash

        salt '*' lvm.pvdisplay
        salt '*' lvm.pvdisplay /dev/md0
    u	pvdisplayu-cucmd.run_alltpython_shelluretcodeiustdoutuis a new physical volumeu:uPhysical Volume DeviceiuVolume Group NameiuPhysical Volume Size (kB)iuInternal Physical Volume NumberiuPhysical Volume Statusiu!Physical Volume (not) AllocatableiuCurrent Logical Volumes HereiuPhysical Extent Size (kB)iuTotal Physical Extentsi	uFree Physical Extentsi
uAllocated Physical ExtentsuReal Physical Volume Device(	tappendRR
R
RRtosRtrealpath(	tpvnametrealRRtcmd_retRRRtdevice((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pyt	pvdisplayCs:

cC@sUi}ddg}|r(|j|�ntd|dt�}|ddkrRiS|dj�}x�|D]�}|j�jd�}i|dd	6|d
d6|dd
6|dd6|dd6|dd6|dd6|dd6|dd6|dd6|dd6|dd6|d d!6|d"d#6|d$d%6|d&d'6|d(d)6||d<qiW|S(*u�
    Return information about the volume group(s)

    CLI Examples:

    .. code-block:: bash

        salt '*' lvm.vgdisplay
        salt '*' lvm.vgdisplay nova-volumes
    u	vgdisplayu-cucmd.run_allRuretcodeiustdoutu:uVolume Group NameiuVolume Group AccessiuVolume Group StatusiuInternal Volume Group NumberiuMaximum Logical VolumesiuCurrent Logical VolumesiuOpen Logical VolumesiuMaximum Logical Volume SizeiuMaximum Physical Volumesi	uCurrent Physical Volumesi
uActual Physical VolumesiuVolume Group Size (kB)iuPhysical Extent Size (kB)i
uTotal Physical ExtentsiuAllocated Physical ExtentsiuFree Physical ExtentsiuUUID(RRR
R
RR(tvgnameRRRRRR((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pyt	vgdisplayys:
cC@sNi}ddg}|r(|j|�n|rMtd|dtdd�}ntd|dt�}|ddkrwiS|d	j�}x�|D]�}|j�jd
�}i
|dd6|dd
6|dd6|dd6|dd6|dd6|dd6|dd6|dd6|dd6|dd6|d d!6|d"d#6||d<q�W|S($u�
    Return information about the logical volume(s)

    CLI Examples:

    .. code-block:: bash

        salt '*' lvm.lvdisplay
        salt '*' lvm.lvdisplay /dev/vg_myserver/root
    u	lvdisplayu-cucmd.run_allRtoutput_logleveluquieturetcodeiustdoutu:uLogical Volume NameiuVolume Group NameiuLogical Volume AccessiuLogical Volume StatusiuInternal Logical Volume NumberiuOpen Logical VolumesiuLogical Volume Sizeiu"Current Logical Extents AssociatediuAllocated Logical Extentsi	uAllocation Policyi
uRead Ahead SectorsiuMajor Device NumberiuMinor Device Number(RRR
R
RR(tlvnametquietRRRRRR((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pyt	lvdisplay�s6
c	
K@s�|s
dSt|tj�r.|jd�}nddg}xr|D]j}tjj|�sqtdj|���nt	|�s�|j
|�qA|sAtdj|���qAqAW|ds�tSd}d}xv|D]n}||r||kr|jdj|�||g�q�||r�||kr�|j
dj|��q�q�Wt
d|dt�}|jd�rt|jd���nx2|D]*}t	|�s�tdj|���q�q�WtS(u<
    Set a physical device to be used as an LVM physical volume

    override
        Skip devices, if they are already LVM physical volumes

    CLI Examples:

    .. code-block:: bash

        salt mymachine lvm.pvcreate /dev/sdb1,/dev/sdb2
        salt mymachine lvm.pvcreate /dev/sdb1 dataalignmentoffset=7s
    u&Error: at least one device is requiredu,upvcreateu-yu{0} does not existu/Device "{0}" is already an LVM physical volume.iumetadatasizeu
dataalignmentudataalignmentoffsetupvmetadatacopiesumetadatacopiesumetadataignoreurestorefileu
norestorefileulabelsectorusetphysicalvolumesizeuforceu--{0}ucmd.run_allRuretcodeustderruDevice "{0}" was not affected.(
umetadatasizeu
dataalignmentudataalignmentoffsetupvmetadatacopiesumetadatacopiesumetadataignoreurestorefileu
norestorefileulabelsectorusetphysicalvolumesize(uforceu
norestorefile(t
isinstanceRtstring_typesRRRtexistsRtformatRRtTruetextendRR
tget(	tdevicestoverridetkwargsRRtvalidtno_parametertvarR((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pytpvcreate�s>


#
cC@s�t|tj�r$|jd�}nddg}xH|D]@}t|�rY|j|�q7|s7tdj|���q7q7W|ds�tSt	d|dt
�}|jd�r�t|jd	���nx2|D]*}t|�r�td
j|���q�q�WtS(u
    Remove a physical device being used as an LVM physical volume

    override
        Skip devices, if they are already not used as LVM physical volumes

    CLI Examples:

    .. code-block:: bash

        salt mymachine lvm.pvremove /dev/sdb1,/dev/sdb2
    u,upvremoveu-yu{0} is not a physical volumeiucmd.run_allRuretcodeustderruDevice "{0}" was not affected.(R&RR'RRRRR)R*RR
R,(R-R.RRR((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pytpvremove	s"



c	K@s�|s|rdSt|tj�r6|jd�}nd|g}x|D]}|j|�qIWd}xN|D]F}||rm||krm|jd
j|��|j||�qmqmWtd|dt�j�}t	|�}|d
j
�|d<|S(u�
    Create an LVM volume group

    CLI Examples:

    .. code-block:: bash

        salt mymachine lvm.vgcreate my_vg /dev/sdb1,/dev/sdb2
        salt mymachine lvm.vgcreate my_vg /dev/sdb1 clustered=y
    u-Error: vgname and device(s) are both requiredu,uvgcreateu	clusteredumaxlogicalvolumesumaxphysicalvolumesuvgmetadatacopiesumetadatacopiesuphysicalextentsizeu--{0}ucmd.runRiuOutput from vgcreate(u	clusteredumaxlogicalvolumesumaxphysicalvolumesuvgmetadatacopiesumetadatacopiesuphysicalextentsize(R&RR'RRR)RR
R
R!R(	R R-R/RRR0R2Rtvgdata((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pytvgcreate0s"

cC@s�|s|rdSt|tj�r6|jd�}nd|g}x|D]}|j|�qIWtd|dt�j�}i|dj�d6}|S(u�
    Add physical volumes to an LVM volume group

    CLI Examples:

    .. code-block:: bash

        salt mymachine lvm.vgextend my_vg /dev/sdb1,/dev/sdb2
        salt mymachine lvm.vgextend my_vg /dev/sdb1
    u-Error: vgname and device(s) are both requiredu,uvgextenducmd.runRiuOutput from vgextend(	R&RR'RRRR
R
R(R R-RRRR5((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pytvgextendOs
c	K@sl|r|rdS|r |r dSd*}
d+}g}|	r�xytj|	�D]e\}
}|
|kry|jdj|
��qH|
|
krH|jdj|
�dj|�g�qHqHWntjjjd�g}|r�|jdd|g�n/|r|jd|g�n|jd|g�|rB|jddj||�g�n
|j|�|rz|rz|jddj|�g�n^|r�|r�d S|r�|jd!dj|�g�n)|r�|jd"dj|�g�nd#S|r�|j|�n|r|j|�n|r|jd$�nt	d%|d&t
�j�}d'j||�}t|�}|d(j
�|d)<|S(,u�
    Create a new logical volume, with option for which physical volume to be used

    CLI Examples:

    .. code-block:: bash

        salt '*' lvm.lvcreate new_volume_name     vg_name size=10G
        salt '*' lvm.lvcreate new_volume_name     vg_name extents=100 pv=/dev/sdb
        salt '*' lvm.lvcreate new_snapshot        vg_name snapshot=volume_name size=3G

    .. versionadded:: to_complete

    Support for thin pools and thin volumes

    CLI Examples:

    .. code-block:: bash

        salt '*' lvm.lvcreate new_thinpool_name   vg_name               size=20G thinpool=True
        salt '*' lvm.lvcreate new_thinvolume_name vg_name/thinpool_name size=10G thinvolume=True

    u1Error: Please specify only one of size or extentsu<Error: Please set only one of thinvolume or thinpool to Trueuactivateu	chunksizeu
contiguousudiscardsustripesu
stripesizeuminoru
persistentumirrorsu
noudevsyncumonitoruignoremonitoringu
permissionupoolmetadatasizeu	readaheadu
regionsizeutypeuvirtualsizeuzerouthinu--{0}u{0}ulvcreateu--thinu-nu
--thinpoolu-su{0}/{1}u-Vu6Error: Thin volume size cannot be specified as extentsu-Lu-lu/Error: Either size or extents must be specifiedu--yesucmd.runRu/dev/{0}/{1}iuOutput from lvcreate(uactivateu	chunksizeu
contiguousudiscardsustripesu
stripesizeuminoru
persistentumirrorsu
noudevsyncumonitoruignoremonitoringu
permissionupoolmetadatasizeu	readaheadu
regionsizeutypeuvirtualsizeuzero(u
noudevsyncuignoremonitoringuthin(Rt	iteritemsRR)R+RRRRRR
R
R%R(R#R tsizetextentstsnapshottpvt
thinvolumetthinpooltforceR/R0R1textra_argumentstktvRRtlvdevtlvdata((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pytlvcreategs\!/"
cC@s/dd|g}td|dt�}|j�S(u�
    Remove an LVM volume group

    CLI Examples:

    .. code-block:: bash

        salt mymachine lvm.vgremove vgname
        salt mymachine lvm.vgremove vgname force=True
    uvgremoveu-fucmd.runR(RR
R(R RR((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pytvgremove�scC@s;dddj||�g}td|dt�}|j�S(u�
    Remove a given existing logical volume from a named existing volume group

    CLI Example:

    .. code-block:: bash

        salt '*' lvm.lvremove lvname vgname force=True
    ulvremoveu-fu{0}/{1}ucmd.runR(R)RR
R(R#R RR((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pytlvremove�s
cC@s�|r|rtjd�iSdg}|rK|jddj|�g�n6|rp|jddj|�g�ntjd�iS|j|�td|dt�j�}i|d	j�d
6S(u�
    Return information about the logical volume(s)

    CLI Examples:

    .. code-block:: bash


        salt '*' lvm.lvresize +12M /dev/mapper/vg1-test
        salt '*' lvm.lvresize lvpath=/dev/mapper/vg1-test extents=+100%FREE

    u1Error: Please specify only one of size or extentsulvresizeu-Lu{0}u-lu/Error: Either size or extents must be specifieducmd.runRiuOutput from lvresize(	tlogterrorR+R)RRR
R
R(R9tlvpathR:RR((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pytlvresize�s

	

(#t__doc__t
__future__RRRtloggingtos.pathRtsalt.utils.pathRtsalt.extRtsalt.exceptionsRt	getLoggert__name__RHR	RRRR
RR!R%R*R3R4R6R7tNoneRERFRGRK(((s:/usr/lib/python2.7/site-packages/salt/modules/linux_lvm.pyt<module>s8				6-,7'		U		

Zerion Mini Shell 1.0