Add storage_dir config field

On the [storage] section of the tahoe.cfg now there is a field
'storage_dir' where the path to the storage folder can be configured.
This commit is contained in:
Ruben Pollan 2014-08-16 02:50:17 -05:00 committed by Jean-Paul Calderone
parent a1cb401f06
commit 136de7d7f7
4 changed files with 33 additions and 5 deletions

View File

@ -784,6 +784,14 @@ Storage Server Configuration
.. _#390: https://tahoe-lafs.org/trac/tahoe-lafs/ticket/390
``storage_dir = (string, optional)``
This specifies a storing directory.
The default value is the ``storage`` directory in the node's base directory
(i.e. ``BASEDIR/storage``), but it can be placed elsewhere. Relative paths
will be interpreted relative to the node's base directory.
Running A Helper
================
@ -1105,16 +1113,16 @@ a legal one.
log_gatherer.furl = pb://soklj4y7eok5c3xkmjeqpw@192.168.69.247:44801/eqpwqtzm
timeout.keepalive = 240
timeout.disconnect = 1800
[client]
introducer.furl = pb://ok45ssoklj4y7eok5c3xkmj@tcp:tahoe.example:44801/ii3uumo
helper.furl = pb://ggti5ssoklj4y7eok5c3xkmj@tcp:helper.tahoe.example:7054/kk8lhr
[storage]
enabled = True
readonly = True
reserved_space = 10000000000
[helper]
enabled = True

View File

@ -350,7 +350,8 @@ class _Client(node.Node, pollmixin.PollMixin):
"is not listening ('tub.port=' is empty)")
readonly = self.get_config("storage", "readonly", False, boolean=True)
storedir = os.path.join(self.basedir, self.STOREDIR)
config_storedir = self.get_config("storage", "storage_dir", self.STOREDIR).decode('utf-8')
storedir = os.path.join(self.basedir, config_storedir)
data = self.get_config("storage", "reserved_space", None)
try:

View File

@ -177,7 +177,8 @@ class CreateClientOptions(_CreateBaseOptions):
class CreateNodeOptions(CreateClientOptions):
optFlags = [
("no-storage", None, "Do not offer storage service to other nodes."),
] + TOR_FLAGS + I2P_FLAGS
("storage-dir", "s", None, "Path where the storage will be placed."),
] + TOR_FLAGS + I2P_FLAGS
synopsis = "[options] [NODEDIR]"
description = "Create a full Tahoe-LAFS node (client+server)."
@ -320,6 +321,11 @@ def write_client_config(c, config):
c.write("enabled = %s\n" % boolstr[storage_enabled])
c.write("#readonly =\n")
c.write("reserved_space = 1G\n")
storage_dir = config.get("storage-dir")
if storage_dir:
c.write("storage_dir = %s\n" % (storage_dir,))
else:
c.write("#storage_dir =\n")
c.write("#expire.enabled =\n")
c.write("#expire.mode =\n")
c.write("\n")

View File

@ -12,6 +12,7 @@ from allmydata.frontends.auth import NeedRootcapLookupScheme
from allmydata import client
from allmydata.storage_client import StorageFarmBroker
from allmydata.util import base32, fileutil
from allmydata.util.fileutil import abspath_expanduser_unicode
from allmydata.interfaces import IFilesystemNode, IFileNode, \
IImmutableFileNode, IMutableFileNode, IDirectoryNode
from foolscap.api import flushEventualQueue
@ -251,6 +252,18 @@ class Basic(testutil.ReallyEqualMixin, testutil.NonASCIIPathMixin, unittest.Test
"port = tcp:0:interface=127.0.0.1\n"))
self.failUnlessRaises(NeedRootcapLookupScheme, client.create_client, basedir)
def test_storage_dir(self):
basedir = u"client.Basic.test_storage_dir"
os.mkdir(basedir)
fileutil.write(os.path.join(basedir, "tahoe.cfg"),
BASECONFIG +
"[storage]\n" +
"enabled = true\n" +
"storage_dir = myowndir\n")
c = client.Client(basedir)
self.failUnlessEqual(c.getServiceNamed("storage").storedir,
os.path.join(abspath_expanduser_unicode(basedir), u"myowndir"))
def _permute(self, sb, key):
return [ s.get_longname() for s in sb.get_servers_for_psi(key) ]