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

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlm
Z
dd
lmZy�ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZWn�ek
r�ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZnXdefd��YZdefd��YZdefd��YZ defd��YZ!de!fd��YZ"d e!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_import
short_description: Manage BIG-IP ASM policy imports
description:
   - Manage BIG-IP ASM policies policy imports.
version_added: 2.8
options:
  name:
    description:
      - The ASM policy to create or override.
    type: str
    required: True
  inline:
    description:
      - When specified the ASM policy is created from a provided string.
      - Content needs to be provided in a valid XML format otherwise the operation will fail.
    type: str
  source:
    description:
      - Full path to a policy file to be imported into the BIG-IP ASM.
      - Policy files exported from newer versions of BIG-IP cannot be imported into older
        versions of BIG-IP. The opposite, however, is true; you can import older into
        newer.
      - The file format can be binary of XML.
    type: path
  force:
    description:
      - When set to C(yes) any existing policy with the same name will be overwritten by the new import.
      - Works for both inline and file imports, if the policy does not exist this setting is ignored.
    default: no
    type: bool
  partition:
    description:
      - Device partition to create policy on.
    type: str
    default: Common
extends_documentation_fragment: f5
author:
  - Wojciech Wypior (@wojtek0806)
s�
- name: Import ASM policy
  bigip_asm_policy_import:
    name: new_asm_policy
    file: /root/asm_policy.xml
    provider:
      server: lb.mydomain.com
      user: admin
      password: secret
  delegate_to: localhost

- name: Import ASM policy inline
  bigip_asm_policy_import:
    name: foo-policy4
    inline: <xml>content</xml>
    provider:
      server: lb.mydomain.com
      user: admin
      password: secret
  delegate_to: localhost

- name: Override existing ASM policy
  bigip_asm_policy:
    name: new_asm_policy
    file: /root/asm_policy_new.xml
    force: yes
    provider:
      server: lb.mydomain.com
      user: admin
      password: secret
  delegate_to: localhost
s�
source:
  description: Local path to an ASM policy file.
  returned: changed
  type: str
  sample: /root/some_policy.xml
inline:
  description: Contents of policy as an inline string
  returned: changed
  type: str
  sample: <xml>foobar contents</xml>
name:
  description: Name of the ASM policy to be created/overwritten
  returned: changed
  type: str
  sample: Asm_APP1_Transparent
force:
  description: Set when overwriting an existing policy
  returned: changed
  type: bool
  sample: yes
N(t
AnsibleModule(tenv_fallback(tF5RestClient(t
F5ModuleError(tAnsibleF5Parameters(tfq_name(ttransform_name(tf5_argument_spec(tupload_file(tmodule_provisionedt
ParameterscB`s@eZgZddddgZddgZidd6dd6ZRS(tnametinlinetsourcetforcetfiletfilename(t__name__t
__module__t
updatablestreturnablestapi_attributestapi_map(((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyR�s		t
ApiParameterscB`seZRS((RR(((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyR�stModuleParameterscB`seZRS((RR(((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyR �stChangescB`seZd�ZRS(cC`sXi}y:x$|jD]}t||�||<qW|j|�}Wntk
rSnX|S(N(Rtgetattrt_filter_paramst	Exception(tselftresultt
returnable((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyt	to_return�s
(RRR((((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyR!�st
UsableChangescB`seZRS((RR(((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyR)�stReportableChangescB`seZRS((RR(((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyR*�st
DifferencecB`s&eZdd�Zd�Zd�ZRS(cC`s||_||_dS(N(twantthave(R%R,R-((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyt__init__�s	cC`s9yt||�}|SWntk
r4|j|�SXdS(N(R"tAttributeErrort_Difference__default(R%tparamR&((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pytcompare�s

cC`sQt|j|�}y&t|j|�}||kr7|SWntk
rL|SXdS(N(R"R,R-R/(R%R1tattr1tattr2((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyt	__default�s
N(RRtNoneR.R2R0(((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyR+�s	t
ModuleManagercB`steZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
RS(cO`sR|jdd�|_t|jj�|_td|jj�|_t�|_	dS(Ntmoduletparams(
tgetR6R8R
R9tclientR R,R)tchanges(R%targstkwargs((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyR.�scC`sji}xBtjD]7}t|j|�dk	rt|j|�||<qqW|rftd|�|_ndS(NR9(RRR"R,R6R)R<(R%tchangedtkey((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyt_set_changed_options�scC`sK|jdg�}x2|D]*}|jjjd|dd|d�qWdS(Nt
__warningstmsgtversion(tpopR;R8t	deprecate(R%R&twarningstwarning((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyt_announce_deprecations�s


cC`s�t|jd�s!td��nt�}|j�}td|jj��}|j�}|j|�|jtd|��|j	|�|S(Ntasms+ASM must be provisioned to use this module.R9R?(
RR;Rtdictt
policy_importR*R<R(tupdateRI(R%R&R?t
reportableR<((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pytexec_module�s	

cC`s�|j�|jjrtS|j�r?|jjtkr?tSn|jjrh|j	�}|j
|�tS|j�|j�tS(N(
RAR8t
check_modetTruetexistsR,RtFalseRt
inline_importt
wait_for_tasktimport_file_to_devicetremove_temp_policy_from_device(R%ttask((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyRL�s



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(tformatR;tproviderR,Rt	partitiontapiR:tjsont
ValueErrorRtstrRQRS(R%turitquerytresptresponsetex((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyRR	s
cC`sddj|jjd|jjd�}yt|j|||�Wntk
r_td��nXdS(Ns1https://{0}:{1}/mgmt/shared/file-transfer/uploadsRYRZsFailed to upload the file.(R\R;R]RR(R%tcontentRturl((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pytupload_file_to_devices

cC`s�dj|jjd|jjd�}dj|jj|jj�}|jjj||�}y|j�}Wn%t	k
r�}t
t|���nX|ddd}|S(Ns%https://{0}:{1}/mgmt/tm/asm/policies/RYRZsR?$filter=contains(name,'{0}')+and+contains(partition,'{1}')&$select=name,partitionR[itselfLink(R\R;R]R,RR^R_R:R`RaRRb(R%RcRdReRfRgtpolicy_link((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyt_get_policy_link(s
cC`s|jj�}dj|jjd|jjd�}|jjrt|jtdi|j	�d6��|j
d�n|jjj|d|�}y|j
�}Wn%tk
r�}tt|���nXd|kr|dd
krd|krt|d��qt|j��n|dS(Ns0https://{0}:{1}/mgmt/tm/asm/tasks/import-policy/RYRZtpolicyReferencetlinkRR`tcodei�i�tmessagetid(i�i�(R<t
api_paramsR\R;R]R,RRMRKRmRER_tpostR`RaRRbRh(R%R9RcReRfRg((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyRT;s"
#cC`s(dj|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|ddkr$tSdS(
Ns3https://{0}:{1}/mgmt/tm/asm/tasks/import-policy/{2}RYRZRpi�RqRt	COMPLETEDtFAILUREisFailed to import ASM policy.(RusFAILURE(
R\R;R]RQR_R:R`RaRRbRhttimetsleep(R%ttask_idRcReRfRg((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyRUTs,

		c	C`s�tjj|jj�d}|j|jj|�tjd�t|jj	|jj
�}|jjr{dj||�}ndj||�}dj|j
jd|j
jd�}tdd	d
dj|��}|j
jj|d|�}yB|j�}d
|kr-d|d
kr-t|d
��q-nWn%tk
rU}tt|���nXd|kr�|ddkr�d|kr�t|d��q�t|j��ntS(NiisFtmsh load asm policy {0} file /var/config/rest/downloads/{1} overwrites<tmsh load asm policy {0} file /var/config/rest/downloads/{1}s"https://{0}:{1}/mgmt/tm/util/bash/RYRZtcommandtruntutilCmdArgss-c "{0}"R`t
commandResultsUnexpected ErrorRpi�Rq(tostpathtsplitR,RRjRwRxR
R^RRR\R;R]RKR_RtR`RRaRbRhRQ(	R%Rt	full_nametcmdRcR=ReRfRg((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyRVss4

cC`s
tjj|jj�d}dj|�}dj|jjd|jjd�}tddd|�}|jj	j
|d	|�}y|j�}Wn%tk
r�}t
t|���nXd
|kr|d
dkrd|kr�t
|d��qt
|j��ndS(
Nis/var/config/rest/downloads/{0}s%https://{0}:{1}/mgmt/tm/util/unix-rm/RYRZRzR{R|R`Rpi�Rq(R~RR�R,RR\R;R]RKR_RtR`RaRRbRh(R%Rt
tpath_nameRcR=ReRfRg((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyRW�s"
	(RRR.RARIRORLRRRjRmRTRURVRW(((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyR7�s											%tArgumentSpeccB`seZd�ZRS(cC`s�t|_tdtdt�dtdd�dt�dtddd	d
�dtd	dd
tdgf��}i|_|jjt�|jj|�ddgg|_dS(NRtrequiredRttypeRRRtbooltdefaulttnoR^tCommontfallbacktF5_PARTITION(RQtsupports_check_modeRKR	t
argument_specRMRtmutually_exclusive(R%R�((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyR.�s 					(RRR.(((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyR��scC`s�t�}td|jd|jd|j�}y,td|�}|j�}|j|�Wn)tk
r�}|j	dt
|��nXdS(NR�R�R�R8RC(R�RR�R�R�R7ROt	exit_jsonRt	fail_jsonRb(tspecR8tmmtresultsRg((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pytmain�s			t__main__(*t
__future__RRRR�t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR~Rwtansible.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.icontrolRRR R!R)R*tobjectR+R7R�R�R(((sV/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_asm_policy_import.pyt<module>sR


*!
�	

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