Commit 017603f5 by Czémán Arnold

storage: remove redundant code and add doc

parent 17a4af7f
......@@ -90,6 +90,10 @@ class DataStore(Model):
@method_cache(30)
def get_orphan_disks(self, timeout=15):
"""Disk image files without Disk object in the database.
Exclude cloud-xxxxxxxx.dump format images.
:param timeout: Seconds before TimeOut exception
:type timeout: int
"""
queue_name = self.get_remote_queue_name('storage', "slow")
files = set(storage_tasks.list_files.apply_async(
......@@ -105,6 +109,9 @@ class DataStore(Model):
@method_cache(30)
def get_missing_disks(self, timeout=15):
"""Disk objects without disk image files.
:param timeout: Seconds before TimeOut exception
:type timeout: int
"""
queue_name = self.get_remote_queue_name('storage', "slow")
files = set(storage_tasks.list_files.apply_async(
......
......@@ -61,15 +61,11 @@ def list_orphan_disks(timeout=15):
Exclude cloud-xxxxxxxx.dump format images.
:param timeout: Seconds before TimeOut exception
:type timeoit: int
:type timeout: int
"""
import re
for ds in DataStore.objects.all():
queue_name = ds.get_remote_queue_name('storage', "slow")
files = set(storage_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:
for i in ds.get_orphan_disks(timeout=timeout):
if not re.match('cloud-[0-9]*\.dump', i):
logging.warning("Orphan disk: %s" % i)
......@@ -79,14 +75,9 @@ def list_missing_disks(timeout=15):
"""List Disk objects without disk image files.
:param timeout: Seconds before TimeOut exception
:type timeoit: int
:type timeout: int
"""
for ds in DataStore.objects.all():
queue_name = ds.get_remote_queue_name('storage', "slow")
files = set(storage_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:
for i in ds.get_missing_disks(timeout=timeout):
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