Anons79 Mini Shell

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

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZddlm
Z
dd
lZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zedkr�e�nd
S(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bysX
---
author:
  - Kairo Araujo (@kairoaraujo)
module: aix_filesystem
short_description: Configure LVM and NFS file systems for AIX
description:
  - This module creates, removes, mount and unmount LVM and NFS file system for
    AIX using C(/etc/filesystems).
  - For LVM file systems is possible to resize a file system.
version_added: '2.8'
options:
  account_subsystem:
    description:
      - Specifies whether the file system is to be processed by the accounting subsystem.
    type: bool
    default: no
  attributes:
    description:
      - Specifies attributes for files system separated by comma.
    type: list
    default: agblksize='4096',isnapshot='no'
  auto_mount:
    description:
      - File system is automatically mounted at system restart.
    type: bool
    default: yes
  device:
    description:
      - Logical volume (LV) device name or remote export device to create a NFS file system.
      - It is used to create a file system on an already existing logical volume or the exported NFS file system.
      - If not mentioned a new logical volume name will be created following AIX standards (LVM).
    type: str
  fs_type:
    description:
      - Specifies the virtual file system type.
    type: str
    default: jfs2
  permissions:
    description:
      - Set file system permissions. C(rw) (read-write) or C(ro) (read-only).
    type: str
    choices: [ ro, rw ]
    default: rw
  mount_group:
    description:
      - Specifies the mount group.
    type: str
  filesystem:
    description:
      - Specifies the mount point, which is the directory where the file system will be mounted.
    type: str
    required: true
  nfs_server:
    description:
      - Specifies a Network File System (NFS) server.
    type: str
  rm_mount_point:
    description:
      - Removes the mount point directory when used with state C(absent).
    type: bool
    default: no
  size:
    description:
      - Specifies the file system size.
      - For already C(present) it will be resized.
      - 512-byte blocks, Megabytes or Gigabytes. If the value has M specified
        it will be in Megabytes. If the value has G specified it will be in
        Gigabytes.
      - If no M or G the value will be 512-byte blocks.
      - If "+" is specified in begin of value, the value will be added.
      - If "-" is specified in begin of value, the value will be removed.
      - If "+" or "-" is not specified, the total value will be the specified.
      - Size will respects the LVM AIX standards.
    type: str
  state:
    description:
      - Controls the file system state.
      - C(present) check if file system exists, creates or resize.
      - C(absent) removes existing file system if already C(unmounted).
      - C(mounted) checks if the file system is mounted or mount the file system.
      - C(unmounted) check if the file system is unmounted or unmount the file system.
    type: str
    required: true
    choices: [ absent, mounted, present, unmounted ]
    default: present
  vg:
    description:
      - Specifies an existing volume group (VG).
    type: str
notes:
  - For more C(attributes), please check "crfs" AIX manual.
sb
- name: Create filesystem in a previously defined logical volume.
  aix_filesystem:
    device: testlv
    filesystem: /testfs
    state: present

- name: Creating NFS filesystem from nfshost.
  aix_filesystem:
    device: /home/ftp
    nfs_server: nfshost
    filesystem: /home/ftp
    state: present

- name: Creating a new file system without a previously logical volume.
  aix_filesystem:
    filesystem: /newfs
    size: 1G
    state: present
    vg: datavg

- name: Unmounting /testfs.
  aix_filesystem:
    filesystem: /testfs
    state: unmounted

- name: Resizing /mksysb to +512M.
  aix_filesystem:
    filesystem: /mksysb
    size: +512M
    state: present

- name: Resizing /mksysb to 11G.
  aix_filesystem:
    filesystem: /mksysb
    size: 11G
    state: present

- name: Resizing /mksysb to -2G.
  aix_filesystem:
    filesystem: /mksysb
    size: -2G
    state: present

- name: Remove NFS filesystem /home/ftp.
  aix_filesystem:
    filesystem: /home/ftp
    rm_mount_point: yes
    state: absent

- name: Remove /newfs.
  aix_filesystem:
    filesystem: /newfs
    rm_mount_point: yes
    state: absent
s�
changed:
  description: Return changed for aix_filesystems actions as true or false.
  returned: always
  type: bool
msg:
  description: Return message regarding the action.
  returned: always
  type: str
(t
AnsibleModule(tismountNcC`su|jdt�}|jd||f�\}}}|dkrmtjd|�rVtS|jdd|�ntSdS(s�
    Check if file system already exists on /etc/filesystems.

    :param module: Ansible module.
    :param filesystem: filesystem name.
    :return: True or False.
    tlsfss%s -l %sisNo record matchingtmsgs%Failed to run lsfs. Error message: %sN(tget_bin_pathtTruetrun_commandtretfindalltFalset	fail_json(tmodulet
filesystemtlsfs_cmdtrctlsfs_outterr((sI/usr/lib/python2.7/site-packages/ansible/modules/system/aix_filesystem.pyt
_fs_exists�s"c	C`s�|jdt�}|jd||f�\}}}|dkrW|jdd|�n>|j�}x+|D]#}|jd�d|krjtSqjWtSdS(	s�
    Validate if NFS server is exporting the device (remote export).

    :param module: Ansible module.
    :param nfs_host: nfs_host parameter, NFS server.
    :param device: device parameter, remote export.
    :return: True or False.
    t	showmounts%s -a %siRs*Failed to run showmount. Error message: %st:iN(RR
RRt
splitlinestsplitR(	Rtnfs_hosttdevicet
showmount_cmdRt
showmount_outRtshowmount_datatline((sI/usr/lib/python2.7/site-packages/ansible/modules/system/aix_filesystem.pyt_check_nfs_device�s	
cC`s�|jdt�}|jd|�\}}}|dkrQ|jdd|�n|jd|�\}}}|dkr�|jdd|�n||kr�||kr�d|}t|fS||kr�d|}t|fSd	|}d
|fSd
S(s�
    Check the current state of volume group.

    :param module: Ansible module argument spec.
    :param vg: Volume Group name.
    :return: True (VG in varyon state) or False (VG in varyoff state) or
             None (VG does not exist), message.
    tlsvgs%s -oiRsFailed executing %s command.s%ss$Volume group %s is in varyoff state.s#Volume group %s is in varyon state.sVolume group %s does not exist.N(RR
RRRtNone(Rtvgtlsvg_cmdRtcurrent_active_vgsRtcurrent_all_vgsR((sI/usr/lib/python2.7/site-packages/ansible/modules/system/aix_filesystem.pyt_validate_vg�s	




c	C`s�|jdt�}|js�|jd|||f�\}}}|dkr\t}||fS|dkr�tjd|�r�t}||fS|jdd|�q�tjd|�r�t}nt}||fSnt}d	}||fSd
S(s Resize LVM file system. tchfss%s -a size="%s" %siisMaximum allocation for logicalRs%Failed to run chfs. Error message: %ssThe filesystem size is alreadytN(RR
t
check_modeRRRRR(	RRtsizetchfs_cmdRtchfs_outRtchangedR((sI/usr/lib/python2.7/site-packages/ansible/modules/system/aix_filesystem.pyt	resize_fss$	%

	
cC`s�dj|�}idt6dt6}|
dk	rFidt6dt6}
nidt6dt6}
|dkrod}n
d	|}|dkr�d}n
d
|}|dkr�d}n8t||�\}}|r�d|}nt}||fS|dkr�d}n
d|}|
|}||}|
dk	r�|jd
t�}|js�|jd||||
|	|f�\}}}|dkr�|jdd|�q�t}d|}||fSq�t}d}||fSn�|jdt�}|js�d|||||||||	||f}|j|�\}}}|dkrG|j	dd|�q�|dkrp|jdd||f�q�t}||fSnt}d}||fSdS(s3 Create LVM file system or NFS remote mount point. s -a s-t yess-t nos-As-as-A yess-A noR-s
-a size=%ss-d %ss-g %ss-u %stmknfsmnts*%s -f "%s" %s -h "%s" -t "%s" "%s" -w "bg"iRs)Failed to run mknfsmnt. Error message: %ssNFS file system %s created.tcrfss,%s -v %s -m %s %s %s %s %s %s -p %s %s -a %si
sVUsing a existent previously defined logical volume, volume group needs to be empty. %ss#Failed to run %s. Error message: %sN(
tjoinR
RR&R+RR.RRt	exit_json(Rtfs_typeRR'RR/tmount_groupt
auto_mounttaccount_subsystemtpermissionst
nfs_servert
attributestaccount_subsys_opttauto_mount_opttvg_stateRR2tmknfsmnt_cmdRtmknfsmnt_outRtcrfs_cmdtcmdtcrfs_out((sI/usr/lib/python2.7/site-packages/ansible/modules/system/aix_filesystem.pyt	create_fs!st


	
	
	

	


		%


	(	
cC`s�idt6dt6}||}|jdt�}|js�d|||f}|j|�\}}}|dkr�|jdd||f�q�t}	|}
|s�d|}
n|	|
fSnt}	d}
|	|
fSd	S(
s) Remove an LVM file system or NFS entry. s-rR-trmfss%s -r %s %siRs#Failed to run %s. Error message: %ssFile system %s removed.N(R
RRR.RR(RRtrm_mount_pointtrm_mount_point_opttrmfs_cmdRERtrmfs_outRR2R((sI/usr/lib/python2.7/site-packages/ansible/modules/system/aix_filesystem.pyt	remove_fs�s$

	

cC`s�|jdt�}|js}|jd||f�\}}}|dkr`|jdd|�q�t}d|}||fSnt}d}||fSdS(	s Mount a file system. tmounts%s %siRs&Failed to run mount. Error message: %ssFile system %s mounted.R-N(RR
R.RR(RRt	mount_cmdRt	mount_outRR2R((sI/usr/lib/python2.7/site-packages/ansible/modules/system/aix_filesystem.pytmount_fs�s	

cC`s�|jdt�}|js}|jd||f�\}}}|dkr`|jdd|�q�t}d|}||fSnt}d}||fSdS(	s Unmount a file system.tunmounts%s %siRs(Failed to run unmount. Error message: %ssFile system %s unmounted.R-N(RR
R.RR(RRtunmount_cmdRtunmount_outRR2R((sI/usr/lib/python2.7/site-packages/ansible/modules/system/aix_filesystem.pyt
unmount_fs�s	"

c$C`s�tdtdtdddt�dtddddd	g�d
tdddt�dtdd�d
tdddt�dtdddd�dtdddddddg�dtdd�dtdd�dtdddt�dtdd�dtdddddddddg�dtdd��
dt�}|jd}|jd}|jd
}|jd}|jd}|jd}|jd}|jd
}|jd}	|jd}
|jd}|jd}|jd}
td td!d"�}|dkr�t|�}t||�}|s |rjd#||d!<t|d <|dk	r�t|||�\|d <|d!<q�q�|	dk	r�|dkr�d$|d!<|j	|�q�t
||	|�r�t||||
|||||||	|�\|d <|d!<q�n|dkr_|
dkr!d%|d!<|j	|�q_t||||
|||||||	|�\|d <|d!<n|dk	r�|	dkr�t||||
|||||||	|�\|d <|d!<q�n3|dkr*t|�r�d&||d!<q�t||�}|sd'||d!<q�t|||
�\|d <|d!<n�|dkr}t|�r]t|d <d(||d!<q�t
||�\|d <|d!<nn|dkr�t|�s�t|d <d)||d!<q�t||�\|d <|d!<nd*||d!<|j	|�|j|�dS(+Nt
argument_specR;ttypetbooltdefaultR>tlistsagblksize='4096'sisnapshot='no'R:RtstrRtrequiredR8tjfs2R<trwtchoicestroR9R=RIR/tstatetpresenttabsenttmountedt	unmountedR'tsupports_check_modeR2RR-sFile system %s already exists.s<Parameter "device" is required when "nfs_server" is defined.sKRequired parameter "device" and/or "vg" is missing for filesystem creation.sFile system %s mounted.sFile system %s does not exist.sFile system %s already mounted.s!File system %s already unmounted.sUnexpected state %s.(RtdictRR
tparamsR	RR&R3RR$RGRMRQRUR7(RR;R>R:RR8R<R9RR=RIR/RaR'tresultt
fs_mountedt	fs_existst	fs_status((sI/usr/lib/python2.7/site-packages/ansible/modules/system/aix_filesystem.pytmain�s�!'	












	
&
>
;>#
 
 
t__main__(t
__future__RRRRWt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtansible.module_utils.basicRtansible.module_utils.ismountR	RRR$R+R3RGRMRQRURmt__name__(((sI/usr/lib/python2.7/site-packages/ansible/modules/system/aix_filesystem.pyt<module>s,

_9					d				p

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