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

def make_pool(name, size, mode):
	_pybakeserver.make_pool(name, size, mode)

class BakeProvider(pymargo.Provider):

12 13 14
	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
15 16

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

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

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

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

	def list_storage_targets(self):
30
		return _pybakeserver.list_storage_targets(self._provider)