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_iapp_template.pyc

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlm
Z
dd
lmZytddlmZddlmZddlmZddlmZddlmZddlmZddlmZWn�ek
r�ddlmZddlmZddlmZddlmZddlmZddlmZddlmZnXyddlmZWn!ek
r�ddlmZnXdefd��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_versiontstableinterfacetstatust	certifiedtsupported_bysR	
---
module: bigip_iapp_template
short_description: Manages TCL iApp templates on a BIG-IP
description:
  - Manages TCL iApp templates on a BIG-IP. This module will allow you to
    deploy iApp templates to the BIG-IP and manage their lifecycle. The
    conventional way to use this module is to import new iApps as needed
    or by extracting the contents of the iApp archive that is provided at
    downloads.f5.com and then importing all the iApps with this module.
    This module can also update existing iApps provided that the source
    of the iApp changed while the name stayed the same. Note however that
    this module will not reconfigure any services that may have been
    created using the C(bigip_iapp_service) module. iApps are normally
    not updated in production. Instead, new versions are deployed and then
    existing services are changed to consume that new template. As such,
    the ability to update templates in-place requires the C(force) option
    to be used.
version_added: 2.4
options:
  force:
    description:
      - Specifies whether or not to force the uploading of an iApp. When
        C(yes), will force update the iApp even if there are iApp services
        using it. This will not update the running service though. Use
        C(bigip_iapp_service) to do that. When C(no), will update the iApp
        only if there are no iApp services using the template.
    type: bool
  name:
    description:
      - The name of the iApp template that you want to delete. This option
        is only available when specifying a C(state) of C(absent) and is
        provided as a way to delete templates that you may no longer have
        the source of.
    type: str
  content:
    description:
      - Sets the contents of an iApp template directly to the specified
        value. This is for simple values, but can be used with lookup
        plugins for anything complex or with formatting. C(content) must
        be provided when creating new templates.
    type: str
  state:
    description:
      - Whether the iApp template should exist or not.
    type: str
    choices:
      - present
      - absent
    default: present
  partition:
    description:
      - Device partition to manage resources on.
    type: str
    default: Common
extends_documentation_fragment: f5
author:
  - Tim Rupp (@caphrim007)
  - Wojciech Wypior (@wojtek0806)
s(
- name: Add the iApp contained in template iapp.tmpl
  bigip_iapp_template:
    content: "{{ lookup('template', 'iapp.tmpl') }}"
    state: present
    provider:
      user: admin
      password: secret
      server: lb.mydomain.com
  delegate_to: localhost

- name: Update a template in place
  bigip_iapp_template:
    content: "{{ lookup('template', 'iapp-new.tmpl') }}"
    state: present
    provider:
      user: admin
      password: secret
      server: lb.mydomain.com
  delegate_to: localhost

- name: Update a template in place that has existing services created from it.
  bigip_iapp_template:
    content: "{{ lookup('template', 'iapp-new.tmpl') }}"
    force: yes
    state: present
    provider:
      user: admin
      password: secret
      server: lb.mydomain.com
  delegate_to: localhost
s
# only common fields returned
N(t
AnsibleModule(tenv_fallback(tF5RestClient(t
F5ModuleError(tAnsibleF5Parameters(tfq_name(tf5_argument_spec(ttransform_name(tupload_file(tStringIOt
ParameterscB`s\eZgZgZed��Zed��Zed��Zd�Zd�Z	d�Z
RS(cC`s9|jdr|jdS|jdr5|j�}|SdS(Ntnametcontent(t_valuest_get_template_nametNone(tselfR((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR�s

cC`s6|jddkrdS|j�}|j|�}|S(NR(RRt_squash_template_name_prefixt_replace_template_name(Rtresult((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR�s
cC`s|jdS(NttmplChecksum(R(R((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pytchecksum�scC`s&d}d}tj|||jd�S(s�Removes the template name prefix

        This method removes that partition from the name
        in the iApp so that comparisons can be done properly and entries
        can be created properly when using REST.

        :return string
        s'sys\s+application\s+template\s+/Common/ssys application template R(tretsubR(Rtpatterntreplace((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR�s	cC`s]d}|jdr#|jd}n|j�}djt|j|��}tj|||�S(s9Replaces template name at runtime

        To allow us to do the switch-a-roo with temporary templates and
        checksum comparisons, we need to take the template provided to us
        and change its name to a temporary value so that BIG-IP will create
        a clone for us.

        :return string
        s$sys\s+application\s+template\s+[^ ]+Rssys application template {0}(RRtformatR
t	partitionRR(RttemplateR RR!((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR�s

cC`sld}tj||jd�}y|jd�j�}Wntk
rQd}nX|r\|Std��dS(NsTsys\s+application\s+template\s+(?P<path>\/[^\{}"\'*?|#]+\/)?(?P<name>[^\{}"\'*?|#]+)RRs*No template name was found in the template(RtsearchRtgrouptstript
IndexErrorRR(RR tmatchesR((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR�s

(t__name__t
__module__tapi_attributestreturnablestpropertyRRRRRR(((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR�s		
	t
ApiParameterscB`seZRS((R*R+(((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR/�stModuleParameterscB`seZRS((R*R+(((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR0�stChangescB`seZd�ZRS(cC`sXi}y:x$|jD]}t||�||<qW|j|�}Wntk
rSnX|S(N(R-tgetattrt_filter_paramst	Exception(RRt
returnable((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyt	to_return�s
(R*R+R6(((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR1�st
UsableChangescB`seZRS((R*R+(((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR7�stReportableChangescB`seZRS((R*R+(((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR8�st
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`s^|jdd�|_t|jj�|_td|jj�|_t�|_	t
�|_dS(Ntmoduletparams(tgetRR:R
R;tclientR0twantR/thaveR7tchanges(Rtargstkwargs((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyt__init__�s
cC`sK|jdg�}x2|D]*}|jjjd|dd|d�qWdS(Nt
__warningstmsgtversion(tpopR=R:t	deprecate(RRtwarningstwarning((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyt_announce_deprecations�s


cC`s�t}t�}|jj}|dkr6|j�}n|dkrQ|j�}ntd|jj��}|j�}|j	|�|j	td|��|j
|�|S(NtpresenttabsentR;tchanged(tFalsetdictR>tstateRLRMR8R@R6tupdateRK(RRNRRQt
reportableR@((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pytexec_modules	

cC`s$|j�r|j�S|j�SdS(N(texistsRRtcreate(R((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyRLs
cC`s%t}|j�r!|j�}n|S(N(RORUtremove(RRN((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyRMscC`s:|jjrtS|j�|j�r*tStd��dS(Ns"Failed to create the iApp template(R:t
check_modetTruetcreate_on_deviceRUR(R((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyRV s
cC`s9|jjrtS|j�|j�r5td��ntS(Ns"Failed to delete the iApp template(R:RXRYtremove_from_deviceRUR(R((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyRW)s
cC`sn|j�|_|j�stS|jjr<|j�r<tS|jjrLt	S|j
�|j�|j�t	S(N(
tread_current_from_deviceR?ttemplates_differROR>tforcettemplate_in_useR:RXRYt_remove_iapp_checksumRZt%_generate_template_checksum_on_device(R((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyRR1s


cC`s�dj|jjd|jjdt|jj|jj��}|jjj|�}y|j	�}Wnt
k
rwtSX|jdks�d|kr�|ddkr�tSt
S(Ns4https://{0}:{1}/mgmt/tm/sys/application/template/{2}tservertserver_porti�tcode(R"R=tproviderRR>R#RtapiR<tjsont
ValueErrorRORRY(Rturitresptresponse((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyRUCs


+cC`s�dj|jjd|jjd�}t|jj|jj�}|jjj|�}y|j	�}Wnt
k
rztSX|jdks�d|kr�|ddkr�tSx&|dD]}|d|kr�t
Sq�WtS(Ns0https://{0}:{1}/mgmt/tm/sys/application/service/RbRci�RdtitemsR$(R"R=ReR
R>R#RRfR<RgRhRORRY(RRiRRjRktitem((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR_Rs

+cC`s�|j�dj|jjd|jjdt|jj|jj��}|jjj	|�}y|j
�}Wn%tk
r�}tt
|���nXd|kr�|ddkr�d|kr�t|d��q�t|j��ntd|�S(Ns4https://{0}:{1}/mgmt/tm/sys/application/template/{2}RbRcRdi�tmessageR;(RaR"R=ReRR>R#RRfR<RgRhRtstrRR/(RRiRjRktex((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR\gs


cC`s�dj|jjd|jjdt|jj|jj��}tdd	�}|jj	j
|d|�}y|j�}Wn%tk
r�}t
t|���nXd|kr�|ddkr�d|kr�t
|d��q�t
|j��nd	S(
s�Removes the iApp tmplChecksum

        This is required for updating in place or else the load command will
        fail with a "AppTemplate ... content does not match the checksum"
        error.

        :return:
        s4https://{0}:{1}/mgmt/tm/sys/application/template/{2}RbRcRRgRdi�RnN(R"R=ReRR>R#RRPRRftpatchRgRhRRoR(RRiR;RjRkRp((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR`}s	

cC`sx|jj}|jjidjttj���d6�|j�}|jji|d6�|j|j	jkrtt
StS(Nsansible-{0}R(R>RRRR"Rotuuidtuuid4t_get_temporary_templateRR?RYRO(Rtbackupttemp((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR]�s cC`s$|j�|j�}|j�|S(N(RZR\R[(RRv((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyRt�s

cC`s�dj|jj�}tddddj|��}dj|jjd|jjd�}|jjj|d	|�}y|j�}Wn%t	k
r�}t
t|���nXd
|kr�|d
dkr�d
|kr�t
|d
��q�t
|j��ndS(Ns3tmsh generate sys application template {0} checksumtcommandtruntutilCmdArgss-c "{0}"s!https://{0}:{1}/mgmt/tm/util/bashRbRcRgRdi�i�Rn(i�i�(
R"R>RRPR=ReRftpostRgRhRRoR(RRwR;RiRjRkRp((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyRa�s"
cC`sddj|jjd|jjd�}yt|j|||�Wntk
r_td��nXdS(Ns1https://{0}:{1}/mgmt/shared/file-transfer/uploadsRbRcsFailed to upload the file.(R"R=ReRR(RRRturl((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pytupload_file_to_device�s

c	C`s�dj|jj�}dj|�}t|jj�}|j||jj�dj|jjd|jjd�}tdddd	j|��}|jj	j
|d
|�}ye|j�}d|krd|dkr�t|d��nd
|dkrt|d��qnWn%t
k
r7}tt|���nXd|kr�|ddkr�d|krst|d��q�t|j��ntS(Ns/var/config/rest/downloads/{0}s&tmsh load sys application template {0}s!https://{0}:{1}/mgmt/tm/util/bashRbRcRwRxRys-c "{0}"Rgt
commandResultsSyntax ErrortERRORRdi�i�Rn(i�i�(R"R>RRRR|R=ReRPRfRzRgRRhRoRY(	Rtremote_pathtload_commandR$RiR;RjRkRp((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyRZ�s2
cC`sydj|jjd|jjdt|jj|jj��}|jjj|�}|j	dkrft
St|j��dS(Ns4https://{0}:{1}/mgmt/tm/sys/application/template/{2}RbRci�(
R"R=ReRR>R#RRftdeleteRRYRR(RRiRk((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR[s

(R*R+RCRKRTRLRMRVRWRRRUR_R\R`R]RtRaR|RZR[(((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR9�s$														 				"tArgumentSpeccB`seZd�ZRS(cC`s�t|_tdt�dtdddddg�dtdd	�d
t�dtddd
tdgf��}i|_|jjt�|jj|�dS(NRRQtdefaultRLtchoicesRMR^ttypetboolRR#tCommontfallbacktF5_PARTITION(RYtsupports_check_modeRPR	t
argument_specRRR(RR�((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyRCs					(R*R+RC(((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyR�scC`s�t�}td|jd|j�}y,td|�}|j�}|j|�Wn)tk
r{}|jdt	|��nXdS(NR�R�R:RE(
R�RR�R�R9RTt	exit_jsonRt	fail_jsonRo(tspecR:tmmtresultsRp((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pytmain*s		t__main__(*t
__future__RRRR�t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRRrtansible.module_utils.basicRR	t%library.module_utils.network.f5.bigipR
t&library.module_utils.network.f5.commonRRR
RRt(library.module_utils.network.f5.icontrolRtImportErrort%ansible.module_utils.network.f5.bigipt&ansible.module_utils.network.f5.commont(ansible.module_utils.network.f5.icontrolRtioRR/R0R1R7R8tobjectR9R�R�R*(((sR/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_iapp_template.pyt<module>sV


=!

I�!	

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