Add nickname/nodeid to storage-status web page. Closes #1204.

Also add tahoe.css to the page, to make it look slightly prettier.
This commit is contained in:
Brian Warner 2012-03-12 19:57:36 -07:00
parent dc28e3144a
commit 880af4e1fd
4 changed files with 19 additions and 10 deletions

View File

@ -3966,13 +3966,16 @@ class WebStatus(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin):
def test_status(self):
basedir = "storage/WebStatus/status"
fileutil.make_dirs(basedir)
ss = StorageServer(basedir, "\x00" * 20)
nodeid = "\x00" * 20
ss = StorageServer(basedir, nodeid)
ss.setServiceParent(self.s)
w = StorageStatus(ss)
w = StorageStatus(ss, "nickname")
d = self.render1(w)
def _check_html(html):
self.failUnlessIn("<h1>Storage Server Status</h1>", html)
s = remove_tags(html)
self.failUnlessIn("Server Nickname: nickname", s)
self.failUnlessIn("Server Nodeid: %s" % base32.b2a(nodeid), s)
self.failUnlessIn("Accepting new shares: Yes", s)
self.failUnlessIn("Reserved space: - 0 B (0)", s)
d.addCallback(_check_html)

View File

@ -142,7 +142,7 @@ class Root(rend.Page):
s = client.getServiceNamed("storage")
except KeyError:
s = None
self.child_storage = storage.StorageStatus(s)
self.child_storage = storage.StorageStatus(s, self.client.nickname)
self.child_uri = URIHandler(client)
self.child_cap = URIHandler(client)

View File

@ -3,7 +3,7 @@ import time, simplejson
from nevow import rend, tags as T, inevow
from allmydata.web.common import getxmlfile, abbreviate_time, get_arg
from allmydata.util.abbreviate import abbreviate_space
from allmydata.util import time_format
from allmydata.util import time_format, idlib
def remove_prefix(s, prefix):
if not s.startswith(prefix):
@ -14,9 +14,10 @@ class StorageStatus(rend.Page):
docFactory = getxmlfile("storage_status.xhtml")
# the default 'data' argument is the StorageServer instance
def __init__(self, storage):
def __init__(self, storage, nickname=""):
rend.Page.__init__(self, storage)
self.storage = storage
self.nickname = nickname
def renderHTTP(self, ctx):
req = inevow.IRequest(ctx)
@ -34,6 +35,11 @@ class StorageStatus(rend.Page):
}
return simplejson.dumps(d, indent=1) + "\n"
def data_nickname(self, ctx, storage):
return self.nickname
def data_nodeid(self, ctx, storage):
return idlib.nodeid_b2a(self.storage.my_nodeid)
def render_storage_running(self, ctx, storage):
if storage:
return ctx.tag

View File

@ -1,6 +1,7 @@
<html xmlns:n="http://nevow.com/ns/nevow/0.1">
<head>
<title>Tahoe-LAFS - Storage Server Status</title>
<link href="/tahoe.css" rel="stylesheet" type="text/css"/>
<link href="/icon.png" rel="shortcut icon" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
@ -53,12 +54,11 @@
</tr>
</table>
<ul n:data="stats">
<li>Accepting new shares:
<span n:render="bool" n:data="accepting_immutable_shares" /></li>
</ul>
<ul>
<li>Server Nickname: <span class="nickname mine" n:render="string" n:data="nickname" /></li>
<li>Server Nodeid: <span class="nodeid mine data-chars" n:render="string" n:data="nodeid" /></li>
<li n:data="stats">Accepting new shares:
<span n:render="bool" n:data="accepting_immutable_shares" /></li>
<li>Total buckets:
<span n:render="string" n:data="last_complete_bucket_count" />
(the number of files and directories for which this server is holding