[PR #4292] Feature: get correct next VMID #4875

Closed
opened 2025-11-20 06:12:06 -05:00 by saavagebueno · 0 comments
Owner

Original Pull Request: https://github.com/community-scripts/ProxmoxVE/pull/4292

State: closed
Merged: Yes


✍️ Description

This PR improves the robustness and usability of the VM creation workflow:

  • Introduces get_valid_nextid(), a helper function to find the next truly available VMID by checking:
    • /etc/pve/qemu-server/<id>.conf
    • /etc/pve/lxc/<id>.conf
    • orphaned LVM volumes via lvs
  • Ensures that the whiptail inputbox for "Virtual Machine ID" is always pre-filled with a valid and unused ID.
  • Fixes the issue where the input field was empty when $VMID was not explicitly set beforehand.
  • Removes reliance on pvesh get /cluster/nextid alone, which may suggest IDs that are technically blocked by orphaned resources.

Benefits

  • Prevents script crashes caused by pvesm alloc failing on orphaned volumes.
  • Improves UX in interactive shell scripts (especially when run via SSH or Proxmox GUI).
  • Ensures reproducibility and automation safety when the script is reused or extended.

Before (Docker-VM without the function):
image

After (Debian-VM with the new function) – set ID to 108 instead of 107):
image

Link: #4289

Prerequisites (X in brackets)

  • Self-review completed – Code follows project standards.
  • Tested thoroughly – Changes work as expected.
  • No security risks – No hardcoded secrets, unnecessary privilege escalations, or permission issues.

🛠️ Type of Change (X in brackets)

  • 🐞 Bug fix – Resolves an issue without breaking functionality.
  • New feature – Adds new, non-breaking functionality.
  • 💥 Breaking change – Alters existing functionality in a way that may require updates.
  • 🆕 New script – A fully functional and tested script or script set.
  • 🌍 Website update – Changes to website-related JSON files or metadata.
  • 🔧 Refactoring / Code Cleanup – Improves readability or maintainability without changing functionality.
  • 📝 Documentation update – Changes to README, AppName.md, CONTRIBUTING.md, or other docs.
**Original Pull Request:** https://github.com/community-scripts/ProxmoxVE/pull/4292 **State:** closed **Merged:** Yes --- ## ✍️ Description This PR improves the robustness and usability of the VM creation workflow: - Introduces `get_valid_nextid()`, a helper function to find the next truly available VMID by checking: - `/etc/pve/qemu-server/<id>.conf` - `/etc/pve/lxc/<id>.conf` - orphaned LVM volumes via `lvs` - Ensures that the `whiptail` inputbox for "Virtual Machine ID" is always pre-filled with a valid and unused ID. - Fixes the issue where the input field was empty when `$VMID` was not explicitly set beforehand. - Removes reliance on `pvesh get /cluster/nextid` alone, which may suggest IDs that are technically blocked by orphaned resources. ## Benefits - Prevents script crashes caused by `pvesm alloc` failing on orphaned volumes. - Improves UX in interactive shell scripts (especially when run via SSH or Proxmox GUI). - Ensures reproducibility and automation safety when the script is reused or extended. **Before (Docker-VM without the function):** ![image](https://github.com/user-attachments/assets/5f9ccb8f-4a11-4a1d-880d-49554c4a029b) **After (Debian-VM with the new function) – set ID to 108 instead of 107):** ![image](https://github.com/user-attachments/assets/eee3e8cc-86ec-4661-b4ae-a507cdd51c7d) ## 🔗 Related PR / Issue Link: #4289 ## ✅ Prerequisites (**X** in brackets) - [x] **Self-review completed** – Code follows project standards. - [x] **Tested thoroughly** – Changes work as expected. - [x] **No security risks** – No hardcoded secrets, unnecessary privilege escalations, or permission issues. --- ## 🛠️ Type of Change (**X** in brackets) - [ ] 🐞 **Bug fix** – Resolves an issue without breaking functionality. - [x] ✨ **New feature** – Adds new, non-breaking functionality. - [ ] 💥 **Breaking change** – Alters existing functionality in a way that may require updates. - [ ] 🆕 **New script** – A fully functional and tested script or script set. - [ ] 🌍 **Website update** – Changes to website-related JSON files or metadata. - [ ] 🔧 **Refactoring / Code Cleanup** – Improves readability or maintainability without changing functionality. - [ ] 📝 **Documentation update** – Changes to `README`, `AppName.md`, `CONTRIBUTING.md`, or other docs.
saavagebueno added the pull-request label 2025-11-20 06:12:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/ProxmoxVE#4875