PaloAltoNetworks / PaloAltoNetworks/pan-os-python

Upgrade from standard to hotfix release fails on 1.12.0

Open
#565 0 comments 0 reactions 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

Upgrade from non-hotifx to a hotfix release fails when pan-os-python==1.12.0

Reverting to pan-os-python 1.11.0 works just fine.

Expected behavior

Device is upgraded

Current behavior

Traceback (most recent call last):
  File ".../venv/lib/python3.11/site-packages/nornir/core/task.py", line 99, in start
    r = self.task(self, **self.params)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../panos_upgrade/run.py", line 197, in upgrade_device
    upgrade_successful = fw.software.upgrade_to_version(target_version)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.11/site-packages/panos/updater.py", line 337, in upgrade_to_version
    elif not self._direct_upgrade_possible(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.11/site-packages/panos/updater.py", line 519, in _direct_upgrade_possible
    and current_version.subrelease_num < target_version.subrelease_num
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'NoneType' and 'int'

Possible solution

Seems the issue is that there is no value for subrelease_num if not coming from a hotfix release. Either populate that with 0, or account for it in the conditional.

Some quick and dirty testing:

>>> from panos import PanOSVersion
>>> t = PanOSVersion("10.1.13-h1")
>>> c = PanOSVersion('10.1.13')
>>> t
PanOSVersion ('10.1.13-h1')
>>> c
PanOSVersion ('10.1.13')
>>> c.subrelease_num
>>> t.subrelease_num
1
>>>

Steps to reproduce

Try to upgrade a firewall from 10.1.13 to 10.1.13-h1 using upgrade_to_version()

Screenshots

n/a

Context

Cannot use this to apply hotfix releases if coming from a normal release.

Your Environment

  • Version used: 1.12.0
  • Environment name and version (e.g. Chrome 59, node.js 5.4, python 3.7.3): python 3.11.9
  • Operating System and version (desktop or mobile): MacOS

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/updater.py at upgrade_to_version() and _direct_upgrade_possible(), then inspect how PanOSVersion parses normal and hotfix versions. Reproduce the 10.1.13 to 10.1.13-h1 upgrade using upgrade_to_version(); done means the comparison no longer raises TypeError and the device upgrade proceeds as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.