3 \me* @ sd U d Z ddlZddlZddlZddlZddlmZ ddlmZm Z ddl mZ ddlm Z ddlmZmZ ddlmZ dd lmZ d Zddd edegddgeg dZeeeZ ejeZdd Zdd Zdd Zdd Zdd Zdd Zdd Z d d! Z!d"efd#efd$efd%efd&efd'efd(e fgZ"d%e!iZ#d)d* Z$d+d, Z%e&e ee'dd-d.d/Z(d0d1 Z)dS )2z:Resizefs: cloud-config module which resizes the filesystem N)dedent)subputil)Cloud)Config) MetaSchemaget_meta_doc)ALL_DISTROS) PER_ALWAYSZnoblockZcc_resizefsZResizefszResize filesystema 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 ``noblock``. This module can be disabled altogether by setting ``resize_rootfs`` to ``false``.z@resize_rootfs: false # disable root filesystem resize operationzAresize_rootfs: noblock # runs resize operation in the background)idnametitledescriptionZdistrosZexamplesZ frequencyZactivate_by_schema_keysc C s t j| r0tjjd| r0ddddd| g}ndddd| g}t jjd}t jjtjddgd jd d j }||kr|j d}|j|d d t|S ) Nz %s/.snapshotsbtrfsZ filesystemresizemaxz5.10z --versionr v z --enqueue) r Zmount_is_read_writeospathisdirZVersionZfrom_strr splitstripindexinserttuple)mount_pointdevpthcmdZbtrfs_with_queueZsystem_btrfs_veridx r! !/usr/lib/python3.6/cc_resizefs.py _resize_btrfs8 s " r# c C s d|fS )NZ resize2fsr! )r r r! r! r" _resize_extY s r$ c C s d| fS )NZ xfs_growfsr! )r r r! r! r" _resize_xfs] s r% c C s dd| fS )Ngrowfsz-yr! )r r r! r! r" _resize_ufsa s r' c C s ddd| |fS )NzpoolZonlinez-er! )r r r! r! r" _resize_zfse s r) c C s dd| fS )Nhammer2r&