Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PanoramaCommitAll - include_template=False includes templates anyway #332

Closed
mrichardson03 opened this issue Apr 26, 2021 · 1 comment · Fixed by #338
Closed

PanoramaCommitAll - include_template=False includes templates anyway #332

mrichardson03 opened this issue Apr 26, 2021 · 1 comment · Fixed by #338
Assignees

Comments

@mrichardson03
Copy link

mrichardson03 commented Apr 26, 2021

Describe the bug

PanoramaCommitAll with include_templates set to False includes the templates in the push anyway.

Sample Code:

#!/usr/bin/env python3

from panos.base import PanDevice
from panos.panorama import PanoramaCommitAll

if __name__ == "__main__":
    pano = PanDevice.create_from_device("panorama.rblabs.org", "admin", "P4loalto!")

    cmd = PanoramaCommitAll("device group", "Lab Firewalls", include_template=False)
    print(cmd.element_str())

    pano.commit(cmd=cmd, sync=True, sync_all=True)

Expected behavior

Commit XML from debug mode:

    <commit-all>
      <shared-policy>
        <device-group>
          <entry name="Lab Firewalls">
            <devices>
              <entry name="007255000166572"/>
            </devices>
          </entry>
        </device-group>
        <include-template>no</include-template>
        <merge-with-candidate-cfg>yes</merge-with-candidate-cfg>
        <force-template-values>no</force-template-values>
        <validate-only>no</validate-only>
      </shared-policy>
    </commit-all>

Firewall reports Panorama push device-group Lab Firewalls with merge-with-candidate-cfg flags set in system log.

Current behavior

Running above sample code gives the following output:

<commit-all><shared-policy><device-group><entry name="Lab Firewalls" /></device-group></shared-policy></commit-all>

Firewall reports Panorama push device-group Lab Firewalls template Lab-Firewalls with merge-with-candidate-cfg include-template flags set in system log.

Possible solution

Always set the include_template element to either "yes" or "no", not just when specified.

if self.include_template:
ET.SubElement(body, "include-template").text = "yes"

Steps to reproduce

  1. Make any change to a Panorama device group and template.
  2. Run sample code.

Context

Reported in PaloAltoNetworks/pan-os-ansible#204.

Your Environment

Version used: pan-os-python 1.0.2, PAN-OS 10.0.4
Environment name and version (e.g. Chrome 59, node.js 5.4, python 3.7.3): Python 3.9.4

@github-actions
Copy link

🎉 This issue has been resolved in version 1.1.1 🎉

The release is available on PyPI and GitHub release

Posted by semantic-release bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants