Ticket #999: snapshot-backend-config-parse.patch

File snapshot-backend-config-parse.patch, 6.0 KB (added by zooko, at 2011-09-21T21:12:15Z)

snapshot of work in progress

  • docs/configuration.rst

    diff -rN -u old-config-parse/docs/configuration.rst new-config-parse/docs/configuration.rst
    old new  
    417417
    418418``backend = disk``
    419419
    420     The default is to store shares on the local filesystem (in
     420    The storage server stores shares on the local filesystem (in
    421421    BASEDIR/storage/shares/). For configuration details (including how to
    422422    reserve a minimum amount of free space), see `<backends/disk.rst>`_.
    423423
    424 ``backend = S3``
     424``backend = s3``
    425425
    426     The storage server can store all shares to an Amazon Simple Storage
    427     Service (S3) bucket. For configuration details, see `<backends/S3.rst>`_.
     426    The storage server stores all shares to an Amazon Simple Storage Service
     427    (S3) bucket. For configuration details, see `<backends/S3.rst>`_.
     428
     429``backend = debug_discard``
     430
     431    The storage server stores all shares in /dev/null. This is actually used,
     432    for testing. It is not recommended for storage of data that you might
     433    want to retrieve in the future.
    428434
    429435
    430436Running A Helper
  • src/allmydata/client.py

    diff -rN -u old-config-parse/src/allmydata/client.py new-config-parse/src/allmydata/client.py
    old new  
    205205        self._secret_holder = SecretHolder(lease_secret, self.convergence)
    206206
    207207    def init_storage(self):
    208         # should we run a storage server (and publish it for others to use)?
     208        # Should we run a storage server (and publish it for others to use)?
    209209        if not self.get_config("storage", "enabled", True, boolean=True):
    210210            return
    211211        readonly = self.get_config("storage", "readonly", False, boolean=True)
    212212
    213         storedir = FilePath(self.basedir).child(self.STOREDIR)
     213        # What sort of backend?
     214        backendtype = self.get_config("storage", "backend", "disk"):
    214215
    215         data = self.get_config("storage", "reserved_space", None)
    216         reserved = None
    217         try:
    218             reserved = parse_abbreviated_size(data)
    219         except ValueError:
    220             log.msg("[storage]reserved_space= contains unparseable value %s"
    221                     % data)
    222         if reserved is None:
    223             reserved = 0
    224         discard = self.get_config("storage", "debug_discard", False,
    225                                   boolean=True)
     216        def config_disk_backend():
     217            storedir = FilePath(self.basedir).child(self.STOREDIR)
     218
     219            data = self.get_config("storage", "reserved_space", None)
     220            reserved = None
     221            try:
     222                reserved = parse_abbreviated_size(data)
     223            except ValueError:
     224                raise InvalidValueError("[storage]reserved_space= contains unparseable value %s"
     225                                        % data)
     226
     227            return DiskBackend(storedir, readonly, reserved)
     228
     229        def config_s3_backend():
     230            k
     231
     232
     233            backend = S3Backend(xxx )
     234
     235        def config_null_backend():
     236            return NullBackend()
     237
     238        backend_configgers = {
     239            'disk': config_disk_backend,
     240            's3': config_s3_backend,
     241            'debug_discard': config_null_backend,
     242            }
     243
     244        if backendtype not in backend_configgers:
     245            raise InvalidValueError("[storage]backend= is required to be one of %s, but was \"%s\"" % (backend_configgers.keys(), quote_output(backendtype),))
     246           
     247
     248        if backendtype == "disk":
     249        elif backendtype == "s3":
     250        elif backendtype == "debug_discard":
    226251
    227252        expire = self.get_config("storage", "expire.enabled", False, boolean=True)
    228253        if expire:
  • src/allmydata/node.py

    diff -rN -u old-config-parse/src/allmydata/node.py new-config-parse/src/allmydata/node.py
    old new  
    4040class _None: # used as a marker in get_config()
    4141    pass
    4242
     43class InvalidValueError(Exception):
     44    """ The configured value was not valid. """
     45
    4346class MissingConfigEntry(Exception):
    4447    """ A required config entry was not found. """
    4548
  • src/allmydata/storage/backends/disk/disk_backend.py

    diff -rN -u old-config-parse/src/allmydata/storage/backends/disk/disk_backend.py new-config-parse/src/allmydata/storage/backends/disk/disk_backend.py
    old new  
    4848class DiskBackend(Backend):
    4949    implements(IStorageBackend)
    5050
    51     def __init__(self, storedir, readonly=False, reserved_space=0, discard_storage=False):
     51    def __init__(self, storedir, readonly=False, reserved_space=0):
    5252        Backend.__init__(self)
    5353        self._setup_storage(storedir, readonly, reserved_space, discard_storage)
    5454        self._setup_corruption_advisory()
  • src/allmydata/test/test_backends.py

    diff -rN -u old-config-parse/src/allmydata/test/test_backends.py new-config-parse/src/allmydata/test/test_backends.py
    old new  
    374374        self.failUnlessReallyEqual(b.remote_read(0, datalen+20), client_data)
    375375        # If you start reading past the end of the file you get the empty string.
    376376        self.failUnlessReallyEqual(b.remote_read(datalen+1, 3), '')
     377
     378
     379class TestConfigureBackends(ReallyEqualMixin):
     380    def test_configure_disk_backend(self):
     381        xyz
  • src/allmydata/uri.py

    diff -rN -u old-config-parse/src/allmydata/uri.py new-config-parse/src/allmydata/uri.py
    old new  
    10781078        if 'hash' in k:
    10791079            unpacked[k] = base32.b2a(unpacked[k])
    10801080    return unpacked
    1081