flatten the result structure

flat is better than nested
This commit is contained in:
Jean-Paul Calderone 2017-07-27 15:32:47 -04:00
parent e0ee726d22
commit 1f16a173f0
3 changed files with 25 additions and 33 deletions

View File

@ -1861,13 +1861,11 @@ of the introducer(s) and storage server(s), here's an example::
}, },
"servers": [{ "servers": [{
"nodeid": "other_nodeid", "nodeid": "other_nodeid",
"description": { "available_space": 123456,
"available_space": 123456, "nickname": "George \u263b",
"nickname": "George \u263b", "version": "1.0",
"version": "1.0", "connection_status": "summary",
"connection_status": "summary", "last_received_data": 1487811257
"last_received_data": 1487811257
}
}] }]
} }
@ -1875,15 +1873,15 @@ of the introducer(s) and storage server(s), here's an example::
The above json ``introducers`` section includes a list of The above json ``introducers`` section includes a list of
introducer connectivity status messages. introducer connectivity status messages.
The above json ``servers`` section is a map The above json ``servers`` section is an array with map elements. Each map
where the key is a storage server node ID and the value has the following properties:
is a map of properties with the following usage for each key:
1. ``available_space`` - the available space in bytes expressed as an integer 1. ``nodeid`` - an identifier derived from the node's public key
2. ``nickname`` - the storage server nickname 2. ``available_space`` - the available space in bytes expressed as an integer
3. ``version`` - the storage server Tahoe-LAFS version 3. ``nickname`` - the storage server nickname
4. ``connection_status`` - connectivity status 4. ``version`` - the storage server Tahoe-LAFS version
5. ``last_received_data`` - the time when data was last received, 5. ``connection_status`` - connectivity status
6. ``last_received_data`` - the time when data was last received,
expressed in seconds since epoch expressed in seconds since epoch
``GET /status/`` ``GET /status/``

View File

@ -754,22 +754,18 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
}, },
u'servers': sorted([ u'servers': sorted([
{u"nodeid": u'other_nodeid', {u"nodeid": u'other_nodeid',
u"description": { u'available_space': 123456,
u'available_space': 123456, u'connection_status': u'summary',
u'connection_status': u'summary', u'last_received_data': None,
u'last_received_data': None, u'nickname': u'other_nickname \u263b',
u'nickname': u'other_nickname \u263b', u'version': u'1.0',
u'version': u'1.0',
},
}, },
{u"nodeid": u'disconnected_nodeid', {u"nodeid": u'disconnected_nodeid',
u"description": { u'available_space': 123456,
u'available_space': 123456, u'connection_status': u'summary',
u'connection_status': u'summary', u'last_received_data': None,
u'last_received_data': None, u'nickname': u'disconnected_nickname \u263b',
u'nickname': u'disconnected_nickname \u263b', u'version': u'1.0',
u'version': u'1.0',
},
}, },
]), ]),
} }

View File

@ -214,10 +214,7 @@ class Root(MultiFormatPage):
def _describe_known_servers(self, broker): def _describe_known_servers(self, broker):
return sorted(list( return sorted(list(
{ self._describe_server(server)
u"nodeid": server.get_serverid(),
u"description": self._describe_server(server),
}
for server for server
in broker.get_known_servers() in broker.get_known_servers()
)) ))
@ -225,6 +222,7 @@ class Root(MultiFormatPage):
def _describe_server(self, server): def _describe_server(self, server):
description = { description = {
u"nodeid": server.get_serverid(),
u"connection_status": server.get_connection_status().summary, u"connection_status": server.get_connection_status().summary,
u"available_space": server.get_available_space(), u"available_space": server.get_available_space(),
u"nickname": server.get_nickname(), u"nickname": server.get_nickname(),