
    Vh2h                     
   d dl mZmZmZ eZdZdZd dlZd dl	Z	d dl
Z
d dlZd dlmZ d dlmZ d dlmZ  G d d	e      Z G d
 de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d  d!e      Z G d" d#e      Z  G d$ d%e      Z! G d& d'e      Z"eeeeeeeeeeee e!e"d(Z#d) Z$e%d*k(  r e$        yy)+    )absolute_importdivisionprint_functionaN  
author:
  - Alexander Bulimov (@abulimov)
  - quidame (@quidame)
module: filesystem
short_description: Makes a filesystem
description:
  - This module creates a filesystem.
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  state:
    description:
      - If O(state=present), the filesystem is created if it does not already exist, that is the default behaviour if O(state)
        is omitted.
      - If O(state=absent), filesystem signatures on O(dev) are wiped if it contains a filesystem (as known by C(blkid)).
      - When O(state=absent), all other options but O(dev) are ignored, and the module does not fail if the device O(dev)
        does not actually exist.
    type: str
    choices: [present, absent]
    default: present
    version_added: 1.3.0
  fstype:
    choices: [bcachefs, btrfs, ext2, ext3, ext4, ext4dev, f2fs, lvm, ocfs2, reiserfs, xfs, vfat, swap, ufs]
    description:
      - Filesystem type to be created. This option is required with O(state=present) (or if O(state) is omitted).
      - Ufs support has been added in community.general 3.4.0.
      - Bcachefs support has been added in community.general 8.6.0.
    type: str
    aliases: [type]
  dev:
    description:
      - Target path to block device (Linux) or character device (FreeBSD) or regular file (both).
      - When setting Linux-specific filesystem types on FreeBSD, this module only works when applying to regular files, aka
        disk images.
      - Currently V(lvm) (Linux-only) and V(ufs) (FreeBSD-only) do not support a regular file as their target O(dev).
      - Support for character devices on FreeBSD has been added in community.general 3.4.0.
    type: path
    required: true
    aliases: [device]
  force:
    description:
      - If V(true), allows to create new filesystem on devices that already has filesystem.
    type: bool
    default: false
  resizefs:
    description:
      - If V(true), if the block device and filesystem size differ, grow the filesystem into the space.
      - Supported for C(bcachefs), C(btrfs), C(ext2), C(ext3), C(ext4), C(ext4dev), C(f2fs), C(lvm), C(xfs), C(ufs) and C(vfat)
        filesystems. Attempts to resize other filesystem types will fail.
      - XFS Will only grow if mounted. Currently, the module is based on commands from C(util-linux) package to perform operations,
        so resizing of XFS is not supported on FreeBSD systems.
      - VFAT will likely fail if C(fatresize < 1.04).
      - Mutually exclusive with O(uuid).
    type: bool
    default: false
  opts:
    description:
      - List of options to be passed to C(mkfs) command.
    type: str
  uuid:
    description:
      - Set filesystem's UUID to the given value.
      - The UUID options specified in O(opts) take precedence over this value.
      - See xfs_admin(8) (C(xfs)), tune2fs(8) (C(ext2), C(ext3), C(ext4), C(ext4dev)) for possible values.
      - For O(fstype=lvm) the value is ignored, it resets the PV UUID if set.
      - Supported for O(fstype) being one of C(bcachefs), C(ext2), C(ext3), C(ext4), C(ext4dev), C(lvm), or C(xfs).
      - This is B(not idempotent). Specifying this option will always result in a change.
      - Mutually exclusive with O(resizefs).
    type: str
    version_added: 7.1.0
requirements:
  - Uses specific tools related to the O(fstype) for creating or resizing a filesystem (from packages e2fsprogs, xfsprogs,
    dosfstools, and so on).
  - Uses generic tools mostly related to the Operating System (Linux or FreeBSD) or available on both, as C(blkid).
  - On FreeBSD, either C(util-linux) or C(e2fsprogs) package is required.
notes:
  - Potential filesystems on O(dev) are checked using C(blkid). In case C(blkid) is unable to detect a filesystem (and in
    case C(fstyp) on FreeBSD is also unable to detect a filesystem), this filesystem is overwritten even if O(force) is V(false).
  - On FreeBSD systems, both C(e2fsprogs) and C(util-linux) packages provide a C(blkid) command that is compatible with this
    module. However, these packages conflict with each other, and only the C(util-linux) package provides the command required
    to not fail when O(state=absent).
seealso:
  - module: community.general.filesize
  - module: ansible.posix.mount
  - name: xfs_admin(8) manpage for Linux
    description: Manual page of the GNU/Linux's xfs_admin implementation.
    link: https://man7.org/linux/man-pages/man8/xfs_admin.8.html
  - name: tune2fs(8) manpage for Linux
    description: Manual page of the GNU/Linux's tune2fs implementation.
    link: https://man7.org/linux/man-pages/man8/tune2fs.8.html
a  
- name: Create a ext2 filesystem on /dev/sdb1
  community.general.filesystem:
    fstype: ext2
    dev: /dev/sdb1

- name: Create a ext4 filesystem on /dev/sdb1 and check disk blocks
  community.general.filesystem:
    fstype: ext4
    dev: /dev/sdb1
    opts: -cc

- name: Blank filesystem signature on /dev/sdb1
  community.general.filesystem:
    dev: /dev/sdb1
    state: absent

- name: Create a filesystem on top of a regular file
  community.general.filesystem:
    dev: /path/to/disk.img
    fstype: vfat

- name: Reset an xfs filesystem UUID on /dev/sdb1
  community.general.filesystem:
    fstype: xfs
    dev: /dev/sdb1
    uuid: generate

- name: Reset an ext4 filesystem UUID on /dev/sdb1
  community.general.filesystem:
    fstype: ext4
    dev: /dev/sdb1
    uuid: random

- name: Reset an LVM filesystem (PV) UUID on /dev/sdc
  community.general.filesystem:
    fstype: lvm
    dev: /dev/sdc
    uuid: random
N)AnsibleModule)	to_native)LooseVersionc                   $    e Zd Zd Zd Zd Zd Zy)Devicec                      || _         || _        y N)modulepath)selfr   r   s      p/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/filesystem.py__init__zDevice.__init__   s    	    c                 V   t        j                  | j                        }t        j                  |j                        rX| j
                  j                  dd      }| j
                  j                  |d| j                  gd      \  }}}t        |      }|S t        j                  |j                        rt        j                         dk(  rh| j
                  j                  dd      }| j
                  j                  || j                  gd      \  }}}t        |j                         d         }|S t         j                  j                  | j                        r+t         j                  j                  | j                        }|S | j
                  j                  d	d
| z         S )z- Return size in bytes of device. Returns int blockdevTrequiredz--getsize64check_rcFreeBSDdiskinfo   FzTarget device not supported: %schangedmsg)osstatr   S_ISBLKst_moder   get_bin_pathrun_commandintS_ISCHRplatformsystemsplitisfilegetsize	fail_json)r   statinfoblockdev_cmddummyoutdevsize_in_bytesdiskinfo_cmds          r   sizezDevice.size   s]   77499%<<(();;33J3NL $ 7 7}VZV_V_8`ko 7 pE3"3x   \\(**+0AY0N;;33J3NL $ 7 7tyy8Q\` 7 aE3"399;q>2   WW^^DII&!wwtyy9   KK!!%5VY]5]!^r   c           	          | j                   j                  dd      }| j                   j                  |ddddd| j                  gd	
      \  }}}|dk7  rd}|S |j	                  d      d   }|S )zCReturn (first) mountpoint of device. Returns None when not mounted.findmntTr   z--mtab--noheadingsz--outputTARGETz--sourceFr   r   N
)r   r#   r$   r   r)   )r   cmd_findmntrc
mountpointr/   s        r   get_mountpointzDevice.get_mountpoint   s    kk..y4.H !% 7 7hP^`j8@*dii9Ych !8 !jJ7J  $))$/2Jr   c                     | j                   S r   )r   r   s    r   __str__zDevice.__str__   s    yyr   N)__name__
__module____qualname__r   r3   r<   r?    r   r   r
   r
      s     $r   r
   c                       e Zd ZdZg ZdZg ZdZdZg Z	dZ
dZdZdZddddZd Zed        Zd Zdd	Zd
 Zd Zd Zd Zd Zy)
FilesystemNFTC)LANGLC_ALLLC_MESSAGESc                     || _         y r   )r   )r   r   s     r   r   zFilesystem.__init__   s	    r   c                 ,    t        |       j                  S r   )typer@   r>   s    r   fstypezFilesystem.fstype   s    Dz"""r   c                     t               )a)  Return size in bytes of filesystem on device (integer).
           Should query the info with a per-fstype command that can access the
           device whenever it is mounted or not, and parse the command output.
           Parser must ensure to return an integer, or raise a ValueError.
        )NotImplementedError)r   devs     r   get_fs_sizezFilesystem.get_fs_size   s     "##r   c                    | j                   j                  ry |rN| j                  rBt        | j                        t        |      z  s!|| j                  d   |g| j                  z   z  }| j                   j                  | j                  d      }|g| j                  z   |z   t        |      gz   }| j                   j                  |d       |r.| j                  r!| j                  | j                  ||       y y y y )Nr   Tr   r   new_uuidrP   )r   
check_modeMKFS_SET_UUID_OPTIONSsetMKFS_SET_UUID_EXTRA_OPTIONSr#   MKFSMKFS_FORCE_FLAGSstrr$   CHANGE_UUIDchange_uuid)r   optsrP   uuidmkfscmds         r   createzFilesystem.create   s    ;;!!D..223c$i?33A6=@`@```{{''		D'Aft,,,t3s3xj@d3D$$)C)C)Kd4 *L$4r   c                     | j                   j                  ry | j                   j                  dd      }|dt        |      g}| j                   j	                  |d       y )NwipefsTr   z--allr   )r   rU   r#   r[   r$   )r   rP   rd   ra   s       r   rd   zFilesystem.wipefs   sT    ;;!! ))(T)BwC)d3r   c                 |    | j                   j                  | j                  d      g}|| j                  |gz   z  }|S )z2Build and return the resizefs commandline as list.Tr   )r   r#   GROWGROW_MAX_SPACE_FLAGS)r   targetcmdlines      r   grow_cmdzFilesystem.grow_cmd  s>    ;;++DII+EF4,,x77r   c           	         |j                         }	 | j                  |      }|k  s-| j                  j                  d| j
                  d	|
       nC| j                  j                  r-| j                  j                  dd| j
                  d|
       | j                  rA|j                         }|s,| j                  j	                  |d| j
                  d       |}nt        |      }| j                  j                  | j!                  |      d      \  }}}|S # t        $ r- | j                  j	                  d| j
                  z         Y 4t        $ rl}| j                  j                  d| j                  dt        |      d       | j                  j	                  d| j                  d|       Y d}~d}~ww xY w)z@Get dev and fs size and compare. Returns stdout of used command.z2module does not support resizing %s filesystem yetr   zunable to process z	 output ''z output for NFz& filesystem is using the whole device r   Tzresizing filesystem z on device  needs to be mounted for  operationsr   )r3   rQ   rO   r   r,   rM   
ValueErrorwarnINFOr   	exit_jsonrU   GROW_MOUNTPOINT_ONLYr<   r[   r$   rj   )	r   rP   r1   fssize_in_byteserrr;   grow_targetr/   r0   s	            r   growzFilesystem.grow  s~   88:	_"..s3O !11KK!!%eiepepru5v!w[[##KK!!$]a]h]hjm4n!o$$++-J%%X[]a]h]h*i%j$Kc(K KK33DMM+4NY]3^sE
) # 	jKK!!&Z]a]h]h&h!i 	_KK499iX[n]^KK!!diiY\&]!^^	_s   D" "2GGA!GGc                     | j                   j                  | j                  d      g}| j                  r|| j                  ||gz  }|S || j                  |gz  }|S )z6Build and return the UUID change command line as list.Tr   )r   r#   r\   CHANGE_UUID_OPTION_HAS_ARGCHANGE_UUID_OPTION)r   rT   rh   ri   s       r   change_uuid_cmdzFilesystem.change_uuid_cmd(  sg    ;;++D,<,<t+LM**//6BBG  //88Gr   c                    | j                   j                  r-| j                   j                  dd| j                  d|       | j                   j	                  | j                  |t        |            d      \  }}}|S )z6Change filesystem UUID. Returns stdout of used commandTz	Changing z filesystem UUID on device )changer   )rT   rh   r   )r   rU   rs   rM   r$   r|   r[   )r   rT   rP   r/   r0   s        r   r]   zFilesystem.change_uuid1  sq    ;;!!KK!!aealalnq3r!s KK33D4H4HRZcfgjck4H4lw{3|sE
r   r   )r@   rA   rB   rY   rZ   rV   rX   rr   rf   rg   rt   r\   r{   rz   LANG_ENVr   propertyrM   rQ   rb   rd   rj   rx   r|   r]   rC   r   r   rE   rE      s    D "$DD K!%s3?H # #$548r   rE   c                   .    e Zd ZdgZdgZdZdZdZdZd Z	y)Extz-F-Utune2fs	resize2fsc                    | j                   j                  | j                  d      }| j                   j                  |dt	        |      gd| j
                        \  }}}dx}}|j                         D ]m  }d|v r,t        |j                  d      d   j                               }n/d	|v r+t        |j                  d      d   j                               }d||fvsi ||z  S  t        t        |            )
z8Get Block count and Block size and return their product.Tr   z-lr   environ_updateNzBlock count::   zBlock size:)r   r#   rr   r$   r[   r   
splitlinesr%   r)   striprp   repr)r   rP   ra   r/   r0   block_count
block_sizelines           r   rQ   zExt.get_fs_sizeB  s    kk&&tyy4&@ KK33S$C4ITXimiviv3wsE#''jNN$ 	(D%!$**S/!"4":":"<=$& C!3!9!9!;<
J44 K''	( T#Y''r   N)
r@   rA   rB   rZ   rV   rr   rf   r\   r{   rQ   rC   r   r   r   r   :  s,    v!FDDK(r   r   c                       e Zd ZdZy)Ext2z	mkfs.ext2Nr@   rA   rB   rY   rC   r   r   r   r   U      Dr   r   c                       e Zd ZdZy)Ext3z	mkfs.ext3Nr   rC   r   r   r   r   Y  r   r   r   c                       e Zd ZdZy)Ext4z	mkfs.ext4Nr   rC   r   r   r   r   ]  r   r   r   c                   0    e Zd ZdZdgZdZdZdZdZdZ	d Z
y	)
XFSzmkfs.xfs-fxfs_info
xfs_growfsT	xfs_adminr   c                    | j                   j                  | j                  d      g}|j                         }|r||gz  }n|t	        |      gz  }| j                   j                  |d| j                        \  }}}dx}}|j                         D ]  }|j                  d      }	|	d   j                         dk(  rn|	d   j                         d	k(  rt        |	d
   j                         d         }|	d
   j                         d   dk(  r t        |	d   j                  d      d         }d||fvs ||z  S  t        t        |            )z.Get bsize and blocks and return their product.Tr   r   N=r   datar   bsizer   blocks   ,)r   r#   rr   r<   r[   r$   r   r   r)   r   r%   rp   r   )
r   rP   ri   r;   r/   r0   r   r   r   cols
             r   rQ   zXFS.get_fs_sizej  sE   ;;++DII+EF '')

|#GCz!G KK33Gd[_[h[h3isE#''
[NN$ 
	(D**S/C1v||~'q6<<>W,!$SV\\^A%6!7Jq6<<>!$0"%c!fll3&7&:";KJ44 K''
	( T#Y''r   N)r@   rA   rB   rY   rZ   rr   rf   rt   r\   r{   rQ   rC   r   r   r   r   a  s/    DvDDK(r   r   c                       e Zd ZdZdgZy)Reiserfszmkfs.reiserfsz-qNr@   rA   rB   rY   rZ   rC   r   r   r   r     s    Dvr   r   c                   4    e Zd ZdZdgZddgZdZdZddgZd Z	y	)
Bcachefszmkfs.bcachefsz--forcer   --uuidbcachefsdeviceresizec                 .   | j                   j                  | j                   j                  | j                        dt	        |      gd      \  }}}|j                         D ]}  }d|v s|j                         }|d   }d}d}g d}	g d}
	 |	j                  |      }d	}|dk(  rt        |d         }nt        |d         }|b|et        |t        ||      z        c S  t        t        |            # t        $ r |
j                  |      }d
}Y uw xY w)7Return size in bytes of filesystem on device (integer).z
show-superTr   zSize: r   N)	BKiBMiBGiBTiBPiBEiBZiBYiB)	r   kBMBGBTBPBEBZBYBi   i  r   r   )r   r$   r#   rr   r[   r   r)   indexrp   r%   floatpowr   )r   rP   r/   stdoutr   partsunitbaseexpunits_2units_10values               r   rQ   zBcachefs.get_fs_size  s'   #{{668P8PQUQZQZ8[8Dc#h8PZ^  7  `vu %%' 	7D4

QxWP !---CD
 !8aME!%(OE#us4~5661	74 f&& "  "...CD s   C55DDN)
r@   rA   rB   rY   rZ   rV   rr   rf   rg   rQ   rC   r   r   r   r     s4    D!{!8,DD$h/'r   r   c                   <     e Zd ZdZdZdZg dZdZ fdZd Z	 xZ
S )Btrfsz
mkfs.btrfsbtrfs)
filesystemr   maxTc                    t         t        |   |       | j                  j	                  | j
                  d      }| j                  j                  |dgd      \  }}}t        j                  d|      }|st        j                  d|      }|r0t        |j                  d            t        d      k\  r	dg| _        y y dg| _        | j                  j                  d	|d
|d       y )NTr   z	--versionr   z v([0-9.]+)r   z3.12r   z'Unable to identify mkfs.btrfs version (z, ))superr   r   r   r#   rY   r$   researchr   grouprZ   rq   )r   r   r`   r/   r   stderrmatch	__class__s          r   r   zBtrfs.__init__  s    eT#F+{{''		D'A $ 7 7{8KVZ 7 [vv		.&1IInf5EEKKN+|F/CC)-% D &*FD!KKQWY_`ar   c                    |j                         }|s,| j                  j                  |d| j                  d       | j                  j	                  | j                  j                  | j                        ddd|gd      \  }}}|j                         D ]$  }d	|v st        |j                         d
         c S  t        t        |            )r   rn   ro   rl   r   usagez-bTr   zDevice size)r<   r   r,   rM   r$   r#   rr   r   r%   r)   rp   r   )r   rP   r;   r/   r   r   s         r   rQ   zBtrfs.get_fs_size  s    '')
KK!!TWY]YdYd&e!f#{{668P8PQUQZQZ8[8DgtU_8ako  7  qvu%%' 	-D$4::<+,,	- f&&r   )r@   rA   rB   rY   rr   rf   rg   rt   r   rQ   __classcell__r   s   @r   r   r     s)    DDD:b"'r   r   c                       e Zd ZdZdgZy)Ocfs2z
mkfs.ocfs2z-FxNr   rC   r   r   r   r     s    Dwr   r   c                   0     e Zd ZdZdZdZ fdZd Z xZS )F2fsz	mkfs.f2fsz	dump.f2fszresize.f2fsc                    t         t        |   |       | j                  j	                  | j
                  d      }| j                  j                  |t        j                  gd| j                        \  }}}t        j                  d|      }|0t        |j                  d            t        d      k\  r	dg| _        y y y )	NTr   Fr   z'F2FS-tools: mkfs.f2fs Ver: ([0-9.]+) \(r   z1.9.0r   )r   r   r   r   r#   rY   r$   r   devnullr   r   r   r   r   rZ   )r   r   r`   r/   r0   r   r   s         r   r   zF2fs.__init__  s    dD"6*{{''		D'A KK33T2::4FQVgkgtgt3usE 		DcJ EKKN+|G/DD)-% E r   c                    | j                   j                  | j                  d      }| j                   j                  |t	        |      gd| j
                        \  }}}dx}}|j                         D ]O  }d|v rt        |j                         d         }n d|v rt        |j                         d         }d||fvsK ||z  S  t        t        |            )	z>Get sector size and total FS sectors and return their product.Tr   r   NzInfo: sector size =    zInfo: total FS sectors =    )r   r#   rr   r$   r[   r   r   r%   r)   rp   r   )r   rP   ra   r/   r0   sector_sizesector_countr   s           r   rQ   zF2fs.get_fs_size  s    kk&&tyy4&@ KK33S#c(Odcgcpcp3qsE%))lNN$ 
	(D%-!$**,q/2,4"4::<?3K66 \))
	( T#Y''r   )	r@   rA   rB   rY   rr   rf   r   rQ   r   r   s   @r   r   r     s    DDD/*r   r   c                   4     e Zd ZdZdZddgZ fdZd Z xZS )VFAT	fatresize-sr   c                 x    t         t        |   |       t        j                         dk(  rd| _        y d| _        y )Nr   newfs_msdosz	mkfs.vfat)r   r   r   r'   r(   rY   )r   r   r   s     r   r   zVFAT.__init__  s/    dD"6*??	)%DI#DIr   c                    | j                   j                  | j                  d      }| j                   j                  |dt	        |      gd| j
                        \  }}}d}|j                         dd D ]V  }|j                  dd      }t        |      dk  r$|\  }}	|j                         d	v s<t        |	j                               } |S  t        t        |            )
z,Get and return size of filesystem, in bytes.Tr   z--infor   Nr   r   r   )SizezCur size)r   r#   rr   r$   r[   r   r   r)   lenr   r%   rp   r   )
r   rP   ra   r/   r0   fssizer   r   paramr   s
             r   rQ   zVFAT.get_fs_size  s    kk&&tyy4&@ KK33S(CH4MX\mqmzmz3{sENN$QR( 		(DJJsA&E5zA~ LE5{{} 44U[[]+ 		( T#Y''r   )	r@   rA   rB   rr   rf   rg   r   rQ   r   r   s   @r   r   r   
  s!    DD %=$r   r   c                   >    e Zd ZdZdgZddgZdgZdZdZdZ	dZ
d	Zd
 Zy)LVMpvcreater   z-ur   z--norestorefilepvspvresizepvchangeFc                     | j                   j                  | j                  d      }| j                   j                  |ddddddt	        |      gd	      \  }}}t        |      }|S )
z!Get and return PV size, in bytes.Tr   r6   -opv_sizez--unitsbz
--nosuffixr   )r   r#   rr   r$   r[   r%   )r   rP   ra   r/   r3   r   s         r   rQ   zLVM.get_fs_size4  s|    kk&&tyy4&@![[44c>4QZ\egjlxz}  B  {C  6D  OS4  TtUd)r   N)r@   rA   rB   rY   rZ   rV   rX   rr   rf   r\   r{   rz   rQ   rC   r   r   r   r   )  sC    Dv!8,#4"5DDK!&r   r   c                       e Zd ZdZdgZy)Swapmkswapr   Nr   rC   r   r   r  r  <  s    Dvr   r  c                   $    e Zd ZdZdZdZdgZd Zy)UFSnewfsdumpfsgrowfsz-yc                    | j                   j                  | j                  d      }| j                   j                  |t	        |      gd| j
                        \  }}}dx}}|j                         D ]\  }|j                  d      rt        |j                         d         }n d|v rt        |j                         d         }d||fvsX ||z  S  t        t        |            )	z<Get providersize and fragment size and return their product.Tr   r   Nfsizer   providersizer   )r   r#   rr   r$   r[   r   r   
startswithr%   r)   rp   r   )r   rP   ra   r/   r0   fragmentsizer  r   s           r   rQ   zUFS.get_fs_sizeG  s    kk&&tyy4&@ KK33S#c(Odcgcpcp3qsE&**|NN$ 	(Dw'"4::<?34'"4::<#34L,77 l**	( T#Y''r   N)r@   rA   rB   rY   rr   rf   rg   rQ   rC   r   r   r  r  A  s    DDD 6+r   r  )r   ext2ext3ext4ext4devf2fsreiserfsxfsr   vfatocfs2LVM2_memberswapufsc                     ddi} t        t        j                               t        | j                               z
  t        | j                               z  }t	        t        t        ddddg      t        ddgt        |            t        d	d
dg      t        d      t        dd      t        dd      t        dd            dddgfgdgd
      }|j                  d   }|j                  d   }|j                  d   }|j                  d   }|j                  d   }|j                  d   }|j                  d   }	g }
||j                         }
d}t        j                  j                  |      s/d|z  }|dk(  r|j                  |       n|j                  |       t        ||      }|j                  dd
      }|j!                  |d t        j"                  d!d"d#d$t%        |      g      \  }}}|j'                         }|sZt)        j*                         d%k(  rC|j                  d&d
      }|j!                  |t%        |      g      \  }}}|j'                         }|dk(  r3|| v r| |   }	 t        |   } |      }|	r.|j.                  s"|j0                  s|j                  dd)|z  (       |xr t        j3                  |      t        |   k(  }|r|s|	s|s|j                  d*       n|rr|rG|j4                  s|j                  dd+|z  (       |j7                  |      }|j                  d
|(       nH|	rF|j9                  |	|,      }|j                  d
|(       n|r|s|j                  d-|d.|d/||0       |j;                  |
||	1       d
}n |rt=        |      }|j?                  |       d
}|j                  |*       y # t,        $ r |j                  dd'|z  (       Y uw xY w)2Nlvmr  r[   presentabsent)rL   defaultchoicesrL   )rL   aliasesr  r   Tr   )rL   r   r   )rL   boolF)rL   r  )rL   r   )staterM   rP   r^   forceresizefsr_   r"  rM   )r$  r_   )argument_specrequired_ifmutually_exclusivesupports_check_moderP   r^   r#  r$  r_   zDevice %s not found.rl   blkidr   z-cr   r   r   TYPEr   fstypz1module does not support this filesystem (%s) yet.r   zAmodule does not support UUID option for this filesystem (%s) yet.)r   z3module does not support resizing %s filesystem yet.rS   rm   z' is already used as z, use force=true to overwrite)r   r:   rv   )r^   rP   r_   ) rW   FILESYSTEMSkeysvaluesr   dictlistparamsr)   r   r   existsr,   rs   r
   r#   r$   r   r[   r   r'   r(   KeyErrorr\   rV   getrf   rx   r]   rb   rE   rd   )friendly_namesfstypesr   r"  rP   rM   r^   r#  r$  r_   	mkfs_optsr   r   ra   r:   raw_fsrv   fsklassr   same_fsr0   s                         r   mainr<  l  s   }N +""$%N,A,A,C(DDs>K^K^K`GaaG E9y(>STUVHd7mL&4(D5!FE2vu5551
 i(,
 !
 !!F& MM'"E
--
C]]8$F== DMM'"E}}Z(H== DIJJL	G77>>#$s*I%%

C
 

g

5C((#tRZZwPTV\^abe^f)ghOB	B(//#y0!!'D!9 ,,c3s8_=FC\\^	^##F+F	n'E 6]
//:3S3SU0sv|0|}C,F0CC8DU+!$$U8mpv8v$w ooc*  3 7 ,,d,D  3 7^ace!fkmsvw 	yc=	'
#
W%K  	nU0cfl0lm	ns   3	O O21O2__main__)&
__future__r   r   r   rL   __metaclass__DOCUMENTATIONEXAMPLESr   r'   r   r    ansible.module_utils.basicr   +ansible.module_utils.common.text.convertersr   Bansible_collections.community.general.plugins.module_utils.versionr   objectr
   rE   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r,  r<  r@   rC   r   r   <module>rF     sQ   A @`D'R 
  	  4 A [&V &Rk k\(* (63 3 3 &(* &(Rz 
''z ''T#'J #'LJ 
#*: #*L: >* &: 
+* +4 $h&V zF r   