-
Notifications
You must be signed in to change notification settings - Fork 103
Loading Elements with Pan~Python
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:
Training for pan-python including the initial install and getting the device api-key are found here:
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.
{{ 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.