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

Use of TemplateVariable for 'Group ID' causes an error due to it being converted to an int() during parse_xml #523

Open
rebelfish opened this issue Aug 31, 2023 · 0 comments
Labels

Comments

@rebelfish
Copy link

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

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

  1. Define a template variable for $groupID
  2. Assign the $groupID to Template>Device>High Availability>Setup>Group ID
  3. Template.refreshall(pano) from a pan-os-python script

Screenshots

Context

Your Environment

  • Version used:
  • pan-os-python 1.11.0
@rebelfish rebelfish added the bug label Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant