from data.database import Image from app import app, storage as store live_image_id_set = set() for image in Image.select(): live_image_id_set.add(image.docker_image_id) 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