Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/a10/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/a10/a10_server.pyc

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZm
Z
mZmZmZmZmZdd
lmZddlmZdddgZd�Zd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bysh
---
module: a10_server
version_added: 1.8
short_description: Manage A10 Networks AX/SoftAX/Thunder/vThunder devices' server object.
description:
    - Manage SLB (Server Load Balancer) server objects on A10 Networks devices via aXAPIv2.
author:
  - Eric Chou (@ericchou1)
  - Mischa Peters (@mischapeters)
notes:
    - Requires A10 Networks aXAPI 2.1.
extends_documentation_fragment:
  - a10
  - url
options:
  partition:
    version_added: "2.3"
    description:
      - set active-partition
  server_name:
    description:
      - The SLB (Server Load Balancer) server name.
    required: true
    aliases: ['server']
  server_ip:
    description:
      - The SLB server IPv4 address.
    aliases: ['ip', 'address']
  server_status:
    description:
      - The SLB virtual server status.
    default: enabled
    aliases: ['status']
    choices: ['enabled', 'disabled']
  server_ports:
    description:
      - A list of ports to create for the server. Each list item should be a
        dictionary which specifies the C(port:) and C(protocol:), but can also optionally
        specify the C(status:). See the examples below for details. This parameter is
        required when C(state) is C(present).
    aliases: ['port']
  state:
    description:
      - This is to specify the operation to create, update or remove SLB server.
    default: present
    choices: ['present', 'absent']
  validate_certs:
    description:
      - If C(no), SSL certificates will not be validated. This should only be used
        on personally controlled devices using self-signed certificates.
    version_added: 2.3
    type: bool
    default: 'yes'

s!
# Create a new server
- a10_server:
    host: a10.mydomain.com
    username: myadmin
    password: mypassword
    partition: mypartition
    server: test
    server_ip: 1.1.1.100
    server_ports:
      - port_num: 8080
        protocol: tcp
      - port_num: 8443
        protocol: TCP

sx
content:
  description: the full info regarding the slb_server
  returned: success
  type: str
  sample: "mynewserver"
N(t
axapi_callta10_argument_spectaxapi_authenticatet
axapi_failuretaxapi_get_port_protocoltaxapi_enabled_disabledtAXAPI_PORT_PROTOCOLS(t
AnsibleModule(turl_argument_spectport_numtprotocolcC`sLxE|D]=}x@|D]8}|tkr|jdd|djt�f�qqWd|kr�yt|d�|d<Wq�tk
r�|jdd�q�Xn|jdd�d|kr�t|d�}|s�|jdddjt��q||d<n|jdd	djt��d
|kr:t|d
�|d
<qd|d
<qWdS(Ntmsgs+invalid port field (%s), must be one of: %st,Rs9port_num entries in the port definitions must be integerss/port definitions must define the port_num fieldRs)invalid port protocol, must be one of: %ss3port definitions must define the port protocol (%s)Ri(tVALID_PORT_FIELDSt	fail_jsontjointintt	ExceptionRRR
(tmoduletportstitemtkeyR((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/a10/a10_server.pytvalidate_portsns&

*
 
cC`s�t�}|jt��|jtdtdddddddg�dtddd	d
gdt�dtddd	d
dg�dtddddd	dgdddg�dtddd	dgdg�dtdddg���td|dt�}|jd}|jd}|jd}|jd}|jd}|jd}|jd}|jd}	|jd}
|jd}|dkr�|j	dd�nd|}t
||||�}
t||�ii|d 6d
6}|	r�|	|d
d<n|r||d
d!<n|
r!t|
�|d
d<nt
||
d"tji|d 6��t
||
d#tji|d 6��}t|�}t}|dkr
|s|	s�|j	dd$�nt
||
d%tj|��}t|�r�|j	dd&|d'd(d�nt}n�d)�}d*�}|jd
i�jd!g�}|jd
i�jd�}|||�s~|||�s~||t|
��r�t
||
d+tj|��}t|�r�|j	dd,|d'd(d�nt}n|rt
||
d#tji|d 6��}q`|}nS|dkr`|rNt
||
d-tji|d 6��}t}q`tdd.�}n|r�|r�t
||
d/�}t|�r�|j	dd0|d'd(d�q�nt
||
d1�|jd2|d3|�dS(4Ntstatettypetstrtdefaulttpresenttchoicestabsenttserver_nametaliasestservertrequiredt	server_iptiptaddresst
server_statustenabledRtdisabledtserver_portstlisttportt	partitiont
argument_spectsupports_check_modethosttusernametpasswordtwrite_configRsserver_name is requireds*https://%s/services/rest/V2.1/?format=jsontnamet	port_lists&method=system.partition.actives&method=slb.server.searchs5you must specify an IP address when creating a servers&method=slb.server.createsfailed to create the server: %stresponseterrcS`s�x�|D]�}t}t}xj|D]b}|d|dkr t}x,tD]$}||||krGt}PqGqGW|s{|r�Pq�q q W|s�|rtSqWtS(s�
                Checks to determine if the port definitions of the src_ports
                array are in or different from those in dst_ports. If there is
                a difference, this function returns true, otherwise false.
                R(tFalsetTrueR(t	src_portst	dst_portstsrc_porttfoundt	differenttdst_porttvalid_field((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/a10/a10_server.pytport_needs_update�s



cS`s||krtStS(s�
                Check to determine if we want to change the status of a server.
                If there is a difference between the current status of the server and
                the desired status, return true, otherwise false.
                (R?R>(tcurrent_statust
new_status((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/a10/a10_server.pytstatus_needs_update�ss&method=slb.server.updatesfailed to update the server: %ss&method=slb.server.deletesthe server was not presents"&method=system.action.write_memorys$failed to save the configuration: %ss&method=session.closetchangedtcontent(R	tupdateRtdictR?RR>tparamstNoneRR
RR
RtjsontdumpsRtgett	exit_json(R4RR6R3R7R8RR9t
slb_servert
slb_server_iptslb_server_statustslb_server_portstaxapi_base_urltsession_urlt	json_posttslb_server_datatslb_server_existsRKtresultRGRJt
defined_portsRHtwrite_result((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/a10/a10_server.pytmain�s�	!*	











$&
#			
#	)	&	&t__main__(t
__future__RRRR t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRQt$ansible.module_utils.network.a10.a10RR	R
RRR
Rtansible.module_utils.basicRtansible.module_utils.urlsRRRRat__name__(((sJ/usr/lib/python2.7/site-packages/ansible/modules/network/a10/a10_server.pyt<module>	s 


:4	!	�

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