Anons79 Mini Shell

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

�
�Udac@s�idd6dgd6dd6ZdZdZdZd	d
lmZmZd	dlmZmZd	dl	m
Z
ed
�Zd�Z
d�Zd�Zd�Zd�Zd�Zedkr�e�ndS(s1.1tmetadata_versiontpreviewtstatustnetworktsupported_bys
---
module: nxos_acl
extends_documentation_fragment: nxos
version_added: "2.2"
short_description: Manages access list entries for ACLs.
description:
  - Manages access list entries for ACLs.
author:
  - Jason Edelman (@jedelman8)
  - Gabriele Gerbino (@GGabriele)
notes:
  - Tested against NXOSv 7.3.(0)D1(1) on VIRL
  - C(state=absent) removes the ACE if it exists.
  - C(state=delete_acl) deletes the ACL if it exists.
  - For idempotency, use port numbers for the src/dest port
    params like I(src_port1) and names for the well defined protocols
    for the I(proto) param.
  - Although this module is idempotent in that if the ace as presented in
    the task is identical to the one on the switch, no changes will be made.
    If there is any difference, what is in Ansible will be pushed (configured
    options will be overridden).  This is to improve security, but at the
    same time remember an ACE is removed, then re-added, so if there is a
    change, the new ACE will be exactly what parameters you are sending to
    the module.
options:
  seq:
    description:
      - Sequence number of the entry (ACE).
  name:
    description:
      - Case sensitive name of the access list (ACL).
    required: true
  action:
    description:
      - Action of the ACE.
    choices: ['permit', 'deny', 'remark']
  remark:
    description:
      - If action is set to remark, this is the description.
  proto:
    description:
      - Port number or protocol (as supported by the switch).
  src:
    description:
      - Source ip and mask using IP/MASK notation and
        supports keyword 'any'.
  src_port_op:
    description:
      - Source port operands such as eq, neq, gt, lt, range.
    choices: ['any', 'eq', 'gt', 'lt', 'neq', 'range']
  src_port1:
    description:
      - Port/protocol and also first (lower) port when using range
        operand.
  src_port2:
    description:
      - Second (end) port when using range operand.
  dest:
    description:
      - Destination ip and mask using IP/MASK notation and supports the
        keyword 'any'.
  dest_port_op:
    description:
      - Destination port operands such as eq, neq, gt, lt, range.
    choices: ['any', 'eq', 'gt', 'lt', 'neq', 'range']
  dest_port1:
    description:
      - Port/protocol and also first (lower) port when using range
        operand.
  dest_port2:
    description:
      - Second (end) port when using range operand.
  log:
    description:
      - Log matches against this entry.
    choices: ['enable']
  urg:
    description:
      - Match on the URG bit.
    choices: ['enable']
  ack:
    description:
      - Match on the ACK bit.
    choices: ['enable']
  psh:
    description:
      - Match on the PSH bit.
    choices: ['enable']
  rst:
    description:
      - Match on the RST bit.
    choices: ['enable']
  syn:
    description:
      - Match on the SYN bit.
    choices: ['enable']
  fin:
    description:
      - Match on the FIN bit.
    choices: ['enable']
  established:
    description:
      - Match established connections.
    choices: ['enable']
  fragments:
    description:
      - Check non-initial fragments.
    choices: ['enable']
  time_range:
    description:
      - Name of time-range to apply.
  precedence:
    description:
      - Match packets with given precedence.
    choices: ['critical', 'flash', 'flash-override', 'immediate',
              'internet', 'network', 'priority', 'routine']
  dscp:
    description:
      - Match packets with given dscp value.
    choices: ['af11', 'af12', 'af13', 'af21', 'af22', 'af23','af31','af32',
              'af33', 'af41', 'af42', 'af43', 'cs1', 'cs2', 'cs3', 'cs4',
              'cs5', 'cs6', 'cs7', 'default', 'ef']
  state:
    description:
      - Specify desired state of the resource.
    default: present
    choices: ['present','absent','delete_acl']
s�
# configure ACL ANSIBLE
- nxos_acl:
    name: ANSIBLE
    seq: 10
    action: permit
    proto: tcp
    src: 192.0.2.1/24
    dest: any
    state: present
s�
commands:
    description: commands sent to the device
    returned: always
    type: list
    sample: ["ip access-list ANSIBLE", "10 permit tcp 192.0.2.1/24 any"]
i����(tload_configtrun_commands(tnxos_argument_spect
check_args(t
AnsibleModulecCs,|d7}|g}t||d|�}|S(Ns | jsontcheck_rc(R(tcommandtmoduleR
tcmdstbody((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_acl.pytexecute_show_command�s
	c	Cs4d}g}i}i}t||dt�}dt|�krIigfS|rn|drn|ddd}n
igfSt|t�r�|jd�|kr�|}q�n0x-|D]%}	|	jd�|kr�|	}Pq�q�Wy!|dd	}
|jd�}Wn"tk
riid
d6gfSXt|
t�r9|
g}
nx�|
D]�}i}i}
|jd�}||d
<t|jd��|d<|r�||d<d|d<n�|jd�|d<t|jd|jd|jd����|d<|jd|jd��|d<|jd�|d<|jd�|d<|jd�|d<|jd|jd��|d<|jd �|d <|jd!�|d"<|jd#�|d$<|jd%�|
d%<|jd&�|
d&<|jd'�|
d'<|jd(�|
d(<|jd)�|
d)<|jd*�|
d*<|jd+�|
d+<|jd,�|
d,<|jd-�|
d.<|jd/�|
d0<|jd1�|
d1<|jd2�|
d3<i}x-|j�D]\}}|r�|||<q�q�Wi}x3|
j�D]%\}}|dk	r�|||<q�q�W||d4<|jd�|krt|�}n|j
|�q@W||fS(5Nsshow ip access-listR
sStructured output unsupporteditTABLE_ip_ipv6_mactROW_ip_ipv6_mactacl_nametTABLE_seqnot	ROW_seqnot
no_entriestacltremarktnametseqnotseqtactiont
permitdenytprotot	proto_strtiptsrc_anyt
src_ip_prefixtsrctsrc_port_opt
src_port1_numt	src_port1t
src_port2_numt	src_port2tdest_anytdest_ip_prefixtdesttdest_port_optdest_port1_numt
dest_port1tdest_port2_numt
dest_port2tlogturgtacktpshtrsttsyntfintestablishedtdscp_strtdscptprecedence_strt
precedencet	fragmentst	timeranget
time_rangetoptions(RtFalsetreprt
isinstancetdicttgettKeyErrortstrtitemstNonetappend(RRt
seq_numberRtnew_acltsavemetacl_bodyRtall_acl_bodyRtacl_entriesteachttempR?Rtkeeptkeytvaluetoptions_no_null((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_acl.pytget_acl�s�







1
cCsAd|}|dkr/|d|d|7}n|d|7}|S(Nt trange((toperandtsrcp1tsprcp2t	sub_entry((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_acl.pyt_acl_operands

cCsA|jd�}|jd�}|jd�}|jd�}|jd�}|jd�}|jd�}|jd�}|jd	�}	|jd
�}
|jd�}|jd�}|||g}
|s/|d
d
j|
�}|r�|t|||�7}n|d
|	7}|
r=|t|
||�7}q=n|d|}|S(NRRRRR"R#R%R'R*R+R-R/RWs remark (RDtjoinR](tproposedRRRRR"R#R%R'R*R+R-R/tace_start_entriestace((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_acl.pytconfig_core_acls,c
Cs�ddddddddd	dg
}d
ddg}|jd
�re|jd
�|d<|jd
�nd}xk|j�D]]\}}||kr�|dkr�|d|7}q�qx||krx|d|d|7}qxqxW|r�|j�}|SdS(NR3R1R0R2R5R7R4R6R<R9R;s
time-rangeR>ttenableRW(RDtpopRGtstrip(R?tENABLE_ONLYtOTHERRtoptionRT((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_acl.pytconfig_acl_options<s"	cCsGg}x:|D]2}t|t�r2|j|�q
|j|�q
W|S(N(RBtlisttextendRI(t
command_liststflat_command_listR((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_acl.pytflatten_listTs
cKs}tdtdtdd�dtdtdd�dtdtddd	d
g�dtdtdd�dtdtdd�dtdtdd�d
tdt�dtdtdd�dtdtdd�dtdtdd�dtdt�dtdtdd�dtdtdd�dtdtddg�dtdtddg�dtdtddg�dtdtddg�dtdtddg�dtdtddg�dtdtddg�dtdtddg�dtdtddg�dtdt�dtdtdd d!d"d#d$d%d&d'g�d(tdtdd)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=g�d>tdd?d@dAgd<d@��}|jt�tdB|dCt�}t�}t||�tdDtdE|�}|jd>}|jd}|jd}|jd(}|jd}|jd}	|jd}
|jd}	|dkrx|rx|j	dFdG�nddddddg}ddg}|d@kr�|r�|r�|	r�q~x�|D]2}
|j|
dkr�|j	dFdHdI|�q�q�Wn�|d?krIxr|D]2}
|j|
dkr|j	dFdJdI|�qqWn5|dAkr~|jddkr~|j	dFdK�q~n|r�|r�|j	dFdL�nddddddddd(dddg�dddddd
dddddddg
�t�fdM�|jj�D��}t�fdN�|jj�D��}i}|j|�|j|�i}t||
|	�\}}|r�|j
dO�}|jdO�ng}i}i}|j
d�s�tt|j��j|j���}|stt|j��j|j���}n|}|r.|}q�tt|j��j|j���}|s�tt|j��j|j���}n|}n'tt|j��j|j���}|d@kr@|s�|r�|r�|jdPj|	�g�n|rt|�}|dQt|�7}nt|�}|g}|j|�q�n{|d?krq|r�|jdPj|	�g�q�nJ|dAkr�|r�|dRj
dS�dTkr�|jdUj|
�g�q�ng}|rbg}|dYkr�dVj|
�g}|jdR|�nt|�}|jr,|jdDtdW|�qbt||�t|dD<dX|krb|jdR�qbn||dW<|j|�dS(ZNRtrequiredttypeRFRRtchoicesRtpermittdenyRR"R#R%R'R*R+R-R/R0RdR1R2R3R4R5R<R6R7R>R;tcriticaltflashsflash-overridet	immediatetinternetRtprioritytroutineR9taf11taf12taf13taf21taf22taf23taf31taf32taf33taf41taf42taf43tcs1tcs2tcs3tcs4tcs5tcs6tcs7tdefaultteftstatetabsenttpresentt
delete_aclt
argument_spectsupports_check_modetchangedtwarningstmsgs3when state is action, remark param is also requireds#req'd params when state is present:tparamss#require params when state is absents)param name req'd when state is delete_acls2only one of the params dscp/precedence are allowedc3s9|]/\}}|�kr|dk	r||fVqdS(N(RH(t.0tparamRT(tCORE(sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_acl.pys	<genexpr>�s	c3s9|]/\}}|�kr|dk	r||fVqdS(N(RH(R�R�RT(t
OPTIONS_NAMES(sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_acl.pys	<genexpr>�s	R?sno {0}RWiRRsno ip access-list {0}sip access-list {0}tcommandst	configure(R�R�(RCR@tTruetupdateRR	RkRR�t	fail_jsonRHRGRVRDRetsett
differenceRItformatRbRjtinsertRot
check_modet	exit_jsonR(R�RR�tresultsR�RRR9R;RRtREQUIREDtABSENTRPt
proposed_coretproposed_optionsR_texisting_optionst
existing_coreRR�t
delta_coret
delta_optionstdcoretdoptionst	myacl_strRR
tpreface((R�R�sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_acl.pytmain^s"!
		










	

				


t__main__N(tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNt&ansible.module_utils.network.nxos.nxosRRRRtansible.module_utils.basicR	R�RRVR]RbRjRoR�t__name__(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_acl.pyt<module>s"


�	[				
	�

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