%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/firewalld.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlmZddl	Z
ddlZ
eje
�Zd�Zd�Zd�Zd�Zd	�Zd
�Zed�Zed�Zed
�Zed�Zed�Zed�Zd�Zed�Zed�Zded�Z ded�Z!ded�Z"ded�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)ded�Z*ded�Z+ded �Z,edd!�Z-ed"�Z.ed#�Z/d$d%edd&�Z0d$d%ed'�Z1ed(�Z2ed)�Z3ed*�Z4ed+�Z5d,�Z6ed-�Z7ed.�Z8ed/�Z9ed0�Z:ed1�Z;ed2�Z<ed3�Z=ed4�Z>ed5�Z?dS(6u4
Support for firewalld.

.. versionadded:: 2015.2.0
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionErrorcC@s#tjjjd�rtStdfS(u-
    Check to see if firewall-cmd exists
    ufirewall-cmdu\The firewalld execution module cannot be loaded: the firewall-cmd binary is not in the path.(tsalttutilstpathtwhichtTruetFalse(((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt__virtual__scC@s�djtjjjd�|�}td|�}|ddkrz|dsX|d}n
|d}tdj|���n|dS(	u*
    Return the firewall-cmd location
    u{0} {1}ufirewall-cmducmd.run_alluretcodeiustderrustdoutufirewall-cmd failed: {0}(tformatRRRRt__salt__R(tcmdtfirewall_cmdtouttmsg((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt__firewall_cmds!


cC@sdj|||�}t|�S(u!
    Perform zone management
    u--{0}-{1}={2} --permanent(RR(tnamet_typetactionR
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt__mgmt1scC@s
td�S(uz
    Return version from firewall-cmd

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.version
    u	--version(R(((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytversion;s
cC@s
td�S(u
    Reload the firewall rules, which makes the permanent configuration the new
    runtime configuration without losing state information.

    .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.reload
    u--reload(R(((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytreload_rulesHs
cC@s
td�S(u�
    Print default zone for connections and interfaces

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.default_zone
    u--get-default-zone(R(((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytdefault_zoneXs
cC@s�i}d}|r|d7}nx�t|�j�D]�}|j�r2ttjd|tj��rq|j�}q�|j�jd�\}}|j	|d�r�||ji||6�q�i||6||<q2q2W|S(u�
    List everything added for or enabled in all zones

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.list_zones
    u--list-all-zonesu --permanentu	^[a-z0-9]u:N(Rt
splitlineststriptbooltretmatchtItrstriptsplittgettNonetupdate(t	permanenttzonesR
tit	zone_nametid_tval((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt
list_zoneses

cC@s)d}|r|d7}nt|�j�S(ur
    Print predefined zones

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.get_zones
    u--get-zonesu --permanent(RR (R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt	get_zones�s

cC@s)d}|r|d7}nt|�j�S(ux
    Print predefined services

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.get_services
    u--get-servicesu --permanent(RR (R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytget_services�s

cC@s)d}|r|d7}nt|�j�S(u{
    Print predefined icmptypes

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.get_icmp_types
    u--get-icmptypesu --permanent(RR (R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytget_icmp_types�s

cC@s5t|dd�}|r1|dkr1td�Sn|S(u3
    Add a new zone

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.new_zone my_zone

    By default firewalld will be reloaded. However, to avoid reloading
    you need to specify the restart as False

    .. code-block:: bash

        salt '*' firewalld.new_zone my_zone False
    uzoneunewusuccessu--reload(RR(tzonetrestartR((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytnew_zone�s

cC@s5t|dd�}|r1|dkr1td�Sn|S(uB
    Delete an existing zone

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.delete_zone my_zone

    By default firewalld will be reloaded. However, to avoid reloading
    you need to specify the restart as False

    .. code-block:: bash

        salt '*' firewalld.delete_zone my_zone False
    uzoneudeleteusuccessu--reload(RR(R.R/R((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytdelete_zone�s

cC@stdj|��S(uz
    Set default zone

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.set_default_zone damian
    u--set-default-zone={0}(RR(R.((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytset_default_zone�s
cC@s5t|dd�}|r1|dkr1td�Sn|S(uB
    Add a new service

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.new_service my_service

    By default firewalld will be reloaded. However, to avoid reloading
    you need to specify the restart as False

    .. code-block:: bash

        salt '*' firewalld.new_service my_service False
    userviceunewusuccessu--reload(RR(RR/R((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytnew_service�s

cC@s5t|dd�}|r1|dkr1td�Sn|S(uQ
    Delete an existing service

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.delete_service my_service

    By default firewalld will be reloaded. However, to avoid reloading
    you need to specify the restart as False

    .. code-block:: bash

        salt '*' firewalld.delete_service my_service False
    userviceudeleteusuccessu--reload(RR(RR/R((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytdelete_services

cC@s)i}d}|r$dj|�}nd}|r=|d7}nx�t|�j�D]�}tjd|tj�r}|j�}qP|jd�r�|||j|j	��qPn|j
dd�\}}|j	�}|j|d	�r||j
i|j	�g|6�qPi|j	�g|6||<qPW|S(
u�
    List everything added for or enabled in a zone

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.list_all

    List a specific zone

    .. code-block:: bash

        salt '*' firewalld.list_all my_zone
    uu--zone={0} --list-allu
--list-allu --permanentu	^[a-z0-9]u	u:iN(RRRRRRRt
startswithtappendRR R!R"R#(R.R$t_zoneR(R
R&R'R)((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytlist_all4s&
$cC@sA|rdj|�}nd}|r1|d7}nt|�j�S(u0
    List services added for zone as a space separated list.
    If zone is omitted, default zone will be used.

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.list_services

    List a specific zone

    .. code-block:: bash

        salt '*' firewalld.list_services my_zone
    u--zone={0} --list-servicesu--list-servicesu --permanent(RRR (R.R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt
list_servicescs
cC@sG|rdj||�}ndj|�}|r=|d7}nt|�S(u#
    Add a service for zone. If zone is omitted, default zone will be used.

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.add_service ssh

    To assign a service to a specific zone:

    .. code-block:: bash

        salt '*' firewalld.add_service ssh my_zone
    u--zone={0} --add-service={1}u--add-service={0}u --permanent(RR(tserviceR.R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytadd_services
cC@sG|rdj||�}ndj|�}|r=|d7}nt|�S(u[
    Remove a service from zone. This option can be specified multiple times.
    If zone is omitted, default zone will be used.

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.remove_service ssh

    To remove a service from a specific zone

    .. code-block:: bash

        salt '*' firewalld.remove_service ssh dmz
    u--zone={0} --remove-service={1}u--remove-service={0}u --permanent(RR(R:R.R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytremove_service�s
cC@s@|tdt�kr$td��ndj||�}t|�S(u�
    Add a new port to the specified service.

    .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.add_service_port zone 80
    R$uThe service does not exist.u(--permanent --service={0} --add-port={1}(R,RRRR(R:tportR
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytadd_service_port�scC@s@|tdt�kr$td��ndj||�}t|�S(u�
    Remove a port from the specified service.

    .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.remove_service_port zone 80
    R$uThe service does not exist.u+--permanent --service={0} --remove-port={1}(R,RRRR(R:R=R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytremove_service_port�scC@sdj|�}t|�j�S(u�
    List ports of a service.

    .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.get_service_ports zone
    u%--permanent --service={0} --get-ports(RRR (R:R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytget_service_ports�scC@sdj||�}t|�S(u�
    Add a new protocol to the specified service.

    .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.add_service_protocol zone ssh
    u,--permanent --service={0} --add-protocol={1}(RR(R:tprotocolR
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytadd_service_protocol�s		cC@sdj||�}t|�S(u�
    Remove a protocol from the specified service.

    .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.remove_service_protocol zone ssh
    u/--permanent --service={0} --remove-protocol={1}(RR(R:RAR
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytremove_service_protocol�s		cC@sdj|�}t|�j�S(u�
    List protocols of a service.

    .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.get_service_protocols zone
    u)--permanent --service={0} --get-protocols(RRR (R:R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytget_service_protocolsscC@sHt||�}dg|j�D]}||dd^qkrDtStS(u�
    Show if masquerading is enabled on a zone.
    If zone is omitted, default zone will be used.

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.get_masquerade zone
    unou
masqueradei(R8tkeysR	R(R.R$t	zone_infoR&((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytget_masquerades1cC@s;|rdj|�}nd}|r1|d7}nt|�S(uF
    Enable masquerade on a zone.
    If zone is omitted, default zone will be used.

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.add_masquerade

    To enable masquerade on a specific zone

    .. code-block:: bash

        salt '*' firewalld.add_masquerade dmz
    u--zone={0} --add-masqueradeu--add-masqueradeu --permanent(RR(R.R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytadd_masquerade1s
cC@s;|rdj|�}nd}|r1|d7}nt|�S(uL
    Remove masquerade on a zone.
    If zone is omitted, default zone will be used.

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.remove_masquerade

    To remove masquerade on a specific zone

    .. code-block:: bash

        salt '*' firewalld.remove_masquerade dmz
    u--zone={0} --remove-masqueradeu--remove-masqueradeu --permanent(RR(R.R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytremove_masqueradeOs
cC@sz|dkr+t}tjjjdd�n|rKt|�rKt|�ndj||�}|rp|d7}nt	|�S(u�
    Allow specific ports in a zone.

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.add_port internal 443/tcp
    uNeonuyadd_port function will no longer force enable masquerading in future releases. Use add_masquerade to enable masquerading.u--zone={0} --add-port={1}u --permanentN(
R"RRRtversionst
warn_untilRGRHRR(R.R=R$tforce_masqueradeR
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytadd_portns


cC@s/dj||�}|r%|d7}nt|�S(u�
    Remove a specific port from a zone.

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.remove_port internal 443/tcp
    u--zone={0} --remove-port={1}u --permanent(RR(R.R=R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytremove_port�s
cC@s2dj|�}|r"|d7}nt|�j�S(u�
    List all ports in a zone.

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.list_ports
    u--zone={0} --list-portsu --permanent(RRR (R.R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt
list_ports�s
utcpucC@s�|dkr+t}tjjjdd�n|rKt|�rKt|�ndj|||||�}|ry|d7}nt	|�S(u�
    Add port forwarding.

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.add_port_fwd public 80 443 tcp
    uNeonu}add_port_fwd function will no longer force enable masquerading in future releases. Use add_masquerade to enable masquerading.uF--zone={0} --add-forward-port=port={1}:proto={2}:toport={3}:toaddr={4}u --permanentN(
R"RRRRJRKRGRHRR(R.tsrctdesttprototdstaddrR$RLR
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytadd_port_fwd�s 

	
cC@s8dj|||||�}|r.|d7}nt|�S(u�
    Remove Port Forwarding.

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.remove_port_fwd public 80 443 tcp
    uI--zone={0} --remove-forward-port=port={1}:proto={2}:toport={3}:toaddr={4}u --permanent(RR(R.RPRQRRRSR$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytremove_port_fwd�s	
c	C@s�g}dj|�}|r(|d7}nx�t|�j�D]~}|jd�\}}}}|ji|jd�dd6|jd�dd6|jd�dd6|jd�dd	6�q;W|S(
u�
    List port forwarding

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.list_port_fwd public
    u--zone={0} --list-forward-portsu --permanentu:u=iuSource portuProtocoluDestination portuDestination address(RRRR R6(	R.R$tretR
R&RPRRRQtaddr((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt
list_port_fwd�s
cC@sx|t|�kr#tjd�tS|t||�krItjd�dSdj||�}|rn|d7}nt|�S(u�
    Block a specific ICMP type on a zone

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.block_icmp zone echo-reply
    uInvalid ICMP typeuICMP block already existsusuccessu--zone={0} --add-icmp-block={1}u --permanent(R-tlogterrorR	tlist_icmp_blocktinfoRR(R.ticmpR$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt
block_icmps


cC@sx|t|�kr#tjd�tS|t||�krItjd�dSdj||�}|rn|d7}nt|�S(u�
    Allow a specific ICMP type on a zone

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.allow_icmp zone echo-reply
    uInvalid ICMP typeuICMP Type is already permittedusuccessu"--zone={0} --remove-icmp-block={1}u --permanent(R-RYRZR	R[R\RR(R.R]R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt
allow_icmp9s


cC@s2dj|�}|r"|d7}nt|�j�S(u�
    List ICMP blocks on a zone

    .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewlld.list_icmp_block zone
    u--zone={0} --list-icmp-blocksu --permanent(RRR (R.R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyR[Us
cC@s
td�S(u�
    Make current runtime configuration permanent.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.make_permanent
    u--runtime-to-permanent(R(((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytmake_permanentiscC@s2dj|�}|r"|d7}nt|�j�S(u�
    List interfaces bound to a zone

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.get_interfaces zone
    u--zone={0} --list-interfacesu --permanent(RRR (R.R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytget_interfacesxs
cC@sT|t||�kr%tjd�ndj||�}|rJ|d7}nt|�S(u�
    Bind an interface to a zone

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.add_interface zone eth0
    u#Interface is already bound to zone.u--zone={0} --add-interface={1}u --permanent(RaRYR\RR(R.t	interfaceR$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt
add_interface�s
cC@sT|t||�kr%tjd�ndj||�}|rJ|d7}nt|�S(u�
    Remove an interface bound to a zone

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.remove_interface zone eth0
    uInterface is not bound to zone.u!--zone={0} --remove-interface={1}u --permanent(RaRYR\RR(R.RbR$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytremove_interface�s
cC@s2dj|�}|r"|d7}nt|�j�S(u�
    List sources bound to a zone

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.get_sources zone
    u--zone={0} --list-sourcesu --permanent(RRR (R.R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytget_sources�s
cC@sT|t||�kr%tjd�ndj||�}|rJ|d7}nt|�S(u�
    Bind a source to a zone

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.add_source zone 192.168.1.0/24
    u Source is already bound to zone.u--zone={0} --add-source={1}u --permanent(ReRYR\RR(R.tsourceR$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt
add_source�s
cC@sT|t||�kr%tjd�ndj||�}|rJ|d7}nt|�S(u�
    Remove a source bound to a zone

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.remove_source zone 192.168.1.0/24
    uSource is not bound to zone.u--zone={0} --remove-source={1}u --permanent(ReRYR\RR(R.RfR$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt
remove_source�s
cC@s2dj|�}|r"|d7}nt|�j�S(u�
    List rich rules bound to a zone

    .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.get_rich_rules zone
    u--zone={0} --list-rich-rulesu --permanent(RRR(R.R$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytget_rich_rules�s
cC@s/dj||�}|r%|d7}nt|�S(u�
    Add a rich rule to a zone

    .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.add_rich_rule zone 'rule'
    u --zone={0} --add-rich-rule='{1}'u --permanent(RR(R.truleR$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt
add_rich_rules
cC@s/dj||�}|r%|d7}nt|�S(u�
    Add a rich rule to a zone

    .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt '*' firewalld.remove_rich_rule zone 'rule'
    u#--zone={0} --remove-rich-rule='{1}'u --permanent(RR(R.RjR$R
((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pytremove_rich_rule$s
(@t__doc__t
__future__RRRtloggingRtsalt.exceptionsRtsalt.utils.pathRtsalt.utils.versionst	getLoggert__name__RYR
RRRRRRR*R+R,R-R0R1R2R3R4R"R8R9R;R<R>R?R@RBRCRDRGRHRIRMRNRORTRURXR^R_R[R`RaRcRdReRgRhRiRkRl(((s:/usr/lib/python2.7/site-packages/salt/modules/firewalld.pyt<module>sl	
		
	
		
 	
/						#) 	

Zerion Mini Shell 1.0