implement-actions #2
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
JustScreaMy/bachelor-thesis!2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "implement-actions"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
🤖 AI Code Review
The PR introduces a new service layer (
action,discovery,resource) and refactors the TUI to utilize these services, enabling server actions and improved data handling. The changes are substantial and generally well-structured.Here's a detailed review:
pve_tui/core/models/client_config.pyverify_ssl: bool = FalsetoContextConfigand itsfrom_dictmethod.Falsemeans SSL verification is disabled unless explicitly configured. While this might simplify initial setup for some users, it's generally recommended to have SSL verification enabled by default in production-like environments to prevent man-in-the-middle attacks. For a TUI, it's a common concession for ease of use in diverse environments. Ensure documentation clearly states this default and how to enable verification.pve_tui/core/models/server.pyAARCH64 = 'aarch64'toServerArch. Fixed typobaloontoballooninServerQEMU.AARCH64is a relevant addition for modern Proxmox deployments.balloonis good.New Service Layer (
pve_tui/core/services/action.py,pve_tui/core/services/actions/*.py,pve_tui/core/services/discovery.py,pve_tui/core/services/resource.py)This is a major architectural improvement, promoting better organization and separation of concerns.
pve_tui/core/services/actions/base.pyActionManagerwith path construction helpers and arun_bulkmethod.get_path_*static methods are excellent for consistency and reducing boilerplate.run_bulkis well-implemented, usingasyncio.gatherwithreturn_exceptions=Truefor robust parallel execution and clear separation of successes and failures. This is a solid pattern.pve_tui/core/services/actions/group.pyGroupManagerfor handling Proxmox tags as groups._format_tagcorrectly ensures thepve-tui-prefix._update_tagscorrectly handles the semicolon-separated tag string Proxmox expects.add_to_group,remove_from_group,create_group_with_servers, andremove_groupsappears sound. Theremove_groupsmethod efficiently builds a map to process multiple group removals for the same server in a single API call per server, which is good.pve_tui/core/services/actions/snapshot.pySnapshotManagerfor snapshot operations.list_snapshots,create,rollback, androllback_to_latestis clear.rollback_to_latestcorrectly filters "current" snapshots and usessnaptimefor determining the latest.create_many,rollback_to_latest_many) leveragerun_bulkeffectively.pve_tui/core/services/actions/status.pyStatusManagerfor server power actions.pve_tui/core/services/discovery.pyDiscoveryServicefor fetching nodes and all servers.asyncio.gatherto fetch resources across multiple nodes and for both VMs and LXCs concurrently is very efficient.fetch_all_serversto skip node-level failures (isinstance(result, Exception)) is good for resilience, allowing partial data to be displayed even if some nodes are unreachable.pve_tui/core/services/resource.pyResourceServicefor parsing server data and fetching details._parse_server_briefis a crucial helper. It correctly uses.get()for robustness against missing fields and handles various tag delimiters. The default forServerStatustoStoppedon unknown status is a reasonable fallback.fetch_server_brief,fetch_server_details_qemu,fetch_server_details_lxccorrectly use the new client and parsing logic.pve_tui/core/services/api.pyverify_sslintoProxmoxClientandaiohttp.TCPConnector.verify_sslsetting.pve_tui/core/utils.pyPVE_TOKEN_IDandPVE_TOKEN.pve_tui/tui/app.pyPveTuiAppto use the newDiscoveryService,ResourceService, andActionService.pve_tui/tui/screens/input_modal.py(New file)InputModalfor text input.on_button_pressedandon_input_submittedhandlers work as expected.pve_tui/tui/screens/main.py_get_groupsnow correctly takesserversas an argument, making it more flexible.action_refreshusesdiscovery_serviceand includes importanttry...exceptblocks for error handling, providing user feedback viaself.notify._sync_right_paneis a critical addition. It ensures that the action list or detail view on the right pane is updated with fresh data after a refresh, preventing stale information. This is good for UI consistency. The comment aboutServerDetailViewnot being reactive is noted; the current approach of updatingbriefor replacing the widget is a pragmatic workaround._handle_selectednow correctly passesselected_groupstoServerActionList, which is essential for group actions._fetch_and_display_server_detailsnow usesresource_service, fitting the new architecture.pve_tui/tui/widgets/multiselect_list_view.pyidparameternoqa.id: str | None = None, # noqais a common pattern in Textual development when shadowing theidargument (which is often already provided byWidget).pve_tui/tui/widgets/server_action_list.pyOptionListand implement action logic.VerticalandOptionListmakes this widget much more functional and user-friendly compared to justStaticwidgets.serversandgroupsare correctly used to triggerrecompose=True, ensuring the list of actions updates dynamically.composemethod intelligently generates options and enables/disables them based on the status of selected servers (e.g., cannot start an already running server). This is excellent UX.on_focuscorrectly delegates focus to theOptionList.handle_option_selecteddispatches to specific action methods, maintaining clear responsibilities.run_*_actionmethods are well-implemented using@work(exclusive=True)to manage concurrent operations and provide user feedback._trigger_refreshwithasyncio.sleepis a practical approach to give Proxmox time to process tasks before refreshing the UI. Consider if a more robust mechanism (e.g., polling for task completion via Proxmox API) would be needed for critical operations, but for general UI updates, this is acceptable.pve_tui/tui/widgets/server_detail_view.pybaloontoballoon.pve_tui/tui/widgets/split_view.py.split-pane:focus-within.Overall Impression
This PR represents a significant and positive leap forward in the architecture and functionality of the
pve_tui. The introduction of the service layer greatly improves code organization, testability, and maintainability. The TUI updates effectively leverage these new services to provide a more interactive and functional user experience.The use of
asynciofor bulk operations andTextual's reactive properties and work decorators is well-executed. Error handling for network operations and user feedback through notifications are also good practices implemented throughout the changes.Potential Minor Improvements (beyond scope of initial review, but good to keep in mind)
verify_ssldefault: As mentioned, whileFalsemight be acceptable for a TUI's ease of use, it's a security consideration. Document this thoroughly.asyncio.sleep, consider adding functionality to poll the Proxmox API for task completion (using the UPID returned by actions) to give more precise feedback to the user about action status.run_bulkreturns failures, the currentnotifymessages only give a count. For a TUI, it might be beneficial to present a modal with details of which servers failed and why.Looks great overall!
This review was generated automatically by an AI model (gemini-2.5-flash). It may contain errors or miss context. Always apply human judgment.
Tokens: 14716 in / 4870 out — Est. cost: $0.016590
🤖 AI Code Review
Here's a review of the code changes:
Overall, this PR introduces a robust and well-structured set of action managers and integrates them into the TUI, significantly enhancing its functionality. The refactoring of the
ClusterServiceintoDiscoveryService,ResourceService, andActionServiceimproves modularity and separation of concerns. TheInputModaland dynamicServerActionListare excellent additions for user interaction.General Observations
ClusterServiceinto more specialized services (DiscoveryService,ResourceService,ActionService) is a significant improvement for maintainability and scalability.asyncio.gatherand@workdecorators for parallel and exclusive execution of actions is crucial for a responsive TUI.run_bulkpattern returning(successes, failures)and the TUI notifying the user about both is a good practice.Detailed Feedback
1.
pve_tui/core/models/client_config.py&pve_tui/core/services/api.pyverify_ssl=FalseDefault:verify_sslwith a default ofFalseinContextConfigand its propagation toProxmoxClientoffers flexibility, especially for environments with self-signed certificates. However, as a general security best practice, verifying SSL certificates (verify_ssl=True) should be the default in production environments to prevent man-in-the-middle attacks. While configurable is good, consider documenting the security implications of disabling SSL verification.verify_ssloption.2.
pve_tui/core/models/server.pybaloontoballoon.3.
pve_tui/core/services/actions/base.pyrun_bulkReturn Type:tuple[dict[int, Any], dict[int, Exception]]forrun_bulkis excellent. It clearly separates successful results from failures and provides a way to associate them with theserver_id.4.
pve_tui/core/services/actions/group.py_format_tagmethod enforcing thepve-tui-prefix for group tags is a good way to namespace and manage custom tags within Proxmox.5.
pve_tui/core/services/actions/snapshot.pyrollback_to_latestto filter out the 'current' snapshot and find the latest based onsnaptimeis sound. RaisingValueErrorif no snapshots are found is appropriate.6.
pve_tui/core/services/discovery.pyfetch_all_servers, skipping node-level failures (if isinstance(result, Exception): continue) allows the TUI to display partial data, which improves user experience if some nodes are temporarily unavailable. Good design choice.7.
pve_tui/core/services/resource.py_parse_server_briefmethod robustly handles various tag delimiters (;,,, space) when parsing Proxmox tags, which is good for compatibility.8.
pve_tui/core/utils.pyPVE_TOKEN_IDandPVE_TOKENto be overridden by environment variables is a significant security and usability improvement, especially for sensitive credentials and automated deployments.9.
pve_tui/tui/screens/main.py_sync_right_paneLogic:_sync_right_panemethod is crucial for ensuring the right-hand action list or detail view is updated with the latest server data after a refresh.ServerDetailViewnot being reactive on itsserverproperty is an internal note. If possible, makingServerDetailView.serverreactive could lead to slightly cleaner updates, but the current approach of re-fetching/replacing is acceptable given Textual's current capabilities.10.
pve_tui/tui/widgets/multiselect_list_view.pyspacebinding is a minor but good improvement for generality.11.
pve_tui/tui/widgets/server_action_list.pycan_start,can_stop) provides an intuitive user experience._trigger_refresh):asyncio.sleep(1.5)andasyncio.sleep(3.0)in_trigger_refreshis a practical heuristic for waiting for Proxmox tasks to initiate and potentially complete before refreshing the UI.on_focusDelegation:OptionListon widget focus is good for keyboard navigability.Conclusion
The PR is well-executed and significantly enhances the TUI's capabilities. The new action service architecture is clean, and the UI components are well-designed for interactivity and responsiveness. The fixes and improvements are valuable.
This review was generated automatically by an AI model (gemini-2.5-flash). It may contain errors or miss context. Always apply human judgment.
Tokens: 15798 in / 4795 out — Est. cost: $0.016727