Implement VM rename functionality

Closes #125
This commit is contained in:
2021-05-23 16:41:42 -04:00
parent 9de14c46fb
commit f46c2e7f6a
6 changed files with 204 additions and 0 deletions

View File

@ -601,6 +601,37 @@ def vm_modify(name, restart, xml):
return output, retcode
def vm_rename(name, new_name):
"""
Rename a VM in the PVC cluster.
"""
if new_name is None:
output = {
'message': 'A new VM name must be specified'
}
return 400, output
zk_conn = pvc_common.startZKConnection(config['coordinators'])
if pvc_vm.searchClusterByName(zk_conn, new_name) is not None:
output = {
'message': 'A VM named \'{}\' is already present in the cluster'.format(new_name)
}
return 400, output
retflag, retdata = pvc_vm.rename_vm(zk_conn, name, new_name)
pvc_common.stopZKConnection(zk_conn)
if retflag:
retcode = 200
else:
retcode = 400
output = {
'message': retdata.replace('\"', '\'')
}
return output, retcode
def vm_undefine(name):
"""
Undefine a VM from the PVC cluster.