-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep ID argument #41
base: main
Are you sure you want to change the base?
Keep ID argument #41
Conversation
get_vmids() is split out of get_free_vmid(), to make it common for new check_vmid_free(). check_vmid_free() checks the availability of a vm id. get_free_vmid() would not use any free IDs before the lowest ID. The length to ID diff was replaced/refactored for readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
Also refactored the get_vmids() function while splitting it, as it had a bug, not using valid VM IDs (>= 100 < FIRST_USED_ID).
I'm sorry, I don't parse that sentence. But I see there is indeed a bug in that it will never hand out IDs below the first existing ID.
Could you split this up into 2 commits:
- fixing the bug / refactoring / splitting
- adding keep-id
@@ -74,6 +74,7 @@ Full invocation specification (``--help``): | |||
prefer, ([email protected] is supposed to | |||
be fast if you have aes on your cpu); set to | |||
"-" to use ssh defaults | |||
--keep-id preserve the source vm id (useful if you want to keep a backup trail) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Limit line lengths to 79 please. (Applies elsewhere ass well.)
if self.opt_keep_id: | ||
dst_id = src_vm.id | ||
if not self.dst_pve.check_vmid_free(dst_id): | ||
raise PrepareError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too late to raise PrepareErrors here. This should've been checked in move_vm()
(also done in dry-run).
Here we can safely assume the ID is free and let Proxmox handle duplicate VM id errors.
What would be a nice extension to this patch would be a way to specify a new base id for migrated VMs. (which for a single move would be a way to specify the new ID for the VM) |
@engelant: will you be working on this? |
@wdoekes : Sorry, but I don't hava a dev environment of two proxmox instances anymore. This was the patch I used for myself at the given time to transfer a server. |
I understand 👍 |
Added an argument for preserving the source ID of the VM if possible.
Raises an error if ID is already in use.
Also refactored the get_vmids() function while splitting it, as it had a bug, not using valid VM IDs (>= 100 < FIRST_USED_ID).