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

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZdd
lm
Z
y�ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZWn�ek
rddl mZddl!mZddl!mZddl!mZddl!mZddl!mZddl"mZddl"mZddl#mZddl#mZddl#mZddl$mZnXdefd��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*e+fd+��YZ.d,�Z/e0d-kr�e/�ndS(.i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontstableinterfacetstatust	certifiedtsupported_bysf

---
module: bigip_selfip
short_description: Manage Self-IPs on a BIG-IP system
description:
  - Manage Self-IPs on a BIG-IP system.
version_added: 2.2
options:
  address:
    description:
      - The IP addresses for the new self IP. This value is ignored upon update
        as addresses themselves cannot be changed after they are created.
      - This value is required when creating new self IPs.
    type: str
  allow_service:
    description:
      - Configure port lockdown for the Self IP. By default, the Self IP has a
        "default deny" policy. This can be changed to allow TCP and UDP ports
        as well as specific protocols. This list should contain C(protocol):C(port)
        values.
    type: list
  name:
    description:
      - The self IP to create.
      - If this parameter is not specified, then it will default to the value supplied
        in the C(address) parameter.
    type: str
    required: True
  description:
    description:
      - Description of the traffic selector.
    type: str
    version_added: 2.8
  netmask:
    description:
      - The netmask for the self IP. When creating a new Self IP, this value
        is required.
    type: str
  state:
    description:
      - When C(present), guarantees that the Self-IP exists with the provided
        attributes.
      - When C(absent), removes the Self-IP from the system.
    type: str
    choices:
      - absent
      - present
    default: present
  traffic_group:
    description:
      - The traffic group for the Self IP addresses in an active-active,
        redundant load balancer configuration. When creating a new Self IP, if
        this value is not specified, the default of C(/Common/traffic-group-local-only)
        will be used.
    type: str
  vlan:
    description:
      - The VLAN that the new self IPs will be on. When creating a new Self
        IP, this value is required.
    type: str
  route_domain:
    description:
      - The route domain id of the system. When creating a new Self IP, if
        this value is not specified, a default value of C(0) will be used.
      - This value cannot be changed after it is set.
    type: int
    version_added: 2.3
  partition:
    description:
      - Device partition to manage resources on. You can set different partitions
        for Self IPs, but the address used may not match any other address used
        by a Self IP. In that sense, Self IPs are not isolated by partitions as
        other resources on a BIG-IP are.
    type: str
    default: Common
    version_added: 2.5
extends_documentation_fragment: f5
author:
  - Tim Rupp (@caphrim007)
  - Wojciech Wypior (@wojtek0806)
s�
- name: Create Self IP
  bigip_selfip:
    address: 10.10.10.10
    name: self1
    netmask: 255.255.255.0
    vlan: vlan1
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost

- name: Create Self IP with a Route Domain
  bigip_selfip:
    name: self1
    address: 10.10.10.10
    netmask: 255.255.255.0
    vlan: vlan1
    route_domain: 10
    allow_service: default
    provider:
      server: lb.mydomain.com
      user: admin
      password: secret
  delegate_to: localhost

- name: Delete Self IP
  bigip_selfip:
    name: self1
    state: absent
    provider:
      user: admin
      password: secret
      server: lb.mydomain.com
  delegate_to: localhost

- name: Allow management web UI to be accessed on this Self IP
  bigip_selfip:
    name: self1
    state: absent
    allow_service:
      - tcp:443
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost

- name: Allow HTTPS and SSH access to this Self IP
  bigip_selfip:
    name: self1
    state: absent
    allow_service:
      - tcp:443
      - tcp:22
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost

- name: Allow all services access to this Self IP
  bigip_selfip:
    name: self1
    state: absent
    allow_service:
      - all
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost

- name: Allow only GRE and IGMP protocols access to this Self IP
  bigip_selfip:
    name: self1
    state: absent
    allow_service:
      - gre:0
      - igmp:0
    provider:
      user: admin
      password: secret
      server: lb.mydomain.com
  delegate_to: localhost

- name: Allow all TCP, but no other protocols access to this Self IP
  bigip_selfip:
    name: self1
    state: absent
    allow_service:
      - tcp:0
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost
s�
allow_service:
  description: Services that allowed via this Self IP
  returned: changed
  type: list
  sample: ['igmp:0','tcp:22','udp:53']
address:
  description: The address for the Self IP
  returned: changed
  type: str
  sample: 192.0.2.10
name:
  description: The name of the Self IP
  returned: created
  type: str
  sample: self1
netmask:
  description: The netmask of the Self IP
  returned: changed
  type: str
  sample: 255.255.255.0
traffic_group:
  description: The traffic group that the Self IP is a member of
  returned: changed
  type: str
  sample: traffic-group-local-only
vlan:
  description: The VLAN set on the Self IP
  returned: changed
  type: str
  sample: vlan1
N(t
AnsibleModule(tenv_fallback(tF5RestClient(t
F5ModuleError(tAnsibleF5Parameters(tfq_name(tf5_argument_spec(ttransform_name(tis_valid_ip(tipv6_netmask_to_cidr(t
ip_address(t
ip_network(tip_interface(tcmp_str_with_nonet
ParameterscB`sseZidd6dd6ZddddddgZdddddddgZdddddgZed	��ZRS(
t
traffic_groupttrafficGroupt
allow_servicetallowServicetvlantnetmasktaddresstdescriptiontroute_domaincC`s.|jddkrdSt|j|jd�S(NR(t_valuestNoneR
t	partition(tself((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR(s(t__name__t
__module__tapi_mapt
updatablestreturnablestapi_attributestpropertyR(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyRs,
			tModuleParameterscB`sqeZed��Zed��Zed��Zed��Zed��Zed��Zed��Z	RS(cC`s"dj|j|j|j�}|S(Ns{0}%{1}/{2}(tformattipRR(R#R((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR0scC`sE|jddkrdSt|jd�r5|jdStd��dS(NRs.The provided address is not a valid IP address(R R!RR(R#((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR-7scC`s.|jddkrdSt|j|jd�S(NR(R R!R
R"(R#((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyRBscC`s.|jddkrdSt|jd�}|S(NR(R R!tint(R#tresult((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyRHscC`s|jddkrdSd}y6t|jd�}d|koJdknrRnWn�tk
r�t|jd�r�tdjt|jd���}|jdkr�t	dt|jd��}|j
}q�t|jd�}q�nX|dkrtdj|���n|S(	NRi����iiu{0}iu
0.0.0.0/%ss8The provided netmask {0} is neither in IP or CIDR format(
R R!R.t
ValueErrorRRR,tstrtversionRt	prefixlenRR(R#R/taddrR-((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyROs$
"cC`s}|jddkrdSg}dddddddd	d
ddd
g}dddg}x|jdD]�}||kr�|g}Pqd||kr�dj|�}|j|�qd|jd�}|d|kr�td|d��nyt|d�}Wn%tk
rtd|d��nX|dks8|dkrPtdj|���qd|j|�qdWtt	t
|���}|S(s�Verifies that a supplied service string has correct format

        The string format for port lockdown is PROTOCOL:PORT. This method
        will verify that the provided input matches the allowed protocols
        and the port ranges before submitting to BIG-IP.

        The only allowed exceptions to this rule are the following values

          * all
          * default
          * none

        These are special cases that are handled differently in the API.
        "all" is set as a string, "default" is set as a one item list, and
        "none" removes the key entirely from the REST API.

        :raises F5ModuleError:
        Rteigrptegptgreticmptigmptigptipiptl2tptospftpimttcptudptalltnonetdefaults{0}:0t:is%The provided protocol '%s' is invalidis&The provided port '%s' is not a numberi��s3The provided port '{0}' must be between 0 and 65535N(R R!R,tappendtsplitRR.t	Exceptiontsortedtlisttset(R#R/tallowed_protocolstspecial_protocolstsvctfull_servicettmptport((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyRfs8	
cC`s9|jddkrdS|jddkr.dS|jdS(NRRBt(snoneRQ(R R!(R#((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR�s
(
R$R%R*RR-RRRRR(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR+/s;t
ApiParameterscB`sSeZed��Zed��Zed��Zed��Zed��ZRS(cC`sN|jddkrdS|jddkr=dg|jd<nt|jd�S(NRRA(R R!RH(R#((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR�s
cC`s}|jddkrdSyBd}tj|d|jd�}tdj|��}|jSWntk
rxtd��nXdS(NRs(?P<rd>%[0-9]+)RQu{0}s-The provided destination is not an IP address(	R R!tretsubRR,twith_prefixlenR0R(R#tpatternR4R-((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pytdestination_ip�s
cC`st|j�}t|jj�S(N(RRWR.tnetworkR3(R#R-((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR�scC`st|j�}t|j�S(N(RRWR1R-(R#R/((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR-�scC`s"|jddkrdS|jdS(NRRB(Nsnone(R R!(R#((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR�s(R$R%R*RRWRR-R(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyRR�s
tChangescB`seZd�ZRS(cC`sXi}y:x$|jD]}t||�||<qW|j|�}Wntk
rSnX|S(N(R(tgetattrt_filter_paramsRG(R#R/t
returnable((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyt	to_return�s
(R$R%R](((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyRY�st
UsableChangescB`seZed��ZRS(cC`sB|jddkrdS|jddgkr1dSt|jd�S(NRRA(R R!RH(R#((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR�s
(R$R%R*R(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR^�stReportableChangescB`seZRS((R$R%(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR_�st
DifferencecB`sqeZdd�Zd�Zd�Zed��Zed��Zed��Z	ed��Z
ed��ZRS(	cC`s||_||_dS(N(twantthave(R#RaRb((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyt__init__�s	cC`s9yt||�}|SWntk
r4|j|�SXdS(N(RZtAttributeErrort_Difference__default(R#tparamR/((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pytcompare�s

cC`sQt|j|�}y&t|j|�}||kr7|SWntk
rL|SXdS(N(RZRaRbRd(R#Rftattr1tattr2((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyt	__default�s
cC`sdS(N(R!(R#((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyRscC`s�|jjdkrdS|jj}|ddkrH|jjdkrHdS|jjdkr^|S|ddkr�|jjddkr�dgS|ddkr�gSt|jj�t|jj�kr�|SdS(s2Returns services formatted for consumption by f5-sdk update

        The BIG-IP endpoint for services takes different values depending on
        what you want the "allowed services" to be. It can be any of the
        following

            - a list containing "protocol:port" values
            - the string "all"
            - a null value, or None

        This is a convenience function to massage the values the user has
        supplied so that they are formatted in such a way that BIG-IP will
        accept them and apply the specified policy.
        iRBRAN(RaRR!RbRJ(R#R/((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyRs"&$cC`s>|jjdkrdS|jj}t|�r|jjdk	r�dj||jj|jj�}dj||jj|jj�}n�|jjdk	r�dj||jj|jj�}dj||jj|jj�}n0dj||jj�}dj||jj�}||kr:|Sntdj|jj���dS(Ns{0}%{1}/{2}s{0}/{1}s4The provided address/netmask value "{0}" was invalid(	RaRR!RbR-RRR,R(R#R-RaRb((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR#s !$!$cC`s&|jj|jjkr"|jjSdS(N(RaRRb(R#((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR9scC`st|jj|jj�S(N(RRaRRb(R#((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR>sN(R$R%R!RcRgReR*RRRRR(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR`�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�ZRS(cO`s[|jdd�|_t|jj�|_d|_td|jj�|_t	�|_
dS(Ntmoduletparams(tgetR!RlR
RmtclientRbR+RaR^tchanges(R#targstkwargs((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyRcDs
	cC`sji}xBtjD]7}t|j|�dk	rt|j|�||<qqW|rftd|�|_ndS(NRm(RR(RZRaR!R^Rp(R#tchangedtkey((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyt_set_changed_optionsKscC`s�t|j|j�}tj}t�}xR|D]J}|j|�}|dkrUq.q.|dkrn||d<q.|||<q.W|r�td|�|_	t
StS(NRRRm(snetmask(R`RaRbRRR'tdictRgR!R^RptTruetFalse(R#tdiffR'Rstktchange((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyt_update_changed_optionsSs		

cC`sK|jdg�}x2|D]*}|jjjd|dd|d�qWdS(Nt
__warningstmsgR2(tpopRoRlt	deprecate(R#R/twarningstwarning((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyt_announce_deprecationses


cC`s�t}t�}|jj}|dkr6|j�}n|dkrQ|j�}ntd|jj��}|j�}|j	|�|j	td|��|j
|�|S(NtpresenttabsentRmRs(RxRvRatstateR�R�R_RpR]tupdateR�(R#RsR/R�t
reportableRp((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pytexec_modulems	

cC`s+|j�r|j�}n|j�}|S(N(texistsR�tcreate(R#Rs((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR�~scC`s%t}|j�r!|j�}n|S(N(RxR�tremove(R#Rs((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR��scC`s9|jjrtS|j�|j�r5td��ntS(NsFailed to delete the Self IP(Rlt
check_modeRwtremove_from_deviceR�R(R#((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR��s
cC`s|j�}|rtStS(N(R|RwRx(R#R/((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyt
should_update�scC`s=|j�|_|j�stS|jjr/tS|j�tS(N(tread_current_from_deviceRbR�RxRlR�Rwtupdate_on_device(R#((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR��s
cC`s�|jjdks$|jjdkr3td��n|jjdkrTtd��n|jjdkr�|j�}|jji|d6�n|jj	dkr�|jjidd6�n|jjdkr�|jjidd6�n|jj
r�d|jj
kr!|jjtddg��q�d	|jj
krO|jjtdg��q�d
|jj
kr�|jjtdd
g��q�n|j�|j
jr�tS|j�|j�r�tStd��dS(Ns*An address and a netmask must be specifiedsA VLAN name must be specifiedRs /Common/traffic-group-local-onlyRiRARRBRCsFailed to create the Self IP(RaRR!RRRRt/read_partition_default_route_domain_from_deviceR�RRRvRuRlR�Rwtcreate_on_deviceR�(R#trd((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR��s6$"

cC`s�dj|jjd|jjdt|jj|jj��}|jjj|�}y|j	�}Wnt
k
rwtSX|jdks�d|kr�|ddkr�tSt
S(Ns$https://{0}:{1}/mgmt/tm/net/self/{2}tservertserver_porti�tcode(R,RotproviderRRaR"tnametapiRntjsonR0RxRRw(R#turitresptresponse((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR��s


+cC`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��ndS(NR�R"s!https://{0}:{1}/mgmt/tm/net/self/R�R�R�R�i�i�tmessage(i�i�(Rpt
api_paramsRaR�R"R,RoR�R�tpostR�R0RR1tcontent(R#RmR�R�R�tex((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR��s
cC`s�|jj�}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��ndS(Ns$https://{0}:{1}/mgmt/tm/net/self/{2}R�R�R�R�i�R�(RpR�R,RoR�RRaR"R�R�tpatchR�R0RR1R�(R#RmR�R�R�R�((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR��s

cC`sjdj|jjd|jjdt|jj|jj��}|jjj|�}|j	dkrft
SdS(Ns$https://{0}:{1}/mgmt/tm/net/self/{2}R�R�i�(R,RoR�RRaR"R�R�tdeleteRRw(R#R�R�((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.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(Ns$https://{0}:{1}/mgmt/tm/net/self/{2}R�R�R�i�R�Rm(R,RoR�RRaR"R�R�RnR�R0RR1R�RR(R#R�R�R�R�((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR�s

cC`s�dj|jjd|jjd|jj�}|jjj|�}y|j�}Wn%tk
r{}t	t
|���nXd|kr�|ddkr�d|kr�t	|d��q�t	|j��nt|d�S(Ns*https://{0}:{1}/mgmt/tm/auth/partition/{2}R�R�R�i�R�tdefaultRouteDomain(
R,RoR�RaR"R�RnR�R0RR1R�R.(R#R�R�R�R�((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR�s

(R$R%RcRuR|R�R�R�R�R�R�R�R�R�R�R�R�R�R�(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyRkCs"												!				
	tArgumentSpeccB`seZd�ZRS(cC`s�t|_tdt�dtdd�dtdt�dt�dt�d	t�d
tdd�dt�d
tdddddg�dtdddtdgf��
}i|_|jjt�|jj|�dS(NRRttypeRIR�trequiredRRRRR.RR�RCR�tchoicesR�R"tCommontfallbacktF5_PARTITION(Rwtsupports_check_modeRvR	t
argument_specR�R(R#R�((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyRc+s&							(R$R%Rc(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyR�*scC`s�t�}td|jd|j�}y,td|�}|j�}|j|�Wn)tk
r{}|jdt	|��nXdS(NR�R�RlR~(
R�RR�R�RkR�t	exit_jsonRt	fail_jsonR1(tspecRltmmtresultsR�((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pytmainDs		t__main__(1t
__future__RRRR�t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRStansible.module_utils.basicRR	t%library.module_utils.network.f5.bigipR
t&library.module_utils.network.f5.commonRRR
RRt)library.module_utils.network.f5.ipaddressRRt%library.module_utils.compat.ipaddressRRRt'library.module_utils.network.f5.compareRtImportErrort%ansible.module_utils.network.f5.bigipt&ansible.module_utils.network.f5.commont)ansible.module_utils.network.f5.ipaddresst%ansible.module_utils.compat.ipaddresst'ansible.module_utils.network.f5.compareRR+RRRYR^R_tobjectR`RkR�R�R$(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigip_selfip.pyt<module>s`


Rd!
({(
W�	

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