Add a tool to compute a list of orphans and missing data between the storage and the database.

This commit is contained in:
yackob03 2013-12-04 17:55:25 -08:00
parent 06582369df
commit 859f2b9db2

24
tools/orphans.py Normal file
View file

@ -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