Skip to content

Commit

Permalink
feat: Add per-admin push for Panorama (#485)
Browse files Browse the repository at this point in the history
Add admins parameter to Panorama push, which supports pushing only changes from specific PAN-OS administrators
  • Loading branch information
jamesholland-uk committed Jan 9, 2023
1 parent 3e2e926 commit bf26305
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions panos/panorama.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,7 @@ class PanoramaCommitAll(object):
name (str): The name of the location to push the config to (e.g. - name
of the device group, name of the template, etc).
description (str): The commit message.
admins (list): (PAN-OS 10.2+) List of admins whose changes are to be pushed.
include_template (bool): (For `device group` style commits) Set to True to include
template changes.
force_template_values (bool): (For `device group`, `template`, or `template stack`
Expand All @@ -1077,6 +1078,7 @@ def __init__(
style,
name,
description=None,
admins=None,
include_template=None,
force_template_values=None,
devices=None,
Expand All @@ -1092,10 +1094,13 @@ def __init__(
raise ValueError("Invalid style {0}".format(style))
if devices and not isinstance(devices, list):
raise ValueError("devices must be a list")
if admins and not isinstance(admins, list):
raise ValueError("admins must be a list")

self.style = style
self.name = name
self.description = description
self.admins = admins
self.include_template = include_template
self.force_template_values = force_template_values
self.devices = devices
Expand Down Expand Up @@ -1126,6 +1131,10 @@ def element(self):
ET.SubElement(de, "entry", {"name": x})
if self.description:
ET.SubElement(body, "description").text = self.description
if self.admins:
adms = ET.SubElement(body, "admin")
for user in self.admins:
ET.SubElement(adms, "member").text = user
if self.include_template:
ET.SubElement(body, "include-template").text = "yes"
elif self.include_template is False:
Expand All @@ -1139,6 +1148,10 @@ def element(self):
ET.SubElement(body, "name").text = self.name
if self.description:
ET.SubElement(body, "description").text = self.description
if self.admins:
adms = ET.SubElement(body, "admin")
for user in self.admins:
ET.SubElement(adms, "member").text = user
if self.force_template_values:
ET.SubElement(body, "force-template-values").text = "yes"
elif self.force_template_values is False:
Expand All @@ -1152,6 +1165,10 @@ def element(self):
ET.SubElement(body, "name").text = self.name
if self.description:
ET.SubElement(body, "description").text = self.description
if self.admins:
adms = ET.SubElement(body, "admin")
for user in self.admins:
ET.SubElement(adms, "member").text = user
if self.force_template_values:
ET.SubElement(body, "force-template-values").text = "yes"
elif self.force_template_values is False:
Expand Down

0 comments on commit bf26305

Please sign in to comment.