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_asm_policy_fetch.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZddl
mZdd
l
mZy�ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZWn�ek
r�ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZnXdefd��YZdefd��YZ defd��YZ!defd��YZ"de"fd��YZ#d e"fd!��YZ$d"e%fd#��YZ&d$e%fd%��YZ'd&�Z(e)d'kr}e(�ndS((i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	certifiedtsupported_bys
---
module: bigip_asm_policy_fetch
short_description: Exports the asm policy from remote nodes.
description:
  - Exports the asm policy from remote nodes.
version_added: 2.8
options:
  name:
    description:
      - The name of the policy exported to create a file on the remote device for downloading.
    type: str
    required: True
  dest:
    description:
      - A directory to save the policy file into.
      - This option is ignored when C(inline) is set to c(yes).
    type: path
  file:
    description:
      - The name of the file to be create on the remote device for downloading.
      - When C(binary) is set to C(no) the ASM policy will be in XML format.
    type: str
  inline:
    description:
      - If C(yes), the ASM policy will be exported C(inline) as a string instead of a file.
      - The policy can be be retrieved in playbook C(result) dictionary under C(inline_policy) key.
    type: bool
  compact:
    description:
      - If C(yes), only the ASM policy custom settings will be exported.
      - Only applies to XML type ASM policy exports.
    type: bool
  base64:
    description:
      - If C(yes), the returned C(inline) ASM policy content will be Base64 encoded.
      - Only applies to C(inline) ASM policy exports.
    type: bool
  binary:
    description:
      - If C(yes), the exported ASM policy will be in binary format.
      - Only applies to C(file) ASM policy exports.
    type: bool
  force:
    description:
      - If C(no), the file will only be transferred if it does not exist in the the destination.
    default: yes
    type: bool
  partition:
    description:
      - Device partition which contains ASM policy to export.
    type: str
    default: Common
extends_documentation_fragment: f5
author:
  - Wojciech Wypior (@wojtek0806)
s�
- name: Export policy in binary format
  bigip_asm_policy_fetch:
    name: foobar
    file: export_foo
    dest: /root/download
    binary: yes
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost

- name: Export policy inline base64 encoded format
  bigip_asm_policy_fetch:
    name: foobar
    inline: yes
    base64: yes
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost

- name: Export policy in XML format
  bigip_asm_policy_fetch:
    name: foobar
    file: export_foo
    dest: /root/download
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost

- name: Export compact policy in XML format
  bigip_asm_policy_fetch:
    name: foobar
    file: export_foo.xml
    dest: /root/download/
    compact: yes
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost

- name: Export policy in binary format, autogenerate name
  bigip_asm_policy_fetch:
    name: foobar
    dest: /root/download/
    binary: yes
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost
s�
name:
  description: Name of the ASM policy to be exported.
  returned: changed
  type: str
  sample: Asm_APP1_Transparent
dest:
  description: Local path to download exported ASM policy.
  returned: changed
  type: str
  sample: /root/downloads/foobar.xml
file:
  description:
    - Name of the policy file on the remote BIG-IP to download. If not
      specified, then this will be a randomly generated filename.
  returned: changed
  type: str
  sample: foobar.xml
inline:
  description: Set when ASM policy to be exported inline
  returned: changed
  type: bool
  sample: yes
compact:
  description: Set only to export custom ASM policy settings.
  returned: changed
  type: bool
  sample: no
base64:
  description: Set to encode inline export in base64 format.
  returned: changed
  type: bool
  sample: no
binary:
  description: Set to export ASM policy in binary format.
  returned: changed
  type: bool
  sample: yes
N(t
AnsibleModule(tenv_fallback(tF5RestClient(t
F5ModuleError(tAnsibleF5Parameters(tfq_name(tf5_argument_spec(tflatten_boolean(tdownload_asm_file(tmodule_provisionedt
Parametersc	B`s_eZidd6dd6dd6ZdddddgZdddddd	d
ddg	ZgZRS(
tfiletfilenametcompacttminimaltbase64tisBase64tinlinetpolicyReferencetforcetbinarytdesttnamet
inline_policy(t__name__t
__module__tapi_maptapi_attributestreturnablest
updatables(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyR�s&
		t
ApiParameterscB`seZRS((R R!(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyR&�stModuleParameterscB`skeZd�Zed��Zed��Zed��Zed��Zed��Zed��Z	RS(cC`s�dj|jjd|jjd�}dj|jj|jj�}|jjj||�}y|j�}Wn%t	k
r�}t
t|���nXd|kr�|dgkr�tSt
S(Ns%https://{0}:{1}/mgmt/tm/asm/policies/tservertserver_portsR?$filter=contains(name,'{0}')+and+contains(partition,'{1}')&$select=name,partitiontitems(tformattclienttprovidertwantRt	partitiontapitgettjsont
ValueErrorRtstrtTruetFalse(tselfturitquerytresptresponsetex((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyt_policy_exists�s
cC`sA|j�r|jdStdj|jd|jd���dS(NRsGThe specified ASM policy {0} on partition {1} does not exist on device.R/(R=t_valuesRR+(R7((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyR�s
cC`sg|jddk	r|jdS|jr@ttj��d}nttj��d}||jd<|S(NRs.plcs.xml(R>tNoneRtnextttempfilet_get_candidate_names(R7tresult((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyRs	
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(R?tostpathtisdirRtjoinRtexiststdirnametstattOSErrorR4tlowerRR+taccesstW_OK(R7RCte((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pytfulldests"!!"!!cC`s7t|jd�}|dkr#tS|dkr3tSdS(NRtyestno(RR>R5R6(R7RC((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyR1s
cC`s7t|jd�}|dkr#tS|dkr3tSdS(NRRQRR(RR>R5R6(R7RC((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyR9s
cC`s7t|jd�}|dkr#tS|dkr3tSdS(NRRQRR(RR>R5R6(R7RC((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyRAs
(
R R!R=tpropertyRRRPRRR(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyR'�s	tChangescB`seZd�ZRS(cC`sXi}y:x$|jD]}t||�||<qW|j|�}Wntk
rSnX|S(N(R$tgetattrt_filter_paramst	Exception(R7RCt
returnable((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyt	to_returnKs
(R R!RY(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyRTJst
UsableChangescB`seZRS((R R!(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyRZVstReportableChangescB`seZRS((R R!(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyR[Zst
ModuleManagercB`s�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�ZRS(cO`sR|jdd�|_t|jj�|_td|jj�|_t�|_	dS(Ntmoduletparams(
R1R?R]R
R^R,R'R.RZtchanges(R7targstkwargs((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyt__init___scC`sji}xBtjD]7}t|j|�dk	rt|j|�||<qqW|rftd|�|_ndS(NR^(RR$RUR.R?RZR_(R7tchangedtkey((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyt_set_changed_optionsescC`sK|jdg�}x2|D]*}|jjjd|dd|d�qWdS(Nt
__warningstmsgtversion(tpopR,R]t	deprecate(R7RCtwarningstwarning((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyt_announce_deprecationsms


cC`st|jd�s!td��nt�}|j�td|jj��}|j�}|j|�|jtdt	��|S(Ntasms+ASM must be provisioned to use this module.R^Rc(
RR,RtdicttexportR[R_RYtupdateR5(R7RCt
reportableR_((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pytexec_moduleus	

cC`s$|j�r|j�S|j�SdS(N(RHRqtcreate(R7((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyRp�s
cC`s8|jjs*tdj|jj���n|j�dS(NsFile '{0}' already exists.(R.RRR+RPtexecute(R7((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyRq�scC`s[|j�|jjrtS|jjr4|j�tS|j�|jjsW|j	�ntS(N(
ReR]t
check_modeR5R.Rt
export_binarytcreate_on_deviceRRu(R7((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyRt�s



cC`s|j�|j�tS(N(texport_binary_on_deviceRuR5(R7((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyRw�s

cC`s?|j|jj�tjj|jj�r/tStd��dS(Ns#Failed to download the remote file.(tdownload_from_deviceR.RPRDRERHR5R(R7((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pytdownload�s
cC`s|j�|j�tS(N(R{tremove_temp_policy_from_deviceR5(R7((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyRu�s

cC`s/|jjs+tjj|jj�r+tSntS(N(R.RRDRERHRPR5R6(R7((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyRH�scC`sA|j�|jj�}dj|jjd|jjd�}|jjj|d|�}y|j�}Wn%t	k
r�}t
t|���nXd|kr�|ddkr�d|kr�t
|d��q�t
|j��n|j
|d	�\}}|r3|r3d
|kr3|jjtd|d
��q3n|r=tSdS(
Ns0https://{0}:{1}/mgmt/tm/asm/tasks/export-policy/R(R)R2tcodei�i�tmessagetidRR(i�i�(t_set_policy_linkR_t
api_paramsR+R,R-R0tpostR2R3RR4tcontentt
wait_for_taskRqRoR5(R7R^R8R:R;R<RCtoutput((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyRx�s(

#cC`sKdj|jjd|jjd|�}x�tr�|jjj|�}y|j�}Wn%tk
r~}tt	|���nXd|kr�|ddkr�d|kr�t|d��q�t|j
��n|dd
kr�Pntjd
�q,W|dd	krtd��n|ddkrG|j
js6tdfSt|dfSndS(Ns3https://{0}:{1}/mgmt/tm/asm/tasks/export-policy/{2}R(R)R}i�R~Rt	COMPLETEDtFAILUREisFailed to export ASM policy.RC(R�sFAILURE(R+R,R-R5R0R1R2R3RR4R�ttimetsleepR.RR?(R7ttask_idR8R:R;R<((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyR��s0

		
cC`sd}dj|jjd|jjd�}dj|jj|jj�}|jjj||�}y|j	�}Wn%t
k
r�}tt|���nXd|kr�|dgkr�|ddd}n|s�td��n|j
jtd	i|d
6��tS(Ns%https://{0}:{1}/mgmt/tm/asm/policies/R(R)sR?$filter=contains(name,'{0}')+and+contains(partition,'{1}')&$select=name,partitionR*itselfLinksThe policy was not foundRtlink(R?R+R,R-R.RR/R0R1R2R3RR4R_RqRoR5(R7tpolicy_linkR8R9R:R;R<((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyR��s"
 cC`sWt|jj|jj�}dj||jj�}dj|jjd|jjd�}tddddj|��}|jj	j
|d	|�}yB|j�}d
|kr�d|d
kr�t|d
��q�nWn%t
k
r�}tt|���nXd|krI|dd
krId|kr7t|d��qIt|j��n|j�tS(Ns%tmsh save asm policy {0} bin-file {1}s"https://{0}:{1}/mgmt/tm/util/bash/R(R)tcommandtruntutilCmdArgss-c "{0}"R2t
commandResultsUnexpected ErrorR}i�R~(R
R.R/RR+RR,R-RoR0R�R2RR3R4R�t_move_binary_to_downloadR5(R7t	full_nametcmdR8R`R:R;R<((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyRy
s,

cC`sNdj|jjd|jj�}dj|jjd|�}tddd|�}dj|jjd	|jjd
�}|jjj|d|�}yB|j�}d|kr�d
|dkr�t	|d��q�nWn%t
k
r�}t	t|���nXd|krJ|ddkrJd|kr8t	|d��qJt	|j��nt
S(Ns{0}~{1}tusers/var/tmp/{0} {1}/{2}s/ts/var/restR�R�R�s%https://{0}:{1}/mgmt/tm/util/unix-mv/R(R)R2R�scannot statR}i�i�R~(i�i�(R+R,R-R.RRoR0R�R2RR3R4R�R5(R7Rt	move_pathR^R8R:R;R<((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyR�)s0"			
cC`s�dj|jjd|jjd|jj�}yt|j||�Wntk
retd��nXtjj	|jj
�r�tStS(Ns7https://{0}:{1}/mgmt/tm/asm/file-transfer/downloads/{2}R(R)sFailed to download the file.(
R+R,R-R.RRRRDRERHRR5R6(R7Rturl((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyRzLs



cC`sdj|jjd|jj�}dj|�}dj|jjd|jjd�}tddd	|�}|jjj|d
|�}y|j�}Wn%t	k
r�}t
t|���nXd|kr|ddkrd
|kr�t
|d
��qt
|j��ndS(Ns{0}~{1}R�s/ts/var/rest/{0}s%https://{0}:{1}/mgmt/tm/util/unix-rm/R(R)R�R�R�R2R}i�R~(
R+R,R-R.RRoR0R�R2R3RR4R�(R7Rt
tpath_nameR8R`R:R;R<((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyR|\s""
	(R R!RbReRmRsRpRqRtRwR{RuRHRxR�R�RyR�RzR|(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyR\^s$													"			#	tArgumentSpeccB`seZd�ZRS(cC`st|_tdtdt�dtdd�dt�dtdd�d	tdd�d
tdd�dtdd�dtd
ddd�dtd
ddtdgf��	}i|_|jjt�|jj|�ddgdd	gddgddgg|_dS(NRtrequiredRttypeRERRtboolRRRRtdefaultRQR/tCommontfallbacktF5_PARTITION(R5tsupports_check_modeRoR	t
argument_specRqRtmutually_exclusive(R7R�((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyRbts8													(R R!Rb(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyR�sscC`s�t�}td|jd|jd|j�}y,td|�}|j�}|j|�Wn)tk
r�}|j	dt
|��nXdS(NR�R�R�R]Rg(R�RR�R�R�R\Rst	exit_jsonRt	fail_jsonR4(tspecR]tmmtresultsR<((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pytmain�s			t__main__(*t
__future__RRRR�t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRDR�RAtansible.module_utils.basicRR	t%library.module_utils.network.f5.bigipR
t&library.module_utils.network.f5.commonRRR
RRt(library.module_utils.network.f5.icontrolRRtImportErrort%ansible.module_utils.network.f5.bigipt&ansible.module_utils.network.f5.commont(ansible.module_utils.network.f5.icontrolRR&R'RTRZR[tobjectR\R�R�R (((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_fetch.pyt<module>sT


:;(
 _�+	

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