PaloAltoNetworks / PaloAltoNetworks/pan-os-python

Modifier calls fail on DeviceGroup when FW is a child

Open
#501 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
400
Forks
199
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

When trying to do a call for a devicegroup that modifies the live device and a Firewall object is attached it errors out
TypeError: Firewall.element() got an unexpected keyword argument 'comparable'

Expected behavior

update the device

Current behavior

Even a simple refresh and apply fails

Possible solution

Steps to reproduce

devicegroup= DeviceGroup('dg-name')
panorama.add(devicegroup)
devicegroup.refresh()
devicegroup.apply()

Screenshots

Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2022.2\plugins\python\helpers\pydev_pydevd_bundle\pydevd_exec2.py", line 3, in Exec
exec(exp, global_vars, local_vars)
File "", line 1, in
File "%localpath%\Anaconda3\envs\KNIME\Lib\site-packages\panos\base.py", line 625, in apply
self.xpath(), self.element_str(), retry_on_peer=self.HA_SYNC
^^^^^^^^^^^^^^^^^^
File "%localpath%\Anaconda3\envs\KNIME\Lib\site-packages\panos\base.py", line 535, in element_str
return ET.tostring(self.element(), encoding="utf-8")
^^^^^^^^^^^^^^
File "%localpath%\Anaconda3\envs\KNIME\Lib\site-packages\panos\base.py", line 2606, in element
self.xml_merge(ans, itertools.chain(*iterchain))
File "%localpath%\Anaconda3\envs\KNIME\Lib\site-packages\panos\base.py", line 1694, in xml_merge
for e in elements:
File "%localpath%\Anaconda3\envs\KNIME\Lib\site-packages\panos\base.py", line 574, in _subelements
e.append(child.element(comparable=comparable))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Firewall.element() got an unexpected keyword argument 'comparable'

Your Environment

Using Anaconda3

  • Version used: 1.7.3
  • Environment name and version: python 3.11.2
  • Operating System and version (desktop or mobile): Windows10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in panos/base.py around element(), _subelements(), and xml_merge(), then reproduce the DeviceGroup refresh/apply example with a Firewall child. Trace how the comparable argument is passed and confirm that the operation completes without the TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.