backups: fix VM size calculation

Count only files included in the backup, not all of them (so ignore
temporary files etc).
This commit is contained in:
Marek Marczykowski-Górecki 2014-02-05 05:48:55 +01:00
parent f461c09d89
commit 7278102aef

View File

@ -135,6 +135,7 @@ def backup_prepare(vms_list = None, exclude_list = None,
s += fmt.format('-')
print_callback(s)
files_to_backup_index = 0
for vm in vms_for_backup:
if vm.is_template():
# handle templates later
@ -184,8 +185,13 @@ def backup_prepare(vms_list = None, exclude_list = None,
else:
s += fmt.format("AppVM" + (" + Sys" if vm.updateable else ""))
vm_size = reduce(lambda x, y: x + y["size"],
files_to_backup[files_to_backup_index:],
0)
files_to_backup_index = len(files_to_backup)
fmt="{{0:>{0}}} |".format(fields_to_display[2]["width"] + 1)
s += fmt.format(size_to_human(vm.get_disk_utilization()))
s += fmt.format(size_to_human(vm_size))
if vm.is_running():
s += " <-- The VM is running, please shut it down before proceeding with the backup!"