Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/netscaler/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZddlZdd
l
mZmZmZmZmZmZyZddlmZddlmZddlmZddlmZddlmZeZWne k
rZ!e"ZnXd�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d�Z/d �Z0e1d!kr�e0�ndS("i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�+
---
module: netscaler_servicegroup
short_description: Manage service group configuration in Netscaler
description:
    - Manage service group configuration in Netscaler.
    - This module is intended to run either on the ansible  control node or a bastion (jumpserver) with access to the actual netscaler instance.

version_added: "2.4"

author: George Nikolopoulos (@giorgos-nikolopoulos)

options:
    servicegroupname:
        description:
            - >-
                Name of the service group. Must begin with an ASCII alphabetic or underscore C(_) character, and must
                contain only ASCII alphanumeric, underscore C(_), hash C(#), period C(.), space C( ), colon C(:), at C(@), equals
                C(=), and hyphen C(-) characters. Can be changed after the name is created.
            - "Minimum length = 1"

    servicetype:
        choices:
            - 'HTTP'
            - 'FTP'
            - 'TCP'
            - 'UDP'
            - 'SSL'
            - 'SSL_BRIDGE'
            - 'SSL_TCP'
            - 'DTLS'
            - 'NNTP'
            - 'RPCSVR'
            - 'DNS'
            - 'ADNS'
            - 'SNMP'
            - 'RTSP'
            - 'DHCPRA'
            - 'ANY'
            - 'SIP_UDP'
            - 'SIP_TCP'
            - 'SIP_SSL'
            - 'DNS_TCP'
            - 'ADNS_TCP'
            - 'MYSQL'
            - 'MSSQL'
            - 'ORACLE'
            - 'RADIUS'
            - 'RADIUSListener'
            - 'RDP'
            - 'DIAMETER'
            - 'SSL_DIAMETER'
            - 'TFTP'
            - 'SMPP'
            - 'PPTP'
            - 'GRE'
            - 'SYSLOGTCP'
            - 'SYSLOGUDP'
            - 'FIX'
            - 'SSL_FIX'
        description:
            - "Protocol used to exchange data with the service."

    cachetype:
        choices:
            - 'TRANSPARENT'
            - 'REVERSE'
            - 'FORWARD'
        description:
            - "Cache type supported by the cache server."

    maxclient:
        description:
            - "Maximum number of simultaneous open connections for the service group."
            - "Minimum value = C(0)"
            - "Maximum value = C(4294967294)"

    maxreq:
        description:
            - "Maximum number of requests that can be sent on a persistent connection to the service group."
            - "Note: Connection requests beyond this value are rejected."
            - "Minimum value = C(0)"
            - "Maximum value = C(65535)"

    cacheable:
        description:
            - "Use the transparent cache redirection virtual server to forward the request to the cache server."
            - "Note: Do not set this parameter if you set the Cache Type."
        type: bool

    cip:
        choices:
            - 'enabled'
            - 'disabled'
        description:
            - "Insert the Client IP header in requests forwarded to the service."

    cipheader:
        description:
            - >-
                Name of the HTTP header whose value must be set to the IP address of the client. Used with the Client
                IP parameter. If client IP insertion is enabled, and the client IP header is not specified, the value
                of Client IP Header parameter or the value set by the set ns config command is used as client's IP
                header name.
            - "Minimum length = 1"

    usip:
        description:
            - >-
                Use client's IP address as the source IP address when initiating connection to the server. With the
                NO setting, which is the default, a mapped IP (MIP) address or subnet IP (SNIP) address is used as
                the source IP address to initiate server side connections.
        type: bool

    pathmonitor:
        description:
            - "Path monitoring for clustering."
        type: bool

    pathmonitorindv:
        description:
            - "Individual Path monitoring decisions."
        type: bool

    useproxyport:
        description:
            - >-
                Use the proxy port as the source port when initiating connections with the server. With the NO
                setting, the client-side connection port is used as the source port for the server-side connection.
            - "Note: This parameter is available only when the Use Source IP C(usip) parameter is set to C(yes)."
        type: bool

    healthmonitor:
        description:
            - "Monitor the health of this service. Available settings function as follows:"
            - "C(yes) - Send probes to check the health of the service."
            - >-
                C(no) - Do not send probes to check the health of the service. With the NO option, the appliance shows
                the service as UP at all times.
        type: bool

    sp:
        description:
            - "Enable surge protection for the service group."
        type: bool

    rtspsessionidremap:
        description:
            - "Enable RTSP session ID mapping for the service group."
        type: bool

    clttimeout:
        description:
            - "Time, in seconds, after which to terminate an idle client connection."
            - "Minimum value = C(0)"
            - "Maximum value = C(31536000)"

    svrtimeout:
        description:
            - "Time, in seconds, after which to terminate an idle server connection."
            - "Minimum value = C(0)"
            - "Maximum value = C(31536000)"

    cka:
        description:
            - "Enable client keep-alive for the service group."
        type: bool

    tcpb:
        description:
            - "Enable TCP buffering for the service group."
        type: bool

    cmp:
        description:
            - "Enable compression for the specified service."
        type: bool

    maxbandwidth:
        description:
            - "Maximum bandwidth, in Kbps, allocated for all the services in the service group."
            - "Minimum value = C(0)"
            - "Maximum value = C(4294967287)"

    monthreshold:
        description:
            - >-
                Minimum sum of weights of the monitors that are bound to this service. Used to determine whether to
                mark a service as UP or DOWN.
            - "Minimum value = C(0)"
            - "Maximum value = C(65535)"

    downstateflush:
        choices:
            - 'enabled'
            - 'disabled'
        description:
            - >-
                Flush all active transactions associated with all the services in the service group whose state
                transitions from UP to DOWN. Do not enable this option for applications that must complete their
                transactions.

    tcpprofilename:
        description:
            - "Name of the TCP profile that contains TCP configuration settings for the service group."
            - "Minimum length = 1"
            - "Maximum length = 127"

    httpprofilename:
        description:
            - "Name of the HTTP profile that contains HTTP configuration settings for the service group."
            - "Minimum length = 1"
            - "Maximum length = 127"

    comment:
        description:
            - "Any information about the service group."

    appflowlog:
        choices:
            - 'enabled'
            - 'disabled'
        description:
            - "Enable logging of AppFlow information for the specified service group."

    netprofile:
        description:
            - "Network profile for the service group."
            - "Minimum length = 1"
            - "Maximum length = 127"

    autoscale:
        choices:
            - 'DISABLED'
            - 'DNS'
            - 'POLICY'
        description:
            - "Auto scale option for a servicegroup."

    memberport:
        description:
            - "member port."

    graceful:
        description:
            - "Wait for all existing connections to the service to terminate before shutting down the service."
        type: bool

    servicemembers:
        description:
            - A list of dictionaries describing each service member of the service group.
        suboptions:
            ip:
                description:
                    - IP address of the service. Must not overlap with an existing server entity defined by name.

            port:
                description:
                    - Server port number.
                    - Range C(1) - C(65535)
                    - "* in CLI is represented as 65535 in NITRO API"
            state:
                choices:
                    - 'enabled'
                    - 'disabled'
                description:
                    - Initial state of the service after binding.
            hashid:
                description:
                    - The hash identifier for the service.
                    - This must be unique for each service.
                    - This parameter is used by hash based load balancing methods.
                    - Minimum value = C(1)

            serverid:
                description:
                    - The identifier for the service.
                    - This is used when the persistency type is set to Custom Server ID.

            servername:
                description:
                    - Name of the server to which to bind the service group.
                    - The server must already be configured as a named server.
                    - Minimum length = 1

            customserverid:
                description:
                    - The identifier for this IP:Port pair.
                    - Used when the persistency type is set to Custom Server ID.

            weight:
                description:
                    - Weight to assign to the servers in the service group.
                    - Specifies the capacity of the servers relative to the other servers in the load balancing configuration.
                    - The higher the weight, the higher the percentage of requests sent to the service.
                    - Minimum value = C(1)
                    - Maximum value = C(100)

    monitorbindings:
        description:
            - A list of monitornames to bind to this service
            - Note that the monitors must have already been setup possibly using the M(netscaler_lb_monitor) module or some other method
        suboptions:
            monitorname:
                description:
                    - The monitor name to bind to this servicegroup.
            weight:
                description:
                    - Weight to assign to the binding between the monitor and servicegroup.

    disabled:
        description:
            - When set to C(yes) the service group state will be set to DISABLED.
            - When set to C(no) the service group state will be set to ENABLED.
            - >-
                Note that due to limitations of the underlying NITRO API a C(disabled) state change alone
                does not cause the module result to report a changed status.
        type: bool
        default: false


extends_documentation_fragment: netscaler
requirements:
    - nitro python sdk
s
# The LB Monitors monitor-1 and monitor-2 must already exist
# Service members defined by C(ip) must not redefine an existing server's ip address.
# Service members defined by C(servername) must already exist.

- name: Setup http service with ip members
  delegate_to: localhost
  netscaler_servicegroup:
    nsip: 172.18.0.2
    nitro_user: nsroot
    nitro_pass: nsroot

    state: present

    servicegroupname: service-group-1
    servicetype: HTTP
    servicemembers:
      - ip: 10.78.78.78
        port: 80
        weight: 50
      - ip: 10.79.79.79
        port: 80
        weight: 40
      - servername: server-1
        port: 80
        weight: 10

    monitorbindings:
      - monitorname: monitor-1
        weight: 50
      - monitorname: monitor-2
        weight: 50

s
loglines:
    description: list of logged messages by the module
    returned: always
    type: list
    sample: ['message 1', 'message 2']

msg:
    description: Message detailing the failure reason
    returned: failure
    type: str
    sample: "Action does not exist"

diff:
    description: List of differences between the actual configured object and the configuration specified in the module
    returned: failure
    type: dict
    sample: { 'clttimeout': 'difference. ours: (float) 10.0 other: (float) 20.0' }
(t
AnsibleModuleN(tConfigProxytget_nitro_clienttnetscaler_common_argumentstlogtloglinestget_immutables_intersection(tservicegroup(t'servicegroup_servicegroupmember_binding(tnitro_exception(tservicegroup_lbmonitor_binding(tlbmonitor_servicegroup_bindingcC`sMtd�tj|d|jd�}td|�|dkrEtStSdS(Ns Checking if service group existssservicegroupname:%stservicegroupnamescount is %si(RRtcount_filteredtparamstTruetFalse(tclienttmoduletcount((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pytservicegroup_exists�s
cC`sFtd�tj|d|jd�}|j|d�r>tStSdS(Ns&Checking if service group is identicalsservicegroupname:%sRi(RRtget_filteredRthas_equal_attributesRR(RRtservicegroup_proxyt
servicegroups((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pytservicegroup_identical�s

cC`s�td�dddddddd	d
g	}ddd
ddg}g}|jddkr]|Sxl|jdD]]}tj|�}|jd|d<tdt�d|d|d|d|�}|j|�qkW|S(Ntget_configured_service_membersRtiptporttstatethashidtserveridt
servernametcustomserveridtweighttdelaytstatechangetimesectsvrstatettickssincelaststatechangetgracefultservicememberstactualRtattribute_values_dicttreadwrite_attrstreadonly_attrs(RRtNonetcopytdeepcopyR	Rtappend(RRR3R4tmemberstconfigtmember_proxy((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pyR"�s:
				cC`s�yKtj||jd�}|dkrDtj||jd�}ng}Wn.tk
r{}|jdkrug}q|�nX|S(NRii(RRRtgetRt	errorcode(RRRtservicegroup_memberste((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pytget_actual_service_members�s
	cC`s�td�t||�}td|�t||�}tdt|��t|�t|�krftSd}x<|D]4}x+|D]#}|j|�r�|d7}Pq�q�WqsW|t|�kr�tStS(Ntservicemembers_identicalsservicemembers %ss"Number of service group members %sii(RR@R"tlenRRR(RRR>tmodule_servicegroupstidentical_countt
actual_membertmember((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pyRA�s 



c
C`s�td�t||�}t||�}g}g}xct|�D]U\}}xFt|�D]8\}}	|j|	�rZ|j|�|j|�qZqZWqAWx�t|�D]�\}}	||kr�td|�q�ntt|	d�|	jdk	t|	d�|	j
dk	g�rd|	_n|jd|	_t
j||	�q�WxDt|�D]6\}}||krxtd|�qLn|j�qLWdS(Ntsync_service_memberss"Skipping actual delete at index %sR#R(Rs#Skipping configured add at index %s(RR"R@t	enumerateRR8tallthasattrR#R5R(RRRtdeletetadd(
RRtconfigured_service_memberstactual_service_memberstskip_addtskip_deletetconfigured_indextconfigured_servicetactual_indextactual_service((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pyRGs6

cC`sGt|j|jk|j|jk|jt|j�kg�rCtStS(N(tanytmonitornametmonitor_nameRR*tfloatRR(t
configuredR1((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pytmonitor_binding_equal.s
c	
C`s�td�i}d|jkr�|jddk	r�x�|jdD]y}dddg}g}tj|�}|jd|d<tdt�d|d|d	|d
|�}|d}|||<q@Wn|S(Ns(Entering get_configured_monitor_bindingstmonitorbindingsRVRR*R1RR2R3R4(RRR5R6R7R	R(	RRtbindingstbindingR3R4R2t
binding_proxytkey((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pytget_configured_monitor_bindings6s&
"			
cC`s�td�i}ytj||jd�}Wn)tk
rX}|jdkrR|S�nX|dkri|SxEtj||jd�D]*}td|j�|j}|||<q�W|S(Ns$Entering get_actual_monitor_bindingsRiis#Gettign actual monitor with name %s(RRRRRR=R<RW(RRR\RR?R]R_((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pytget_actual_monitor_bindingsOs
 	c
C`sDtd�t||�}t||�}t|j��}t|j��}||A}x8d
D]0}||kr]td|�|j|�q]q]Wt|�dkr�tSx�|D]�}||}	t|	d�s�d|	_	ntd|	j
|	j|	j	g�td	||j||j||j	g�t
|	||�s�tSq�WtS(Ns#Entering monitor_bindings_identicalstcp-defaultsping-defaults(Excluding %s monitor from key comparisoniR*isconfigured_proxy %ssactual_bindings %s(stcp-defaultsping-default(RR`RatsettkeystremoveRBRRJR*RVRRWRZR(
RRtconfigured_bindingstactual_bindingstconfigured_key_settactual_key_settsymmetrical_difftdefault_monitorR_tconfigured_proxy((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pytmonitor_bindings_identicalgs*




 ,cC`sntd�t||�}x$dD]}||kr ||=q q Wt||�}tt|j��t|j���}tt|j��t|j���}tt|j��t|j��@�}xf||D]Z}||}	t�}
|	j|
_|j	d|
_
|
jdkrq�ntj||
�q�Wx7||D]+}||}	td|	j�|	j�q;WdS(NsEntering sync_monitor_bindingsstcp-defaultsping-defaultRs	Adding %s(stcp-defaultsping-default(stcp-defaultsping-default(
RRaR`tlistRbRcRRWRVRRRKRL(RRRfRVRet	to_removetto_addt	to_modifyR_R]tb((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pytsync_monitor_bindings�s*

(((
	
cC`s4tj|d|jd�}|j|d�}|S(Nsservicegroupname:%sRi(RRRtdiff_object(RRRtservicegroup_listRs((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pytdiff�scC`sR|jdr/td�tj||j�}ntd�tj||j�}|S(NtdisabledsDisabling servicesEnabling service(RRRtdisableR1tenable(RRRtresult((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pytdo_state_change�s


cAC`s�	tdtdd�dtddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*g%�d+tdddd,d-d.g�d/tdd0�d1tdd0�d2tdd3�d4tdddd5d6g�d7tdd�d8tdd3�d9tdd3�d:tdd3�d;tdd3�d<tdd3�d=tdd3�d>tdd3�d?tdd0�d@tdd0�dAtdd3�dBtdd3�dCtdd3�dDtdd0�dEtdd0�dFtdddd5d6g�dGtdd�dHtdd�dItdd�dJtdddd5d6g�dKtdd�dLtddddMddNg�dOtddP�dQtdd3��}tdRtddS�dTtddS�d6tdd3dUt��}t�}|jt�|j|�|j|�tdV|dWt�}tdXtdYtdZt�}tsF|jd[d\�nt	|�}y|j
�Wn�tk
r�}d]t|j
�|jf}|jd[|�n�tk
r7}tt|��d^kr�|jd[d_t|��q8tt|��d`kr|jd[dat|��q8|jd[dbt|��nXddd+d/d1d2d4d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdOdQg}dcdddedfdgdhdidjdkdldmdndodpdqdrdsg}	ddd+dtd7dudLdOdvdwdxdydzd{d|dQd}d~g}
idgd:6dgd26dgdA6dgd96dgdB6d�gd=6dgd86dgd<6dgd;6d�gd>6dgdQ6dgdC6d��gd46d��gdF6d��gdJ6}td�t�d�|d�|jd�|d�|	d�|
d�|�}y�|jdud�kr�td��t||�sd|jsWtd��|j�|jd�rW|j�qWnt|dX<n�t|||�st|||�}
t||
j��}|gkr�d�|f}|jd[|d�|
|�n|js|j�|jd�r|j�qnt|dX<n
t|dX<t||�sh|js[t||�|jd�r[|j�q[nt|dX<nt||�s�|js�t ||�|jd�r�|j�q�nt|dX<n|jst!|||�}|j
d�krd�|j
|jf}|jd[||�qn|js�	td��t||�sH|jd[d�|�nt|||�s�|jd[d�d�t|||�|�nt||�s�|jd[d�|�nt||�s�|jd[d�|�q�q�	n�|jdud�kr�	td��t||�r;	|js.	|j"�|jd�r.	|j�q.	nt|dX<n
t|dX<|js�	td��t||�r�	|jd[d�|�q�	q�	nWnDtk
r�	}d�t|j
�d�|j}|jd[||�nX|j#�|j$|�dS(�NRttypetstrtservicetypetchoicestHTTPtFTPtTCPtUDPtSSLt
SSL_BRIDGEtSSL_TCPtDTLStNNTPtRPCSVRtDNStADNStSNMPtRTSPtDHCPRAtANYtSIP_UDPtSIP_TCPtSIP_SSLtDNS_TCPtADNS_TCPtMYSQLtMSSQLtORACLEtRADIUStRADIUSListenertRDPtDIAMETERtSSL_DIAMETERtTFTPtSMPPtPPTPtGREt	SYSLOGTCPt	SYSLOGUDPtFIXtSSL_FIXt	cachetypetTRANSPARENTtREVERSEtFORWARDt	maxclientRXtmaxreqt	cacheabletbooltciptenabledRvt	cipheadertusiptpathmonitortpathmonitorindvtuseproxyportt
healthmonitortsptrtspsessionidremapt
clttimeoutt
svrtimeouttckattcpbtcmptmaxbandwidthtmonthresholdtdownstateflushttcpprofilenamethttpprofilenametcommentt
appflowlogt
netprofilet	autoscaletDISABLEDtPOLICYt
memberporttintR/R0RmR[tdefaultt
argument_spectsupports_check_modetchangedtfailedR
tmsgsCould not load nitro python sdks6nitro exception during login. errorcode=%s, message=%ss-<class 'requests.exceptions.ConnectionError'>sConnection error %ss&<class 'requests.exceptions.SSLError'>sSSL Error %ss Unexpected error during login %stnumofconnectionstserviceconftypetvalueR-R#tmonstatcodet
monstatparam1t
monstatparam2t
monstatparam3tstatechangetimemsectstateupdatereasont
clmonownert	clmonviewt
groupcounttriseapbrstatsmsgcode2tserviceipstrtservicegroupeffectivestatettdR%R(R$R'tmonitor_name_svct
dup_weighttriseapbrstatsmsgcodeR+tincludememberstnewnametbool_yes_notbool_on_offcS`s
|j�S(N(tupper(tv((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pyt<lambda>�scS`s
|j�S(N(R�(R�((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pyR��scS`s
|j�S(N(R�(R�((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pyR��sR1RR2R3R4timmutable_attrst
transformstpresents"Applying actions for state presentsAdding service grouptsave_configsGCannot update immutable attributes %s. Must delete and recreate entity.Ruis<Error when setting disabled state. errorcode: %s message: %ssSanity checks for state presentsService group is not presents/Service group is not identical to configurations/Service group members differ from configurations"Monitor bindings are not identicaltabsents!Applying actions for state absentsSanity checks for state absentsService group is presentsnitro exception errorcode=s	,message=(%tdictRtupdateRRRR
tPYTHON_SDK_IMPORTEDt	fail_jsonR
tloginRR|R=tmessaget	ExceptionR{R	RRRRt
check_modeRLR�R!RuRRcRlRrRARGRzRKtlogoutt	exit_json(tmodule_specific_argumentsthand_inserted_argumentsR�Rt
module_resultRR?R�R3R4R�R�Rt	diff_dicttimmutables_changedtres((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pytmain�s,	


					













			
	




	



	


	


		
	

	



	
 
t__main__(2t
__future__RRRR{t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtansible.module_utils.basicRR6t0ansible.module_utils.network.netscaler.netscalerR	R
RRR
RtCnssrc.com.citrix.netscaler.nitro.resource.config.basic.servicegroupRt^nssrc.com.citrix.netscaler.nitro.resource.config.basic.servicegroup_servicegroupmember_bindingRt:nssrc.com.citrix.netscaler.nitro.exception.nitro_exceptionRtUnssrc.com.citrix.netscaler.nitro.resource.config.basic.servicegroup_lbmonitor_bindingRtRnssrc.com.citrix.netscaler.nitro.resource.config.lb.lbmonitor_servicegroup_bindingRRR�tImportErrorR?RRR!R"R@RARGRZR`RaRlRrRuRzR�t__name__(((s\/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_servicegroup.pyt<module>sJ


�H#.

	
			(			-					"		
	�]

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