Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/f5/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyo

�
�Udac@`swddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZddl
mZdd
lmZytddlmZddlmZddlmZddlmZddlmZddlmZddlmZWn�ek
r�ddlmZddlmZddlmZddlmZddlmZddlmZddlmZnXdefd��YZdefd��YZ de fd��YZ!de fd��YZ"de#fd��YZ$de#fd ��YZ%d!e%fd"��YZ&d#e%fd$��YZ'd%e#fd&��YZ(d'�Z)e*d(krse)�ndS()i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	certifiedtsupported_bys�
---
module: bigip_ucs_fetch
short_description: Fetches a UCS file from remote nodes
description:
   - This module is used for fetching UCS files from remote machines and
     storing them locally in a file tree, organized by hostname. Note that
     this module is written to transfer UCS files that might not be present,
     so a missing remote UCS won't be an error unless fail_on_missing is
     set to 'yes'.
version_added: 2.5
options:
  backup:
    description:
      - Create a backup file including the timestamp information so you can
        get the original file back if you somehow clobbered it incorrectly.
    type: bool
    default: no
  create_on_missing:
    description:
      - Creates the UCS based on the value of C(src) if the file does not already
        exist on the remote system.
    type: bool
    default: yes
  dest:
    description:
      - A directory to save the UCS file into.
    type: path
    required: True
  encryption_password:
    description:
      - Password to use to encrypt the UCS file if desired.
    type: str
  fail_on_missing:
    description:
      - Make the module fail if the UCS file on the remote system is missing.
    type: bool
    default: no
  force:
    description:
      - If C(no), the file will only be transferred if the destination does not
        exist.
    type: bool
    default: yes
  src:
    description:
      - The name of the UCS file to create on the remote server for downloading
    type: str
notes:
  - BIG-IP provides no way to get a checksum of the UCS files on the system
    via any interface except, perhaps, logging in directly to the box (which
    would not support appliance mode). Therefore, the best this module can
    do is check for the existence of the file on disk; no check-summing.
  - If you are using this module with either Ansible Tower or Ansible AWX, you
    should be aware of how these Ansible products execute jobs in restricted
    environments. More information can be found here
    https://clouddocs.f5.com/products/orchestration/ansible/devel/usage/module-usage-with-tower.html
extends_documentation_fragment: f5
author:
  - Tim Rupp (@caphrim007)
  - Wojciech Wypior (@wojtek0806)
s�
- name: Download a new UCS
  bigip_ucs_fetch:
    src: cs_backup.ucs
    dest: /tmp/cs_backup.ucs
    provider:
      server: lb.mydomain.com
      user: admin
      password: secret
  delegate_to: localhost
s�
checksum:
  description: The SHA1 checksum of the downloaded file
  returned: success or changed
  type: str
  sample: 7b46bbe4f8ebfee64761b5313855618f64c64109
dest:
  description: Location on the ansible host that the UCS was saved to
  returned: success
  type: str
  sample: /path/to/file.txt
src:
  description:
    - Name of the UCS file on the remote BIG-IP to download. If not
      specified, then this will be a randomly generated filename
  returned: changed
  type: str
  sample: cs_backup.ucs
backup_file:
  description: Name of backup file created
  returned: changed and if backup=yes
  type: str
  sample: /path/to/file.txt.2015-02-12@22:09~
gid:
  description: Group id of the UCS file, after execution
  returned: success
  type: int
  sample: 100
group:
  description: Group of the UCS file, after execution
  returned: success
  type: str
  sample: httpd
owner:
  description: Owner of the UCS file, after execution
  returned: success
  type: str
  sample: httpd
uid:
  description: Owner id of the UCS file, after execution
  returned: success
  type: int
  sample: 100
md5sum:
  description: The MD5 checksum of the downloaded file
  returned: changed or success
  type: str
  sample: 96cacab4c259c4598727d7cf2ceb3b45
mode:
  description: Permissions of the target UCS, after execution
  returned: success
  type: str
  sample: 0644
size:
  description: Size of the target UCS, after execution
  returned: success
  type: int
  sample: 1220
N(t
AnsibleModule(tLooseVersion(tF5RestClient(t
F5ModuleError(tAnsibleF5Parameters(tf5_argument_spec(ttransform_name(t
download_file(ttmos_versiont
ParameterscB`s\eZgZdddddgZgZiZed��Zed��Zed��Z	RS(tdesttsrctmd5sumtchecksumtbackup_filecC`s2g}|jr.|jtd|jj��n|S(Nt
passphrase(Rtappendtdicttwant(tselftresult((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pytoptions�s
	cC`sE|jddk	r|jdSttj��d}||jd<|S(NRs.ucs(t_valuestNonetnextttempfilet_get_candidate_names(RR((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR�s

cC`s?d}tjj|j�r9tjj|j|j�}n�tjjtjj|j��rf|j}n�ytj	tjj|��Wnpt
k
r�}dt|�j�kr�t
djtjj|����nt
djtjj|����nXtjtjj|�tj�s;t
djtjj|����n|S(Nspermission denieds+Destination directory {0} is not accessibles(Destination directory {0} does not existsDestination {0} not writable(RtostpathtisdirRtjoinRtexiststdirnametstattOSErrortstrtlowerRtformattaccesstW_OK(RRte((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pytfulldest�s"!!"!!(
t__name__t
__module__t
updatablestreturnablestapi_attributestapi_maptpropertyRRR1(((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR�s		tChangescB`seZd�ZRS(cC`sXi}y:x$|jD]}t||�||<qW|j|�}Wntk
rSnX|S(N(R5tgetattrt_filter_paramst	Exception(RRt
returnable((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyt	to_return�s
(R2R3R>(((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR9�st
UsableChangescB`seZRS((R2R3(((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR?�stReportableChangescB`seZRS((R2R3(((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR@�st
ModuleManagercB`s,eZd�Zd�Zd�Zd�ZRS(cO`s7||_|jdd�|_t|jj�|_dS(Ntmodule(tkwargstgetRRBR
tparamstclient(RtargsRC((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyt__init__�s	cC`s7|j�r|jd�}n|jd�}|j�S(Ntv1tv2(t
is_version_v1tget_managertexec_module(Rtmanager((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRMscC`s6|dkrt|j�S|dkr2t|j�SdS(NRIRJ(t	V1ManagerRCt	V2Manager(Rttype((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRLs
cC`s3t|j�}t|�td�kr+tStSdS(sDChecks to see if the TMOS version is less than 12.1.0

        Versions prior to 12.1.0 have a bug which prevents the REST
        API from properly listing any UCS files when you query the
        /mgmt/tm/sys/ucs endpoint. Therefore you need to do everything
        through tmsh over REST.

        :return: bool
        s12.1.0N(RRFR	tTruetFalse(Rtversion((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRKs
(R2R3RHRMRLRK(((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRA�s			tBaseManagercB`skeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZRS(cO`sR|jdd�|_t|jj�|_td|jj�|_t�|_	dS(NRBRE(
RDRRBR
RERFRRR?tchanges(RRGRC((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRH#scC`s^t�}|j�td|jj��}|j�}|j|�|jtdt��|S(NREtchanged(RtpresentR@RVR>tupdateRR(RRt
reportableRV((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRM)s	

cC`s'|j�r|j�n
|j�dS(N(R'RYtcreate(R((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRX4s
cC`sStjj|jj�rE|jjsEtdj|jj���qEn|j�dS(NsFile '{0}' already exists(	R#R$R'RR1tforceRR-texecute(R((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRY:s
cC`s|jj|jj�S(N(RBtbackup_localRR1(R((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyt_get_backup_fileBscC`s�y[|jjrPtjj|jj�rP|j�}|jji|d6�qPn|j	�Wn5t
k
r�tdj|jj
|jj���nX|j�|j�|jj|jj�}|jj|t�S(NRsFailed to copy: {0} to {1}(RtbackupR#R$R'R1R_RVRYtdownloadtIOErrorRR-Rt
_set_checksumt_set_md5sumRBtload_file_common_argumentsREtset_fs_attributes_if_differentRR(RRt	file_args((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR]Es
%

cC`sKy3|jj|jj�}|jji|d6�Wntk
rFnXdS(NR(RBtsha1RR1RYt
ValueError(RR((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRcUs

cC`sKy3|jj|jj�}|jji|d6�Wntk
rFnXdS(NR(RBtmd5RR1RYRi(RR((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRd\s

cC`s�|jjr*tdj|jj���n|jjsTtdj|jj���n|jjrdtS|jjr}|j	�n|j
�tS(NsUCS '{0}' was not found(Rtfail_on_missingRR-Rtcreate_on_missingRBt
check_modeRRtcreate_on_deviceR](R((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR[cs

c	C`s%|jjr@tddd|jjdi|jjd6g�}ntddd|jj�}dj|jjd|jjd�}|jjj	|d	|�}y|j
�}Wn%tk
r�}tt
|���nXd
|kr!|d
dkr!d
|krt|d
��q!t|j��ndS(NtcommandtsavetnameRRshttps://{0}:{1}/mgmt/tm/sys/ucstservertserver_porttjsontcodei�i�tmessage(i�i�(RRRRtencryption_passwordR-RFtprovidertapitpostRtRiRR+tcontent(RREturitresptresponsetex((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRnus(
cC`s?|j|jj�tjj|jj�r/tStd��dS(Ns"Failed to download the remote file(tdownload_from_deviceRRR#R$R'RRR(R((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRa�s
(
R2R3RHRMRXRYR_R]RcRdR[RnRa(((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRU"s										ROcB`sGeZd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(cO`s#tt|�j|�d|_dS(Ns/var/config/rest/madm(tsuperRORHt
remote_dir(RRGRC((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRH�scC`s8d}|j�}d|kr4|j|d�}n|S(Nt
commandResult(Rtread_current_from_devicet_read_ucs_files_from_output(RRtoutput((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pytread_current�s
cC`s�tdddd�}dj|jjd|jjd�}|jjj|d|�}y|j�}Wn%tk
r�}tt	|���nXd	|kr�|d	d
kr�d|kr�t|d��q�t|j
��n|S(NRotruntutilCmdArgss-c "tmsh list sys ucs"s!https://{0}:{1}/mgmt/tm/util/bashRrRsRtRui�i�Rv(i�i�(RR-RFRxRyRzRtRiRR+R{(RRER|R}R~R((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR��s 	
cC`sVtjd�j}|jd�}gt||�D]}|r1|jd�^q1}|S(Nsfilename\s+(.*)s
i(tretcompiletsearchtsplittmaptgroup(RR�R�tlinestmR((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR��s1c`sH|j�}tjj|jj��t�fd�|D��rDtStS(Nc3`s'|]}�tjj|�kVqdS(N(R#R$tbasename(t.0tx(tbase(sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pys	<genexpr>�s(	R�R#R$R�RRtanyRRRS(Rt
collection((R�sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR'�s
cC`s�dj|jjd|jjd|jj�}yt|j||�Wntk
retd��nXtjj	|jj
�r�tStS(Ns2https://{0}:{1}/mgmt/shared/file-transfer/madm/{2}RrRssFailed to download the file.(
R-RFRxRtfilenameRRR#R$R'RRRRS(RRturl((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR��s



cC`s,dj|jj|j�}tddd|�}dj|jjd|jjd�}|jjj|d|�}yB|j	�}d	|kr�d
|d	kr�t
|d	��q�nWn%tk
r�}t
t|���nXd|kr(|ddkr(d|krt
|d��q(t
|j
��ntS(Ns/var/local/ucs/{0} {1}/{0}RoR�R�s%https://{0}:{1}/mgmt/tm/util/unix-mv/RrRsRtR�scannot statRui�i�Rv(i�i�(R-RR�R�RRFRxRyRzRtRRiR+R{RR(Rt	move_pathRER|R}R~R((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyt_move_to_download�s*	
(	R2R3RHR�R�R�R'R�R�(((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRO�s						RPcB`s,eZd�Zd�Zd�Zd�ZRS(cC`s�dj|jjd|jjd�}|jjj|�}y|j�}Wn%tk
rr}tt|���nXd|kr�|ddkr�d|kr�t|d��q�t|j	��n|S(Nshttps://{0}:{1}/mgmt/tm/sys/ucsRrRsRui�Rv(
R-RFRxRyRDRtRiRR+R{(RR|R}R~R((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR��s
cC`sK|j�}d|krgS|d}g|D]}|dd^q-}|S(NtitemstapiRawValuesR�(R�(RR�t	resourcesR�R((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR�s
!c`sH|j�}tjj|jj��t�fd�|D��rDtStS(Nc3`s'|]}�tjj|�kVqdS(N(R#R$R�(R�R�(R�(sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pys	<genexpr>s(	R�R#R$R�RRR�RRRS(RR�((R�sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR's
cC`s�dj|jjd|jjd|jj�}yt|j||�Wntk
retd��nXtjj	|jj
�r�tStS(Ns;https://{0}:{1}/mgmt/shared/file-transfer/ucs-downloads/{2}RrRssFailed to download the file.(
R-RFRxRRRRR#R$R'RRRRS(RRR�((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR� s



(R2R3R�R�R'R�(((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRP�s			tArgumentSpeccB`seZd�ZRS(cC`s�t|_tdtdddd�dtdddd�dtd	t�d
tdtdd�d
tdddd�dtdddd�dt��}i|_|jjt�|jj|�t|_dS(NR`tdefaulttnoRQtboolRltyesRwtno_logRtrequiredR$R\RkR(RRtsupports_check_modeRt
argument_specRYR
tadd_file_common_args(RR�((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyRH2s.							(R2R3RH(((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyR�1scC`s�t�}td|jd|jd|j�}y,td|�}|j�}|j|�Wn)tk
r�}|j	dt
|��nXdS(NR�R�R�RBtmsg(R�RR�R�R�RARMt	exit_jsonRt	fail_jsonR+(tspecRBtmmtresultsR((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pytmainRs			t__main__(+t
__future__RRRRQt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR#R�R!tansible.module_utils.basicRtdistutils.versionR	t%library.module_utils.network.f5.bigipR
t&library.module_utils.network.f5.commonRRR
Rt(library.module_utils.network.f5.icontrolRRtImportErrort%ansible.module_utils.network.f5.bigipt&ansible.module_utils.network.f5.commont(ansible.module_utils.network.f5.icontrolRR9R?R@tobjectRARURORPR�R�R2(((sN/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_ucs_fetch.pyt<module>sP


?<
;$xb5!	

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