Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Keep ID argument #41

wants to merge 2 commits into from

Conversation

engelant
Copy link

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).

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.
Copy link
Member

@wdoekes wdoekes left a 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, (aes128-gcm@openssh.com 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)
Copy link
Member

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(
Copy link
Member

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.

@mjbnz
Copy link

mjbnz commented Jul 30, 2022

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)

@wdoekes
Copy link
Member

wdoekes commented Sep 7, 2022

@engelant: will you be working on this?

@engelant
Copy link
Author

engelant commented Sep 7, 2022

@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.

@wdoekes
Copy link
Member

wdoekes commented Sep 7, 2022

I understand 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants