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

�
�Udac@`svddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
yJddlmZdd
l
mZddlmZddlmZeZWnek
r�ZeZnXddlmZddlmZmZmZmZmZm Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*e+dkrre*�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�1
---
module: netscaler_service
short_description: Manage service configuration in Netscaler
description:
    - Manage service configuration in Netscaler.
    - This module allows the creation, deletion and modification of Netscaler services.
    - This module is intended to run either on the ansible  control node or a bastion (jumpserver) with access to the actual netscaler instance.
    - This module supports check mode.

version_added: "2.4.0"

author: George Nikolopoulos (@giorgos-nikolopoulos)

options:

    name:
        description:
            - >-
                Name for the service. 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. Cannot be changed after the service has been created.
            - "Minimum length = 1"

    ip:
        description:
            - "IP to assign to the service."
            - "Minimum length = 1"

    servername:
        description:
            - "Name of the server that hosts the service."
            - "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 in which data is exchanged with the service."

    port:
        description:
            - "Port number of the service."
            - "Range 1 - 65535"
            - "* in CLI is represented as 65535 in NITRO API"

    cleartextport:
        description:
            - >-
                Port to which clear text data must be sent after the appliance decrypts incoming SSL traffic.
                Applicable to transparent SSL services.
            - "Minimum value = 1"

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

    maxclient:
        description:
            - "Maximum number of simultaneous open connections to the service."
            - "Minimum value = 0"
            - "Maximum value = 4294967294"

    healthmonitor:
        description:
            - "Monitor the health of this service"
        default: yes
        type: bool

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

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

    cip:
        choices:
            - 'enabled'
            - 'disabled'
        description:
            - >-
                Before forwarding a request to the service, insert an HTTP header with the client's IPv4 or IPv6
                address as its value. Used if the server needs the client's IP address for security, accounting, or
                other purposes, and setting the Use Source IP parameter is not a viable option.

    cipheader:
        description:
            - >-
                Name for the HTTP header whose value must be set to the IP address of the client. Used with the
                Client IP parameter. If you set the Client IP parameter, and you do not specify a name for the
                header, the appliance uses the header name specified for the global Client IP Header parameter (the
                cipHeader parameter in the set ns param CLI command or the Client IP Header parameter in the
                Configure HTTP Parameters dialog box at System > Settings > Change HTTP parameters). If the global
                Client IP Header parameter is not specified, the appliance inserts a header with the name
                "client-ip.".
            - "Minimum length = 1"

    usip:
        description:
            - >-
                Use the client's IP address as the source IP address when initiating a connection to the server. When
                creating a service, if you do not set this parameter, the service inherits the global Use Source IP
                setting (available in the enable ns mode and disable ns mode CLI commands, or in the System >
                Settings > Configure modes > Configure Modes dialog box). However, you can override this setting
                after you create the service.
        type: bool

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

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

    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 (USIP) parameter is set to YES."
        type: bool

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

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

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

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

    customserverid:
        description:
            - >-
                Unique identifier for the service. Used when the persistency type for the virtual server is set to
                Custom Server ID.
        default: 'None'

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

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

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

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

    maxbandwidth:
        description:
            - "Maximum bandwidth, in Kbps, allocated to the service."
            - "Minimum value = 0"
            - "Maximum value = 4294967287"

    accessdown:
        description:
            - >-
                Use Layer 2 mode to bridge the packets sent to this service if it is marked as DOWN. If the service
                is DOWN, and this parameter is disabled, the packets are dropped.
        default: no
        type: bool
    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 = 0"
            - "Maximum value = 65535"

    downstateflush:
        choices:
            - 'enabled'
            - 'disabled'
        description:
            - >-
                Flush all active transactions associated with a service 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."
            - "Minimum length = 1"
            - "Maximum length = 127"

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

    hashid:
        description:
            - >-
                A numerical identifier that can be used by hash based load balancing methods. Must be unique for each
                service.
            - "Minimum value = 1"

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

    appflowlog:
        choices:
            - 'enabled'
            - 'disabled'
        description:
            - "Enable logging of AppFlow information."

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

    td:
        description:
            - >-
                Integer value that uniquely identifies the traffic domain in which you want to configure the entity.
                If you do not specify an ID, the entity becomes part of the default traffic domain, which has an ID
                of 0.
            - "Minimum value = 0"
            - "Maximum value = 4094"

    processlocal:
        choices:
            - 'enabled'
            - 'disabled'
        description:
            - >-
                By turning on this option packets destined to a service in a cluster will not under go any steering.
                Turn this option for single packet request response mode or when the upstream device is performing a
                proper RSS for connection based distribution.

    dnsprofilename:
        description:
            - >-
                Name of the DNS profile to be associated with the service. DNS profile properties will applied to the
                transactions processed by a service. This parameter is valid only for ADNS and ADNS-TCP services.
            - "Minimum length = 1"
            - "Maximum length = 127"

    ipaddress:
        description:
            - "The new IP address of the service."

    graceful:
        description:
            - >-
                Shut down gracefully, not accepting any new connections, and disabling the service when all of its
                connections are closed.
        default: no
        type: bool

    monitor_bindings:
        description:
            - A list of load balancing monitors to bind to this service.
            - Each monitor entry is a dictionary which may contain the following options.
            - Note that if not using the built in monitors they must first be setup.
        suboptions:
            monitorname:
                description:
                    - Name of the monitor.
            weight:
                description:
                    - Weight to assign to the binding between the monitor and service.
            dup_state:
                choices:
                    - 'enabled'
                    - 'disabled'
                description:
                    - State of the monitor.
                    - The state setting for a monitor of a given type affects all monitors of that type.
                    - For example, if an HTTP monitor is enabled, all HTTP monitors on the appliance are (or remain) enabled.
                    - If an HTTP monitor is disabled, all HTTP monitors on the appliance are disabled.
            dup_weight:
                description:
                    - Weight to assign to the binding between the monitor and service.

    disabled:
        description:
            - When set to C(yes) the service state will be set to DISABLED.
            - When set to C(no) the service 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
sh
# Monitor monitor-1 must have been already setup

- name: Setup http service
  gather_facts: False
  delegate_to: localhost
  netscaler_service:
    nsip: 172.18.0.2
    nitro_user: nsroot
    nitro_pass: nsroot

    state: present

    name: service-http-1
    servicetype: HTTP
    ipaddress: 10.78.0.1
    port: 80

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

diff:
    description: A dictionary with a 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' }"
N(tservice(tservice_lbmonitor_binding(tlbmonitor_service_binding(tnitro_exception(t
AnsibleModule(tConfigProxytget_nitro_clienttnetscaler_common_argumentstlogtloglinestget_immutables_intersectioncC`s/tj|d|jd�dkr'tStSdS(Nsname:%stnamei(Rtcount_filteredtparamstTruetFalse(tclienttmodule((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pytservice_exists�s#cC`sztj|d|jd�}|j|d�}d|krF|d=nd|kr\|d=nt|�dkrrtStSdS(Nsname:%sRitiptgraceful(Rtget_filteredRtdiff_objecttlenRR(RRt
service_proxytservice_listt	diff_dict((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pytservice_identical�s

cC`sJtj|d|jd�}|j|d�}d|krF|d=n|S(Nsname:%sRiR(RRRR(RRR R!R((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pytdiff�s

c
C`s�i}|jddk	r�xo|jdD]]}tj|�}|jd|d<tdt�d|d|d|�}|j}|||<q'Wn|S(Ntmonitor_bindingsRtservicegroupnametactualRtattribute_values_dicttreadwrite_attrs(RtNonetcopytdeepcopyR
R
tmonitorname(RRtmonitor_bindings_rw_attrstbindingstbindingR(t
binding_proxytkey((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pytget_configured_monitor_bindings�s			cC`s�i}tj||jd�dkr)|Sx�tj||jd�D]k}|jdkr^qCn|j}t�}|j|_|j|_|j|_|jd|_	|||<qCW|S(NRistcp-defaultsping-default(stcp-defaultsping-default(
R	tcountRtgettmonitor_nameR
tweightR-t
dup_weighttservicename(RRR/R0R2R'((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pytget_actual_monitor_bindings�s 		cC`s�t|||�}t||�}t|j��}t|j��}||A}t|�dkretSxr|D]j}||}	||}
|	j|
�}d|kr�|	j|
jkr�|d=q�nt|�dkrltSqlWt	S(NiR&(
R3R:tsettkeysRRRR&R9R(RRR.tconfigured_proxystactual_bindingstconfigured_key_settactual_key_settsymmetrical_diffR6tproxyR'R"((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pytmonitor_bindings_identical�s"




c
C`s8t|||�}t||�}t|j��}t|j��}t||�}x0|D](}td|�tj|||�q\Wt||@�}	x\|	D]T}||}
||}|
j|�s�td|�tj||�|
j	�q�q�Wt||�}x*|D]"}td|�||j	�qWdS(NsDeleting binding for monitor %ss-Deleting and re adding binding for monitor %ssAdding binding for monitor %s(
R3R:R;R<tlistRR
tdeletethas_equal_attributestadd(
RRR.R=R>tconfigured_keysett
actual_keysettdelete_keysR6t
common_keysetRBR'tnew_keys((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pytsync_monitor_bindingss(




cC`s"t|||�o!t|||�S(N(R#RC(RRR R.((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pyt
all_identical,scC`sR|jdr/td�tj||j�}ntd�tj||j�}|S(NtdisabledsDisabling servicesEnabling service(RRRtdisableR'tenable(RRR tresult((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pytdo_state_change0s


cOC`sk
tdtdd�dtdd�dtdd�dtddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,g%�d-tdd.�d/tdd.�d0tdddd1d2d3g�d4tdd5�d6tdd7d8t�d9tdd5�d:tdd7d8t�d;tdddd<d=g�d>tdd�d?tdd7�d@tdd7�dAtdd7�dBtdd7d8t�dCtdd5�dDtdd5�dEtddd8dF�dGtdd7�dHtdd7�dItdd7�dJtdd5�dKtdd7d8t�dLtdd5�dMtdddd<d=g�dNtdd�dOtdd�dPtdd5�dQtdd�dRtdddd<d=g�dStdd�dTtdddd<d=g�dUtdd�dVtdd�dWtdd7d8t��%}tdXtddY�d=tdd7d8t��}t�}|jt�|j|�|j|�tdZ|d[t�}td\td]td^t�}ts�|jd_d`�nt	|�}y|j
�Wn�tk
r
}dat|j
�|jf}|jd_|�n�tk
r�}tt|��dbkrQ|jd_dct|��q�tt|��ddkr�|jd_det|��q�|jd_dft|��nXddddd-d/d0d4d6d9d:d;d>d?d@dAdBdCdDdEdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWg%}dgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dd�g}	ddddd-d/d0d>d�d�d�d�d�d�d�d�g}
id�gd�6d�gd:6d�gdG6d�gd�6d�gdH6d�gdA6d�gdW6d�gd?6d�gd66d�gd@6d�gdB6d�gdK6d�gdI6d��gd;6d��gdM6d��gdR6d��gdT6}d�d�dmd�d�d�g}|jddkr�|jdV|jd<ntd�t�d�|d�|jd�|d�|	d�|
d�|�}
y1|jd�d�krY	td��t||�sV|jsI|
j�t|||�|jd�rI|j�qInt|d\<n
t|||
|�sVt|||
�}t|
|j��}|gkr�d�|f}|jd_|d�||�nt|||
�s�|js�|
j�q�nt |||�s#|js#t|||�q#nt|d\<|js`|jd�rS|j�qSq`n
t|d\<|js�t!|||
�}|j
d�kr�d�|j
|jf}|jd_||�q�n|js

td��t||�s�|jd_d�|�nt|||
�s+	|jd_d�d�t|||
�|�nt |||�sV	|jd_d�|�qV	q

n�|jd�d�kr

td��t||�r�	|js�	|
j"�|jd�r�	|j�q�	nt|d\<n
t|d\<|js

td��t||�r
|jd_d�|�q
q

nWnBtk
rO
}d�t|j
�|jf}|jd_||�nX|j#�|j$|�dS(�NRttypetstrRt
servernametservicetypetchoicestHTTPtFTPtTCPtUDPtSSLt
SSL_BRIDGEtSSL_TCPtDTLStNNTPtRPCSVRtDNStADNStSNMPtRTSPtDHCPRAtANYtSIP_UDPtSIP_TCPtSIP_SSLtDNS_TCPtADNS_TCPtMYSQLtMSSQLtORACLEtRADIUStRADIUSListenertRDPtDIAMETERtSSL_DIAMETERtTFTPtSMPPtPPTPtGREt	SYSLOGTCPt	SYSLOGUDPtFIXtSSL_FIXtporttintt
cleartextportt	cachetypetTRANSPARENTtREVERSEtFORWARDt	maxclienttfloatt
healthmonitortbooltdefaulttmaxreqt	cacheabletciptenabledROt	cipheadertusiptuseproxyporttsptrtspsessionidremapt
clttimeoutt
svrtimeouttcustomserveridR*tckattcpbtcmptmaxbandwidtht
accessdowntmonthresholdtdownstateflushttcpprofilenamethttpprofilenamethashidtcommentt
appflowlogt
netprofiletprocesslocaltdnsprofilenamet	ipaddressRR%RDt
argument_spectsupports_check_modetchangedtfailedRtmsgsCould 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 %stnumofconnectionst
policynametserviceconftypetserviceconftype2tvaluetgslbt	dup_statetpublicipt
publicporttsvrstatet
monitor_statetmonstatcodetlastresponsetresponsetimetriseapbrstatsmsgcode2t
monstatparam1t
monstatparam2t
monstatparam3tstatechangetimesectstatechangetimemsecttickssincelaststatechangetstateupdatereasont
clmonownert	clmonviewtserviceipstrtoracleserverversiontserveridtstatettdtmonitor_name_svctriseapbrstatsmsgcodetalltInternaltnewnametbool_yes_notpathmonitorindvtpathmonitortbool_on_offcS`s
|j�S(N(tupper(tv((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pyt<lambda>TscS`s
|j�S(N(R�(R�((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pyR�UscS`s
|j�S(N(R�(R�((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pyR�VscS`s
|j�S(N(R�(R�((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pyR�WsR9R&R8R-R7R'RR(R)treadonly_attrstimmutable_attrst
transformstpresents"Applying actions for state presenttsave_configsGCannot update immutable attributes %s. Must delete and recreate entity.R$is<Error when setting disabled state. errorcode: %s message: %ssSanity checks for state presentsService does not existsService differs from configureds"Monitor bindings are not identicaltabsents!Applying actions for state absentsSanity checks for state absentsService still existss(nitro exception errorcode=%s, message=%s(%tdictRRtupdateRRRtPYTHON_SDK_IMPORTEDt	fail_jsonRtloginRRUt	errorcodetmessaget	ExceptionRTRR*R
RRRt
check_modeRGRMR�RNR$RR<R#RCRSREtlogoutt	exit_json(tmodule_specific_argumentsthand_inserted_argumentsR�Rt
module_resultRteR�R)R�R�R�R.R R"timmutables_changedtres((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pytmain:sb						


					















				
	



		
	

		
(
	



	
 
t__main__(,t
__future__RRRRTt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR+t>nssrc.com.citrix.netscaler.nitro.resource.config.basic.serviceRtPnssrc.com.citrix.netscaler.nitro.resource.config.basic.service_lbmonitor_bindingR	tMnssrc.com.citrix.netscaler.nitro.resource.config.lb.lbmonitor_service_bindingR
t:nssrc.com.citrix.netscaler.nitro.exception.nitro_exceptionRRR�tImportErrorR�Rtansible.module_utils.basicRt0ansible.module_utils.network.netscaler.netscalerR
RRRRRRR#R$R3R:RCRMRNRSR�t__name__(((sW/usr/lib/python2.7/site-packages/ansible/modules/network/netscaler/netscaler_service.pyt<module>s@


�o

.									
	��

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