cdot65 / pan-os-upgrade

An efficient tool to execute configuration backups, network state snapshots, system readiness checks, and operating system upgrades of Palo Alto Networks firewalls and Panorama appliances.
https://cdot65.github.io/pan-os-upgrade/
Apache License 2.0
39 stars 7 forks source link

Add Multithreading Support for Firewall Upgrade Process #53

Closed cdot65 closed 7 months ago

cdot65 commented 7 months ago

Overview

The current script for upgrading PAN-OS firewalls operates sequentially, which can be time-consuming when dealing with multiple firewalls. The goal of this enhancement is to integrate multithreading into the script to improve the efficiency and reduce the overall execution time.

Detailed Explanation

The script needs to be updated to use multithreading for the following parts of the workflow:

Initial pass of upgrades when connected to Panorama. Revisiting firewalls that were active in an HA pair and had the same version as their peers. The proposed solution is to use ThreadPoolExecutor from Python's concurrent.futures module to manage threads efficiently.

Expected Benefits

Implementation Considerations

Thread safety needs to be ensured, particularly when accessing shared resources like firewalls_to_revisit. Error handling within threads should be robust to avoid any unmanaged thread terminations. Testing should be thorough to ensure that the new implementation does not introduce any regressions.

Additional Notes

This feature should be optional, allowing users to choose between sequential and parallel execution modes. Logging should clearly indicate the start, progress, and completion of tasks in each thread for ease of monitoring and debugging.

cdot65 commented 7 months ago

resolved in 6b4fa72c0dd2b9b6db1fc8b6574ee3f3efb09564