%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/ipset.pyc

�
���^c@@s�dZddlmZmZmZddlZddlmZddlm	Z	m
Z
ddlZddl
mZeje�Zd�Zidd	6dd
6dd6dd
6Zedddddddddddddddg�Ziedddd d!d"g�d6eddd d!d"g�d6eddd d!d"g�d6ed#d$d%ddd d!d"g�d6ed$d%dd d!d"g�d6ed#d$d%ddd d!d"g�d6ed#d$d%ddd d!d"g�d6ed#d$d%ddd d!d"g�d6ed#d$d%ddd d!d"g�d6ed#d$d%ddd d!d"g�d6ed#d$d%ddd d!d"g�d6ed#d$d%ddd d!d"g�d6ed#d&d$d%dd d!d"g�d6ed#d$d%ddd d!d"g�d6ed'dd d!g�d6Zed!d d"g�Zidgd6dgd6dgd6gd6gd6gd6gd6gd6gd6gd6gd6gd6gd6gd6gd6Ziedd(d)d*d+d,g�d6edd(d)d*d+d,g�d6edd(d)d*d+d+g�d6edd(d)d*d+d,g�d6edd(d)d*d+d,g�d6edd-d(d)d*d+d,g�d6edd-d(d)d*d+d,g�d6edd-d(d)d*d+d,g�d6edd-d(d)d*d+d,g�d6edd(d)d*d+d,g�d6edd-d(d)d*d+d,g�d6edd-d(d)d*d+d,g�d6edd-d(d)d*d+d,g�d6edd(d)d*d+d,g�d6edd(d)d*d+d,g�d6Zd.�Zd/�Zd0�Zddd	ed1�Zdd	d2�Z ddd	d3�Z!d	d4�Z"dd	d5�Z#ddd	d6�Z$ddd	d7�Z%ddd	d8�Z&ddd	d9�Z'dd	d:�Z(d;�Z)d<�Z*d=�Z+d>�Z,ed?�Z-d@�Z.dA�Z/dB�Z0dC�Z1dD�Z2dS(Eu
Support for ipset
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tmaptrange(t	ipaddresscc@s&x||kr!|V|d7}qWdS(Ni((tstarttend((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyt
long_rangesuinetuipv4uip4uinet6uipv6uip6u	bitmap:ipu
bitmap:ip,macubitmap:portuhash:ipuhash:macuhash:ip,portuhash:ip,port,ipuhash:ip,port,netuhash:netuhash:net,netuhash:net,ifaceu
hash:net,portuhash:net,port,netuhash:ip,markulist:seturangeunetmaskutimeoutucountersucommentuskbinfoufamilyuhashsizeumaxelemumarkmaskusizeupacketsubytesuskbmarkuskbpriouskbqueueunomatchcC@s#tjjjd�rtStdfS(u4
    Only load the module if ipset is installed
    uipsetuGThe ipset execution modules cannot be loaded: ipset binary not in path.(tsalttutilstpathtwhichtTruetFalse(((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyt__virtual__rscC@stjjjd�S(u 
    Return correct command
    uipset(R
RRR
(((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyt
_ipset_cmd{scC@s0djt��}td|�j�}|dS(uz
    Return version from ipset --version

    CLI Example:

    .. code-block:: bash

        salt '*' ipset.version

    u
{0} --versionucmd.runi(tformatRt__salt__tsplit(tcmdtout((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pytversion�sc	K@s8t|}|sdS|sdS|tkr.dSx+t|D]}||kr9dj|�Sq9Wdjt�||�}x[t|D]O}||kr|tkr�dj||�}q�dj||||�}qqWdt|kr�d	j||�}n|rd
j|�}ntd|dt�}|s4t	}n|S(
u.
    .. versionadded:: 2014.7.0

    Create new custom set

    CLI Example:

    .. code-block:: bash

        salt '*' ipset.new_set custom_set list:set

        salt '*' ipset.new_set custom_set list:set comment=True

        IPv6:
        salt '*' ipset.new_set custom_set list:set family=ipv6
    u Error: Set needs to be specifiedu%Error: Set Type needs to be specifieduError: Set Type is invalidu!Error: {0} is a required argumentu{0} create {1} {2}u{0} {1} u{0} {1} {2} ufamilyu{0} family {1}u{0} commentucmd.runtpython_shell(
t_IPSET_FAMILIESt_IPSET_SET_TYPESt_CREATE_OPTIONS_REQUIREDRRt_CREATE_OPTIONSt_CREATE_OPTIONS_WITHOUT_VALUERRR(	tsettset_typetfamilytcommenttkwargstipset_familytitemRR((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pytnew_set�s0
 	cC@sH|s
dSdjt�|�}td|dt�}|sDt}n|S(u�
    .. versionadded:: 2014.7.0

    Delete ipset set.

    CLI Example:

    .. code-block:: bash

        salt '*' ipset.delete_set custom_set

        IPv6:
        salt '*' ipset.delete_set custom_set family=ipv6
    u Error: Set needs to be specifiedu{0} destroy {1}ucmd.runR(RRRRR(RR RR((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyt
delete_set�s	cC@s�|s
dS|sdSt|�}|s*dSt|�}|r@dSdjt�||�}td|dt�}|s}t}n|S(u
    .. versionadded:: 2014.7.0

    Delete ipset set.

    CLI Example:

    .. code-block:: bash

        salt '*' ipset.rename_set custom_set new_set=new_set_name

        IPv6:
        salt '*' ipset.rename_set custom_set new_set=new_set_name family=ipv6
    u Error: Set needs to be specifiedu-Error: New name for set needs to be specifieduError: Set does not existuError: New Set already existsu{0} rename {1} {2}ucmd.runR(t_find_set_typeRRRRR(RR%R tsettypeRR((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyt
rename_set�s	c	C@s�djt��}td|dt�}|jd�}d}g}|ji�xg|D]_}t|�dkr�|d}|ji�qWn|jdd�\}}|d|||<qWW|S(u�
    .. versionadded:: 2014.7.0

    List all ipset sets.

    CLI Example:

    .. code-block:: bash

        salt '*' ipset.list_sets

    u{0} list -tucmd.runRu
iiu:(RRRRRtappendtlen(	R RRt_tmptcounttsetsR$tkeytvalue((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyt	list_setss




cC@s$|s
dSt|�}|s tStS(u�
    Check that given ipset set exists.

    .. versionadded:: 2014.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' ipset.check_set setname

    u Error: Set needs to be specified(t_find_set_infoRR(RR tsetinfo((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyt	check_set*s
c
K@s|s
dS|sdSt|�}|s3dj|�S|d}dj|�}d|krxd|dkrxdj|�Snd	|ks�d
|kr�d|dkr�dj|�Snd
|krd
|dkr�dj|�Sd
|krdj||d
�}qnttdddg�t|j��@�dkrRd|dkrRdj|�Snx:t|D].}||kr]dj||||�}q]q]Wt|�}||kr�dj||�Sdjt�||�}td|dt	�}	t|	�dkr�dSdj|	�S(u�
    Append an entry to the specified set.

    CLI Example:

    .. code-block:: bash

        salt '*' ipset.add setname 192.168.1.26

        salt '*' ipset.add setname 192.168.0.3,AA:BB:CC:DD:EE:FF

    u Error: Set needs to be specifiedu"Error: Entry needs to be specifieduError: Set {0} does not existuTypeu{0}utimeoutuHeaderu/Error: Set {0} not created with timeout supportupacketsubytesucountersu0Error: Set {0} not created with counters supportucommentu/Error: Set {0} not created with comment supportu{0} comment "{1}"uskbmarkuskbpriouskbqueueiuskbinfou/Error: Set {0} not created with skbinfo supportu{0} {1} {2}u)Warn: Entry {0} already exists in set {1}u{0} add -exist {1} {2}ucmd.runRuSuccessu
Error: {0}(
R2RR+Rtkeyst_ADD_OPTIONSt_find_set_membersRRR(
tsetnametentryR R"R3R(RR$tcurrent_membersR((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pytadd@sD



1 cK@s�|s
dS|sdSt|�}|s3dj|�Sdjt�||�}td|dt�}t|�dkrwdSd	j|�S(
u�
    Delete an entry from the specified set.

    CLI Example:

    .. code-block:: bash

        salt '*' ipset.delete setname 192.168.0.3,AA:BB:CC:DD:EE:FF

    u Error: Set needs to be specifiedu"Error: Entry needs to be specifieduError: Set {0} does not existu{0} del {1} {2}ucmd.runRiuSuccessu
Error: {0}(R'RRRRR+(RR9R R"R(RR((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pytdelete}s
cC@s�|s
dS|sdSt|�}|s3dj|�St|t|��}t|�sXtSt|t�ryt||�}nt||�g}x2|D]*}x!|D]}t	||�r�t
Sq�Wq�WtS(u
    Check that an entry exists in the specified set.

    set
        The ipset name

    entry
        An entry in the ipset.  This parameter can be a single IP address, a
        range of IP addresses, or a subnet block.  Example:

        .. code-block:: cfg

            192.168.0.1
            192.168.0.2-192.168.0.19
            192.168.0.0/25

    family
        IP protocol version: ipv4 or ipv6

    CLI Example:

    .. code-block:: bash

        salt '*' ipset.check setname '192.168.0.1 comment "Hello"'

    u Error: Set needs to be specifiedu"Error: Entry needs to be specifieduError: Set {0} does not exist(R'Rt_parse_membersR7R+Rt
isinstancetlistt
_parse_membert_member_containsR(RR9R R(R:tentriestcurrent_member((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pytcheck�s$


cK@sy|s
dS|sdSt|�}|s3dj|�Sdjt�||�}td|dt�}|ddkrutStS(	u�
    Test if an entry is in the specified set.

    CLI Example:

    .. code-block:: bash

        salt '*' ipset.test setname 192.168.0.2

        IPv6:
        salt '*' ipset.test setname fd81:fc56:9ac7::/48
    u Error: Set needs to be specifiedu"Error: Entry needs to be specifieduError: Set {0} does not existu{0} test {1} {2}ucmd.run_allRuretcodei(R'RRRRR(RR9R R"R(RR((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyttest�s

cC@s�t|�}|sdj|�St|}|rGdjt�|�}ndjt��}td|dt�}t|�dkr�tStSdS(u
    Flush entries in the specified set,
    Flush all sets if set is not specified.

    CLI Example:

    .. code-block:: bash

        salt '*' ipset.flush

        salt '*' ipset.flush set

        IPv6:
        salt '*' ipset.flush

        salt '*' ipset.flush set
    uError: Set {0} does not existu
{0} flush {1}u	{0} flushucmd.runRiN(R'RRRRRR+R(RR R(R#RR((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pytflush�s

cC@s�djt�|�}td|dt�}|ddkr?tS|djd�}g}t}x9|D]1}|r�|j|�nd|kret}qeqeW|S(	u*
    Return list of members for a set
    u{0} list {1}ucmd.run_allRuretcodeiustdoutu
uMembers:(RRRRRR*R(RRRR,tmemberststartMembersti((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyR7s

cC@s�djt�|�}td|dt�}|ddkr?tSi}|djd�}xC|D];}d|kr_|jdd	�\}}|d	||<q_q_W|S(
u*
    Return information about the set
    u{0} list -t {1}ucmd.run_allRuretcodeiustdoutu
u:i(RRRRR(RRRR3R,R$R/R0((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyR2+s
cC@s"t|�}|r|dStSdS(u"
    Find the type of the set
    uTypeN(R2R(RR3((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyR'AscC@sBt|tj�r"t||�gSg|D]}t||�^q)S(N(R>Rtstring_typesR@(R(RGtmember((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyR=MscC@sr|jd�djd�}|jdd�}|djd�}g}x�tt|��D]�}||}||}	|dkry�d|	kr�tj|	d	|�}	n]d
|	kr�tttj|	jd
���\}
}ttj|
|��}	ntj|	�}	Wq7t	k
rq7Xn|dkr7t
|	�}	n|j|	�qZWt|�dkrn|j|d�n|S(
Nu:iu,u iuipunetu/tstrictu-uport(uipunet(RRR+Rt
ip_networkR?Rt
ip_addresstsummarize_address_ranget
ValueErrortintR*(R(RKRLtsubtypest	all_partstpartst
parsed_memberRItsubtypetpartRR((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyR@Us.

'
cC@sdS(N((RGR9((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyt_members_containxscC@sXt|�t|�krtSx5tt|��D]!}t||||�s/tSq/WtS(N(R+RRt_compare_member_partsR(RKR9RI((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyRA|scC@s�||krtSt|t�rGx!|D]}t||�s&tSq&WtSt|�rlt|�r�||kSn&t|�r�t|�r�||kStStS(N(RR>R?RYRt_is_addresst_is_network(tmember_partt
entry_parttentry_part_item((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyRY�s


cC@s"t|tj�p!t|tj�S(N(R>RtIPv4NetworktIPv6Network(to((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyR[�scC@s"t|tj�p!t|tj�S(N(R>RtIPv4AddresstIPv6Address(Ra((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyRZ�s(3t__doc__t
__future__RRRtloggingtsalt.extRtsalt.ext.six.movesRRtsalt.utils.pathR
tsalt._compatRt	getLoggert__name__tlogR	RRRRRRR6RRRtNoneRR%R&R)R1R4R;R<RDRERFR7R2R'R=R@RXRARYR[RZ(((s6/usr/lib/python2.7/site-packages/salt/modules/ipset.pyt<module>s�	
%%%%%%%%%%



""""""""				8&=6 $				#			"	

Zerion Mini Shell 1.0