Skip to content

Commit

Permalink
Teach client to talk to storage nodes in tahoe.cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
david415 committed Jan 15, 2014
1 parent 8ec0486 commit 1947a04
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 10 deletions.
33 changes: 33 additions & 0 deletions docs/configuration.rst
Expand Up @@ -386,6 +386,39 @@ Client Configuration
.. _performance.rst: performance.rst
.. _mutable.rst: specifications/mutable.rst

Client Server Selection
=======================

``[client-server-selection]``

``use_introducer = (Boolean, optional)``

This defaults to True. If set to False then the client will not
use any introducer.

Note that in the following configuration options "serverid" is not
literal but instead should be set to the appropriate serverid of a
given node.

``server.serverid.type = (type, mandatory)``

Right now only the 'tahoe-foolscap' storage server type is
supported.

``server.serverid.nickname = (nickname, mandatory)``

Storage server nickname.

``server.serverid.seed = (permutation-seed-base32, mandatory)``

Storage server seed.

``server.serverid.furl = (furl, mandatory)``

Storage server furl.



Frontend Configuration
======================

Expand Down
20 changes: 10 additions & 10 deletions src/allmydata/client.py
Expand Up @@ -179,6 +179,8 @@ def init_introducer_client(self):
# exit function if we are not supposed to use the introducer
if not self.get_config("client-server-selection", "use_introducer",
default=True, boolean=True):
self.introducer_client = None
self.introducer_furl = None
return

self.introducer_furl = self.get_config("client", "introducer.furl")
Expand Down Expand Up @@ -358,27 +360,25 @@ def init_client_storage_broker(self):

if pieces[0] == "server":
serverid = pieces[1]
if serverid not in server_params:
server_params[serverid] = {}
server_params[serverid][pieces[2]] = value
else:
# if not a server line then skip
continue
if serverid not in server_params:
server_params[serverid] = {}
server_params[serverid][pieces[2]] = value

for serverid, params in server_params.items():
server_type = params.pop("type")
if server_type == "tahoe-foolscap":
# BUG: create a legit looking announcement dict
ann = { }
s = NativeStorageServer(self._node_key, ann)
ann = { 'nickname': server_params[serverid]['nickname'], 'anonymous-storage-FURL':server_params[serverid]['furl'], 'permutation-seed-base32':server_params[serverid]['seed'], 'service-name':'storage','my-version':'unknown'}
s = storage_client.NativeStorageServer(serverid, ann.copy())
sb._got_announcement(serverid, ann)
#add_server(s.get_serverid(), s)
else:
msg = ("unrecognized server type '%s' in "
"tahoe.cfg [client-server-selection]server.%s.type"
% (server_type, serverid))
raise storage_client.UnknownServerTypeError(msg)
# BUG: create a legit looking announcement dict
ann = { }
sb._got_announcement(self._node_key, ann)
add_server(s.get_serverid(), s)

# check to see if we're supposed to use the introducer too
if self.get_config("client-server-selection", "use_introducer",
Expand Down
9 changes: 9 additions & 0 deletions src/allmydata/web/root.py
Expand Up @@ -202,6 +202,10 @@ def render_services(self, ctx, data):
return ctx.tag[ul]

def data_introducer_furl_prefix(self, ctx, data):

if not self.client.introducer_furl:
return

ifurl = self.client.introducer_furl
# trim off the secret swissnum
(prefix, _, swissnum) = ifurl.rpartition("/")
Expand Down Expand Up @@ -289,6 +293,11 @@ def render_service_row(self, ctx, server):
version = announcement["my-version"]
service_name = announcement["service-name"]

seed = announcement['permutation-seed-base32']
furl = announcement['anonymous-storage-FURL']

ctx.fillSlots("seed", seed)
ctx.fillSlots("furl", furl)
ctx.fillSlots("address", addr)
ctx.fillSlots("connected", connected)
ctx.fillSlots("connected-bool", bool(rhost))
Expand Down
6 changes: 6 additions & 0 deletions src/allmydata/web/welcome.xhtml
Expand Up @@ -167,6 +167,8 @@
<thead>
<tr n:pattern="header">
<td><h3>Nickname</h3></td>
<td><h3>Seed</h3></td>
<td><h3>FURL</h3></td>
<td><h3>Address</h3></td>
<td><h3>Service</h3></td>
<td><h3>Since</h3></td>
Expand All @@ -180,6 +182,10 @@
<div class="nickname"><n:slot name="nickname"/></div>
<div class="nodeid"><n:slot name="peerid"/></div>
</td>

<td class="seed"><n:slot name="seed"/></td>
<td class="furl"><n:slot name="furl"/></td>

<td class="address"><n:slot name="address"/></td>
<td class="service-service-name"><n:slot name="service_name"/></td>
<td class="service-since timestamp"><n:slot name="since"/></td>
Expand Down

0 comments on commit 1947a04

Please sign in to comment.