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

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZdd
lm
Z
ddlmZy�ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZWn�ek
r�ddlmZddlmZddlmZddlmZddlmZddlmZddl mZddl!mZddl mZnXdefd��YZ"de"fd��YZ#de"fd��YZ$de"fd��YZ%d e%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_bysZ
---
module: bigip_monitor_external
short_description: Manages external LTM monitors on a BIG-IP
description:
  - Manages external LTM monitors on a BIG-IP.
version_added: 2.6
options:
  name:
    description:
      - Specifies the name of the monitor.
    type: str
    required: True
  description:
    description:
      - The description of the monitor.
    type: str
    version_added: 2.7
  parent:
    description:
      - The parent template of this monitor template. Once this value has
        been set, it cannot be changed. By default, this value is the C(http)
        parent on the C(Common) partition.
    type: str
    default: /Common/external
  arguments:
    description:
      - Specifies any command-line arguments that the script requires.
    type: str
  ip:
    description:
      - IP address part of the IP/port definition. If this parameter is not
        provided when creating a new monitor, then the default value will be
        '*'.
    type: str
  port:
    description:
      - Port address part of the IP/port definition. If this parameter is not
        provided when creating a new monitor, then the default value will be
        '*'. Note that if specifying an IP address, a value between 1 and 65535
        must be specified.
    type: str
  external_program:
    description:
      - Specifies the name of the file for the monitor to use. In order to reference
        a file, you must first import it using options on the System > File Management > External
        Monitor Program File List > Import screen. The BIG-IP system automatically
        places the file in the proper location on the file system.
    type: str
  interval:
    description:
      - The interval specifying how frequently the monitor instance of this
        template will run. If this parameter is not provided when creating
        a new monitor, then the default value will be 5. This value B(must)
        be less than the C(timeout) value.
    type: int
  timeout:
    description:
      - The number of seconds in which the node or service must respond to
        the monitor request.
      - If the target responds within the set time period, it is considered up.
      - If the target does not respond within the set time period, it is considered
        down.
      - You can change this number to any number you want, however, it should be
        3 times the interval number of seconds plus 1 second.
      - If this parameter is not provided when creating a new monitor, then the
        default value will be C(16).
    type: int
  variables:
    description:
      - Specifies any variables that the script requires.
      - Note that double quotes in values will be suppressed.
    type: dict
  partition:
    description:
      - Device partition to manage resources on.
    type: str
    default: Common
  state:
    description:
      - When C(present), ensures that the monitor exists.
      - When C(absent), ensures the monitor is removed.
    type: str
    choices:
      - present
      - absent
    default: present
extends_documentation_fragment: f5
author:
  - Tim Rupp (@caphrim007)
  - Wojciech Wypior (@wojtek0806)
s

- name: Create an external monitor
  bigip_monitor_external:
    name: foo
    state: present
    provider:
      user: admin
      password: secret
      server: lb.mydomain.com
  delegate_to: localhost

- name: Create an external monitor with variables
  bigip_monitor_external:
    name: foo
    timeout: 10
    variables:
      var1: foo
      var2: bar
    state: present
    provider:
      user: admin
      password: secret
      server: lb.mydomain.com
  delegate_to: localhost

- name: Add a variable to an existing set
  bigip_monitor_external:
    name: foo
    timeout: 10
    variables:
      var1: foo
      var2: bar
      cat: dog
    state: present
    provider:
      user: admin
      password: secret
      server: lb.mydomain.com
  delegate_to: localhost
sX
parent:
  description: New parent template of the monitor.
  returned: changed
  type: str
  sample: external
description:
  description: The description of the monitor.
  returned: changed
  type: str
  sample: Important Monitor
ip:
  description: The new IP of IP/port definition.
  returned: changed
  type: str
  sample: 10.12.13.14
interval:
  description: The new interval in which to run the monitor check.
  returned: changed
  type: int
  sample: 2
timeout:
  description: The new timeout in which the remote system must respond to the monitor.
  returned: changed
  type: int
  sample: 10
N(t
AnsibleModule(tenv_fallback(t	iteritems(tF5RestClient(t
F5ModuleError(tAnsibleF5Parameters(tfq_name(tf5_argument_spec(ttransform_name(tcompare_dictionary(tis_valid_ip(tcmp_str_with_nonet
Parametersc	B`s�eZidd6dd6dd6dd6Zddd	d
dddgZddd
dd	ddddg	Zd
dd	ddddgZed��Zejd��Zed��Z	ed��Z
ed��Zed��Zed��Z
ed��ZRS(tparenttdefaultsFromt	variablestapiRawValuestexternal_programtrunt	argumentstargstintervalttimeouttdestinationtdescriptiontiptportcC`s>|jdkr"|jdkr"dSdj|j|j�}|S(Ns{0}:{1}(R!tNoneR"tformat(tselfR((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR�scC`s3|jd�\}}||jd<||jd<dS(Nt:R!R"(tsplitt_values(R%tvalueR!R"((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR�s
cC`s`|jddkrdSdt|jd�ko;dknrOtd��nt|jd�S(NRii�Qs*Interval value must be between 1 and 86400(R(R#tintR(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRs)cC`s(|jddkrdSt|jd�S(NR(R(R#R*(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRscC`s\|jddkrdS|jddkr.dSt|jd�rL|jdStd��dS(NR!t*s0.0.0.0s1The provided 'ip' parameter is not an IP address.(R+s0.0.0.0(R(R#RR(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR!scC`s?|jddkrdS|jddkr.dSt|jd�S(NR"R+(R(R#R*(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR""s
cC`s4|jddkrdSt|j|jd�}|S(NR(R(R#Rt	partition(R%tresult((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR*scC`sdS(Ntexternal((R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyttype1s(t__name__t
__module__tapi_maptapi_attributestreturnablest
updatablestpropertyRtsetterRRR!R"RR/(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR�sH
			

t
ApiParameterscB`s&eZed��Zed��ZRS(cC`s"|jddkrdS|jdS(NR tnone(NR9(R(R#(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR 7scC`s�|jddkrdSd}i}xat|jd�D]L\}}tj||�}|sjtd��n|jd�}|||<q7W|S(NRs^userDefined\s(?P<key>.*)s5Unable to find the variable 'key' in the API payload.tkey(R(R#R
tretmatchRtgroup(R%tpatternR-tktvtmatchesR:((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR=s (R0R1R6R R(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR86stModuleParameterscB`s5eZed��Zed��Zed��ZRS(cC`s9|jddkrdS|jddkr.dS|jdS(NR R9t(snoneRC(R(R#(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR Os
cC`sa|jddkrdSi}x=t|jd�D](\}}t|�jdd�||<q1W|S(NRt"RC(R(R#R
tstrtreplace(R%R-R?R@((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRWs  cC`s.|jddkrdSt|j|jd�S(NR(R(R#RR,(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR`s(R0R1R6R RR(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRBNs	tChangescB`seZd�ZRS(cC`sXi}y:x$|jD]}t||�||<qW|j|�}Wntk
rSnX|S(N(R4tgetattrt_filter_paramst	Exception(R%R-t
returnable((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyt	to_returnhs
(R0R1RL(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRGgst
UsableChangescB`seZRS((R0R1(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRMsstReportableChangescB`seZRS((R0R1(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRNwst
DifferencecB`sqeZdd�Zd�Zd�Zed��Zed��Zed��Z	ed��Z
ed��ZRS(	cC`s||_||_dS(N(twantthave(R%RPRQ((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyt__init__|s	cC`s9yt||�}|SWntk
r4|j|�SXdS(N(RHtAttributeErrort_Difference__default(R%tparamR-((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pytcompare�s

cC`sQt|j|�}y&t|j|�}||kr7|SWntk
rL|SXdS(N(RHRPRQRS(R%RUtattr1tattr2((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyt	__default�s
cC`s+|jj|jjkr'td��ndS(Ns$The parent monitor cannot be changed(RPRRQR(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR�scC`s�|jjdkr(|jjdkr(dS|jjdkrZ|jji|jjd6�n|jjdkr�|jji|jjd6�n|jjdkr�|jjdkr�td��n|jj|jjkr�|jjSdS(NR"R!R+sASpecifying an IP address requires that a port number be specified(NR+(RPR!R#R"tupdateRQRR(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR�s$  $cC`s�|jjdk	rN|jjdk	rN|jj|jjkr�td��q�nx|jjdk	r�|jj|jjkr�td��q�n<|jjdk	r�|jj|jjkr�td��q�n|jj|jjkr�|jjSdS(Ns1Parameter 'interval' must be less than 'timeout'.(RPRR#RRRQ(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR�s$cC`s?|jjdkrdS|jjdkr;td|jj�St�}t|jj|jj�}|sidSxtt|jj�D]`\}}||jjkr�||jj|kr�|||<q|||jjkr||||<q|q|Wx?t|jj�D]+\}}||jjkr�d||<q�q�W|r;td|�}|SdS(NRR9(RPRR#RQtdictRR
(R%R-t	differentR?R@((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR�s*
	(
	cC`st|jj|jj�S(N(RRPR RQ(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR �sN(R0R1R#RRRVRTR6RRRRR (((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRO{s			t
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(tgetR#R^RR_tclientRBRPR8RQRMtchanges(R%Rtkwargs((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRR�s
cC`sji}xBtjD]7}t|j|�dk	rt|j|�||<qqW|rftd|�|_ndS(NR_(RR4RHRPR#RMRb(R%tchangedR:((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyt_set_changed_options�scC`s�t|j|j�}tj}t�}xX|D]P}|j|�}|dkrUq.q.t|t�rt|j	|�q.|||<q.W|r�t
d|�|_tSt
S(NR_(RORPRQRR5R[RVR#t
isinstanceRZRMRbtTruetFalse(R%tdiffR5RdR?tchange((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyt_update_changed_options�s		
cC`s|j�}|rtStS(N(RkRgRh(R%R-((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyt
should_update�scC`s�t}t�}|jj}|dkr6|j�}n|dkrQ|j�}ntd|jj��}|j�}|j	|�|j	td|��|j
|�|S(NtpresenttabsentR_Rd(RhR[RPtstateRmRnRNRbRLRZt_announce_deprecations(R%RdR-Rot
reportableRb((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pytexec_modules	

cC`sK|jdg�}x2|D]*}|jjjd|dd|d�qWdS(Nt
__warningstmsgtversion(tpopRaR^t	deprecate(R%R-twarningstwarning((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRps


cC`s$|j�r|j�S|j�SdS(N(texistsRZtcreate(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRms
cC`s�dj|jjd|jjdt|jj|jj��}|jjj|�}y|j	�}Wnt
k
rwtSX|jdks�d|kr�|ddkr�tSt
S(Ns0https://{0}:{1}/mgmt/tm/ltm/monitor/external/{2}tservertserver_porti�tcode(R$RatproviderRRPR,tnametapiR`tjsont
ValueErrorRhRRg(R%turitresptresponse((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRz#s


+cC`s=|j�|_|j�stS|jjr/tS|j�tS(N(tread_current_from_deviceRQRlRhR^t
check_modeRgtupdate_on_device(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRZ2s
cC`s9|jjrtS|j�|j�r5td��ntS(NsFailed to delete the resource.(R^R�Rgtremove_from_deviceRzR(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pytremove;s
cC`s2|j�|j�|jjr$tS|j�tS(N(Ret_set_default_creation_valuesR^R�Rgtcreate_on_device(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR{Cs


cC`s�|jjdkr,|jjidd6�n|jjdkrX|jjidd6�n|jjdkr�|jjidd6�n|jjdkr�|jjidd6�ndS(NiRiRR+R!R"(RPRR#RZRR!R"(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR�KscC`s|jj�}|jj|d<|jj|d<dj|jjd|jjd�}|jjj	|d|�}y|j
�}Wn%tk
r�}tt
|���nXd|kr�|ddkr�d
|kr�t|d
��q�t|j��n|jjr|j|jj�ndS(NR�R,s-https://{0}:{1}/mgmt/tm/ltm/monitor/external/R|R}R�R~i�i�tmessage(i�i�(Rbt
api_paramsRPR�R,R$RaRR�tpostR�R�RREtcontentRtset_variable_on_device(R%R_R�R�R�tex((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR�Us"
c
C`s:djgt|�D]\}}dj||�^q�}dj|jj|�}dj|jjd|jjd�}tddd	d
j|��}|jjj	|d|�}y|j
�}Wn%tk
r�}	tt
|	���nXd|kr6|dd
kr6d|kr$t|d��q6t|j��ndS(Nt suser-defined {0} \"{1}\"s(tmsh modify ltm monitor external {0} {1}s!https://{0}:{1}/mgmt/tm/util/bashR|R}tcommandRtutilCmdArgss-c "{0}"R�R~i�R�(tjoinR
R$RPR�RaRR[R�R�R�R�RRER�(
R%tcommandsR?R@R�R�RR�R�R�((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR�ls":
cC`s|jj�}|r�dj|jjd|jjdt|jj|jj��}|jj	j
|d|�}y|j�}Wn%tk
r�}t
t|���nXd|kr�|ddkr�d|kr�t
|d��q�t
|j��q�n|jjr|j|jj�ndS(Ns0https://{0}:{1}/mgmt/tm/ltm/monitor/external/{2}R|R}R�R~i�R�(RbR�R$RaRRRPR,R�R�tpatchR�R�RRER�RR�(R%R_R�R�R�R�((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR��s"

cC`s|j�r|j�StS(N(RzR�Rh(R%((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRn�s
cC`sjdj|jjd|jjdt|jj|jj��}|jjj|�}|j	dkrft
SdS(Ns0https://{0}:{1}/mgmt/tm/ltm/monitor/external/{2}R|R}i�(R$RaRRRPR,R�R�tdeleteRRg(R%R�R�((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR��s

cC`s�dj|jjd|jjdt|jj|jj��}|jjj|�}y|j	�}Wn%t
k
r�}tt|���nXd|kr�|ddkr�d|kr�t|d��q�t|j
��ntd|�S(Ns0https://{0}:{1}/mgmt/tm/ltm/monitor/external/{2}R|R}R~i�R�R_(R$RaRRRPR,R�R�R`R�R�RRER�R8(R%R�R�R�R�((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR��s

(R0R1RRReRkRlRrRpRmRzRZR�R{R�R�R�R�RnR�R�(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR]�s$													
					
tArgumentSpeccB`seZd�ZRS(cC`s�t|_tdtdt�dtdd�dt�dt�dt�d	t�d
t�dtdd
�dtdd
�dtdddddg�dtdd�dtdddtdgf��}i|_|jjt�|jj|�dS(NR�trequiredRtdefaults/Common/externalR RR!R"RRR/R*RRoRmtchoicesRnRR[R,tCommontfallbacktF5_PARTITION(Rgtsupports_check_modeR[R	t
argument_specRZR(R%R�((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyRR�s*							(R0R1RR(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyR��scC`s�t�}td|jd|j�}y,td|�}|j�}|j|�Wn)tk
r{}|jdt	|��nXdS(NR�R�R^Rt(
R�RR�R�R]Rrt	exit_jsonRt	fail_jsonRE(tspecR^tmmtresultsR�((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pytmain�s		t__main__(.t
__future__RRRR/t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR;tansible.module_utils.basicRR	tansible.module_utils.sixR
t%library.module_utils.network.f5.bigipRt&library.module_utils.network.f5.commonRR
RRRt'library.module_utils.network.f5.compareRt)library.module_utils.network.f5.ipaddressRRtImportErrort%ansible.module_utils.network.f5.bigipt&ansible.module_utils.network.f5.commont'ansible.module_utils.network.f5.comparet)ansible.module_utils.network.f5.ipaddressRR8RBRGRMRNtobjectROR]R�R�R0(((sU/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_monitor_external.pyt<module>sV


])
ia�	

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