server.py 1.14 KB
Newer Older
Matthieu Dorier's avatar
Matthieu Dorier committed
1 2
# (C) 2018 The University of Chicago
# See COPYRIGHT in top-level directory.
3
import _pybaketarget
Matthieu Dorier's avatar
Matthieu Dorier committed
4 5
import _pybakeserver
import pymargo
Matthieu Dorier's avatar
Matthieu Dorier committed
6
from pybake.target import BakeTargetID
Matthieu Dorier's avatar
Matthieu Dorier committed
7 8

def make_pool(name, size, mode):
9
    _pybakeserver.make_pool(name, size, mode)
Matthieu Dorier's avatar
Matthieu Dorier committed
10 11 12

class BakeProvider(pymargo.Provider):

13 14 15
    def __init__(self, mid, provider_id):
        super(BakeProvider, self).__init__(mid, provider_id)
        self._provider = _pybakeserver.register(mid._mid, provider_id)
Matthieu Dorier's avatar
Matthieu Dorier committed
16

17 18 19
    def add_storage_target(self, name):
        tid = _pybakeserver.add_storage_target(self._provider, name)
        return BakeTargetID(tid)
Matthieu Dorier's avatar
Matthieu Dorier committed
20

21 22
    def remove_storage_target(self, target):
        return _pybakeserver.remove_storage_target(self._provider, target._tid)
Matthieu Dorier's avatar
Matthieu Dorier committed
23

24 25
    def remove_all_storage_targets(self):
        return _pybakeserver.remove_all_storage_targets(self._provider)
Matthieu Dorier's avatar
Matthieu Dorier committed
26

27 28
    def count_storage_targets(self):
        return _pybakeserver.count_storage_targets(self._provider)
Matthieu Dorier's avatar
Matthieu Dorier committed
29

30 31 32 33 34 35
    def list_storage_targets(self):
        l = _pybakeserver.list_storage_targets(self._provider)
        if(l is None):
            return []
        else:
            return [ BakeTargetID(tid) for tid in l ]