mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-20 03:36:25 +00:00
introweb: combine announcement and subscriber information to show version+nickname for each client
This commit is contained in:
parent
c21d30c320
commit
89be2e1bea
@ -880,7 +880,7 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
self.failUnless("allmydata: %s" % str(allmydata.__version__)
|
self.failUnless("allmydata: %s" % str(allmydata.__version__)
|
||||||
in res)
|
in res)
|
||||||
self.failUnless("Clients:" in res)
|
self.failUnless("Summary: storage: 5, stub_client: 5" in res)
|
||||||
except unittest.FailTest:
|
except unittest.FailTest:
|
||||||
print
|
print
|
||||||
print "GET %s output was:" % self.introweb_url
|
print "GET %s output was:" % self.introweb_url
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<html xmlns:n="http://nevow.com/ns/nevow/0.1">
|
<html xmlns:n="http://nevow.com/ns/nevow/0.1">
|
||||||
<head>
|
<head>
|
||||||
<title>AllMyData - Tahoe</title>
|
<title>Introducer Status - AllMyData Tahoe</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -15,9 +15,8 @@
|
|||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<div>Storage Servers: <span n:render="string" n:data="known_storage_servers" /> known</div>
|
<div>Announcement Summary: <span n:render="announcement_summary" /></div>
|
||||||
|
<div>Subscription Summary: <span n:render="client_summary" /></div>
|
||||||
<div>Clients: <span n:render="string" n:data="num_clients" /> subscribed</div>
|
|
||||||
|
|
||||||
<h2>Service Announcements</h2>
|
<h2>Service Announcements</h2>
|
||||||
|
|
||||||
@ -46,10 +45,11 @@
|
|||||||
<div>
|
<div>
|
||||||
<table n:render="sequence" n:data="subscribers" border="1">
|
<table n:render="sequence" n:data="subscribers" border="1">
|
||||||
<tr n:pattern="header">
|
<tr n:pattern="header">
|
||||||
<td>PeerID</td>
|
<td>PeerID / Nickname</td>
|
||||||
<td>Advertised IPs</td>
|
<td>Advertised IPs</td>
|
||||||
<td>Connected From</td>
|
<td>Connected From</td>
|
||||||
<td>Since</td>
|
<td>Since</td>
|
||||||
|
<td>Version</td>
|
||||||
<td>Subscribed To</td>
|
<td>Subscribed To</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr n:pattern="item" n:render="subscriber_row">
|
<tr n:pattern="item" n:render="subscriber_row">
|
||||||
@ -57,6 +57,7 @@
|
|||||||
<td><tt><n:slot name="advertised"/></tt></td>
|
<td><tt><n:slot name="advertised"/></tt></td>
|
||||||
<td><tt><n:slot name="connected"/></tt></td>
|
<td><tt><n:slot name="connected"/></tt></td>
|
||||||
<td><tt><n:slot name="since"/></tt></td>
|
<td><tt><n:slot name="since"/></tt></td>
|
||||||
|
<td><tt><n:slot name="version"/></tt></td>
|
||||||
<td><tt><n:slot name="service_name"/></tt></td>
|
<td><tt><n:slot name="service_name"/></tt></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr n:pattern="empty"><td>no peers!</td></tr>
|
<tr n:pattern="empty"><td>no peers!</td></tr>
|
||||||
|
@ -19,25 +19,32 @@ class IntroducerRoot(rend.Page):
|
|||||||
def data_my_nodeid(self, ctx, data):
|
def data_my_nodeid(self, ctx, data):
|
||||||
return idlib.nodeid_b2a(IClient(ctx).nodeid)
|
return idlib.nodeid_b2a(IClient(ctx).nodeid)
|
||||||
|
|
||||||
def data_known_storage_servers(self, ctx, data):
|
def render_announcement_summary(self, ctx, data):
|
||||||
i = IClient(ctx).getServiceNamed("introducer")
|
i = IClient(ctx).getServiceNamed("introducer")
|
||||||
storage = [1
|
services = {}
|
||||||
for (furl, service_name, ri_name, nickname, ver, oldest)
|
for ann in i.get_announcements():
|
||||||
in i.get_announcements()
|
(furl, service_name, ri_name, nickname, ver, oldest) = ann
|
||||||
if service_name == "storage"]
|
if service_name not in services:
|
||||||
return len(storage)
|
services[service_name] = 0
|
||||||
|
services[service_name] += 1
|
||||||
|
service_names = services.keys()
|
||||||
|
service_names.sort()
|
||||||
|
return ", ".join(["%s: %d" % (service_name, services[service_name])
|
||||||
|
for service_name in service_names])
|
||||||
|
|
||||||
def data_num_clients(self, ctx, data):
|
def render_client_summary(self, ctx, data):
|
||||||
i = IClient(ctx).getServiceNamed("introducer")
|
i = IClient(ctx).getServiceNamed("introducer")
|
||||||
num_clients = 0
|
clients = i.get_subscribers()
|
||||||
subscribers = i.get_subscribers()
|
service_names = clients.keys()
|
||||||
for service_name,who in subscribers.items():
|
service_names.sort()
|
||||||
num_clients += len(who)
|
return ", ".join(["%s: %d" % (service_name, len(clients[service_name]))
|
||||||
return num_clients
|
for service_name in service_names])
|
||||||
|
|
||||||
def data_services(self, ctx, data):
|
def data_services(self, ctx, data):
|
||||||
i = IClient(ctx).getServiceNamed("introducer")
|
i = IClient(ctx).getServiceNamed("introducer")
|
||||||
ann = list(i.get_announcements())
|
ann = [a
|
||||||
|
for a in i.get_announcements()
|
||||||
|
if a[1] != "stub_client"]
|
||||||
ann.sort(lambda a,b: cmp( (a[1], a), (b[1], b) ) )
|
ann.sort(lambda a,b: cmp( (a[1], a), (b[1], b) ) )
|
||||||
return ann
|
return ann
|
||||||
|
|
||||||
@ -45,8 +52,9 @@ class IntroducerRoot(rend.Page):
|
|||||||
(furl, service_name, ri_name, nickname, ver, oldest) = announcement
|
(furl, service_name, ri_name, nickname, ver, oldest) = announcement
|
||||||
sr = SturdyRef(furl)
|
sr = SturdyRef(furl)
|
||||||
nodeid = sr.tubID
|
nodeid = sr.tubID
|
||||||
advertised = [loc.split(":")[0] for loc in sr.locationHints]
|
advertised = [loc.split(":")[0] for loc in sr.locationHints
|
||||||
ctx.fillSlots("peerid", "%s %s" % (idlib.nodeid_b2a(nodeid), nickname))
|
if not loc.startswith("127.0.0.1:")]
|
||||||
|
ctx.fillSlots("peerid", "%s %s" % (nodeid, nickname))
|
||||||
ctx.fillSlots("advertised", " ".join(advertised))
|
ctx.fillSlots("advertised", " ".join(advertised))
|
||||||
ctx.fillSlots("connected", "?")
|
ctx.fillSlots("connected", "?")
|
||||||
ctx.fillSlots("since", "?")
|
ctx.fillSlots("since", "?")
|
||||||
@ -57,23 +65,40 @@ class IntroducerRoot(rend.Page):
|
|||||||
|
|
||||||
def data_subscribers(self, ctx, data):
|
def data_subscribers(self, ctx, data):
|
||||||
i = IClient(ctx).getServiceNamed("introducer")
|
i = IClient(ctx).getServiceNamed("introducer")
|
||||||
|
# use the "stub_client" announcements to get information per nodeid
|
||||||
|
clients = {}
|
||||||
|
for ann in i.get_announcements():
|
||||||
|
if ann[1] != "stub_client":
|
||||||
|
continue
|
||||||
|
(furl, service_name, ri_name, nickname, ver, oldest) = ann
|
||||||
|
sr = SturdyRef(furl)
|
||||||
|
nodeid = sr.tubID
|
||||||
|
clients[nodeid] = ann
|
||||||
|
|
||||||
|
# then we actually provide information per subscriber
|
||||||
s = []
|
s = []
|
||||||
for service_name, subscribers in i.get_subscribers().items():
|
for service_name, subscribers in i.get_subscribers().items():
|
||||||
for rref in subscribers:
|
for rref in subscribers:
|
||||||
s.append( (service_name, rref) )
|
sr = rref.getSturdyRef()
|
||||||
|
nodeid = sr.tubID
|
||||||
|
ann = clients.get(nodeid)
|
||||||
|
s.append( (service_name, rref, ann) )
|
||||||
s.sort()
|
s.sort()
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def render_subscriber_row(self, ctx, s):
|
def render_subscriber_row(self, ctx, s):
|
||||||
(service_name, rref) = s
|
(service_name, rref, ann) = s
|
||||||
|
nickname = "?"
|
||||||
|
version = "?"
|
||||||
|
if ann:
|
||||||
|
(furl, service_name_2, ri_name, nickname, version, oldest) = ann
|
||||||
|
|
||||||
sr = rref.getSturdyRef()
|
sr = rref.getSturdyRef()
|
||||||
nodeid = sr.tubID
|
|
||||||
# if the subscriber didn't do Tub.setLocation, nodeid will be None
|
# if the subscriber didn't do Tub.setLocation, nodeid will be None
|
||||||
nodeid_s = "?"
|
nodeid = sr.tubID or "?"
|
||||||
if nodeid:
|
ctx.fillSlots("peerid", "%s %s" % (nodeid, nickname))
|
||||||
nodeid_s = idlib.nodeid_b2a(nodeid)
|
advertised = [loc.split(":")[0] for loc in sr.locationHints
|
||||||
ctx.fillSlots("peerid", nodeid_s)
|
if not loc.startswith("127.0.0.1:")]
|
||||||
advertised = [loc.split(":")[0] for loc in sr.locationHints]
|
|
||||||
ctx.fillSlots("advertised", " ".join(advertised))
|
ctx.fillSlots("advertised", " ".join(advertised))
|
||||||
remote_host = rref.tracker.broker.transport.getPeer()
|
remote_host = rref.tracker.broker.transport.getPeer()
|
||||||
if isinstance(remote_host, address.IPv4Address):
|
if isinstance(remote_host, address.IPv4Address):
|
||||||
@ -83,6 +108,7 @@ class IntroducerRoot(rend.Page):
|
|||||||
remote_host_s = str(remote_host)
|
remote_host_s = str(remote_host)
|
||||||
ctx.fillSlots("connected", remote_host_s)
|
ctx.fillSlots("connected", remote_host_s)
|
||||||
ctx.fillSlots("since", "?")
|
ctx.fillSlots("since", "?")
|
||||||
|
ctx.fillSlots("version", version)
|
||||||
ctx.fillSlots("service_name", service_name)
|
ctx.fillSlots("service_name", service_name)
|
||||||
return ctx.tag
|
return ctx.tag
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user