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

�
���^c
@@s�dZddlmZmZmZddlZddlZddlZddlZej	e
�Zddlm
Z
y:ddlZddlZddlZddlZeZWnek
r�eZnXddlZdZdgZd�Zi=gd6gd	6gd
6gd6ed6ed
6gd6gd6gd6gd6gd6gd6gd6ed6ed6gd6ed6ed6gd6gd6gd6gd6gd6ed6gd 6ed!6gd"6gd#6gd$6gd%6gd&6ed'6ed(6ed)6gd*6ed+6gd,6ed-6gd.6ed/6ed06gd16gd26ed36gd46gd56gd66ed76gd86gd96ed:6ed;6gd<6gd=6ed>6ed?6ed@6edA6edB6edC6edD6Zd"d#dd	d
d@dAdBd3g	ZiZer�ejj j!Z"dE�Z#e$e"dFe#�e"e�Z%x]e&e%�D]OZ'e(e'dG�p;e'j)dH�p;e'e'j*�krDqne+e%e'�ee'<qWdIejj j,fdJ��YZ-dKejj j!fdL��YZ.ndM�Z/dN�Z0dO�Z1dP�Z2dQ�Z3dR�Z4eedS�Z5dT�Z6edU�Z7dVeeedW�Z8edVeeedX�Z9eeedYdZ�Z:edVeeeeeedYeed[�Z;eeedVeeeeeeedYd\�Z<eedVeeeeeeedYd]�Z=dVeed^�Z>dVeed_�Z?dS(`u�
Capirca ACL
===========

Generate ACL (firewall) configuration for network devices.

.. versionadded:: 2017.7.0

:codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Robert Ankeny <robankeny@google.com>
:maturity:   new
:depends:    capirca
:platform:   unix

Dependencies
------------

The firewall configuration is generated by Capirca_.

.. _Capirca: https://github.com/google/capirca

To install Capirca, execute: ``pip install capirca``.
i(tabsolute_importtprint_functiontunicode_literalsN(tsixucapircau*cC@str
tStdfSdS(u8
    This module requires at least Capirca to work.
    u2The capirca module (capirca_acl) cannot be loaded.N(tHAS_CAPIRCAt__virtualname__tFalse(((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt__virtual__<suactionuaddressuaddress_excludeucommentucounteru
expirationudestination_addressudestination_address_excludeudestination_portudestination_prefixuforwarding_classuforwarding_class_exceptuloggingulog_nameu
loss_priorityuoptionuownerupoliceruportu
precedenceu
principalsuprotocoluprotocol_exceptuqosupan_applicationurouting_instanceusource_addressusource_address_excludeusource_portu
source_prefixuverbatimu
packet_lengthufragment_offsetu	hop_limitu	icmp_typeu	icmp_codeu
ether_typeutraffic_class_countutraffic_typeu
translatedudscp_setu
dscp_matchudscp_exceptunext_ipuflexible_match_rangeusource_prefix_exceptudestination_prefix_exceptuvpnu
source_tagudestination_tagusource_interfaceudestination_interfaceuplatformuplatform_excludeutimeoutu	flatteneduflattened_addruflattened_saddruflattened_daddrupriorityuttlcC@sdS(N((tselftobj((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt_add_object�su	AddObjectu__func__u_t_PolicycB@seZdZd�ZRS(uW
        Extending the Capirca Policy class to allow inserting custom filters.
        cC@sg|_d|_dS(Nu(tfilterstfilename(R((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt__init__�s	(t__name__t
__module__t__doc__R(((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyR�st_TermcB@seZdZd�ZRS(u\
        Extending the Capirca Term class to allow setting field valued on the fly.
        cC@s4x-tjt�D]\}}t|||�qWdS(N(Rt	iteritemst_TERM_FIELDStsetattr(Rtfieldtdefault((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyR�s(RRRR(((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyR�sc
C@s�tjdjd|��x�tjtj�D]�\}}||kr,tj|�r,xjtj|�D]V\}}tj|�rct	|tj
jj�rctjdjd|d|��|SqcWq,q,Wtj
djd|��dS(u�
    Given a specific platform (under the Capirca conventions),
    return the generator class.
    The generator class is identified looking under the <platform> module
    for a class inheriting the `ACLGenerator` class.
    uUsing platform: {plat}tplatu)Identified Capirca class {cls} for {plat}tclsu7Unable to identify any Capirca plaform class for {plat}N(tlogtdebugtformattinspectt
getmemberstcapircataclgentismoduletisclasst
issubclasstlibtaclgeneratortACLGeneratorterror(tplatformtmod_nametmod_objt
plat_obj_nametplat_obj((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt_import_platform_generator�s'
cC@s�tr
tSd}y@tjjjdd��"}tjjj|j��}WdQXWn.tk
r�}t	j
d�t	j
|�tSXtjd�}x
|j
�D]�}|j|�}|r�t|j��dkr�|j�\}}}}	|tkrigd6gd	6t|<nyt|djt|��WnStk
r�}
t	j
|
�t	j
d
�t	j
|�t	j
djd|��nXt|d	j|�q�q�WtS(
ur
    Build a map of services based on the IANA assignment list:
    http://www.iana.org/assignments/port-numbers

    It will load the /etc/services file and will build the mapping on the fly,
    similar to the Capirca's SERVICES file:
    https://github.com/google/capirca/blob/master/def/SERVICES.svc

    As this module is be available on Unix systems only,
    we'll read the services from /etc/services.
    In the worst case, the user will not be able to specify the
    services shortcut and they will need to specify the protocol / port combination
    using the source_port / destination_port & protocol fields.
    uu
/etc/servicesurNu"Unable to read from /etc/services:u(^([a-zA-Z0-9-]+)\s+(\d+)\/(tcp|udp)(.*)$iuportuprotocoluDid not read that properly:uGPlease report the above error: {port} does not seem a valid port value!tport(t	_SERVICEStsalttutilstfilestfopentstringutilst
to_unicodetreadtIOErrorRR'tretcompilet
splitlinestsearchtlentgroupstappendtintt
ValueErrorR(tservices_txttsrv_ftioetservice_rgxtlinet
service_rgx_stsrv_nameR.tprotocolt_tverr((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt_get_services_mapping�s8%




cC@s7t�}||kr3||dr3||ddS|S(ub
    Look into services and return the port value using the
    service name as lookup value.
    uporti(RK(R.tservices((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt_translate_ports	c	C@s�g}||kr||}n|dkr/|St|ttf�r9|dkrg}xF|D]>}t|ttf�s�|j||f�q]|j|�q]Wg}xc|D][\}}t|t�s�t|�}nt|t�s�t|�}n|j||f�q�Wtt||��Stt|t|���S|dkr�t|t�sct|�}ntt|||fg��Stt||g��S(u!
    Return the object list.
    usource_portudestination_portN(usource_portudestination_port(usource_portudestination_port(tNonet
isinstancettupletlistR>R?RMtset(	tdict_t
field_nametvaluet
prev_valuetportvalR.ttranslated_portvalt
port_starttport_end((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt
_make_it_lists6

c
C@s�i}t�}x�tj|�D]�\}}|dkr)|r)t|tj�rdt|||�}ntjd�tj|�x_|D]W}|r�||kr�t|d||d�|d<t|d||d�|d<q�q�Wtjd�tj|jd��tjd�tj|jd��q|dkr'|r't|tj�rbt|||�}ntjd	�tj|�x_|D]W}|r�||kr�t|d
||d�|d
<t|d||d�|d<q�q�Wtjd�tj|jd��tjd�tj|jd��q|t	kr|r|t	|krtt	|t
�rqt|||�}n|tkr�g}xH|D]@}tjr�tj
|�}n|jtjjjj|��q�W|}n|||<qqW|S(
u�
    Cleanup the term opts:

    - strip Null and empty valuee, defaulting their value to their base definition from _TERM_FIELDS
    - convert to `nacaddr.IP` fields from `_IP_FILEDS`
    - create lists for those fields requiring it
    usource_serviceu#Processing special source services:usource_portuportuprotocoluBBuilt source_port field, after processing special source services:u?Built protocol field, after processing special source services:udestination_serviceu(Processing special destination services:udestination_portuGBuilt source_port field, after processing special destination services:uDBuilt protocol field, after processing special destination services:(RKRRROtstring_typesR[RRtgetRRQt
_IP_FILEDStPY2t	text_typeR>RR$tpolicytnacaddrtIP(t	term_optst
clean_optst	_servicesRRUtservicet	ip_valuestaddr((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt_clean_term_optsEsb	









"
	#
cC@s`|s
iSxO|D]G}|st|t�r4qn|j�d|kr|j�dSqWiS(uK
    Find an dictionary in a list of dictionaries, given its main key.
    i(ROtdicttkeystvalues(tlsttkeytele((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt_lookup_element�s
cC@s td|d|d|�}|S(u>
    Retrieve the pillar data from the right environment.
    u
pillar.gett	pillarenvtsaltenv(t__salt__(t
pillar_keyRrRst
pillar_cfg((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt_get_pillar_cfg�s
	cC@s@g}x3|D]+}|r
t|t�r
|j|�q
q
W|S(u2
    Return a list of non-empty dictionaries.
    (RORkR>(RntcleanRp((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt_cleanup�s

c	C@sAt|�}t|�}|r*|r*gS|r;|r;|S|rL|rL|Sg}g}g}xc|D][}t||j�d�r�|j|�qe|r�|j|�qe|se|j|�qeqeWx`|D]X}|j�d}t||�rt||�}|ji||6�q�|j|�q�W|s=|j|�n|S(u<
    Merge lists of dictionaries.
    Each element of the list is a dictionary having one single key.
    That key is then used as unique lookup.
    The first element list has higher priority than the second.
    When there's an overlap between the two lists,
    it won't change the position, but the content.
    i(RyRqRlR>textend(	tfirsttsecondtprependtoverlapstmergedtappendedRptele_keyt
ele_val_first((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt_merge_list_of_dict�s6	



uaclc	K@s_tjdjd|d|��t�}||_i}|r�t||d|d|d|�}tjd�tj|�t|�}tjd�tj|�ntjd	�tj|�tjd
�t|�}tj|�tjd�|j|�tj|�x-tj	|�D]\}	}
t
||	|
�qWtjd�tjtj|��|S(
uK
    Return an instance of the ``_Term`` class given the term options.
    u7Generating config for term {tname} under filter {fname}ttnametfnameRuRsRruMerging with pillar data:uCleaning up pillar data:uReceived processing opts:uCleaning up processing opts:uFinal term opts:uTerm config:(RRRRtnametget_term_pillarRjtupdateRRRR`(tfilter_namet	term_nameRuRrRstmerge_pillartterm_fieldsttermRdRRU((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt_get_term_object�s<

			










cC@st�}g}|sg}nxj|D]b}|s%t|t�rHq%n|j�d}	|j�d}
tjjj�}||	g}|
j	dd�}
|
r�ti|	|
�}
|j|
�ntjjj
|�}|j|�g}x�|
jdg�D]u}|rct|t�rc|j�d}|j�d}t|	|d|d|d|d||�}n|j|�q�W|j||f�q%W||_tjd�tjtj|��t|�}||d	�}tjd
jd|��tjtj|��|S(
uO
    Return an instance of the ``_Policy`` class given the filters config.
    iuoptionsutermsRuRrRsR�uPolicy config:iu(Generating policy config for {platform}:R(N(RRORkRlRmRR$RatHeadertpopRNR[RztTargett	AddObjectR]R�R>RRRRR`R-R(R(RRuRrRsR�Ratpolicy_filterstfilter_R�t
filter_configtheaderttarget_optstfilter_optionsttargettfilter_termstterm_R�R�R�tplatform_generatort
policy_config((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt_get_policy_objectsT			
	
	

u%Y/%m/%dcC@s�tjj�j|�}g}x�|j�D]�}d|krj|sIq+n|jddjd|��}nd|kr�|s�q+n|jddjd|��}nd|kr�|s�q+n|jddjd	|��}n|j|�q+Wd
j|�S(ud
    Refactor revision tag comments.
    Capirca generates the filter text having the following tag keys:

    - $Id:$
    - $Revision:$
    - $Date:$

    This function goes through all the config lines and replaces
    those tags with the content requested by the user.
    If a certain value is not provided, the corresponding tag will be stripped.
    u$Id:$u$Id: {rev_id} $trev_idu$Revision:$u$Revision: {rev_no} $trev_nou$Date:$u
$Date: {ts} $ttsu
(tdatetimetnowtstrftimeR:treplaceRR>tjoin(ttexttrevision_idtrevision_not
revision_datetrevision_date_formatt	timestamptnew_textRE((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt
_revision_tag@s"!!!cK@s�g}ii|6}||j|�||jitid|�d6tid|
�d6�|j|�|swg}nt||d|d|d|d|d|d|d	td
|d|	d|
d
|�S(u_
    Return the configuration of a single policy term.

    platform
        The name of the Capirca platform.

    filter_name
        The name of the policy filter.

    term_name
        The name of the term.

    filter_options
        Additional filter options. These options are platform-specific.
        E.g.: ``inet6``, ``bridge``, ``object-group``,
        See the complete list of options_.

        .. _options: https://github.com/google/capirca/wiki/Policy-format#header-section

    pillar_key: ``acl``
        The key in the pillar containing the default attributes values. Default: ``acl``.
        If the pillar contains the following structure:

        .. code-block:: yaml

            firewall:
              - my-filter:
                  terms:
                    - my-term:
                        source_port: 1234
                        source_address:
                            - 1.2.3.4/32
                            - 5.6.7.8/32

        The ``pillar_key`` field would be specified as ``firewall``.

    pillarenv
        Query the master to generate fresh pillar data on the fly,
        specifically from the requested pillar environment.

    saltenv
        Included only for compatibility with
        :conf_minion:`pillarenv_from_saltenv`, and is otherwise ignored.

    merge_pillar: ``True``
        Merge the CLI variables with the pillar. Default: ``True``.

    revision_id
        Add a comment in the term config having the description for the changes applied.

    revision_no
        The revision count.

    revision_date: ``True``
        Boolean flag: display the date when the term configuration was generated. Default: ``True``.

    revision_date_format: ``%Y/%m/%d``
        The date format to be used when generating the perforce data. Default: ``%Y/%m/%d`` (<year>/<month>/<day>).

    source_service
        A special service to choose from. This is a helper so the user is able to
        select a source just using the name, instead of specifying a source_port and protocol.

        As this module is available on Unix platforms only,
        it reads the IANA_ port assignment from ``/etc/services``.

        If the user requires additional shortcuts to be referenced, they can add entries under ``/etc/services``,
        which can be managed using the :mod:`file state <salt.states.file>`.

        .. _IANA: http://www.iana.org/assignments/port-numbers

    destination_service
        A special service to choose from. This is a helper so the user is able to
        select a source just using the name, instead of specifying a destination_port and protocol.
        Allows the same options as ``source_service``.

    term_fields
        Term attributes.
        To see what fields are supported, please consult the list of supported keywords_.
        Some platforms have few other optional_ keywords.

        .. _keywords: https://github.com/google/capirca/wiki/Policy-format#keywords
        .. _optional: https://github.com/google/capirca/wiki/Policy-format#optionally-supported-keywords

    .. note::
        The following fields are accepted:

        - action
        - address
        - address_exclude
        - comment
        - counter
        - expiration
        - destination_address
        - destination_address_exclude
        - destination_port
        - destination_prefix
        - forwarding_class
        - forwarding_class_except
        - logging
        - log_name
        - loss_priority
        - option
        - policer
        - port
        - precedence
        - principals
        - protocol
        - protocol_except
        - qos
        - pan_application
        - routing_instance
        - source_address
        - source_address_exclude
        - source_port
        - source_prefix
        - verbatim
        - packet_length
        - fragment_offset
        - hop_limit
        - icmp_type
        - ether_type
        - traffic_class_count
        - traffic_type
        - translated
        - dscp_set
        - dscp_match
        - dscp_except
        - next_ip
        - flexible_match_range
        - source_prefix_except
        - destination_prefix_except
        - vpn
        - source_tag
        - destination_tag
        - source_interface
        - destination_interface
        - flattened
        - flattened_addr
        - flattened_saddr
        - flattened_daddr
        - priority

    .. note::
        The following fields can be also a single value and a list of values:

        - action
        - address
        - address_exclude
        - comment
        - destination_address
        - destination_address_exclude
        - destination_port
        - destination_prefix
        - forwarding_class
        - forwarding_class_except
        - logging
        - option
        - port
        - precedence
        - principals
        - protocol
        - protocol_except
        - pan_application
        - source_address
        - source_address_exclude
        - source_port
        - source_prefix
        - verbatim
        - icmp_type
        - ether_type
        - traffic_type
        - dscp_match
        - dscp_except
        - flexible_match_range
        - source_prefix_except
        - destination_prefix_except
        - source_tag
        - destination_tag
        - source_service
        - destination_service

        Example: ``destination_address`` can be either defined as:

        .. code-block:: yaml

            destination_address: 172.17.17.1/24

        or as a list of destination IP addresses:

        .. code-block:: yaml

            destination_address:
                - 172.17.17.1/24
                - 172.17.19.1/24

        or a list of services to be matched:

        .. code-block:: yaml

            source_service:
                - ntp
                - snmp
                - ldap
                - bgpd

    .. note::
        The port fields ``source_port`` and ``destination_port`` can be used as above to select either
        a single value, either a list of values, but also they can select port ranges. Example:

        .. code-block:: yaml

            source_port:
                - [1000, 2000]
                - [3000, 4000]

        With the configuration above, the user is able to select the 1000-2000 and 3000-4000 source port ranges.

    CLI Example:

    .. code-block:: bash

        salt '*' capirca.get_term_config arista filter-name term-name source_address=1.2.3.4 destination_address=5.6.7.8 action=accept

    Output Example:

    .. code-block:: text

        ! $Date: 2017/03/22 $
        no ip access-list filter-name
        ip access-list filter-name
         remark term-name
         permit ip host 1.2.3.4 host 5.6.7.8
        exit
    usource_serviceudestination_serviceR�ttermsRuRrRsR�tonly_lower_mergeR�R�R�R�(R�R[R>tget_filter_configtTrue(R(R�R�R�RuRrRsR�R�R�R�R�tsource_servicetdestination_serviceR�R�R�((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pytget_term_confighs.�


	cC@s|sg}n|sg}n|r�|	r�t|d|d|�}t||�}|pg|jdd�}|r�|jdg�}t||d|�}q�ng}|jiiti||�d6|d6|6�t|d|d|d|d|d|d	t	d
|
d|d|d
|
�
S(u�
    Return the configuration of a policy filter.

    platform
        The name of the Capirca platform.

    filter_name
        The name of the policy filter.

    filter_options
        Additional filter options. These options are platform-specific.
        See the complete list of options_.

        .. _options: https://github.com/google/capirca/wiki/Policy-format#header-section

    terms
        List of terms for this policy filter.
        If not specified or empty, will try to load the configuration from the pillar,
        unless ``merge_pillar`` is set as ``False``.

    prepend: ``True``
        When ``merge_pillar`` is set as ``True``, the final list of terms generated by merging
        the terms from ``terms`` with those defined in the pillar (if any): new terms are prepended
        at the beginning, while existing ones will preserve the position. To add the new terms
        at the end of the list, set this argument to ``False``.

    pillar_key: ``acl``
        The key in the pillar containing the default attributes values. Default: ``acl``.

    pillarenv
        Query the master to generate fresh pillar data on the fly,
        specifically from the requested pillar environment.

    saltenv
        Included only for compatibility with
        :conf_minion:`pillarenv_from_saltenv`, and is otherwise ignored.

    merge_pillar: ``True``
        Merge the CLI variables with the pillar. Default: ``True``.

    only_lower_merge: ``False``
        Specify if it should merge only the terms fields. Otherwise it will try
        to merge also filters fields. Default: ``False``.

    revision_id
        Add a comment in the filter config having the description for the changes applied.

    revision_no
        The revision count.

    revision_date: ``True``
        Boolean flag: display the date when the filter configuration was generated. Default: ``True``.

    revision_date_format: ``%Y/%m/%d``
        The date format to be used when generating the perforce data. Default: ``%Y/%m/%d`` (<year>/<month>/<day>).

    CLI Example:

    .. code-block:: bash

        salt '*' capirca.get_filter_config ciscoxr my-filter pillar_key=netacl

    Output Example:

    .. code-block:: text

        ! $Id:$
        ! $Date:$
        ! $Revision:$
        no ipv4 access-list my-filter
        ipv4 access-list my-filter
         remark $Id:$
         remark my-term
         deny ipv4 any eq 1234 any
         deny ipv4 any eq 1235 any
         remark my-other-term
         permit tcp any range 5678 5680 any
        exit

    The filter configuration has been loaded from the pillar, having the following structure:

    .. code-block:: yaml

        netacl:
          - my-filter:
              terms:
                - my-term:
                    source_port: [1234, 1235]
                    action: reject
                - my-other-term:
                    source_port:
                      - [5678, 5680]
                    protocol: tcp
                    action: accept
    RsRruoptionsutermsR}RRuR�R�R�R�R�R�N(
RwRqR�RNR]R�R>R[tget_policy_configR�(R(R�R�R�R}RuRrRsR�R�R�R�R�R�tacl_pillar_cfgtfilter_pillar_cfgtpillar_termsR((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyR�~s:m		
				c
C@s�|sg}n|rL|rLt|d|d|�}t||d|�}nt|d|d|d|d|d|�}
tj|
�}t|d|d|	d	|
d
|�S(u�
    Return the configuration of the whole policy.

    platform
        The name of the Capirca platform.

    filters
        List of filters for this policy.
        If not specified or empty, will try to load the configuration from the pillar,
        unless ``merge_pillar`` is set as ``False``.

    prepend: ``True``
        When ``merge_pillar`` is set as ``True``, the final list of filters generated by merging
        the filters from ``filters`` with those defined in the pillar (if any): new filters are prepended
        at the beginning, while existing ones will preserve the position. To add the new filters
        at the end of the list, set this argument to ``False``.

    pillar_key: ``acl``
        The key in the pillar containing the default attributes values. Default: ``acl``.

    pillarenv
        Query the master to generate fresh pillar data on the fly,
        specifically from the requested pillar environment.

    saltenv
        Included only for compatibility with
        :conf_minion:`pillarenv_from_saltenv`, and is otherwise ignored.

    merge_pillar: ``True``
        Merge the CLI variables with the pillar. Default: ``True``.

    only_lower_merge: ``False``
        Specify if it should merge only the filters and terms fields. Otherwise it will try
        to merge everything at the policy level. Default: ``False``.

    revision_id
        Add a comment in the policy config having the description for the changes applied.

    revision_no
        The revision count.

    revision_date: ``True``
        Boolean flag: display the date when the policy configuration was generated. Default: ``True``.

    revision_date_format: ``%Y/%m/%d``
        The date format to be used when generating the perforce data. Default: ``%Y/%m/%d`` (<year>/<month>/<day>).

    CLI Example:

    .. code-block:: bash

        salt '*' capirca.get_policy_config juniper pillar_key=netacl

    Output Example:

    .. code-block:: text

        firewall {
            family inet {
                replace:
                /*
                ** $Id:$
                ** $Date:$
                ** $Revision:$
                **
                */
                filter my-filter {
                    term my-term {
                        from {
                            source-port [ 1234 1235 ];
                        }
                        then {
                            reject;
                        }
                    }
                    term my-other-term {
                        from {
                            protocol tcp;
                            source-port 5678-5680;
                        }
                        then accept;
                    }
                }
            }
        }
        firewall {
            family inet {
                replace:
                /*
                ** $Id:$
                ** $Date:$
                ** $Revision:$
                **
                */
                filter my-other-filter {
                    interface-specific;
                    term dummy-term {
                        from {
                            protocol [ tcp udp ];
                        }
                        then {
                            reject;
                        }
                    }
                }
            }
        }

    The policy configuration has been loaded from the pillar, having the following structure:

    .. code-block:: yaml

        netacl:
          - my-filter:
              options:
                - not-interface-specific
              terms:
                - my-term:
                    source_port: [1234, 1235]
                    action: reject
                - my-other-term:
                    source_port:
                      - [5678, 5680]
                    protocol: tcp
                    action: accept
          - my-other-filter:
              terms:
                - dummy-term:
                    protocol:
                      - tcp
                      - udp
                    action: reject
    RsRrR}RRuR�R�R�R�R�(RwR�R�RR`R�(R(RR}RuRrRsR�R�R�R�R�R�tpolicy_pillar_cfgt
policy_objecttpolicy_text((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyR�s&�	
					cC@s%t|d|d|�}t||�S(u�
    Helper that can be used inside a state SLS,
    in order to get the filter configuration given its name.

    filter_name
        The name of the filter.

    pillar_key
        The root key of the whole policy config.

    pillarenv
        Query the master to generate fresh pillar data on the fly,
        specifically from the requested pillar environment.

    saltenv
        Included only for compatibility with
        :conf_minion:`pillarenv_from_saltenv`, and is otherwise ignored.
    RrRs(RwRq(R�RuRrRsRv((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pytget_filter_pillar�s		cC@sCt|d|d|d|�}|jdg�}t||�}|S(uw
    Helper that can be used inside a state SLS,
    in order to get the term configuration given its name,
    under a certain filter uniquely identified by its name.

    filter_name
        The name of the filter.

    term_name
        The name of the term.

    pillar_key: ``acl``
        The root key of the whole policy config. Default: ``acl``.

    pillarenv
        Query the master to generate fresh pillar data on the fly,
        specifically from the requested pillar environment.

    saltenv
        Included only for compatibility with
        :conf_minion:`pillarenv_from_saltenv`, and is otherwise ignored.
    RuRrRsuterms(R�R]Rq(R�R�RuRrRsR�tterm_pillar_cfgRd((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyR��s		(@Rt
__future__RRRR8RtloggingR�t	getLoggert__file__Rtsalt.extRRtcapirca.aclgentcapirca.lib.policytcapirca.lib.aclgeneratorR�RtImportErrorRtsalt.utils.filesR0Rt__proxyenabled__RRNRR^R/R$RatTermt	_TempTermR
Rt	dumy_termtdirtitemthasattrt
startswithtlowertgetattrtPolicyRRR-RKRMR[RjRqRwRyR�R�R�R�R�R�R�R�R�(((s</usr/lib/python2.7/site-packages/salt/modules/capirca_acl.pyt<module>sL


		
		0"			/		3	F	
	-(5'���

Zerion Mini Shell 1.0