From 859f2b9db2996636ac2f5974ded808b8c30d755f Mon Sep 17 00:00:00 2001 From: yackob03 Date: Wed, 4 Dec 2013 17:55:25 -0800 Subject: [PATCH] Add a tool to compute a list of orphans and missing data between the storage and the database. --- tools/orphans.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tools/orphans.py diff --git a/tools/orphans.py b/tools/orphans.py new file mode 100644 index 000000000..f928fdec6 --- /dev/null +++ b/tools/orphans.py @@ -0,0 +1,24 @@ +from data.database import Image +from app import app + +live_image_id_set = set() + +for image in Image.select(): + live_image_id_set.add(image.docker_image_id) + +store = app.config['STORAGE'] + +storage_image_id_set = set() +for customer in store.list_directory('images/'): + for repo in store.list_directory(customer): + for image in store.list_directory(repo): + storage_image_id_set.add(image.split('/')[-1]) + +orphans = storage_image_id_set.difference(live_image_id_set) +missing_image_data = live_image_id_set.difference(storage_image_id_set) + +for orphan in orphans: + print "Orphan: %s" % orphan + +for missing in missing_image_data: + print "Missing: %s" % missing