Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/system/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/system/filesystem.pyo

�
�Udac@`sGddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	m
Z
ddlZddlZddl
Z
ddlmZmZd
efd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd ��YZd!efd"��YZd#efd$��YZd%efd&��YZd'efd(��YZied)6ed*6ed+6ed,6ed-6ed.6ed/6ed06ed16ed26ed36ed46Z d5�Z!e"d6krCe!�ndS(7i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
author:
- Alexander Bulimov (@abulimov)
module: filesystem
short_description: Makes a filesystem
description:
  - This module creates a filesystem.
version_added: "1.2"
options:
  fstype:
    choices: [ btrfs, ext2, ext3, ext4, ext4dev, f2fs, lvm, ocfs2, reiserfs, xfs, vfat, swap ]
    description:
    - Filesystem type to be created.
    - reiserfs support was added in 2.2.
    - lvm support was added in 2.5.
    - since 2.5, I(dev) can be an image file.
    - vfat support was added in 2.5
    - ocfs2 support was added in 2.6
    - f2fs support was added in 2.7
    - swap support was added in 2.8
    required: yes
    aliases: [type]
  dev:
    description:
    - Target path to device or image file.
    required: yes
    aliases: [device]
  force:
    description:
    - If C(yes), allows to create new filesystem on devices that already has filesystem.
    type: bool
    default: 'no'
  resizefs:
    description:
    - If C(yes), if the block device and filesystem size differ, grow the filesystem into the space.
    - Supported for C(ext2), C(ext3), C(ext4), C(ext4dev), C(f2fs), C(lvm), C(xfs), C(vfat), C(swap) filesystems.
    - XFS Will only grow if mounted.
    - vFAT will likely fail if fatresize < 1.04.
    type: bool
    default: 'no'
    version_added: "2.0"
  opts:
    description:
    - List of options to be passed to mkfs command.
requirements:
  - Uses tools related to the I(fstype) (C(mkfs)) and C(blkid) command. When I(resizefs) is enabled, C(blockdev) command is required too.
notes:
  - Potential filesystem on I(dev) are checked using C(blkid), in case C(blkid) isn't able to detect an existing filesystem,
    this filesystem is overwritten even if I(force) is C(no).
s�
- name: Create a ext2 filesystem on /dev/sdb1
  filesystem:
    fstype: ext2
    dev: /dev/sdb1

- name: Create a ext4 filesystem on /dev/sdb1 and check disk blocks
  filesystem:
    fstype: ext4
    dev: /dev/sdb1
    opts: -cc
(tLooseVersionN(t
AnsibleModuletget_platformtDevicecB`s#eZd�Zd�Zd�ZRS(cC`s||_||_dS(N(tmoduletpath(tselfRR
((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyt__init__Xs	cC`s�tj|j�}tj|j�rs|jjddt�}|jj|d|jgdt�\}}}t	|�Stjj
|j�r�tjj|j�S|jjdt
dd|�dS(	s- Return size in bytes of device. Returns int tblockdevtrequireds--getsize64tcheck_rctchangedtmsgsTarget device not supported: %sN(toststatR
tS_ISBLKtst_modeRtget_bin_pathtTruetrun_commandtinttisfiletgetsizet	fail_jsontFalse(Rtstatinfotblockdev_cmdt_tdevsize_in_bytes((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pytsize\s-
cC`s|jS(N(R
(R((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyt__str__hs(t__name__t
__module__RR%R&(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyRWs		t
FilesystemcB`sqeZdZdZdZidd6dd6dd6Zd�Zed��Z	d�Z
d�Zd	�Zd
�Z
RS(ttCtLANGtLC_ALLtLC_MESSAGEScC`s
||_dS(N(R(RR((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyRtscC`s
t|�jS(N(ttypeR'(R((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pytfstypewscC`s
t��dS(s; Return size in bytes of filesystem on device. Returns int N(tNotImplementedError(Rtdev((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pytget_fs_size{scC`s�|jjrdS|jj|jdt�}|dkrPd||j|f}nd||j||f}|jj|dt�dS(NRs
%s %s '%s's
%s %s %s '%s'R(Rt
check_modeRtMKFSRtNonetMKFS_FORCE_FLAGSR(RtoptsR2tmkfstcmd((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pytcreatescC`s+|jj|jdt�}|t|�gS(NR(RRtGROWRtstr(RR2R:((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pytgrow_cmd�scC`s�|j�}y|j|�}Wn1tk
rR|jjdtdd|j�nX||ks�|jjdtdd|j|f�nc|jjr�|jjdt	dd|j|f�n.|jj
|j|�dt	�\}}}|SdS(s@Get dev and fs size and compare. Returns stdout of used command.RRs3module does not support resizing %s filesystem yet.s*%s filesystem is using the whole device %ss#Resizing filesystem %s on device %sRN(R%R3R1RRR R0t	exit_jsonR4RRR>(RR2R$tfssize_in_bytesR#tout((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pytgrow�s
$))*N(R'R(R6R<R5R7tLANG_ENVRtpropertyR0R3R;R>RB(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyR)ls				tExtcB`seZdZdZd�ZRS(s-Ft	resize2fscC`s�|jjddt�}|jj|dt|�gdtd|j�\}}}xu|j�D]g}d|kr�t|jd�dj	��}q^d	|kr^t|jd�dj	��}||Sq^WdS(
Nttune2fsRs-lRtenviron_updatesBlock count:t:isBlock size:(
RRRRR=RCt
splitlinesRtsplittstrip(RR2R:R#R%tlinetblock_countt
block_size((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyR3�s9"(R'R(R7R<R3(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyRE�stExt2cB`seZdZRS(s	mkfs.ext2(R'R(R5(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyRP�stExt3cB`seZdZRS(s	mkfs.ext3(R'R(R5(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyRQ�stExt4cB`seZdZRS(s	mkfs.ext4(R'R(R5(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyRR�stXFScB`s#eZdZdZdZd�ZRS(smkfs.xfss-ft
xfs_growfsc	C`s,|jjddt�}|jj|dt|�gdtd|j�\}}}x�|j�D]�}|jd�}|dj�dkr^|d	j�d
kr�|jj	dd�n|d
j�d	dkr�|jj	dd�nt
|d
j�d�}t
|djd�d�}||Sq^WdS(NRTRs-nRRHt=itdataitbsizeRsCUnexpected output format from xfs_growfs (could not locate "bsize")itblockssDUnexpected output format from xfs_growfs (could not locate "blocks")it,(RRRRR=RCRJRKRLRR(	RR2R:R#R%RMtcolRORN((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyR3�s9(R'R(R5R7R<R3(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyRS�stReiserfscB`seZdZdZRS(s
mkfs.reiserfss-f(R'R(R5R7(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyR[�stBtrfscB`seZdZd�ZRS(s
mkfs.btrfscC`s�tt|�j|�|jjd|jdt�\}}}tjd|�}|sktjd|�}n|r�t	|j
d��t	d�kr�d|_q�d|_n#d|_|jjd||f�dS(	Ns%s --versionRs v([0-9.]+)is3.12s-fR*s.Unable to identify mkfs.btrfs version (%r, %r)(
tsuperR\RRRR5RtretsearchRtgroupR7twarn(RRR#tstdouttstderrtmatch((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyR�s(!	(R'R(R5R(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyR\�stOcfs2cB`seZdZdZRS(s
mkfs.ocfs2s-Fx(R'R(R5R7(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyRe�stF2fscB`s,eZdZdZed��Zd�ZRS(s	mkfs.f2fssresize.f2fscC`s�|jj|jdt�}d|tjf}|jj|dtd|j�\}}}t	j
d|�}|dk	r�t|j
d��td�kr�dSnd	S(
NRs%s %sRRHs'F2FS-tools: mkfs.f2fs Ver: ([0-9.]+) \(is1.9.0s-fR*(RRR5RRtdevnullRR RCR^R_R6RR`(RR9R:R#RARd((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyR7�s*!cC`s|jjddt�}|jj|t|�gdtd|j�\}}}d}d}x�|j�D]f}d|kr�t|j	�d�}n%d|kr�t|j	�d�}nd||fkrgPqgqgW|jj
d	d
j|��|jjdd|�||S(
Ns	dump.f2fsRRRHsInfo: sector size = isInfo: total FS sectors = is'Unable to process dump.f2fs output '%s's
Rs)Unable to process dump.f2fs output for %s(
RRRRR=RCR6RJRRKRatjoinR(RR2R:R#tdumptsector_sizetsector_countRM((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyR3s6(R'R(R5R<RDR7R3(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyRf�stVFATcB`s>eZe�dkrdZndZdZd�Zd�ZRS(tFreeBSDtnewfs_msdoss	mkfs.vfatt	fatresizecC`s�|jj|jdt�}|jj|dt|�gdtd|j�\}}}xR|j�dD]@}|jdd�\}}|j	�dkret
|j	��SqeW|jjdd	|�dS(
NRs--infoRRHiRItSizeRs2fatresize failed to provide filesystem size for %s(RRR<RRR=RCRJRKRLRR(RR2R:R#toutputRMtparamtvalue((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyR3"s9cC`s:|jj|j�}|dt|j��t|j�gS(Ns-s(RRR<R=R%R
(RR2R:((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyR>+s(R'R(R
R5R<R3R>(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyRls			tLVMcB`s#eZdZdZdZd�ZRS(tpvcreates-ftpvresizec
C`sg|jjddt�}|jj|ddddddt|�gd	t�\}}}t|�}|S(
NtpvsRs--noheadingss-otpv_sizes--unitstbs
--nosuffixR(RRRRR=R(RR2R:R#R%RN((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyR35s?(R'R(R5R7R<R3(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyRt0stSwapcB`seZdZdZRS(tmkswaps-f(R'R(R5R7(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyRz<stext2text3text4text4devtf2fstreiserfstxfstbtrfstvfattocfs2tLVM2_membertswapcC`s�idd6}ttj��t|j��t|j��B}tdtdtdtddgdt|��d	tdtdd
g�dt�dtdd
dt�dtdd
dt��dt�}|j	d	}|j	d}|j	d}|j	d}|j	d}||kr ||}nt}yt|}	Wn+t
k
ra|jdtdd|�nXtj
j|�s�|jdd|�nt||�}|jddt�}
|jd|
|f�\}}}
|j�}|	|�}|otj|�t|k}|r/|r/|r/|jdt�n�|r�|r�|jsa|jdtdd|�n|j|�}|jdtd|�n6|r�|r�|jdd||fd|d|
�n|j||�t}|jd|�dS(NR�tlvmt
argument_specR0RtaliasesR/tchoicesR2tdeviceR8tforcetbooltdefaulttresizefstsupports_check_modeRRs1module does not support this filesystem (%s) yet.sDevice %s not found.tblkids#%s -c /dev/null -o value -s TYPE %ss3module does not support resizing %s filesystem yet.s6'%s' is already used as %s, use force=yes to overwritetrcterr(tsettFILESYSTEMStkeystvaluesR	tdictRtlistR tparamstKeyErrorRRR
texistsRRRRLtgetR?R<RBR;(tfriendly_namestfstypesRR2R0R8R�R�RtklassR:R�traw_fsR�tfst
filesystemtsame_fsRA((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pytmainQsX
2		






"	
)t__main__(#t
__future__RRRR/t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStdistutils.versionRRR^Rtansible.module_utils.basicR	R
tobjectRR)RERPRQRRRSR[R\ReRfRlRtRzR�R�R'(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.pyt<module>sR


4
4+
	D

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]