Add UUID check and fix wording

Don't suggest renaming any more as it's not enough.
This commit is contained in:
Joshua Boniface 2024-08-20 17:03:48 -04:00
parent 9a661d0173
commit 9b3075be18
2 changed files with 12 additions and 3 deletions

View File

@ -1970,7 +1970,7 @@ def cli_vm_snapshot_import(
The import will include the VM configuration, metainfo, and the point-in-time snapshot of all attached RBD volumes. Incremental imports will be automatically handled. The import will include the VM configuration, metainfo, and the point-in-time snapshot of all attached RBD volumes. Incremental imports will be automatically handled.
A VM named DOMAIN or with the same UUID must not exist; if a VM with the same name or UUID already exists, it must be removed, or renamed and then undefined (to preserve volumes), before importing. A VM named DOMAIN or with the same UUID must not exist; if a VM with the same name or UUID already exists, it must be removed (or renamed and then undefined, to preserve volumes while freeing the UUID) before importing.
If the "-r"/"--retain-snapshot" option is specified (the default), for incremental imports, only the parent snapshot is kept; for full imports, the imported snapshot is kept. If the "-R"/"--remove-snapshot" option is specified, the imported snapshot is removed. If the "-r"/"--retain-snapshot" option is specified (the default), for incremental imports, only the parent snapshot is kept; for full imports, the imported snapshot is kept. If the "-R"/"--remove-snapshot" option is specified, the imported snapshot is removed.
@ -2082,7 +2082,7 @@ def cli_vm_backup_restore(domain, backup_datestring, backup_path, retain_snapsho
The restore will import the VM configuration, metainfo, and the point-in-time snapshot of all attached RBD volumes. Incremental backups will be automatically handled. The restore will import the VM configuration, metainfo, and the point-in-time snapshot of all attached RBD volumes. Incremental backups will be automatically handled.
A VM named DOMAIN or with the same UUID must not exist; if a VM with the same name or UUID already exists, it must be removed, or renamed and then undefined (to preserve volumes), before restoring. A VM named DOMAIN or with the same UUID must not exist; if a VM with the same name or UUID already exists, it must be removed (or renamed and then undefined, to preserve volumes while freeing the UUID) before importing.
If the "-r"/"--retain-snapshot" option is specified (the default), for incremental restores, only the parent snapshot is kept; for full restores, the restored snapshot is kept. If the "-R"/"--remove-snapshot" option is specified, the imported snapshot is removed. If the "-r"/"--retain-snapshot" option is specified (the default), for incremental restores, only the parent snapshot is kept; for full restores, the restored snapshot is kept. If the "-R"/"--remove-snapshot" option is specified, the imported snapshot is removed.

View File

@ -2627,7 +2627,7 @@ def vm_worker_import_snapshot(
if dom_uuid: if dom_uuid:
fail( fail(
celery, celery,
f'VM "{domain}" already exists in the cluster; remove or rename it before importing a snapshot', f"VM '{domain}' (UUID '{dom_uuid}') already exists in the cluster; remove it before importing a snapshot",
) )
return return
@ -2672,6 +2672,15 @@ def vm_worker_import_snapshot(
) )
return return
# Check that another VM with the same UUID doesn't already exist (rename is not enough!)
dom_name = getDomainName(zkhandler, export_source_details["vm_detail"]["uuid"])
if dom_name:
fail(
celery,
f"VM UUID '{export_source_details['vm_detail']['uuid']}' (Name '{dom_name}') already exists in the cluster; remove it before importing a snapshot",
)
return
# Handle incrementals # Handle incrementals
incremental_parent = export_source_details.get("incremental_parent", None) incremental_parent = export_source_details.get("incremental_parent", None)
if incremental_parent is not None: if incremental_parent is not None: