From: Daira Hopwood Date: Fri, 17 May 2013 16:39:20 +0000 (+0100) Subject: Refactoring to make backend configuration accessible from outside Client. refs #1971 X-Git-Url: https://git.rkrishnan.org/vdrive/quickstart.html?a=commitdiff_plain;h=6cb76559d5cd92b912d1b8b8cc256f5d1b7ae5f7;p=tahoe-lafs%2Ftahoe-lafs.git Refactoring to make backend configuration accessible from outside Client. refs #1971 Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 9f56a7d1..6218d5b9 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -262,16 +262,14 @@ class Client(node.Node, pollmixin.PollMixin): self.write_config("permutation-seed", seed+"\n") return seed.strip() - def init_storage(self): - self.accountant = None - # Should we run a storage server (and publish it for others to use)? - if not self.get_config("storage", "enabled", True, boolean=True): - return + @classmethod + def configure_backend(cls, config): + """This is also called directly by the implementation of 'tahoe admin create-container'.""" - storedir = os.path.join(self.basedir, self.STOREDIR) + storedir = os.path.join(config.basedir, cls.STOREDIR) # What sort of backend? - backendtype = self.get_config("storage", "backend", "disk") + backendtype = config.get_config("storage", "backend", "disk") if backendtype == "s3": backendtype = "cloud.s3" backendprefix = backendtype.partition('.')[0] @@ -285,9 +283,18 @@ class Client(node.Node, pollmixin.PollMixin): if backendprefix not in backend_configurators: raise InvalidValueError("%s is not supported; it must start with one of %s" - % (quote_output("[storage]backend = " + backendtype), backend_configurators.keys()) ) + % (quote_output("[storage]backend = " + backendtype), + backend_configurators.keys()) ) + + return (backend_configurators[backendprefix](storedir, config), storedir) + + def init_storage(self): + self.accountant = None + # Should we run a storage server (and publish it for others to use)? + if not self.get_config("storage", "enabled", True, boolean=True): + return - backend = backend_configurators[backendprefix](storedir, self) + (backend, storedir) = self.configure_backend(self) if self.get_config("storage", "debug_discard", False, boolean=True): raise OldConfigOptionError("[storage]debug_discard = True is no longer supported.")