mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-24 15:16:41 +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 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):
|
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
|
Get an ``IResource`` that can be published in the Tahoe-LAFS web interface
|
||||||
to expose information related to this plugin.
|
to expose information related to this plugin.
|
||||||
|
|
||||||
:param dict configuration: Any configuration given in the section for
|
:param allmydata.node._Config configuration: A representation of the
|
||||||
this plugin in the node's configuration file.
|
configuration for the node into which this plugin has been loaded.
|
||||||
|
|
||||||
:rtype: ``IResource``
|
:rtype: ``IResource``
|
||||||
"""
|
"""
|
||||||
|
@ -292,8 +292,13 @@ class _Config(object):
|
|||||||
"Unable to write config file '{}'".format(fn),
|
"Unable to write config file '{}'".format(fn),
|
||||||
)
|
)
|
||||||
|
|
||||||
def items(self, section):
|
def items(self, section, default=_None):
|
||||||
return self.config.items(section)
|
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):
|
def get_config(self, section, option, default=_None, boolean=False):
|
||||||
try:
|
try:
|
||||||
|
@ -197,10 +197,16 @@ class StorageFarmBroker(service.MultiService):
|
|||||||
storage_server.setServiceParent(self)
|
storage_server.setServiceParent(self)
|
||||||
storage_server.start_connecting(self._trigger_connections)
|
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
|
Get all of the client-side ``IResource`` implementations provided by
|
||||||
enabled storage plugins.
|
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 = {
|
plugins = {
|
||||||
plugin.name: plugin
|
plugin.name: plugin
|
||||||
@ -208,7 +214,7 @@ class StorageFarmBroker(service.MultiService):
|
|||||||
in getPlugins(IFoolscapStoragePlugin)
|
in getPlugins(IFoolscapStoragePlugin)
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
name: plugins[name].get_client_resource(config)
|
name: plugins[name].get_client_resource(node_config)
|
||||||
for (name, config)
|
for (name, config)
|
||||||
in self.storage_client_config.storage_plugins.items()
|
in self.storage_client_config.storage_plugins.items()
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,10 @@ class RIDummy(RemoteInterface):
|
|||||||
class DummyStorage(object):
|
class DummyStorage(object):
|
||||||
name = attr.ib()
|
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):
|
def get_storage_server(self, configuration, get_anonymous_storage_server):
|
||||||
if u"invalid" in configuration:
|
if u"invalid" in configuration:
|
||||||
raise Exception("The plugin is unhappy.")
|
raise Exception("The plugin is unhappy.")
|
||||||
@ -69,8 +73,11 @@ class DummyStorage(object):
|
|||||||
:return: A static data resource that produces the given configuration when
|
:return: A static data resource that produces the given configuration when
|
||||||
rendered, as an aid to testing.
|
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)
|
@implementer(RIDummy)
|
||||||
|
Loading…
Reference in New Issue
Block a user