Proxmox dynamic storage#59
Conversation
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #59 +/- ##
==========================================
- Coverage 89.54% 89.40% -0.14%
==========================================
Files 29 29
Lines 10910 10939 +29
Branches 84 84
==========================================
+ Hits 9769 9780 +11
- Misses 1141 1159 +18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds dynamic Proxmox import-storage selection instead of hardcoding local.
Changes:
- Selects storage supporting the
importcontent type. - Propagates its name through upload and VM creation.
- Adds a clearer error when no suitable storage exists.
| pub async fn get_storage_name(session: &ProxmoxSession, node: &str) -> Result<String> { | ||
| let storage_list = list_storage(&session, node).await?; | ||
| for storage in storage_list { | ||
| if storage.content.contains(&"import".to_string()) { |
| //Get the proxmox storage name for install before downloading the image and wasting bandwidth | ||
| let storage_name = get_storage_name(session, &config.node).await?; |
| node: &str, | ||
| local_path: &std::path::PathBuf, | ||
| progress_callback: &P, | ||
| storage_name: &str, |
| } | ||
|
|
||
| /// Get the name of available storage on a node | ||
| pub async fn get_storage_name(session: &ProxmoxSession, node: &str) -> Result<String> { |
There was a problem hiding this comment.
These tests already used local before my change, I just added the parameter to keep the same behavior. I haven't addressed the tests, so simply kept the same hardcoded string for them.
| }; | ||
|
|
||
| let result = create_vm_with_disk(&session, &config, "test-image.qcow2").await; | ||
| let result = create_vm_with_disk(&session, &config, "test-image.qcow2", "local").await; |
There was a problem hiding this comment.
This is part of testing, see comment above
| let result = | ||
| upload_image_to_proxmox(&session, "pve", &temp_file, &callback, "local").await; |
There was a problem hiding this comment.
This is part of testing, see comment above
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| pub async fn get_storage_name(session: &ProxmoxSession, node: &str) -> Result<String> { | ||
| let storage_list = list_storage(session, node).await?; | ||
| for storage in storage_list { | ||
| if storage.active && storage.content.iter().any(|content| content == "import") { |
| pub async fn get_storage_name(session: &ProxmoxSession, node: &str) -> Result<String> { | ||
| let storage_list = list_storage(session, node).await?; | ||
| for storage in storage_list { | ||
| if storage.active && storage.content.iter().any(|content| content == "import") { |
| //! 1. Download the qcow2.xz image locally | ||
| //! 2. Extract to qcow2 | ||
| //! 3. Upload qcow2 to Proxmox "local" storage (content=import) | ||
| //! 3. Upload qcow2 to Proxmox storage (content=import). storage is checked for import flag and set dynamically |
| node: &str, | ||
| local_path: &std::path::PathBuf, | ||
| progress_callback: &P, | ||
| storage_name: &str, |
| pub async fn get_storage_name(session: &ProxmoxSession, node: &str) -> Result<String> { | ||
| let storage_list = list_storage(session, node).await?; | ||
| for storage in storage_list { | ||
| if storage.active && storage.content.iter().any(|content| content == "import") { |
There was a problem hiding this comment.
ESXi storage is very unlikely for this use case but this could be considered if needed
Description
The Proxmox part of the installer hardcoded the upload storage name as
local. It also doesn't check to see if the storage hasimportenabled.This change adds a
get_storage_namefunction to query available storage, and find the first one withimportenabled. The storage name is then passed across the process. This step also runs before the installer is downloaded, meaning that the user doesn't have to wait for the download to complete, only for it to error (like it did for me a few times). I've also added error handling in the event Proxmox has no storage withimportenabled (which is the case for a default install), to give a different error message for clarity that it's something the user has to action currently.Type of Change
Related Issues
Closes #56
Testing
Tested end to end via windows on the Proxmox 9.2.4
Screenshots
New error message UI

Checklist
cargo fmtandnpm run lintdevices.rs)