Commit 4e70ff47 by Fukász Rómeó Ervin

ceph: add get_file_statistics ceph implementation

parent fad6cdd0
...@@ -127,27 +127,25 @@ def get_storage_stat(data_store_type, path): ...@@ -127,27 +127,25 @@ def get_storage_stat(data_store_type, path):
@celery.task() @celery.task()
def get_file_statistics(data_store_type, datastore): def get_file_statistics(data_store_type, path_or_pool):
if data_store_type == 'ceph_block': if data_store_type == 'ceph_block':
# TODO get proper data pool = path_or_pool
disks = [] disk_list = list(data_store_type, str(pool))
dumps = [] disks = [ceph_disk for ceph_disk in disk_list
trash = [] if not ceph_disk['name'].endswith('.dump')]
dumps = [ceph_disk for ceph_disk in disk_list
if ceph_disk['name'].endswith('.dump')]
else: else:
disks = [Disk.get(datastore, name).get_desc() ds_path = path_or_pool
for name in listdir(datastore) disks = [Disk.get(ds_path, name).get_desc()
for name in listdir(ds_path)
if not name.endswith(".dump") and if not name.endswith(".dump") and
not path.isdir(path.join(datastore, name))] not path.isdir(path.join(ds_path, name))]
dumps = [{'name': name, dumps = [{'name': name,
'size': path.getsize(path.join(datastore, name))} 'size': path.getsize(path.join(ds_path, name))}
for name in listdir(datastore) if name.endswith(".dump")] for name in listdir(ds_path) if name.endswith(".dump")]
trash = [{'name': name,
'size': path.getsize(path.join(datastore, trash_directory,
name))}
for name in listdir(path.join(datastore, trash_directory))]
return { return {
'dumps': dumps, 'dumps': dumps,
'trash': trash,
'disks': disks, 'disks': disks,
} }
......
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