[PR #400] [MERGED] Optional GuestID during creation. #443

Closed
opened 2026-02-28 00:42:13 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Telmate/proxmox-api-go/pull/400
Author: @Tinyblargon
Created: 3/1/2025
Status: Merged
Merged: 3/1/2025
Merged by: @Tinyblargon

Base: masterHead: id-fetch


📝 Commits (10+)

  • 9b95514 feat: input validation for GetNextID()
  • 39b6f7a refactor: Update types to PoolName
  • 79b9919 feat: GuestID optional during creation
  • 6d4cb62 refactor: remove pointer to mutex
  • 566f5b4 style: fix indentation
  • 71c44b1 fix: incorrect deprecation tag
  • 9ee8e80 fix: nil pointer exeption
  • 71c5f57 fix: name should not be the same on Lxc and Qemu
  • 1e198b5 fix: passes lock by value
  • fba8096 fix: copies lock value

📊 Changes

17 files changed (+958 additions, -207 deletions)

View changed files

📝 README.md (+6 -41)
📝 cli/command/get/id/get-id-next.go (+1 -1)
📝 main.go (+24 -16)
📝 proxmox/client.go (+43 -39)
📝 proxmox/client_test.go (+17 -21)
📝 proxmox/config_guest.go (+28 -2)
📝 proxmox/config_lxc.go (+1 -0)
📝 proxmox/config_pool.go (+4 -0)
📝 proxmox/config_qemu.go (+97 -47)
📝 proxmox/config_qemu_disk.go (+4 -0)
📝 proxmox/config_qemu_test.go (+50 -16)
proxmox/vmref.go (+305 -0)
proxmox/vmref_test.go (+353 -0)
📝 test/api/CloudInit/cloudinit_test.go (+1 -1)
📝 test/api/Qemu/qemu_clone_test.go (+22 -21)
📝 test/api/Qemu/qemu_create_update_delete_test.go (+1 -1)
📝 test/api/Qemu/qemu_start_test.go (+1 -1)

📄 Description

This pull request makes the GuestID optional during creation.
When no GuestID is provided we will ask for the next guest ID.
This bring the treading for the guest creation into the client class, ensuring a client instance can't create conflicts with itself.
If a GuestID conflict occurs due to the use of multiple systems creating guests in PVE, we will ask again for an available GuestID and try to create the guest again. This will happen until the guest is created or we run into some other error.

Due to the complexity of this change it was easier to re-implement the cloning logic for Lxc/Qemu then it was to retrofit the existing code. The old code didn't have test.

All deprecated code has been marked with the deprecation flag and instruction on migrating to the new functions.

Closes #382


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Telmate/proxmox-api-go/pull/400 **Author:** [@Tinyblargon](https://github.com/Tinyblargon) **Created:** 3/1/2025 **Status:** ✅ Merged **Merged:** 3/1/2025 **Merged by:** [@Tinyblargon](https://github.com/Tinyblargon) **Base:** `master` ← **Head:** `id-fetch` --- ### 📝 Commits (10+) - [`9b95514`](https://github.com/Telmate/proxmox-api-go/commit/9b95514b3fb474c4c3b1e66d739c7e691c6adba7) feat: input validation for `GetNextID()` - [`39b6f7a`](https://github.com/Telmate/proxmox-api-go/commit/39b6f7ac8eb25d8d17a245e3e77275d0fc7db73f) refactor: Update types to `PoolName` - [`79b9919`](https://github.com/Telmate/proxmox-api-go/commit/79b99193a56fdbf66765b8e91f8f726f507f3526) feat: GuestID optional during creation - [`6d4cb62`](https://github.com/Telmate/proxmox-api-go/commit/6d4cb62a2b28696e4c526e32c807826cd4cc7941) refactor: remove pointer to mutex - [`566f5b4`](https://github.com/Telmate/proxmox-api-go/commit/566f5b4da0a2fd1996cc07b1dda5487171f12214) style: fix indentation - [`71c44b1`](https://github.com/Telmate/proxmox-api-go/commit/71c44b1a06b511fcdb7b81ed2af84d724fd4e3b4) fix: incorrect deprecation tag - [`9ee8e80`](https://github.com/Telmate/proxmox-api-go/commit/9ee8e80d84beb866ebc0cb406df866d1e4fb66a4) fix: nil pointer exeption - [`71c5f57`](https://github.com/Telmate/proxmox-api-go/commit/71c5f57b952448ac477b0f40e79861fbdaa95f5b) fix: name should not be the same on Lxc and Qemu - [`1e198b5`](https://github.com/Telmate/proxmox-api-go/commit/1e198b51ceaa4dd458009a870f2857c642eb7f3f) fix: passes lock by value - [`fba8096`](https://github.com/Telmate/proxmox-api-go/commit/fba8096869f7fd4b62efa1391b1390e551d8a098) fix: copies lock value ### 📊 Changes **17 files changed** (+958 additions, -207 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+6 -41) 📝 `cli/command/get/id/get-id-next.go` (+1 -1) 📝 `main.go` (+24 -16) 📝 `proxmox/client.go` (+43 -39) 📝 `proxmox/client_test.go` (+17 -21) 📝 `proxmox/config_guest.go` (+28 -2) 📝 `proxmox/config_lxc.go` (+1 -0) 📝 `proxmox/config_pool.go` (+4 -0) 📝 `proxmox/config_qemu.go` (+97 -47) 📝 `proxmox/config_qemu_disk.go` (+4 -0) 📝 `proxmox/config_qemu_test.go` (+50 -16) ➕ `proxmox/vmref.go` (+305 -0) ➕ `proxmox/vmref_test.go` (+353 -0) 📝 `test/api/CloudInit/cloudinit_test.go` (+1 -1) 📝 `test/api/Qemu/qemu_clone_test.go` (+22 -21) 📝 `test/api/Qemu/qemu_create_update_delete_test.go` (+1 -1) 📝 `test/api/Qemu/qemu_start_test.go` (+1 -1) </details> ### 📄 Description This pull request makes the `GuestID` optional during creation. When no `GuestID` is provided we will ask for the next guest ID. This bring the treading for the guest creation into the client class, ensuring a client instance can't create conflicts with itself. If a `GuestID` conflict occurs due to the use of multiple systems creating guests in PVE, we will ask again for an available `GuestID` and try to create the guest again. This will happen until the guest is created or we run into some other error. Due to the complexity of this change it was easier to re-implement the cloning logic for Lxc/Qemu then it was to retrofit the existing code. The old code didn't have test. All deprecated code has been marked with the deprecation flag and instruction on migrating to the new functions. Closes #382 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 00:42:13 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/proxmox-api-go#443
No description provided.