Palo Alto NGFW lab 22 of 30

Automating PAN-OS with the XML and REST APIs

Manage the firewall from code: get an API key, run operational commands, read and write configuration by XPath, commit and poll the job, use the REST API with JSON, and bulk-load depot devices from a CSV file with a Python script, learning the XML of any CLI command with debug cli on.

Run this lab

It needs Lite: its 2 nodes are set to 3 vCPU and 6,656 MB in total. That fits the free demo too.

In your workspace: Shared, then Palo Alto NGFW PAN-OS 11 guided labs, then 22 - Automating PAN-OS with the XML and REST APIs

Try it free for 30 minutesRun it on Lite from £3 a day

The free demo needs no card and no email. Every lab plan includes every guided lab.

Level
Advanced
Time
About 50 minutes
Nodes need
3 vCPU, 6,656 MB
Smallest plan
Lite

The scenario

Calder is rolling out new handheld scanners to every depot, and each one needs an address object. Doing that by hand on dozens of firewalls is slow and error-prone. You'll learn the firewall's two APIs from Client-PC (which has curl and Python 3), then load the handhelds from a CSV file.

Before you start. Start all the nodes. The firewall takes 6-8 minutes to boot and comes up with this lab's starting configuration already loaded. Wait until the FW1 console shows FW1 login:, then log in as admin / Lab-Access-1. Until the management plane is ready it answers Login incorrect, even with the right password. The Linux hosts are ready within seconds.

What you’ll practise

  • Generate an API key and pass it safely in a header
  • Run operational commands and learn their XML with debug cli on
  • Read and write configuration with XPath through the XML API
  • Commit through the API and poll the job to completion
  • Use the REST API with JSON and automate a bulk change with Python

The tasks

  1. Get an API key
  2. Operational commands, and how to find their XML
  3. Read configuration by XPath
  4. Write configuration and commit through the API
  5. The REST API
  6. Bulk load from a CSV with Python
  7. Export the configuration

The Lab Tasks pane has the scenario, these tasks, the checks to run, hints and the full solution.

Topology and devices

The network as it opens in EVE-NG, drawn from the lab’s own canvas, and the image each node runs.

Topology of Automating PAN-OS with the XML and REST APIs2 nodes and 1 network, 3 links. Every link is listed as text below the diagram.FW1Client-PCInsidemgmtethernet1/2eth0
2 nodes and 1 network, with the interface names each link uses.
Nodes in Automating PAN-OS with the XML and REST APIs, with the image each runs and the vCPU and RAM it’s set to
NodeDeviceImage in Add NodeSet to
FW1Palo Alto Networks VM-Series (PAN-OS)paloalto-11.2.52 vCPU, 5,632 MB
Client-PCEVE-NG GUI server (Docker)eve-gui-server:latest1 vCPU, 1,024 MB

How to open this lab

  1. Sign in to your workspace at lab.cloudlabbox.com.

  2. In File Manager, open Shared, then the folder Palo Alto NGFW PAN-OS 11 guided labs.

  3. Open 22 - Automating PAN-OS with the XML and REST APIs and start its nodes, then open Lab Tasks for the scenario and the steps.

The lab is read-only. You can start the nodes and configure the devices, but changes to the topology can’t be saved. To change it, rebuild it in your own folder.

More Palo Alto NGFW labs

All Palo Alto NGFW labs

Related labs in other courses

CloudLabBox is independent of Palo Alto Networks and Cisco. The lab follows exam topics and isn’t vendor training material; vendor names identify the exams and the images in the workspace.