Current File : //lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pyc
�
oB�]c@s�dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZddlm
Z
ddlmZdZe
ZdgZi	d	d
6dd6d
d6ed�d6ed6dgd6e
d6dd6iieeegd6ed�d6d6d6Ze
e�Zd�Zd�Zd�Zd�Zd�Zd �Zd!�Zd"�Zd#efd$efd%efd&efd'efgZied&6Zd(�Z d)�Z!d*�Z"d+�Z#dS(,s:Resizefs: cloud-config module which resizes the filesystemi����N(tdedent(tget_schema_doctvalidate_cloudconfig_schema(t
PER_ALWAYS(tutiltnoblocktalltcc_resizefstidtResizefstnamesResize filesystemttitles�        Resize a filesystem to use all avaliable space on partition. This
        module is useful along with ``cc_growpart`` and will ensure that if the
        root partition has been resized the root filesystem will be resized
        along with it. By default, ``cc_resizefs`` will resize the root
        partition and will block the boot process while the resize command is
        running. Optionally, the resize operation can be performed in the
        background while cloud-init continues running modules. This can be
        enabled by setting ``resize_rootfs`` to ``true``. This module can be
        disabled altogether by setting ``resize_rootfs`` to ``false``.tdescriptiontdistross@resize_rootfs: false  # disable root filesystem resize operationtexamplest	frequencytobjectttypetenumsE                Whether to resize the root partition. Default: 'true't
resize_rootfst
propertiescCsTtj|�r=tjjd|�r=ddddd|fSdddd|fSdS(Ns
%s/.snapshotstbtrfst
filesystemtresizetmax(Rtmount_is_read_writetostpathtisdir(tmount_pointtdevpth((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pyt
_resize_btrfs<s
cCs
d|fS(Nt	resize2fs((RR((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pyt_resize_extJscCs
d|fS(Nt
xfs_growfs((RR((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pyt_resize_xfsNscCs
dd|fS(Ntgrowfss-y((RR((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pyt_resize_ufsRscCsddd||fS(Ntzpooltonlines-e((RR((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pyt_resize_zfsVscCstjdd|g�dS(Ntdumpfss-mi(Rtsubp(R((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pyt_get_dumpfs_outputZscCstjdd|g�dS(Ntgparttshowi(RR*(tpart((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pyt_get_gpart_output^scCs^d	}d	}t|�}x�|j�D]�}|jd�s%tj|�}d}tj|d|�\}}	xM|D]B\}
}|
dkr�t|�}n|
dkrrt|�}qrqrWq%q%Wd	}tj	d|�}
t
|
jd��}xE|j�D]7}tj	d|�r�|j�}t|d�}q�q�W|||d}||krVtSt
Sd	S(
s�
    # dumpfs -m /
    # newfs command for / (/dev/label/rootfs)
      newfs -L rootf -O 2 -U -a 4 -b 32768 -d 32768 -e 4096 -f 4096 -g 16384
            -h 64 -i 8192 -j -k 6408 -m 8 -o time -s 58719232 /dev/label/rootf
    t#sO:Ua:s:b:d:e:f:g:h:i:jk:m:o:L:is-ss-fs^(/dev/.+)p([0-9])$sfreebsd-ufsiN(tNoneR+t
splitlinest
startswithtshlextsplittgetopttinttretsearchR/tgrouptTruetFalse(RRt	cur_fs_sztfrag_szt
dumpfs_restlinet	newfs_cmdt	opt_valuetoptlistt_argstotat	expect_sztmt	gpart_restfieldstnormal_expect_sz((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pyt_can_skip_resize_ufsbs0
RtexttxfstufstzfscCsI|j�}x6tj�D](\}}|j|�r|||�SqWtS(N(tlowertRESIZE_FS_PRECHECK_CMDStitemsR3R<(tfs_typetresize_whatRt	fstype_lctitfunc((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pytcan_skip_resize�s
c	Cs�tj�}|dkrwtjj|�rw|rwtjtj��}|dkrd|jd�dS|j	d|�n|dkr�|j	d||�dS|j
d�r�|j	d�|S|j
d�rtjj|�rd|jd	�}|j	d
||�|}nytj|�}Wnpt
k
r�}|r_|jtjkr_|j	d||�n.|jtjkr�|jd||�n|�dSXtj|j�r�tj|j�r�|r�|j	d
||f�n|jd||f�dS|S(s�Return updated devpath if the devpath is a writable block device.

    @param devpath: Requested path to the root device we want to resize.
    @param info: String representing information about the requested device.
    @param log: Logger to which logs will be added upon error.

    @returns devpath or updated devpath per kernel commandline if the device
        path is a writable block device, returns None otherwise.
    s	/dev/roots!Unable to find device '/dev/root's.Converted /dev/root to '%s' per kernel cmdlinetoverlayroots)Not attempting to resize devpath '%s': %ssgpt/s#We have a gpt label - just go aheads/dev/t/s:'%s' doesn't appear to be a valid device path. Trying '%s's9Device '%s' did not exist in container. cannot resize: %ss,Device '%s' did not exist. cannot resize: %ss>device '%s' not a block device in container. cannot resize: %ss1device '%s' not a block device. cannot resize: %sN(Rtis_containerRRtexiststrootdev_from_cmdlinetget_cmdlineR1twarningtdebugR3tlstriptstattOSErrorterrnotENOENTtS_ISBLKtst_modetS_ISCHR(tdevpathtinfotlogt	containertfulldevpathtstatrettexc((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pytmaybe_get_writable_device_path�sL


#	
		
	
&		cCs�t|�dkr|d}ntj|dt�}t|t�tj|dtg�sm|jd|�dSd}tj	||�}|s�|j
d|�dS|\}}	}
|	dkr�|jd�d}tj|�}|s�dS|}nd||
|f}|jd	|�t
|||�}|s/dSd}
t|	||�r^|jd
|	|�dS|	j�}x-tD]%\}}|j|�rq|}
PqqqqW|
s�|j
d|	|�dS|
||�}|jd||	d
j|��|tkr%tjtjd|jdddtd||f�n+tjd|jdddtd||f�d}|tkrkd}n|jd||	|�dS(NiRtaddonss+Skipping module named %s, resizing disabledR[s)Could not determine filesystem type of %sRPsdev=%s mnt_point=%s path=%ssresize_info: %ss%Skip resize filesystem type %s for %ss.Not resizing unknown filesystem type %s for %ssResizing %s (%s) using %st tlogfunctmsgsbackgrounded ResizingRXtargstResizingtResizedsResizing (via forking)s$%s root filesystem (type=%s, val=%s)(tlenRtget_cfg_option_strR;Rtschemattranslate_booltNOBLOCKRatget_mount_infoR`R5tget_device_info_from_zpoolRqR1RYRQtRESIZE_FS_PREFIXES_CMDSR3tjointfork_cbtlog_timet	do_resize(R
tcfgt_cloudRlRvtresize_rootRUtresultRRTRR&RktresizerRVtpfixtroot_cmdt
resize_cmdtaction((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pythandle�sh

		
	
	cCsBytj|�Wn*tjk
r=tj|d|��nXdS(Ns$Failed to resize filesystem (cmd=%s)(RR*tProcessExecutionErrortlogexc(R�Rl((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pyR�3s
($t__doc__ReR6RR8R4RcttextwrapRtcloudinit.config.schemaRRtcloudinit.settingsRt	cloudinitRR}RR
R;R<R{RR!R#R%R(R+R/RLR�RRRYRqR�R�(((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pyt<module>	s`		

								2				
		?	L