From 75d0b34f4bbed38df4f20fc3ef81dc7ea241bdb7 Mon Sep 17 00:00:00 2001 From: jakedt Date: Fri, 7 Mar 2014 15:37:56 -0500 Subject: [PATCH] Add a tool to compute how much storage shared images have saved us. --- tools/sharedimagestorage.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tools/sharedimagestorage.py diff --git a/tools/sharedimagestorage.py b/tools/sharedimagestorage.py new file mode 100644 index 000000000..1fbae8c5a --- /dev/null +++ b/tools/sharedimagestorage.py @@ -0,0 +1,14 @@ +from data.database import Image, ImageStorage + +query = ImageStorage.select().annotate(Image) + +saved_bytes = 0 +total_bytes = 0 + +for storage in query: + if storage.image_size is not None: + saved_bytes += (storage.count - 1) * storage.image_size + total_bytes += storage.count * storage.image_size + +print "Saved: %s" % saved_bytes +print "Total: %s" % total_bytes