Skip to content

Proxmox dynamic storage#59

Draft
abb848 wants to merge 7 commits into
home-assistant:mainfrom
abb848:proxmox-dynamic-storage
Draft

Proxmox dynamic storage#59
abb848 wants to merge 7 commits into
home-assistant:mainfrom
abb848:proxmox-dynamic-storage

Conversation

@abb848

@abb848 abb848 commented Jul 14, 2026

Copy link
Copy Markdown
Member

Description

The Proxmox part of the installer hardcoded the upload storage name as local. It also doesn't check to see if the storage has import enabled.

This change adds a get_storage_name function to query available storage, and find the first one with import enabled. 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 with import enabled (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

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD changes

Related Issues

Closes #56

Testing

  • Unit tests added/updated
  • E2E tests added/updated
  • Manually tested on macOS
  • Manually tested on Windows
  • Manually tested on Linux

Tested end to end via windows on the Proxmox 9.2.4

Screenshots

New error message UI
image

Checklist

  • My code follows the project's code style
  • I have run cargo fmt and npm run lint
  • I have added tests for my changes - I'm not sure how to add tests to this but can look into it if needed
  • All new and existing tests pass - There's one test that doesn't pass, but it's unrelated to this change (in devices.rs)
  • I have updated documentation if needed - I don't think documentation needs updating
  • My commits follow conventional commit format

Copilot AI review requested due to automatic review settings July 14, 2026 15:35

@home-assistant home-assistant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @abb848

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant

Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant
home-assistant Bot marked this pull request as draft July 14, 2026 15:35
@codecov-commenter

codecov-commenter commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 47.50000% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.40%. Comparing base (a831cc1) to head (90e200e).

Files with missing lines Patch % Lines
crates/hai-core/src/proxmox.rs 47.50% 21 Missing ⚠️
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     
Flag Coverage Δ
backend 91.79% <47.50%> (-0.22%) ⬇️
frontend 84.86% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds dynamic Proxmox import-storage selection instead of hardcoding local.

Changes:

  • Selects storage supporting the import content type.
  • Propagates its name through upload and VM creation.
  • Adds a clearer error when no suitable storage exists.

Comment thread crates/hai-core/src/proxmox.rs Outdated
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()) {
Comment on lines +1009 to +1010
//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,
Copilot AI review requested due to automatic review settings July 14, 2026 15:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Comment thread crates/hai-core/src/proxmox.rs Outdated
}

/// Get the name of available storage on a node
pub async fn get_storage_name(session: &ProxmoxSession, node: &str) -> Result<String> {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of testing, see comment above

Comment on lines +3102 to +3103
let result =
upload_image_to_proxmox(&session, "pve", &temp_file, &callback, "local").await;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of testing, see comment above

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 14, 2026 15:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

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") {
Comment on lines +402 to +405
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
Copilot AI review requested due to automatic review settings July 14, 2026 16:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

node: &str,
local_path: &std::path::PathBuf,
progress_callback: &P,
storage_name: &str,
Copilot AI review requested due to automatic review settings July 14, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

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") {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ESXi storage is very unlikely for this use case but this could be considered if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamic storage selection for Proxmox image upload

3 participants