Skip to content

Loading Elements with Pan~Python

scotchoaf edited this page May 8, 2018 · 6 revisions

pan-python overview

Pan-python provides a simple command-line model to use the Panorama/PAN-OS API. It leverages the standard xml xpath+element model to push configuration changes to the device. The GitHub repo is found here:

pan-python repo

Training for pan-python including the initial install and getting the device api-key are found here:

pan-python api lab

Before using pan-python, it helps to be familiar with the xpaths used in the template along with the configuration load order. These provide the foundation for the xpath and element references in the examples below.

xpath and snippet load order

pan-python full syntax for loading a config element

{{ ip address }} is the device ip address

{{ api-key }} is the user/device specific api-key

{{ filename }} is the xml snippet to be loaded

{{ xpath }} is the xpath specific to the config element

panxapi.py -h {{ ip address }} -K {{ api-key }} -S {{ filename.xml }} "{{ xpath }}"

For example, to load the tag.xml file to ip address 192.168.55.10 and api-key: 12345 would be:

panxapi.py -h 192.168.55.10 -K 12345 -S tag.xml "/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/tag"

or an external list object (aka EDL):

panxapi.py -h 192.168.55.10 -K 12345 -S external_list.xml "/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/external-list"

NOTE: Based on the local pan-python install and use of .panrc you may not require the -h and -K elements and only have to reference the xpath and filename.

Clone this wiki locally