The PAN-OS SDK for Python is a package to help interact with Palo Alto Networks devices (including physical and virtualized Next-generation Firewalls and Panorama). The pan-os-python SDK is object oriented and mimics the traditional interaction with the device via the GUI or CLI/API.
I attempt Template.refreshall(pano) which fails because a Template is making use of a 'Group ID' template value of '$groupID'. pan-os-python attempts to convert the value to int() during parse_xml.
Expected behavior
I would expect a condition of str(elm.text) if elm.text.startswith('$') else int(elm.text)
Current behavior
Traceback (most recent call last):
File "<pyshell#157>", line 1, in <module>
Template.refreshall(pano)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/panos/base.py", line 1338, in refreshall
instances = class_instance.refreshall_from_xml(obj)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/panos/base.py", line 1404, in refreshall_from_xml
instance._refresh_children(xml=obj)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/panos/base.py", line 1038, in _refresh_children
l = child.refreshall_from_xml(childroot)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/panos/base.py", line 1389, in refreshall_from_xml
instance.parse_xml(obj)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/panos/base.py", line 2789, in parse_xml
var_path.parse_xml(xml, settings, possibilities)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/panos/base.py", line 3223, in parse_xml
self.parse_value_from_xml_last_tag(e, settings, attr)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/panos/base.py", line 3306, in parse_value_from_xml_last_tag
settings[self.param] = int(elm.text)
ValueError: invalid literal for int() with base 10: '$groupID'
Possible solution
Use of a conditional statement such as settings[self.param] = str(elm.text) if elm.text.startswith('$') else int(elm.text)
Steps to reproduce
Define a template variable for $groupID
Assign the $groupID to Template>Device>High Availability>Setup>Group ID
Template.refreshall(pano) from a pan-os-python script
Describe the bug
I attempt
Template.refreshall(pano)
which fails because a Template is making use of a 'Group ID' template value of '$groupID'. pan-os-python attempts to convert the value to int() during parse_xml.Expected behavior
I would expect a condition of str(elm.text) if elm.text.startswith('$') else int(elm.text)
Current behavior
Possible solution
Use of a conditional statement such as settings[self.param] = str(elm.text) if elm.text.startswith('$') else int(elm.text)
Steps to reproduce
Template.refreshall(pano)
from a pan-os-python scriptScreenshots
Context
Your Environment