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

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlm
Z
dd
lmZddlmZy�ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZWn�ek
r�ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZnXdefd��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(kr�e)�ndS()i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	certifiedtsupported_bysR
---
module: bigip_apm_policy_fetch
short_description: Exports the APM policy or APM access profile from remote nodes.
description:
  - Exports the apm policy or APM access profile from remote nodes.
version_added: 2.8
options:
  name:
    description:
      - The name of the APM policy or APM access profile exported to create a file on the remote device for downloading.
    type: str
    required: True
  dest:
    description:
      - A directory to save the file into.
    type: path
  file:
    description:
      - The name of the file to be created on the remote device for downloading.
    type: str
  type:
    description:
      - Specifies the type of item to export from device.
    type: str
    choices:
      - profile_access
      - access_policy
    default: profile_access
  force:
    description:
      - If C(no), the file will only be transferred if it does not exist in the the destination.
    type: bool
    default: yes
  partition:
    description:
      - Device partition to which contain APM policy or APM access profile to export.
    type: str
    default: Common
notes:
  - Due to ID685681 it is not possible to execute ng_* tools via REST api on v12.x and 13.x, once this is fixed
    this restriction will be removed.
  - Requires BIG-IP >= 14.0.0
extends_documentation_fragment: f5
author:
  - Wojciech Wypior (@wojtek0806)
s�
- name: Export APM access profile
  bigip_apm_policy_fetch:
    name: foobar
    file: export_foo
    dest: /root/download
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost

- name: Export APM access policy
  bigip_apm_policy_fetch:
    name: foobar
    file: export_foo
    dest: /root/download
    type: access_policy
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost

- name: Export APM access profile, autogenerate name
  bigip_apm_policy_fetch:
    name: foobar
    dest: /root/download
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost
st
name:
  description: Name of the APM policy or APM access profile to be exported.
  returned: changed
  type: str
  sample: APM_policy_global
file:
  description:
    - Name of the exported 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_file
dest:
  description: Local path to download exported APM policy.
  returned: changed
  type: str
  sample: /root/downloads/profile-foobar_file.conf.tar.gz
type:
  description: Set to specify type of item to export.
  returned: changed
  type: str
  sample: access_policy
N(t
AnsibleModule(tenv_fallback(tLooseVersion(tF5RestClient(t
F5ModuleError(tAnsibleF5Parameters(tf5_argument_spec(ttransform_name(t
download_file(ttmos_version(tmodule_provisionedt
ParameterscB`s/eZiZgZdddddgZgZRS(tnametfiletdestttypetforce(t__name__t
__module__tapi_maptapi_attributestreturnablest
updatables(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyR�s	t
ApiParameterscB`seZRS((RR(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyR�stModuleParameterscB`s>eZd�Zed��Zed��Zed��ZRS(cC`s�|jdkrJdj|jjd|jjdt|j|j��}n8dj|jjd|jjdt|j|j��}|jjj|�}y|j	�}Wn%t
k
r�}tt|���nXd|kr�|dgkr�t
StS(Nt
access_policys4https://{0}:{1}/mgmt/tm/apm/policy/access-policy/{2}tservertserver_ports.https://{0}:{1}/mgmt/tm/apm/profile/access/{2}titems(RtformattclienttproviderRt	partitionRtapitgettjsont
ValueErrorRtstrtTruetFalse(tselfturitresptresponsetex((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyt_item_exists�s"



cC`sE|jddk	r|jdSttj��d}||jd<|S(NRs.tar.gz(t_valuestNonetnextttempfilet_get_candidate_names(R0tresult((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_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(R7tostpathtisdirRtjoinRtexiststdirnametstattOSErrorR-tlowerRR%taccesstW_OK(R0R;te((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pytfulldest�s"!!"!!cC`s<|j�s1tdj|j|jd���n|jdS(Ns<The provided {0} with the name {1} does not exist on device.R(R5RR%RR6(R0((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyR�s	(RRR5tpropertyRRHR(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyR �s	tChangescB`seZd�ZRS(cC`sXi}y:x$|jD]}t||�||<qW|j|�}Wntk
rSnX|S(N(Rtgetattrt_filter_paramst	Exception(R0R;t
returnable((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyt	to_return�s
(RRRO(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyRJ�st
UsableChangescB`seZRS((RR(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyRP�stReportableChangescB`seZRS((RR(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyRQst
ModuleManagercB`s�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�ZRS(cO`sR|jdd�|_t|jj�|_td|jj�|_t�|_	dS(Ntmoduletparams(
R*R7RSRRTR&R twantRPtchanges(R0targstkwargs((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyt__init__scC`sji}xBtjD]7}t|j|�dk	rt|j|�||<qqW|rftd|�|_ndS(NRT(RRRKRUR7RPRV(R0tchangedtkey((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyt_set_changed_optionsscC`sK|jdg�}x2|D]*}|jjjd|dd|d�qWdS(Nt
__warningstmsgtversion(tpopR&RSt	deprecate(R0R;twarningstwarning((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyt_announce_deprecationss


cC`s�t|jd�s!td��n|j�r<td��nt�}|j�td|jj��}|j�}|j	|�|j	tdt
��|S(Ntapms+APM must be provisioned to use this module.sTDue to bug ID685681 it is not possible to use this module on TMOS version below 14.xRTRZ(RR&Rtversion_less_than_14tdicttexportRQRVROtupdateR.(R0R;t
reportableRV((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pytexec_modules	

cC`s/t|j�}t|�td�kr+tStS(Ns14.0.0(RR&R
R.R/(R0R_((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyRf.scC`s$|j�r|j�S|j�SdS(N(R@Ritcreate(R0((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyRh4s
cC`s8|jjs*tdj|jj���n|j�dS(NsFile '{0}' already exists.(RURRR%RHtexecute(R0((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyRi:scC`s2|j�|jjrtS|j�|j�tS(N(R\RSt
check_modeR.tcreate_on_deviceRm(R0((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyRlAs


cC`s?|j|jj�tjj|jj�r/tStd��dS(Ns#Failed to download the remote file.(tdownload_from_deviceRURHR<R=R@R.R(R0((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pytdownloadIs
cC`s|j�|j�tS(N(Rqtremove_temp_file_from_deviceR.(R0((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyRmQs

cC`s tjj|jj�rtStS(N(R<R=R@RURHR.R/(R0((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyR@VscC`s3dj|jj|jj|jj|jj�}dj|jjd|jjd�}tddddj|��}|jjj	|d	|�}y|j
�}Wn%tk
r�}tt
|���nXd
|kr|d
dkrd
|krt|d
��qt|j��nd|kr/td��ntS(Nsng_export -t {0} {1} {2} -p {3}s"https://{0}:{1}/mgmt/tm/util/bash/R"R#tcommandtruntutilCmdArgss-c "{0}"R+tcodei�i�tmessaget
commandResultsItem export command failed.(i�i�(R%RURRR(R&R'RgR)tpostR+R,RR-tcontentR.(R0tcmdR1RWR2R3R4((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyRo[s(*
c	C`se|jjdkrd}nd}dj||jj�}dj|d|jj�}tddd	|�}d
j|jjd|jjd�}|jjj	|d
|�}yB|j
�}d|kr�d|dkr�t|d��q�nWn%tk
r}tt
|���nXd|kra|ddkrad|krOt|d��qat|j��ntS(NR!tpolicytprofiles{0}-{1}.conf.tar.gzs/shared/tmp/{0} {1}/{2}s/ts/var/restRsRtRus%https://{0}:{1}/mgmt/tm/util/unix-mv/R"R#R+Rxscannot statRvi�i�Rw(i�i�(RURR%RRRgR&R'R)RyR+RR,R-RzR.(	R0titemRt	move_pathRTR1R2R3R4((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyt_move_file_to_downloadws6		
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'RURRRR<R=R@RR.R/(R0Rturl((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyRp�s



cC`s�dj|jj�}dj|jjd|jjd�}tddd|�}|jjj|d|�}y|j�}Wn%t	k
r�}t
t|���nXd	|kr�|d	d
kr�d|kr�t
|d��q�t
|j��ndS(Ns/ts/var/rest/{0}s%https://{0}:{1}/mgmt/tm/util/unix-rm/R"R#RsRtRuR+Rvi�Rw(
R%RURR&R'RgR)RyR+R,RR-Rz(R0t
tpath_nameR1RWR2R3R4((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyRr�s 
	(RRRYR\RdRkRfRhRiRlRqRmR@RoR�RpRr(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyRRs													(	tArgumentSpeccB`seZd�ZRS(cC`s�t|_tdtdt�dtdd�dtddddd	g�d
t�dtdddd
�dtdddtdgf��}i|_|jjt�|jj|�dS(NRtrequiredRRR=tdefaulttprofile_accesstchoicesR!RRtyestboolR(tCommontfallbacktF5_PARTITION(R.tsupports_check_modeRgR	t
argument_specRiR(R0R�((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyRY�s&						(RRRY(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyR��scC`s�t�}td|jd|j�}y,td|�}|j�}|j|�Wn)tk
r{}|jdt	|��nXdS(NR�R�RSR^(
R�RR�R�RRRkt	exit_jsonRt	fail_jsonR-(tspecRStmmtresultsR4((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pytmain�s		t__main__(+t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR<R9tansible.module_utils.basicRR	tdistutils.versionR
t%library.module_utils.network.f5.bigipRt&library.module_utils.network.f5.commonRR
RRt(library.module_utils.network.f5.icontrolRRRtImportErrort%ansible.module_utils.network.f5.bigipt&ansible.module_utils.network.f5.commont(ansible.module_utils.network.f5.icontrolRRR RJRPRQtobjectRRR�R�R(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_apm_policy_fetch.pyt<module>sR


0#
F�	

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