storagedriver.py 858 Bytes
Newer Older
1
from disk import Disk
Guba Sándor committed
2
from storagecelery import celery
3
from os import path, unlink
Bach Dániel committed
4

5
@celery.task()
6
def list(dir):
Dudás Ádám committed
7
    return [d.get_desc() for d in Disk.list(dir)]
Bach Dániel committed
8 9


10
@celery.task()
11
def create(disk_desc):
Dudás Ádám committed
12
    disk = Disk.deserialize(disk_desc)
13
    disk.create()
Bach Dániel committed
14 15


16
@celery.task()
17 18
def delete(json_data):
    disk = Disk.deserialize(json_data)
19
    disk.delete()
Bach Dániel committed
20 21


22
@celery.task()
23 24 25 26 27 28
def delete_dump():
    if path.endswith(".dump") and os.path.isfile(path):
        os.unlink(path)


@celery.task()
Guba Sándor committed
29
def snapshot(json_data):
30
    disk = Disk.deserialize(json_data)
Guba Sándor committed
31 32 33 34
    disk.snapshot()


@celery.task()
Guba Sándor committed
35
def merge(old_json, new_json):
36 37
    disk = Disk.deserialize(old_json)
    new_disk = Disk.deserialize(new_json)
Guba Sándor committed
38 39 40 41
    disk.merge(new_disk)


@celery.task()
42
def get(json_data):
Guba Sándor committed
43 44
    disk = Disk.get(dir=json_data['dir'], name=json_data['name'])
    return disk.get_desc()