mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 13:07:56 +00:00
Merge pull request #650 from tahoe-lafs/3242.pass-config-object-to-storage-plugin-client-resource
Pass _Config object to storage plugin client resource Fixes: ticket:3242
This commit is contained in:
commit
2c9e724996
0
newsfragments/3242.minor
Normal file
0
newsfragments/3242.minor
Normal file
@ -895,7 +895,9 @@ class _Client(node.Node, pollmixin.PollMixin):
|
||||
|
||||
:return dict[bytes, IResource provider]: The implementations.
|
||||
"""
|
||||
return self.storage_broker.get_client_storage_plugin_web_resources()
|
||||
return self.storage_broker.get_client_storage_plugin_web_resources(
|
||||
self.config,
|
||||
)
|
||||
|
||||
def _enable_storage_servers(self, announceable_storage_servers):
|
||||
"""
|
||||
|
@ -3122,8 +3122,8 @@ class IFoolscapStoragePlugin(IPlugin):
|
||||
Get an ``IResource`` that can be published in the Tahoe-LAFS web interface
|
||||
to expose information related to this plugin.
|
||||
|
||||
:param dict configuration: Any configuration given in the section for
|
||||
this plugin in the node's configuration file.
|
||||
:param allmydata.node._Config configuration: A representation of the
|
||||
configuration for the node into which this plugin has been loaded.
|
||||
|
||||
:rtype: ``IResource``
|
||||
"""
|
||||
|
@ -292,8 +292,13 @@ class _Config(object):
|
||||
"Unable to write config file '{}'".format(fn),
|
||||
)
|
||||
|
||||
def items(self, section):
|
||||
return self.config.items(section)
|
||||
def items(self, section, default=_None):
|
||||
try:
|
||||
return self.config.items(section)
|
||||
except ConfigParser.NoSectionError:
|
||||
if default is _None:
|
||||
raise
|
||||
return default
|
||||
|
||||
def get_config(self, section, option, default=_None, boolean=False):
|
||||
try:
|
||||
|
@ -197,10 +197,16 @@ class StorageFarmBroker(service.MultiService):
|
||||
storage_server.setServiceParent(self)
|
||||
storage_server.start_connecting(self._trigger_connections)
|
||||
|
||||
def get_client_storage_plugin_web_resources(self):
|
||||
def get_client_storage_plugin_web_resources(self, node_config):
|
||||
"""
|
||||
Get all of the client-side ``IResource`` implementations provided by
|
||||
enabled storage plugins.
|
||||
|
||||
:param allmydata.node._Config node_config: The complete node
|
||||
configuration for the node from which these web resources will be
|
||||
served.
|
||||
|
||||
:return dict[unicode, IResource]: Resources for all of the plugins.
|
||||
"""
|
||||
plugins = {
|
||||
plugin.name: plugin
|
||||
@ -208,7 +214,7 @@ class StorageFarmBroker(service.MultiService):
|
||||
in getPlugins(IFoolscapStoragePlugin)
|
||||
}
|
||||
return {
|
||||
name: plugins[name].get_client_resource(config)
|
||||
name: plugins[name].get_client_resource(node_config)
|
||||
for (name, config)
|
||||
in self.storage_client_config.storage_plugins.items()
|
||||
}
|
||||
|
@ -48,6 +48,10 @@ class RIDummy(RemoteInterface):
|
||||
class DummyStorage(object):
|
||||
name = attr.ib()
|
||||
|
||||
@property
|
||||
def _client_section_name(self):
|
||||
return u"storageclient.plugins.{}".format(self.name)
|
||||
|
||||
def get_storage_server(self, configuration, get_anonymous_storage_server):
|
||||
if u"invalid" in configuration:
|
||||
raise Exception("The plugin is unhappy.")
|
||||
@ -69,8 +73,11 @@ class DummyStorage(object):
|
||||
:return: A static data resource that produces the given configuration when
|
||||
rendered, as an aid to testing.
|
||||
"""
|
||||
return Data(dumps(configuration), b"text/json")
|
||||
|
||||
items = configuration.items(self._client_section_name, [])
|
||||
return Data(
|
||||
dumps(dict(items)),
|
||||
b"text/json",
|
||||
)
|
||||
|
||||
|
||||
@implementer(RIDummy)
|
||||
|
Loading…
Reference in New Issue
Block a user