def delete_vm(xenhost, vm_uuid): vdi_uuids = lib.vdis_of(xenhost, vm_uuid) xenhost.run("xe vm-uninstall vm={vm_uuid} force=true".format(vm_uuid=vm_uuid)) for vdi_uuid in vdi_uuids: uuid = xenhost.run("xe vdi-list --minimal uuid={vdi_uuid}".format(vdi_uuid=vdi_uuid)) if uuid: xenhost.run("xe vdi-destroy uuid={uuid}".format(uuid=uuid))