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

Erroring out when trying to the upgrade of the firewalls #136

Open
d945028 opened this issue Apr 10, 2024 · 3 comments
Open

Erroring out when trying to the upgrade of the firewalls #136

d945028 opened this issue Apr 10, 2024 · 3 comments

Comments

@d945028
Copy link

d945028 commented Apr 10, 2024

Describe the bug
A clear and concise description of what the bug is.
The Error message is a 'TypeError: 'NoneType' object does not support the context manager protocol'.

To Reproduce
Steps to reproduce the behavior:

  1. Go to folder for the repo pan-os-upgrade
  2. Run the command ' pan-os-upgrade firewall'
  3. Enter the firewall details
  4. See error: TypeError: 'NoneType' object does not support the context manager protocol

Expected behavior
The script should successfully upgrade the firewall to the target OS version

**Screenshots and text from the script: **
[admin@spopvcladcaph01 pan-os-upgrade]$ pan-os-upgrade firewall
Firewall hostname or IP: 10.52.184.49
Firewall username: axxxx
Firewall password:
Target version: 10.2.6-h1
Dry Run? [Y/n]: Y

Welcome to the PAN-OS upgrade tool

This script software is provided on an 'as-is' basis with no warranties, and no support provided.

The selected firewall subcommand will upgrade a single Firewall appliance.

Settings: No settings.yaml file was found, default values will be used.
You can create a settings.yaml file with 'pan-os-upgrade settings' command.

🚀 10.52.184.49: Connection to the appliance successful.
📝 N1122322R-exh-pan-b: 015354000084294 10.52.184.49
📝 N1122322R-exh-pan-b: HA mode: passive
📝 N1122322R-exh-pan-b: Local state: passive, Local version: 10.1.10, Peer version: 10.1.10
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/admin/.local/lib/python3.11/site-packages/pan_os_upgrade/main.py:245 in firewall │
│ │
│ 242 │ ) │
│ 243 │ │
│ 244 │ # Perform upgrade │
│ ❱ 245 │ upgrade_firewall( │
│ 246 │ │ dry_run=dry_run, │
│ 247 │ │ firewall=device, │
│ 248 │ │ settings_file=SETTINGS_FILE, │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ banner = '\x1b[1;33m===============================================================… │ │
│ │ device = <Firewall '015354000084294' None at 0x7f3ea7894a10> │ │
│ │ dry_run = True │ │
│ │ hostname = '10.52.184.49' │ │
│ │ password = 'IPvas2.0' │ │
│ │ target_version = '10.2.6-h1' │ │
│ │ username = 'admin' │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/admin/.local/lib/python3.11/site-packages/pan_os_upgrade/components/upgrade.py:669 in │
│ upgrade_firewall │
│ │
│ 666 │ │
│ 667 │ # If firewall is part of HA pair, determine if it's active or passive │
│ 668 │ if ha_details: │
│ ❱ 669 │ │ proceed_with_upgrade, peer_firewall = handle_firewall_ha( │
│ 670 │ │ │ dry_run=dry_run, │
│ 671 │ │ │ hostname=hostname, │
│ 672 │ │ │ settings_file=settings_file, │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ deploy_info = 'passive' │ │
│ │ dry_run = True │ │
│ │ firewall = <Firewall '015354000084294' None at 0x7f3ea7894a10> │ │
│ │ firewall_details = <SystemSettings 0x7f3ea78a2d50> │ │
│ │ ha_details = { │ │
│ │ │ 'result': { │ │
│ │ │ │ 'enabled': 'yes', │ │
│ │ │ │ 'group': { │ │
│ │ │ │ │ 'mode': 'Active-Passive', │ │
│ │ │ │ │ 'local-info': { │ │
│ │ │ │ │ │ 'url-compat': 'Match', │ │
│ │ │ │ │ │ 'app-version': '8811-8573', │ │
│ │ │ │ │ │ 'gpclient-version': 'Not Installed', │ │
│ │ │ │ │ │ 'build-rel': '10.1.10', │ │
│ │ │ │ │ │ 'ha2-port': 'ethernet1/5', │ │
│ │ │ │ │ │ 'av-version': '0', │ │
│ │ │ │ │ │ 'url-version': '0000.00.00.000', │ │
│ │ │ │ │ │ 'ha1-backup-ipaddr': '192.168.10.12/29', │ │
│ │ │ │ │ │ 'active-passive': { │ │
│ │ │ │ │ │ │ 'passive-link-state': 'auto', │ │
│ │ │ │ │ │ │ 'monitor-fail-holddown': '1' │ │
│ │ │ │ │ │ }, │ │
│ │ │ │ │ │ 'platform-model': 'PA-VM', │ │
│ │ │ │ │ │ ... +49 │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ 'peer-info': { │ │
│ │ │ │ │ │ 'app-version': '8811-8573', │ │
│ │ │ │ │ │ 'gpclient-version': 'Not Installed', │ │
│ │ │ │ │ │ 'VMS': '2.1.10', │ │
│ │ │ │ │ │ 'url-version': '0000.00.00.000', │ │
│ │ │ │ │ │ 'ha1-backup-ipaddr': '192.168.10.11', │ │
│ │ │ │ │ │ 'av-version': '0', │ │
│ │ │ │ │ │ 'platform-model': 'PA-VM', │ │
│ │ │ │ │ │ 'ha2-ipaddr': '192.168.11.3', │ │
│ │ │ │ │ │ 'ha1-ipaddr': '192.168.10.3', │ │
│ │ │ │ │ │ 'ha2-backup-ipaddr': '192.168.11.11', │ │
│ │ │ │ │ │ ... +26 │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ 'link-monitoring': { │ │
│ │ │ │ │ │ 'failure-condition': 'any', │ │
│ │ │ │ │ │ 'enabled': 'yes', │ │
│ │ │ │ │ │ 'groups': {} │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ 'path-monitoring': { │ │
│ │ │ │ │ │ 'virtual-wire': {}, │ │
│ │ │ │ │ │ 'failure-condition': 'any', │ │
│ │ │ │ │ │ 'enabled': 'yes', │ │
│ │ │ │ │ │ 'vlan': {}, │ │
│ │ │ │ │ │ 'virtual-router': { │ │
│ │ │ │ │ │ │ 'entry': [ │ │
│ │ │ │ │ │ │ │ { │ │
│ │ │ │ │ │ │ │ │ 'failure-condition': 'any', │ │
│ │ │ │ │ │ │ │ │ 'name': 'trust-vr', │ │
│ │ │ │ │ │ │ │ │ 'enabled': 'yes', │ │
│ │ │ │ │ │ │ │ │ 'ping-interval': '6000', │ │
│ │ │ │ │ │ │ │ │ 'ping-count': '10', │ │
│ │ │ │ │ │ │ │ │ 'destination-groups': { │ │
│ │ │ │ │ │ │ │ │ │ 'entry': [ │ │
│ │ │ │ │ │ │ │ │ │ │ { │ │
│ │ │ │ │ │ │ │ │ │ │ │ 'dest-ip': { │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ 'entry': [ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ { │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ 'status': 'up', │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 'addr': │ │
│ │ '203.48.105.145' │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ } │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ ] │ │
│ │ │ │ │ │ │ │ │ │ │ │ }, │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ 'failure-condition': 'any', │ │
│ │ │ │ │ │ │ │ │ │ │ │ 'enabled': 'yes', │ │
│ │ │ │ │ │ │ │ │ │ │ │ 'name': 'trust-vr' │ │
│ │ │ │ │ │ │ │ │ │ │ } │ │
│ │ │ │ │ │ │ │ │ │ ] │ │
│ │ │ │ │ │ │ │ │ } │ │
│ │ │ │ │ │ │ │ }, │ │
│ │ │ │ │ │ │ │ { │ │
│ │ │ │ │ │ │ │ │ 'failure-condition': 'all', │ │
│ │ │ │ │ │ │ │ │ 'name': 'untrust-vr', │ │
│ │ │ │ │ │ │ │ │ 'enabled': 'yes', │ │
│ │ │ │ │ │ │ │ │ 'ping-interval': '6000', │ │
│ │ │ │ │ │ │ │ │ 'ping-count': '10', │ │
│ │ │ │ │ │ │ │ │ 'destination-groups': { │ │
│ │ │ │ │ │ │ │ │ │ 'entry': [ │ │
│ │ │ │ │ │ │ │ │ │ │ { │ │
│ │ │ │ │ │ │ │ │ │ │ │ 'dest-ip': { │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ 'entry': [ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ { │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ 'status': 'up', │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 'addr': │ │
│ │ '203.42.188.169' │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ } │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ ] │ │
│ │ │ │ │ │ │ │ │ │ │ │ }, │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ 'failure-condition': 'all', │ │
│ │ │ │ │ │ │ │ │ │ │ │ 'enabled': 'yes', │ │
│ │ │ │ │ │ │ │ │ │ │ │ 'name': │ │
│ │ 'untrust-vr' │ │
│ │ │ │ │ │ │ │ │ │ │ } │ │
│ │ │ │ │ │ │ │ │ │ ] │ │
│ │ │ │ │ │ │ │ │ } │ │
│ │ │ │ │ │ │ │ } │ │
│ │ │ │ │ │ │ ] │ │
│ │ │ │ │ │ } │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ 'running-sync': 'synchronized', │ │
│ │ │ │ │ 'running-sync-enabled': 'yes' │ │
│ │ │ │ } │ │
│ │ │ } │ │
│ │ } │ │
│ │ hostname = 'N1122322R-exh-pan-b' │ │
│ │ settings_file = <dynaconf.base.LazySettings object at 0x7f3eaf77f490> │ │
│ │ settings_file_path = PosixPath('/home/admin/pan-os-upgrade/settings.yaml') │ │
│ │ target_devices_to_revisit = None │ │
│ │ target_devices_to_revisit_lock = None │ │
│ │ target_version = '10.2.6-h1' │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/admin/.local/lib/python3.11/site-packages/pan_os_upgrade/components/ha.py:248 in │
│ handle_firewall_ha │
│ │
│ 245 │ ) │
│ 246 │ │
│ 247 │ # Check if the firewall is in the revisit list │
│ ❱ 248 │ with target_devices_to_revisit_lock: │
│ 249 │ │ is_device_to_revisit = target_device in target_devices_to_revisit │
│ 250 │ │
│ 251 │ if is_device_to_revisit: │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ deploy_info = 'passive' │ │
│ │ dry_run = True │ │
│ │ ha_details = { │ │
│ │ │ 'result': { │ │
│ │ │ │ 'enabled': 'yes', │ │
│ │ │ │ 'group': { │ │
│ │ │ │ │ 'mode': 'Active-Passive', │ │
│ │ │ │ │ 'local-info': { │ │
│ │ │ │ │ │ 'url-compat': 'Match', │ │
│ │ │ │ │ │ 'app-version': '8811-8573', │ │
│ │ │ │ │ │ 'gpclient-version': 'Not Installed', │ │
│ │ │ │ │ │ 'build-rel': '10.1.10', │ │
│ │ │ │ │ │ 'ha2-port': 'ethernet1/5', │ │
│ │ │ │ │ │ 'av-version': '0', │ │
│ │ │ │ │ │ 'url-version': '0000.00.00.000', │ │
│ │ │ │ │ │ 'ha1-backup-ipaddr': '192.168.10.12/29', │ │
│ │ │ │ │ │ 'active-passive': { │ │
│ │ │ │ │ │ │ 'passive-link-state': 'auto', │ │
│ │ │ │ │ │ │ 'monitor-fail-holddown': '1' │ │
│ │ │ │ │ │ }, │ │
│ │ │ │ │ │ 'platform-model': 'PA-VM', │ │
│ │ │ │ │ │ ... +49 │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ 'peer-info': { │ │
│ │ │ │ │ │ 'app-version': '8811-8573', │ │
│ │ │ │ │ │ 'gpclient-version': 'Not Installed', │ │
│ │ │ │ │ │ 'VMS': '2.1.10', │ │
│ │ │ │ │ │ 'url-version': '0000.00.00.000', │ │
│ │ │ │ │ │ 'ha1-backup-ipaddr': '192.168.10.11', │ │
│ │ │ │ │ │ 'av-version': '0', │ │
│ │ │ │ │ │ 'platform-model': 'PA-VM', │ │
│ │ │ │ │ │ 'ha2-ipaddr': '192.168.11.3', │ │
│ │ │ │ │ │ 'ha1-ipaddr': '192.168.10.3', │ │
│ │ │ │ │ │ 'ha2-backup-ipaddr': '192.168.11.11', │ │
│ │ │ │ │ │ ... +26 │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ 'link-monitoring': { │ │
│ │ │ │ │ │ 'failure-condition': 'any', │ │
│ │ │ │ │ │ 'enabled': 'yes', │ │
│ │ │ │ │ │ 'groups': {} │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ 'path-monitoring': { │ │
│ │ │ │ │ │ 'virtual-wire': {}, │ │
│ │ │ │ │ │ 'failure-condition': 'any', │ │
│ │ │ │ │ │ 'enabled': 'yes', │ │
│ │ │ │ │ │ 'vlan': {}, │ │
│ │ │ │ │ │ 'virtual-router': { │ │
│ │ │ │ │ │ │ 'entry': [ │ │
│ │ │ │ │ │ │ │ { │ │
│ │ │ │ │ │ │ │ │ 'failure-condition': 'any', │ │
│ │ │ │ │ │ │ │ │ 'name': 'trust-vr', │ │
│ │ │ │ │ │ │ │ │ 'enabled': 'yes', │ │
│ │ │ │ │ │ │ │ │ 'ping-interval': '6000', │ │
│ │ │ │ │ │ │ │ │ 'ping-count': '10', │ │
│ │ │ │ │ │ │ │ │ 'destination-groups': { │ │
│ │ │ │ │ │ │ │ │ │ 'entry': [ │ │
│ │ │ │ │ │ │ │ │ │ │ { │ │
│ │ │ │ │ │ │ │ │ │ │ │ 'dest-ip': { │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ 'entry': [ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ { │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ 'status': 'up', │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 'addr': │ │
│ │ '203.48.105.145' │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ } │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ ] │ │
│ │ │ │ │ │ │ │ │ │ │ │ }, │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ 'failure-condition': 'any', │ │
│ │ │ │ │ │ │ │ │ │ │ │ 'enabled': 'yes', │ │
│ │ │ │ │ │ │ │ │ │ │ │ 'name': 'trust-vr' │ │
│ │ │ │ │ │ │ │ │ │ │ } │ │
│ │ │ │ │ │ │ │ │ │ ] │ │
│ │ │ │ │ │ │ │ │ } │ │
│ │ │ │ │ │ │ │ }, │ │
│ │ │ │ │ │ │ │ { │ │
│ │ │ │ │ │ │ │ │ 'failure-condition': 'all', │ │
│ │ │ │ │ │ │ │ │ 'name': 'untrust-vr', │ │
│ │ │ │ │ │ │ │ │ 'enabled': 'yes', │ │
│ │ │ │ │ │ │ │ │ 'ping-interval': '6000', │ │
│ │ │ │ │ │ │ │ │ 'ping-count': '10', │ │
│ │ │ │ │ │ │ │ │ 'destination-groups': { │ │
│ │ │ │ │ │ │ │ │ │ 'entry': [ │ │
│ │ │ │ │ │ │ │ │ │ │ { │ │
│ │ │ │ │ │ │ │ │ │ │ │ 'dest-ip': { │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ 'entry': [ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ { │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ 'status': 'up', │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 'addr': │ │
│ │ '203.42.188.169' │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ } │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ ] │ │
│ │ │ │ │ │ │ │ │ │ │ │ }, │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ 'failure-condition': 'all', │ │
│ │ │ │ │ │ │ │ │ │ │ │ 'enabled': 'yes', │ │
│ │ │ │ │ │ │ │ │ │ │ │ 'name': │ │
│ │ 'untrust-vr' │ │
│ │ │ │ │ │ │ │ │ │ │ } │ │
│ │ │ │ │ │ │ │ │ │ ] │ │
│ │ │ │ │ │ │ │ │ } │ │
│ │ │ │ │ │ │ │ } │ │
│ │ │ │ │ │ │ ] │ │
│ │ │ │ │ │ } │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ 'running-sync': 'synchronized', │ │
│ │ │ │ │ 'running-sync-enabled': 'yes' │ │
│ │ │ │ } │ │
│ │ │ } │ │
│ │ } │ │
│ │ hostname = 'N1122322R-exh-pan-b' │ │
│ │ local_state = 'passive' │ │
│ │ local_version = '10.1.10' │ │
│ │ peer_version = '10.1.10' │ │
│ │ settings_file = <dynaconf.base.LazySettings object at 0x7f3eaf77f490> │ │
│ │ settings_file_path = PosixPath('/home/admin/pan-os-upgrade/settings.yaml') │ │
│ │ target_device = <Firewall '015354000084294' None at 0x7f3ea7894a10> │ │
│ │ target_devices_to_revisit = None │ │
│ │ target_devices_to_revisit_lock = None │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: 'NoneType' object does not support the context manager protocol

Screenshots:
Pan-01
Pan-02

Desktop (please complete the following information):

  • OS: [e.g. Linux]
@alperenkose
Copy link
Contributor

Hi,

I couldn't replicate the issue. Could you please confirm you are using the latest version of the tool ( which should be 1.3.10 ) as of now. You may check this with the poetry version command.

If you are using the latest version could you please provide the following details:

  • Are you targeting an HA pair or a standalone firewall ?
  • Provide debug log of the firewall upgrade after setting to DEBUG logging. You may do so by running pan-os-upgrade settings and set Logging level [INFO]: prompt to DEBUG, leave all the rest to default selections.

Thanks,

@d945028
Copy link
Author

d945028 commented Apr 24, 2024 via email

@alperenkose
Copy link
Contributor

Hi, Thanks for confirmation. So I will close the issue if you don't have the problem anymore?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants