%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/states/panos.pyo

�
���^c@@sdZddlmZddlZddljjZddlm	Z
eje�Z
d�Zed�Zd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zedeeeeed�Zedeeed�Zeeed�Zd�Zeed�Z eeed�Z!eeed�Z"eeeed�Z#d�Z$eeed�Z%edeeeeeeeeeeeeeeeeeeeeeeeeed�Z&edeeeed�Z'edeeed�Z(eeed �Z)dS(!sT

A state module to manage Palo Alto network devices.

:codeauthor: ``Spencer Ervin <spencer_ervin@hotmail.com>``
:maturity:   new
:depends:    none
:platform:   unix


About
=====
This state module was designed to handle connections to a Palo Alto based
firewall. This module relies on the Palo Alto proxy module to interface with the devices.

This state module is designed to give extreme flexibility in the control over XPATH values on the PANOS device. It
exposes the core XML API commands and allows state modules to chain complex XPATH commands.

Below is an example of how to construct a security rule and move to the top of the policy. This will take a config
lock to prevent execution during the operation, then remove the lock. After the XPATH has been deployed, it will
commit to the device.

.. code-block:: yaml

    panos/takelock:
        panos.add_config_lock
    panos/service_tcp_22:
        panos.set_config:
            - xpath: /config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/service
            - value: <entry name='tcp-22'><protocol><tcp><port>22</port></tcp></protocol></entry>
            - commit: False
    panos/create_rule1:
        panos.set_config:
            - xpath: /config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security/rules
            - value: '
              <entry name="rule1">
                <from><member>trust</member></from>
                <to><member>untrust</member></to>
                <source><member>10.0.0.1</member></source>
                <destination><member>10.0.1.1</member></destination>
                <service><member>tcp-22</member></service>
                <application><member>any</member></application>
                <action>allow</action>
                <disabled>no</disabled>
              </entry>'
            - commit: False
    panos/moveruletop:
        panos.move_config:
            - xpath: /config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security/rules/entry[@name='rule1']
            - where: top
            - commit: False
    panos/removelock:
        panos.remove_config_lock
    panos/commit:
        panos.commit

Version Specific Configurations
===============================
Palo Alto devices running different versions will have different supported features and different command structures. In
order to account for this, the proxy module can be leveraged to check if the panos device is at a specific revision
level.

The proxy['panos.is_required_version'] method will check if a panos device is currently running a version equal or
greater than the passed version. For example, proxy['panos.is_required_version']('7.0.0') would match both 7.1.0 and
8.0.0.

.. code-block:: jinja

    {% if proxy['panos.is_required_version']('8.0.0') %}
    panos/deviceconfig/system/motd-and-banner:
      panos.set_config:
        - xpath: /config/devices/entry[@name='localhost.localdomain']/deviceconfig/system/motd-and-banner
        - value: |
          <banner-header>BANNER TEXT</banner-header>
          <banner-header-color>color2</banner-header-color>
          <banner-header-text-color>color18</banner-header-text-color>
          <banner-header-footer-match>yes</banner-header-footer-match>
        - commit: False
    {% endif %}

.. seealso::
    :py:mod:`Palo Alto Proxy Module <salt.proxy.panos>`

i(tabsolute_importN(tElementTreecC@s
dtkS(Nspanos.commit(t__salt__(((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt__virtual__ascC@sdt|t�rS|r%d|kr%dSd}x!|D]}|dj|�7}q2W|Sdj|�SdS(s>
    Builds a member formatted string for XML operation.

    tanys<member>any</member>ts<member>{0}</member>N(t
isinstancetlisttformat(tmemberstanychecktresponsetm((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt_build_memberses
cC@s-i|d6id6dd6td6dd6}|S(s+
    Set the default response values.

    tnametchangestcommittresultRtcommentN(tNonetFalse(Rtret((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt_default_retws
cC@s<idd6dd6|d6|d6}td|�}t|�S(s/
    Sends an edit request to the device.

    tconfigttypetedittactiontxpathtelements
panos.call(t	__proxy__t_validate_response(RRtqueryR((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt_edit_config�s

cC@s/idd6dd6|d6}td|�}|S(s.
    Retrieves an xpath from the device.

    RRtgetRRs
panos.call(R(RRR((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt_get_config�s


cC@sCidd6dd6|d6dd6|d6}td	|�}t|�S(
s6
    Moves an xpath to the after of its section.

    RRtmoveRRtaftertwheretdsts
panos.call(RR(RttargetRR((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt_move_after�s

cC@sCidd6dd6|d6dd6|d6}td	|�}t|�S(
s7
    Moves an xpath to the bottom of its section.

    RRR#RRtbeforeR%R&s
panos.call(RR(RR'RR((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt_move_before�s

cC@s<idd6dd6|d6dd6}td|�}t|�S(	s7
    Moves an xpath to the bottom of its section.

    RRR#RRtbottomR%s
panos.call(RR(RRR((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt_move_bottom�s

cC@s<idd6dd6|d6dd6}td|�}t|�S(	s4
    Moves an xpath to the top of its section.

    RRR#RRttopR%s
panos.call(RR(RRR((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt	_move_top�s

cC@s<idd6dd6|d6|d6}td|�}t|�S(s-
    Sends a set request to the device.

    RRtsetRRRs
panos.call(RR(RRRR((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt_set_config�s

cC@s�|stdfSd|kr�d|dkru|dddkrJt|fS|dddkrht|fSt|fSq�|ddkr�t|fSt|fSn=d|kr�|ddkr�t|fSt|fSn
t|fSd	S(
s\
    Validates a response from a Palo Alto device. Used to verify success of commands.

    s(Unable to validate response from device.tmsgtlinesalready at the topsalready at the bottomscommand succeededtstatustsuccessN(RtTrue(R((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyR�s"







cC@s2t|�}|jitd�d6td6�|S(s�
    Prevent other users from changing configuration until the lock is released.

    name: The name of the module function to execute.

    SLS Example:

    .. code-block:: yaml

        panos/takelock:
            panos.add_config_lock

    spanos.add_config_lockRR(RtupdateRR5(RR((s5/usr/lib/python2.7/site-packages/salt/states/panos.pytadd_config_locks
	icC@st|�}|s*|jidd6�|Std||�d}	|	r`d|	kr`|	d}	ni}	d}
|r�dj|�}
nH|r�dj|�}
n0|r�d	j|�}
n|jid
d6�|S|r�|
dj|�7}
ndj||
�}tjtj|�t�}|	|kr@|jid
d6td6�|Sdj||�}
t	|
|�\}}|s�|ji|d6�|S|tkr�|jii|	d6|d6d6td�d6dd6td6�n0|jii|	d6|d6d6dd6td6�|S(s�	
    Ensures that an address object exists in the configured state. If it does not exist or is not configured with the
    specified attributes, it will be adjusted to match the specified values.

    This module will only process a single address type (ip-netmask, ip-range, or fqdn). It will process the specified
    value if the following order: ip-netmask, ip-range, fqdn. For proper execution, only specify a single address
    type.

    name: The name of the module function to execute.

    addressname(str): The name of the address object.  The name is case-sensitive and can have up to 31 characters,
    which an be letters, numbers, spaces, hyphens, and underscores. The name must be unique on a firewall and, on
    Panorama, unique within its device group and any ancestor or descendant device groups.

    vsys(str): The string representation of the VSYS ID. Defaults to VSYS 1.

    ipnetmask(str): The IPv4 or IPv6 address or IP address range using the format ip_address/mask or ip_address where
    the mask is the number of significant binary digits used for the network portion of the address. Ideally, for IPv6,
    you specify only the network portion, not the host portion.

    iprange(str): A range of addresses using the format ip_address–ip_address where both addresses can be  IPv4 or both
    can be IPv6.

    fqdn(str): A fully qualified domain name format. The FQDN initially resolves at commit time. Entries are
    subsequently refreshed when the firewall performs a check every 30 minutes; all changes in the IP address for the
    entries are picked up at the refresh cycle.

    description(str): A description for the policy (up to 255 characters).

    commit(bool): If true the firewall will commit the changes, if false do not commit changes.

    SLS Example:

    .. code-block:: yaml

        panos/address/h-10.10.10.10:
            panos.address_exists:
              - addressname: h-10.10.10.10
              - vsys: 1
              - ipnetmask: 10.10.10.10
              - commit: False

        panos/address/10.0.0.1-10.0.0.50:
            panos.address_exists:
              - addressname: r-10.0.0.1-10.0.0.50
              - vsys: 1
              - iprange: 10.0.0.1-10.0.0.50
              - commit: False

        panos/address/foo.bar.com:
            panos.address_exists:
              - addressname: foo.bar.com
              - vsys: 1
              - fqdn: foo.bar.com
              - description: My fqdn object
              - commit: False

    s(The service name field must be provided.Rspanos.get_addressRtentryRs<ip-netmask>{0}</ip-netmask>s<ip-range>{0}</ip-range>s<fqdn>{0}</fqdn>s'A valid address type must be specified.s<description>{0}</description>s<entry name='{0}'>{1}</entry>s3Address object already exists. No changes required.sk/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys{0}']/address/entry[@name='{1}']R)R$Rspanos.commitRs'Address object successfully configured.s'Service object successfully configured.(
RR6RRtxmltto_dicttETt
fromstringR5R (Rtaddressnametvsyst	ipnetmasktiprangetfqdntdescriptionRRtaddressRtfull_elementtnew_addressRRR1((s5/usr/lib/python2.7/site-packages/salt/states/panos.pytaddress_exists$sXB
				cC@s�t|�}|s*|jidd6�|Std||�d}|r`d|kr`|d}ni}|r�djt|t��}n|jidd6�|S|r�|dj|�7}nd	j||�}	tjtj	|	�t�}
||
kr|jid
d6td6�|Sdj||�}t
||	�\}}
|sX|ji|
d6�|S|tkr�|jii|d6|
d
6d6td�d6dd6td6�n0|jii|d6|
d
6d6dd6td6�|S(sC
    Ensures that an address group object exists in the configured state. If it does not exist or is not configured with
    the specified attributes, it will be adjusted to match the specified values.

    This module will enforce group membership. If a group exists and contains members this state does not include,
    those members will be removed and replaced with the specified members in the state.

    name: The name of the module function to execute.

    groupname(str): The name of the address group object.  The name is case-sensitive and can have up to 31 characters,
    which an be letters, numbers, spaces, hyphens, and underscores. The name must be unique on a firewall and, on
    Panorama, unique within its device group and any ancestor or descendant device groups.

    vsys(str): The string representation of the VSYS ID. Defaults to VSYS 1.

    members(str, list): The members of the address group. These must be valid address objects or address groups on the
    system that already exist prior to the execution of this state.

    description(str): A description for the policy (up to 255 characters).

    commit(bool): If true the firewall will commit the changes, if false do not commit changes.

    SLS Example:

    .. code-block:: yaml

        panos/address-group/my-group:
            panos.address_group_exists:
              - groupname: my-group
              - vsys: 1
              - members:
                - my-address-object
                - my-other-address-group
              - description: A group that needs to exist
              - commit: False

    s&The group name field must be provided.Rspanos.get_address_groupRR8s<static>{0}</static>s#The group members must be provided.s<description>{0}</description>s<entry name='{0}'>{1}</entry>s9Address group object already exists. No changes required.sq/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys{0}']/address-group/entry[@name='{1}']R)R$Rspanos.commitRs-Address group object successfully configured.(RR6RRR
R5R9R:R;R<R (Rt	groupnameR>R	RBRRtgroupRRDt	new_groupRRR1((s5/usr/lib/python2.7/site-packages/salt/states/panos.pytaddress_group_exists�sN+
				cC@s�t|�}|s|S|s |Sidd6dd6|d6|d6}ttd|��\}}|ji|d6|d	6�|s�|S|tkr�|jitd
�d6td	6�n|S(s�
    Clone a specific XPATH and set it to a new name.

    name: The name of the module function to execute.

    xpath(str): The XPATH of the configuration API tree to clone.

    newname(str): The new name of the XPATH clone.

    commit(bool): If true the firewall will commit the changes, if false do not commit changes.

    SLS Example:

    .. code-block:: yaml

        panos/clonerule:
            panos.clone_config:
              - xpath: /config/devices/entry/vsys/entry[@name='vsys1']/rulebase/security/rules&from=/config/devices/
              entry/vsys/entry[@name='vsys1']/rulebase/security/rules/entry[@name='rule1']
              - value: rule2
              - commit: True

    RRtcloneRRtnewnames
panos.callRRspanos.commitR(RRRR6R5R(RRRLRRRRR((s5/usr/lib/python2.7/site-packages/salt/states/panos.pytclone_configs(

		cC@s2t|�}|jitd�d6td6�|S(s�
    Commits the candidate configuration to the running configuration.

    name: The name of the module function to execute.

    SLS Example:

    .. code-block:: yaml

        panos/commit:
            panos.commit_config

    spanos.commitRR(RR6RR5(RR((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt
commit_configMs
	cC@s�t|�}|s|Sidd6dd6|d6}ttd|��\}}|ji|d6|d6�|sr|S|tkr�|jitd	�d
6td6�n|S(sW
    Deletes a Palo Alto XPATH to a specific value.

    Use the xpath parameter to specify the location of the object to be deleted.

    name: The name of the module function to execute.

    xpath(str): The XPATH of the configuration API tree to control.

    commit(bool): If true the firewall will commit the changes, if false do not commit changes.

    SLS Example:

    .. code-block:: yaml

        panos/deletegroup:
            panos.delete_config:
              - xpath: /config/devices/entry/vsys/entry[@name='vsys1']/address-group/entry[@name='test']
              - commit: True

    RRtdeleteRRs
panos.callRRspanos.commitR(RRRR6R5R(RRRRRRR((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt
delete_configes"

		c
C@s�t|�}|tkr&td�ntd�d}d|ksgd|dksgd|ddkr�|jidd6td6�|SxY|dddD]E}|d	|kr�|d
dkr�|jidd6td6�n|SW|jitd
d	|d|�d6�td�d}d|ksJd|dksJd|ddkrb|jitd6�|SxR|dddD]>}|d	|kr�|d
dkr�|jitd6�n|SW|S(s�
    Ensures that a software version is downloaded.

    name: The name of the module function to execute.

    version(str): The software version to check. If this version is not already downloaded, it will attempt to download
    the file from Palo Alto.

    synch(bool): If true, after downloading the file it will be synched to its peer.

    check(bool): If true, the PANOS device will first attempt to pull the most recent software inventory list from Palo
    Alto.

    SLS Example:

    .. code-block:: yaml

        panos/version8.0.0:
            panos.download_software:
              - version: 8.0.0
              - synch: False
              - check: True

    spanos.check_softwarespanos.get_software_infoRs
sw-updatestversionsR8s9Software version is not found in the local software list.Rtversiont
downloadedtyess'Software version is already downloaded.spanos.download_software_versiontsynchR(RR5RR6R(RRRRUtcheckRRQR8((s5/usr/lib/python2.7/site-packages/salt/states/panos.pytdownload_software�s@	 			 	cC@s�t|�}|jd�}t|�dkr\|d}d|kr\|jd�d}q\ntd|�d}|r�|r�||kr�||}ni}tjtj|�t�}||kr�|j	idd6td6�|St
||�\}	}
|j	i|
d6|	d6�|	s|S|tkra|j	ii|d	6|d
6d6td�d
6td6�n)|j	ii|d	6|d
6d6td6�|S(s'
    Edits a Palo Alto XPATH to a specific value. This will always overwrite the existing value, even if it is not
    changed.

    You can replace an existing object hierarchy at a specified location in the configuration with a new value. Use
    the xpath parameter to specify the location of the object, including the node to be replaced.

    This is the recommended state to enforce configurations on a xpath.

    name: The name of the module function to execute.

    xpath(str): The XPATH of the configuration API tree to control.

    value(str): The XML value to edit. This must be a child to the XPATH.

    commit(bool): If true the firewall will commit the changes, if false do not commit changes.

    SLS Example:

    .. code-block:: yaml

        panos/addressgroup:
            panos.edit_config:
              - xpath: /config/devices/entry/vsys/entry[@name='vsys1']/address-group/entry[@name='test']
              - value: <static><entry name='test'><member>abc</member><member>xyz</member></entry></static>
              - commit: True

    t/ii����t[spanos.get_xpathRs.XPATH is already equal to the specified value.RR)R$Rspanos.commitR(RtsplittlenRR9R:R;R<R5R6R (RRtvalueRRtxpath_splittheadtcurrent_elementtnew_elementRR1((s5/usr/lib/python2.7/site-packages/salt/states/panos.pytedit_config�s>

				cC@st|�}|s|S|s |S|dkrDt||�\}}nf|dkrht||�\}}nB|dkr�t|�\}}n!|dkr�t|�\}}n|ji|d6|d6�|s�|S|tkr|jitd�d6td6�n|S(	s�
    Moves a XPATH value to a new location.

    Use the xpath parameter to specify the location of the object to be moved, the where parameter to
    specify type of move, and dst parameter to specify the destination path.

    name: The name of the module function to execute.

    xpath(str): The XPATH of the configuration API tree to move.

    where(str): The type of move to execute. Valid options are after, before, top, bottom. The after and before
    options will require the dst option to specify the destination of the action. The top action will move the
    XPATH to the top of its structure. The botoom action will move the XPATH to the bottom of its structure.

    dst(str): Optional. Specifies the destination to utilize for a move action. This is ignored for the top
    or bottom action.

    commit(bool): If true the firewall will commit the changes, if false do not commit changes. If the operation is
    not successful, it will not commit.

    SLS Example:

    .. code-block:: yaml

        panos/moveruletop:
            panos.move_config:
              - xpath: /config/devices/entry/vsys/entry[@name='vsys1']/rulebase/security/rules/entry[@name='rule1']
              - where: top
              - commit: True

        panos/moveruleafter:
            panos.move_config:
              - xpath: /config/devices/entry/vsys/entry[@name='vsys1']/rulebase/security/rules/entry[@name='rule1']
              - where: after
              - dst: rule2
              - commit: True

    R$R)R-R+RRspanos.commitR(RR(R*R.R,R6R5R(RRR%R&RRRR1((s5/usr/lib/python2.7/site-packages/salt/states/panos.pytmove_config2s.'		cC@s2t|�}|jitd�d6td6�|S(s�
    Release config lock previously held.

    name: The name of the module function to execute.

    SLS Example:

    .. code-block:: yaml

        panos/takelock:
            panos.remove_config_lock

    spanos.remove_config_lockRR(RR6RR5(RR((s5/usr/lib/python2.7/site-packages/salt/states/panos.pytremove_config_lock{s
	cC@s�t|�}|s|S|s |Sidd6dd6|d6|d6}ttd|��\}}|ji|d6|d	6�|s�|S|tkr�|jitd
�d6td	6�n|S(s�
    Rename a Palo Alto XPATH to a specific value. This will always rename the value even if a change is not needed.

    name: The name of the module function to execute.

    xpath(str): The XPATH of the configuration API tree to control.

    newname(str): The new name of the XPATH value.

    commit(bool): If true the firewall will commit the changes, if false do not commit changes.

    SLS Example:

    .. code-block:: yaml

        panos/renamegroup:
            panos.rename_config:
              - xpath: /config/devices/entry/vsys/entry[@name='vsys1']/address/entry[@name='old_address']
              - value: new_address
              - commit: True

    RRtrenameRRRLs
panos.callRRspanos.commitR(RRRR6R5R(RRRLRRRRR((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt
rename_config�s(

		t1c*C@set|�}|s|Std||�d}|rLd|krL|d}ni}d}|r}|djt|t��7}n|jidd6�|S|r�|djt|t��7}n|jid	d6�|S|r�|d
jt|t��7}n|jidd6�dS|r4|d
jt|t��7}n|jidd6�|S|	rq|djt|	t��7}n|jidd6�|S|
r�|djt|
t��7}n|jidd6�|S|r�|dj|�7}n|jidd6�|S|dk	r&|r|d7}q&|d7}n|rB|dj|�7}n|r^|dj|�7}n|
dk	r�|
r}|d7}q�|d7}n|dk	r�|r�|d7}q�|d7}n|dk	r�|r�|d7}q�|d7}n|dk	r|r|d7}q|d 7}nd}|r,d!j|�}n�d} |rN| d"j|�7} n|rj| d#j|�7} n|r�| d$j|�7} n|r�| d%j|�7} n|r�| d&j|�7} n|r�| d'j|�7} n|r�| d(j|�7} n| dkrd)j| �}n|r0|d*j|�7}nd+j||�}!tjt	j
|!�t�}"t}#||"kr�|jid,d6�ntt}#d-j||�}$t|$|!�\}%}&|%s�|ji|&d6�|S|jii|d.6|"d/6d06d1d6�|rd-j||�}'t}(d})|d.krH|rHt
|'|�\}(})nf|d/krlt|'|�\}(})nB|d2kr�t|'�\}(})n!|d3kr�t|'�\}(})n|#r�|jii|d.6|"d/6|)d46d06�n|jii|)d46d06�|(s|ji|)d6�|Sn|tkrM|jitd5�d66td6�n|jitd6�|S(7s�
    Ensures that a security rule exists on the device. Also, ensure that all configurations are set appropriately.

    This method will create the rule if it does not exist. If the rule does exist, it will ensure that the
    configurations are set appropriately.

    If the rule does not exist and is created, any value that is not provided will be provided as the default.
    The action, to, from, source, destination, application, and service fields are mandatory and must be provided.

    This will enforce the exact match of the rule. For example, if the rule is currently configured with the log-end
    option, but this option is not specified in the state method, it will be removed and reset to the system default.

    It is strongly recommended to specify all options to ensure proper operation.

    When defining the profile group settings, the device can only support either a profile group or individual settings.
    If both are specified, the profile group will be preferred and the individual settings are ignored. If neither are
    specified, the value will be set to system default of none.

    name: The name of the module function to execute.

    rulename(str): The name of the security rule.  The name is case-sensitive and can have up to 31 characters, which
    can be letters, numbers, spaces, hyphens, and underscores. The name must be unique on a firewall and, on Panorama,
    unique within its device group and any ancestor or descendant device groups.

    vsys(str): The string representation of the VSYS ID. Defaults to VSYS 1.

    action(str): The action that the security rule will enforce. Valid options are: allow, deny, drop, reset-client,
    reset-server, reset-both.

    disabled(bool): Controls if the rule is disabled. Set 'True' to disable and 'False' to enable.

    sourcezone(str, list): The source zone(s). The value 'any' will match all zones.

    destinationzone(str, list): The destination zone(s). The value 'any' will match all zones.

    source(str, list): The source address(es). The value 'any' will match all addresses.

    destination(str, list): The destination address(es). The value 'any' will match all addresses.

    application(str, list): The application(s) matched. The value 'any' will match all applications.

    service(str, list): The service(s) matched. The value 'any' will match all services. The value
    'application-default' will match based upon the application defined ports.

    description(str): A description for the policy (up to 255 characters).

    logsetting(str): The name of a valid log forwarding profile.

    logstart(bool): Generates a traffic log entry for the start of a session (disabled by default).

    logend(bool): Generates a traffic log entry for the end of a session (enabled by default).

    negatesource(bool): Match all but the specified source addresses.

    negatedestination(bool): Match all but the specified destination addresses.

    profilegroup(str): A valid profile group name.

    datafilter(str): A valid data filter profile name. Ignored with the profilegroup option set.

    fileblock(str): A valid file blocking profile name. Ignored with the profilegroup option set.

    spyware(str): A valid spyware profile name. Ignored with the profilegroup option set.

    urlfilter(str): A valid URL filtering profile name. Ignored with the profilegroup option set.

    virus(str): A valid virus profile name. Ignored with the profilegroup option set.

    vulnerability(str): A valid vulnerability profile name. Ignored with the profilegroup option set.

    wildfire(str): A valid vulnerability profile name. Ignored with the profilegroup option set.

    move(str): An optional argument that ensure the rule is moved to a specific location. Valid options are 'top',
    'bottom', 'before', or 'after'. The 'before' and 'after' options require the use of the 'movetarget' argument
    to define the location of the move request.

    movetarget(str): An optional argument that defines the target of the move operation if the move argument is
    set to 'before' or 'after'.

    commit(bool): If true the firewall will commit the changes, if false do not commit changes.

    SLS Example:

    .. code-block:: yaml

        panos/rulebase/security/rule01:
            panos.security_rule_exists:
              - rulename: rule01
              - vsys: 1
              - action: allow
              - disabled: False
              - sourcezone: untrust
              - destinationzone: trust
              - source:
                - 10.10.10.0/24
                - 1.1.1.1
              - destination:
                - 2.2.2.2-2.2.2.4
              - application:
                - any
              - service:
                - tcp-25
              - description: My test security rule
              - logsetting: logprofile
              - logstart: False
              - logend: True
              - negatesource: False
              - negatedestination: False
              - profilegroup: myprofilegroup
              - move: top
              - commit: False

        panos/rulebase/security/rule01:
            panos.security_rule_exists:
              - rulename: rule01
              - vsys: 1
              - action: allow
              - disabled: False
              - sourcezone: untrust
              - destinationzone: trust
              - source:
                - 10.10.10.0/24
                - 1.1.1.1
              - destination:
                - 2.2.2.2-2.2.2.4
              - application:
                - any
              - service:
                - tcp-25
              - description: My test security rule
              - logsetting: logprofile
              - logstart: False
              - logend: False
              - datafilter: foobar
              - fileblock: foobar
              - spyware: foobar
              - urlfilter: foobar
              - virus: foobar
              - vulnerability: foobar
              - wildfire: foobar
              - move: after
              - movetarget: rule02
              - commit: False
    spanos.get_security_ruleRR8Rs<from>{0}</from>s&The sourcezone field must be provided.Rs<to>{0}</to>s+The destinationzone field must be provided.s<source>{0}</source>s"The source field must be provided.Ns<destination>{0}</destination>s'The destination field must be provided.s<application>{0}</application>s'The application field must be provided.s<service>{0}</service>s#The service field must be provided.s<action>{0}</action>s"The action field must be provided.s<disabled>yes</disabled>s<disabled>no</disabled>s<description>{0}</description>s<log-setting>{0}</log-setting>s<log-start>yes</log-start>s<log-start>no</log-start>s<log-end>yes</log-end>s<log-end>no</log-end>s"<negate-source>yes</negate-source>s!<negate-source>no</negate-source>s,<negate-destination>yes</negate-destination>s+<negate-destination>no</negate-destination>s#<group><member>{0}</member></group>s5<data-filtering><member>{0}</member></data-filtering>s3<file-blocking><member>{0}</member></file-blocking>s'<spyware><member>{0}</member></spyware>s3<url-filtering><member>{0}</member></url-filtering>s#<virus><member>{0}</member></virus>s3<vulnerability><member>{0}</member></vulnerability>s;<wildfire-analysis><member>{0}</member></wildfire-analysis>s<profiles>{0}</profiles>s&<profile-setting>{0}</profile-setting>s<entry name='{0}'>{1}</entry>s2Security rule already exists. No changes required.s{/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys{0}']/rulebase/security/rules/entry[@name='{1}']R)R$Rs$Security rule verified successfully.R-R+R#spanos.commitR(RRRR
R5R6RR9R:R;R<RR R*R(R.R,(*RtrulenameR>Rtdisabledt
sourcezonetdestinationzonetsourcetdestinationtapplicationtserviceRBt
logsettingtlogstarttlogendtnegatesourcetnegatedestinationtprofilegroupt
datafiltert	fileblocktspywaret	urlfiltertvirust
vulnerabilitytwildfireR#t
movetargetRRtruleRtprofile_stringt
member_stringRDtnew_rulet
config_changeRRR1tmovepathtmove_resulttmove_msg((s5/usr/lib/python2.7/site-packages/salt/states/panos.pytsecurity_rule_exists�s�










				#				cC@s�t|�}|s*|jidd6�|Std||�d}|r`d|kr`|d}ni}|r�|dkr�|jidd6�|S|s�|jid	d6�|Sd
j||�}	|r�|	dj|�7}	ndj||	�}
tjtj|
�t�}||kr5|jid
d6td6�|Sdj||�}t	||
�\}
}|
sz|ji|d6�|S|tkr�|jii|d6|d6d6td�d6dd6td6�n0|jii|d6|d6d6dd6td6�|S(sO
    Ensures that a service object exists in the configured state. If it does not exist or is not configured with the
    specified attributes, it will be adjusted to match the specified values.

    name: The name of the module function to execute.

    servicename(str): The name of the security object.  The name is case-sensitive and can have up to 31 characters,
    which an be letters, numbers, spaces, hyphens, and underscores. The name must be unique on a firewall and, on
    Panorama, unique within its device group and any ancestor or descendant device groups.

    vsys(str): The string representation of the VSYS ID. Defaults to VSYS 1.

    protocol(str): The protocol that is used by the service object. The only valid options are tcp and udp.

    port(str): The port number that is used by the service object. This can be specified as a single integer or a
    valid range of ports.

    description(str): A description for the policy (up to 255 characters).

    commit(bool): If true the firewall will commit the changes, if false do not commit changes.

    SLS Example:

    .. code-block:: yaml

        panos/service/tcp-80:
            panos.service_exists:
              - servicename: tcp-80
              - vsys: 1
              - protocol: tcp
              - port: 80
              - description: Hypertext Transfer Protocol
              - commit: False

        panos/service/udp-500-550:
            panos.service_exists:
              - servicename: udp-500-550
              - vsys: 3
              - protocol: udp
              - port: 500-550
              - commit: False

    s(The service name field must be provided.Rspanos.get_serviceRR8ttcptudps5The protocol must be provided and must be tcp or udp.s The port field must be provided.s0<protocol><{0}><port>{1}</port></{0}></protocol>s<description>{0}</description>s<entry name='{0}'>{1}</entry>s3Service object already exists. No changes required.sk/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys{0}']/service/entry[@name='{1}']R)R$Rspanos.commitRs'Service object successfully configured.(R�R�(
RR6RRR9R:R;R<R5R (RtservicenameR>tprotocoltportRBRRRnRRDtnew_serviceRRR1((s5/usr/lib/python2.7/site-packages/salt/states/panos.pytservice_exists3sT,
				cC@s�t|�}|s*|jidd6�|Std||�d}|r`d|kr`|d}ni}|r�djt|t��}n|jidd6�|S|r�|dj|�7}nd	j||�}	tjtj	|	�t�}
||
kr|jid
d6td6�|Sdj||�}t
||	�\}}
|sX|ji|
d6�|S|tkr�|jii|d6|
d
6d6td�d6dd6td6�n0|jii|d6|
d
6d6dd6td6�|S(s2
    Ensures that a service group object exists in the configured state. If it does not exist or is not configured with
    the specified attributes, it will be adjusted to match the specified values.

    This module will enforce group membership. If a group exists and contains members this state does not include,
    those members will be removed and replaced with the specified members in the state.

    name: The name of the module function to execute.

    groupname(str): The name of the service group object.  The name is case-sensitive and can have up to 31 characters,
    which an be letters, numbers, spaces, hyphens, and underscores. The name must be unique on a firewall and, on
    Panorama, unique within its device group and any ancestor or descendant device groups.

    vsys(str): The string representation of the VSYS ID. Defaults to VSYS 1.

    members(str, list): The members of the service group. These must be valid service objects or service groups on the
    system that already exist prior to the execution of this state.

    description(str): A description for the policy (up to 255 characters).

    commit(bool): If true the firewall will commit the changes, if false do not commit changes.

    SLS Example:

    .. code-block:: yaml

        panos/service-group/my-group:
            panos.service_group_exists:
              - groupname: my-group
              - vsys: 1
              - members:
                - tcp-80
                - custom-port-group
              - description: A group that needs to exist
              - commit: False

    s&The group name field must be provided.Rspanos.get_service_groupRR8s<members>{0}</members>s#The group members must be provided.s<description>{0}</description>s<entry name='{0}'>{1}</entry>s9Service group object already exists. No changes required.sq/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys{0}']/service-group/entry[@name='{1}']R)R$Rspanos.commitRs-Service group object successfully configured.(RR6RRR
R5R9R:R;R<R (RRGR>R	RBRRRHRRDRIRRR1((s5/usr/lib/python2.7/site-packages/salt/states/panos.pytservice_group_exists�sN+
				cC@s{t|�}t||�\}}|ji|d6|d6�|sF|S|tkrw|jitd�d6td6�n|S(su
    Sets a Palo Alto XPATH to a specific value. This will always overwrite the existing value, even if it is not
    changed.

    You can add or create a new object at a specified location in the configuration hierarchy. Use the xpath parameter
    to specify the location of the object in the configuration

    name: The name of the module function to execute.

    xpath(str): The XPATH of the configuration API tree to control.

    value(str): The XML value to set. This must be a child to the XPATH.

    commit(bool): If true the firewall will commit the changes, if false do not commit changes.

    SLS Example:

    .. code-block:: yaml

        panos/hostname:
            panos.set_config:
              - xpath: /config/devices/entry[@name='localhost.localdomain']/deviceconfig/system
              - value: <hostname>foobar</hostname>
              - commit: True

    RRspanos.commitR(RR0R6R5R(RRR\RRRR1((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt
set_configs		(*t__doc__t
__future__Rtloggingtsalt.utils.xmlutiltutilstxmlutilR9tsalt._compatRR;t	getLoggert__name__tlogRRR
RR R"R(R*R,R.R0RR7RRFRJRMRNRPRWRaRbRcReR�R�R�R�(((s5/usr/lib/python2.7/site-packages/salt/states/panos.pyt<module>Ts�											�e8	2IRI	8�Ooe

Zerion Mini Shell 1.0