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) |
---|
-
docs/configuration.rst
diff -rN -u old-config-parse/docs/configuration.rst new-config-parse/docs/configuration.rst
old new 417 417 418 418 ``backend = disk`` 419 419 420 The default is to storeshares on the local filesystem (in420 The storage server stores shares on the local filesystem (in 421 421 BASEDIR/storage/shares/). For configuration details (including how to 422 422 reserve a minimum amount of free space), see `<backends/disk.rst>`_. 423 423 424 ``backend = S3``424 ``backend = s3`` 425 425 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. 428 434 429 435 430 436 Running 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 205 205 self._secret_holder = SecretHolder(lease_secret, self.convergence) 206 206 207 207 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)? 209 209 if not self.get_config("storage", "enabled", True, boolean=True): 210 210 return 211 211 readonly = self.get_config("storage", "readonly", False, boolean=True) 212 212 213 storedir = FilePath(self.basedir).child(self.STOREDIR) 213 # What sort of backend? 214 backendtype = self.get_config("storage", "backend", "disk"): 214 215 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": 226 251 227 252 expire = self.get_config("storage", "expire.enabled", False, boolean=True) 228 253 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 40 40 class _None: # used as a marker in get_config() 41 41 pass 42 42 43 class InvalidValueError(Exception): 44 """ The configured value was not valid. """ 45 43 46 class MissingConfigEntry(Exception): 44 47 """ A required config entry was not found. """ 45 48 -
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 48 48 class DiskBackend(Backend): 49 49 implements(IStorageBackend) 50 50 51 def __init__(self, storedir, readonly=False, reserved_space=0 , discard_storage=False):51 def __init__(self, storedir, readonly=False, reserved_space=0): 52 52 Backend.__init__(self) 53 53 self._setup_storage(storedir, readonly, reserved_space, discard_storage) 54 54 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 374 374 self.failUnlessReallyEqual(b.remote_read(0, datalen+20), client_data) 375 375 # If you start reading past the end of the file you get the empty string. 376 376 self.failUnlessReallyEqual(b.remote_read(datalen+1, 3), '') 377 378 379 class 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 1078 1078 if 'hash' in k: 1079 1079 unpacked[k] = base32.b2a(unpacked[k]) 1080 1080 return unpacked 1081