Skip to content

Add a way to list available tags from .panrc #57

Description

@alevieux

Hi,

I use a .panrc file containing credentials for several PAN-OS firewalls:

hostname%firewall-a=192.0.2.10
api_key%firewall-a=...

hostname%firewall-b=192.0.2.11
api_key%firewall-b=...

I’m writing a monitoring script that needs to run the same operational command on each configured firewall.

At the moment, PanXapi(tag="firewall-a") works well when the tag is already known, but I couldn’t find a public method to list the tags available in .panrc. The script therefore has to parse the file itself.

Would it make sense to add something like this to PanRc?

from pan.rc import PanRc

tags = PanRc.list_tags()

For example:

from pan.rc import PanRc
from pan.xapi import PanXapi

for tag in PanRc.list_tags():
    xapi = PanXapi(tag=tag)
    xapi.op(cmd="show system info", cmd_xml=True)

The method could return unique tag names in a stable order, without exposing hostnames, API keys or other values.

A matching read-only CLI option could also be useful:

panxapi.py --list-tags

What do you think? If this would be useful and fits the project, I can put together an implementation and submit a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions