Add Multithreading Support for Firewall Upgrade Process
Closed this issue · 1 comments
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
- Performance Improvement: Parallel processing of firewall upgrades will significantly reduce the time taken for bulk upgrades.
- Scalability: The script will be more scalable, handling a larger number of firewalls efficiently.
- Maintainability: Using ThreadPoolExecutor simplifies thread management, leading to cleaner and more maintainable code.
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.