ó oBú]c@s×dZddlZddlZddlZddlZddlZddlZddlmZddl m Z m Z ddl m Z ddlmZdZe ZdgZi d d 6d d 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(tutiltnoblocktallt cc_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``.t descriptiontdistross@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(t mount_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 | j dƒƒ}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])$s freebsd-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_typet resize_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|j d ƒ}|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 cmdlinet overlayroots)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_cmdlinet get_cmdlineR1twarningtdebugR3tlstriptstattOSErrorterrnotENOENTtS_ISBLKtst_modetS_ISCHR(tdevpathtinfotlogt containert fulldevpathtstatrettexc((s@/usr/lib/python2.7/site-packages/cloudinit/config/cc_resizefs.pytmaybe_get_writable_device_path¨sL     #       &  c Cs…t|ƒdkr|d}ntj|dtƒ}t|tƒtj|dtgƒsm|jd|ƒdSd}tj ||ƒ}|sŸ|j d|ƒdS|\}} } | dkrï|j dƒ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_cloudRlRvt resize_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 s`                  2       ? L