PaloAltoNetworks / PaloAltoNetworks/pan-os-python
Crash when calling refresh_devices(expand_vsys=False)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 400
- Forks
- 199
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
After establishing an initial connection to Panorama, calling the refresh_devices() function with expand_vsys set to False throws an AttributeError exception.
Expected behavior
The devices should be returned from Panorama.
Current behavior
An Exception is thrown.
Possible solution
Unsure at this point. Will update later if I'm able to find one.
Current workaround is to leave it as its default value of True: expand_vsys=True
Steps to reproduce
- Run this code snippet, substituting in the correct hostname, username, and password:
from panos.panorama import Panorama
pano = Panorama(hostname="foo", api_username="admin", api_password="admin")
pano.refresh_devices(expand_vsys=False)
Screenshots
Hostname, credentials, and device group names changed to example values.
>>> from panos.panorama import Panorama
>>> pano = Panorama(hostname="foo", api_username="admin", api_password="admin")
>>> pano.refresh_devices(expand_vsys=False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/matt/Library/Caches/pypoetry/virtualenvs/nautobot-plugin-chatops-panorama-B7XIf4lc-py3.9/lib/python3.9/site-packages/panos/panorama.py", line 640, in refresh_devices
firewall_instances = tmp_fw.refreshall_from_xml(
File "/Users/matt/Library/Caches/pypoetry/virtualenvs/nautobot-plugin-chatops-panorama-B7XIf4lc-py3.9/lib/python3.9/site-packages/panos/firewall.py", line 378, in refreshall_from_xml
fw._set_version_and_version_info(entry.findtext("sw-version"))
File "/Users/matt/Library/Caches/pypoetry/virtualenvs/nautobot-plugin-chatops-panorama-B7XIf4lc-py3.9/lib/python3.9/site-packages/panos/base.py", line 4027, in _set_version_and_version_info
tokens = self.version.split(".")[:3]
AttributeError: 'NoneType' object has no attribute 'split'
>>> pano.refresh_devices()
[<DeviceGroup Foobar1 0x105cab230>, <DeviceGroup Foobar2 0x105cabee3>]
>>>
Context
I am trying to pull a list of Palo Alto firewall devices, but am unable to use this optional argument.
Your Environment
- Version used: 1.4.0
- Environment name and version (e.g. Chrome 59, node.js 5.4, python 3.7.3): Python 3.9.6, Panorama 10.1.0
- Operating System and version (desktop or mobile): OSX 11.4
- Link to your project: n/a (internal project)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in panos/panorama.py at refresh_devices(), then follow the traceback through panos/firewall.py refreshall_from_xml() and panos/base.py _set_version_and_version_info(). Reproduce against the stated Panorama and expand_vsys=False path; done means the call returns the devices without the AttributeError while the default behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100