Commit 0bd5e524 by Őry Máté

storage: fix coding style

parent 18b4e814
......@@ -12,6 +12,7 @@ logger = logging.getLogger(__name__)
@celery.task
def garbage_collector(timeout=15):
""" Garbage collector for disk images.
Moves 1 day old deleted images to trash folder.
If there is not enough free space on datastore (default 10%)
deletes oldest images from trash.
......@@ -40,6 +41,7 @@ def garbage_collector(timeout=15):
@celery.task
def list_orphan_disks(timeout=15):
"""List disk image files without Disk object in the database.
Exclude cloud-xxxxxxxx.dump format images.
:param timeout: Seconds before TimeOut exception
......@@ -48,10 +50,10 @@ def list_orphan_disks(timeout=15):
import re
for ds in DataStore.objects.all():
queue_name = ds.get_remote_queue_name('storage')
file_list = remote_tasks.list_files.apply_async(
args=[ds.path], queue=queue_name).get(timeout=timeout)
disk_list = [disk.filename for disk in ds.disk_set.all()]
for i in set(file_list).difference(disk_list):
files = set(remote_tasks.list_files.apply_async(
args=[ds.path], queue=queue_name).get(timeout=timeout))
disks = set([disk.filename for disk in ds.disk_set.all()])
for i in files - disks:
if not re.match('cloud-[0-9]*\.dump', i):
logging.warning("Orphan disk: %s" % i)
......@@ -65,10 +67,10 @@ def list_missing_disks(timeout=15):
"""
for ds in DataStore.objects.all():
queue_name = ds.get_remote_queue_name('storage')
file_list = remote_tasks.list_files.apply_async(
args=[ds.path], queue=queue_name).get(timeout=timeout)
disk_list = [disk.filename for disk in
ds.disk_set.filter(destroyed__isnull=True)]
for i in set(disk_list).difference(file_list):
files = set(remote_tasks.list_files.apply_async(
args=[ds.path], queue=queue_name).get(timeout=timeout))
disks = set([disk.filename for disk in
ds.disk_set.filter(destroyed__isnull=True)])
for i in disks - files:
logging.critical("Image: %s is missing from %s datastore."
% (i, ds.path))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment