Simplify VM rename to preserve data
A rename is simply a change to two values, so instead of undefining and re-defining the VM, just edit those two fields. This ensures things like snapshots are preserved automatically.
This commit is contained in:
parent
7cc354466f
commit
8937ddf331
|
@ -618,28 +618,14 @@ def rename_vm(zkhandler, domain, new_domain):
|
|||
# Get VM information
|
||||
_b, dom_info = get_info(zkhandler, dom_uuid)
|
||||
|
||||
# Undefine the old VM
|
||||
undefine_vm(zkhandler, dom_uuid)
|
||||
|
||||
# Define the new VM
|
||||
define_vm(
|
||||
zkhandler,
|
||||
vm_config_new,
|
||||
dom_info["node"],
|
||||
dom_info["node_limit"],
|
||||
dom_info["node_selector"],
|
||||
dom_info["node_autostart"],
|
||||
migration_method=dom_info["migration_method"],
|
||||
migration_max_downtime=dom_info["migration_max_downtime"],
|
||||
profile=dom_info["profile"],
|
||||
tags=dom_info["tags"],
|
||||
initial_state="stop",
|
||||
# Edit the VM data
|
||||
zkhandler.write(
|
||||
[
|
||||
(("domain", dom_uuid), new_domain),
|
||||
(("domain.xml", dom_uuid), vm_config_new),
|
||||
]
|
||||
)
|
||||
|
||||
# If the VM is migrated, store that
|
||||
if dom_info["migrated"] != "no":
|
||||
zkhandler.write([(("domain.last_node", dom_uuid), dom_info["last_node"])])
|
||||
|
||||
return True, 'Successfully renamed VM "{}" to "{}".'.format(domain, new_domain)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue