mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-22 22:32:23 +00:00
hack in grid-manager announcements to storage-servers
This commit is contained in:
parent
c76d25ed87
commit
64eb9d7c30
@ -1,4 +1,9 @@
|
|||||||
import os, stat, time, weakref
|
import os
|
||||||
|
import stat
|
||||||
|
import time
|
||||||
|
import weakref
|
||||||
|
import json
|
||||||
|
from allmydata import node
|
||||||
from base64 import urlsafe_b64encode
|
from base64 import urlsafe_b64encode
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from errno import ENOENT, EPERM
|
from errno import ENOENT, EPERM
|
||||||
@ -564,23 +569,54 @@ class _Client(node.Node, pollmixin.PollMixin):
|
|||||||
sharetypes.append("mutable")
|
sharetypes.append("mutable")
|
||||||
expiration_sharetypes = tuple(sharetypes)
|
expiration_sharetypes = tuple(sharetypes)
|
||||||
|
|
||||||
ss = StorageServer(storedir, self.nodeid,
|
ss = StorageServer(
|
||||||
reserved_space=reserved,
|
storedir, self.nodeid,
|
||||||
discard_storage=discard,
|
reserved_space=reserved,
|
||||||
readonly_storage=readonly,
|
discard_storage=discard,
|
||||||
stats_provider=self.stats_provider,
|
readonly_storage=readonly,
|
||||||
expiration_enabled=expire,
|
stats_provider=self.stats_provider,
|
||||||
expiration_mode=mode,
|
expiration_enabled=expire,
|
||||||
expiration_override_lease_duration=o_l_d,
|
expiration_mode=mode,
|
||||||
expiration_cutoff_date=cutoff_date,
|
expiration_override_lease_duration=o_l_d,
|
||||||
expiration_sharetypes=expiration_sharetypes)
|
expiration_cutoff_date=cutoff_date,
|
||||||
|
expiration_sharetypes=expiration_sharetypes,
|
||||||
|
)
|
||||||
ss.setServiceParent(self)
|
ss.setServiceParent(self)
|
||||||
|
|
||||||
furl_file = self.config.get_private_path("storage.furl").encode(get_filesystem_encoding())
|
grid_manager_certificates = []
|
||||||
|
cert_fnames = self.get_config("storage", "grid_manager_certificate_files", "")
|
||||||
|
for fname in cert_fnames.split():
|
||||||
|
fname = abspath_expanduser_unicode(fname.decode('ascii'), base=self.basedir)
|
||||||
|
if not os.path.exists(fname):
|
||||||
|
raise ValueError(
|
||||||
|
"Grid Manager certificate file '{}' doesn't exist".format(
|
||||||
|
fname
|
||||||
|
)
|
||||||
|
)
|
||||||
|
with open(fname, 'r') as f:
|
||||||
|
cert = json.load(f)
|
||||||
|
if set(cert.keys()) != {"certificate", "signature"}:
|
||||||
|
raise ValueError(
|
||||||
|
"Unknown key in Grid Manager certificate '{}'".format(
|
||||||
|
fname
|
||||||
|
)
|
||||||
|
)
|
||||||
|
grid_manager_certificates.append(cert)
|
||||||
|
|
||||||
|
# XXX we should probably verify that the certificates are
|
||||||
|
# valid and not expired, as that could be confusing for the
|
||||||
|
# storage-server operator -- but then we need the public key
|
||||||
|
# of the Grid Manager (should that go in the config too,
|
||||||
|
# then? How to handle multiple grid-managers?)
|
||||||
|
|
||||||
|
|
||||||
|
furl_file = os.path.join(self.basedir, "private", "storage.furl").encode(get_filesystem_encoding())
|
||||||
furl = self.tub.registerReference(ss, furlFile=furl_file)
|
furl = self.tub.registerReference(ss, furlFile=furl_file)
|
||||||
ann = {"anonymous-storage-FURL": furl,
|
ann = {
|
||||||
"permutation-seed-base32": self._init_permutation_seed(ss),
|
"anonymous-storage-FURL": furl,
|
||||||
}
|
"permutation-seed-base32": self._init_permutation_seed(ss),
|
||||||
|
"grid-manager-certificates": grid_manager_certificates,
|
||||||
|
}
|
||||||
for ic in self.introducer_clients:
|
for ic in self.introducer_clients:
|
||||||
ic.publish("storage", ann, self._node_key)
|
ic.publish("storage", ann, self._node_key)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user