parent
1ddc73416c
commit
12924784ce
6 changed files with 93 additions and 12 deletions
30
util/backfillreplication.py
Normal file
30
util/backfillreplication.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
import logging
|
||||
import features
|
||||
|
||||
from endpoints.replication import queue_storage_replication
|
||||
from data.database import Image, ImageStorage, Repository, User
|
||||
|
||||
def backfill_replication():
|
||||
encountered = set()
|
||||
query = (Image.select(Image, ImageStorage, Repository, User)
|
||||
.join(ImageStorage)
|
||||
.switch(Image)
|
||||
.join(Repository)
|
||||
.join(User))
|
||||
|
||||
for image in query:
|
||||
if image.storage.uuid in encountered:
|
||||
continue
|
||||
|
||||
print "Enqueueing image storage %s to be replicated" % (image.storage.uuid)
|
||||
encountered.add(image.storage.uuid)
|
||||
queue_storage_replication(image.repository.namespace_user.username, image.storage)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
if not features.STORAGE_REPLICATION:
|
||||
print "Storage replication is not enabled"
|
||||
else:
|
||||
backfill_replication()
|
||||
|
Reference in a new issue