mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-19 03:06:33 +00:00
add "Available" column to welcome page (#648)
add get_available_space() to NativeStorageServer It uses a new 'available-space' key in the server's v1 version dict, or falls back to 'maximum-immutable-share-size' (which presently always has the same value but could have a different meaning in the future). This is a squash merge of 9773555bb87fab71145ad7a0e84785a4e92d11f7
This commit is contained in:
parent
9c1beac57b
commit
335c2ed06a
@ -227,6 +227,7 @@ class StorageServer(service.MultiService, Referenceable):
|
||||
version = { "http://allmydata.org/tahoe/protocols/storage/v1" :
|
||||
{ "maximum-immutable-share-size": remaining_space,
|
||||
"maximum-mutable-share-size": MAX_MUTABLE_SHARE_SIZE,
|
||||
"available-space": remaining_space,
|
||||
"tolerates-immutable-read-overrun": True,
|
||||
"delete-mutable-shares-with-zero-length-writev": True,
|
||||
"fills-holes-with-zero-bytes": True,
|
||||
|
@ -265,6 +265,16 @@ class NativeStorageServer:
|
||||
def get_announcement_time(self):
|
||||
return self.announcement_time
|
||||
|
||||
def get_available_space(self):
|
||||
version = self.get_version()
|
||||
if version is None:
|
||||
return None
|
||||
protocol_v1_version = version.get('http://allmydata.org/tahoe/protocols/storage/v1', {})
|
||||
available_space = protocol_v1_version.get('available-space')
|
||||
if available_space is None:
|
||||
available_space = protocol_v1_version.get('maximum-immutable-share-size', None)
|
||||
return available_space
|
||||
|
||||
def start_connecting(self, tub, trigger_cb):
|
||||
furl = str(self.announcement["anonymous-storage-FURL"])
|
||||
self._trigger_cb = trigger_cb
|
||||
|
@ -191,6 +191,8 @@ class FakeDisplayableServer(StubServer):
|
||||
return self.announcement
|
||||
def get_nickname(self):
|
||||
return self.announcement["nickname"]
|
||||
def get_available_space(self):
|
||||
return 0
|
||||
|
||||
class FakeBucketCounter(object):
|
||||
def get_state(self):
|
||||
|
@ -288,7 +288,11 @@ class Root(rend.Page):
|
||||
announcement = server.get_announcement()
|
||||
version = announcement["my-version"]
|
||||
service_name = announcement["service-name"]
|
||||
|
||||
available_space = server.get_available_space()
|
||||
if available_space is None:
|
||||
available_space = "N/A"
|
||||
else:
|
||||
available_space = abbreviate_size(available_space)
|
||||
ctx.fillSlots("address", addr)
|
||||
ctx.fillSlots("connected", connected)
|
||||
ctx.fillSlots("connected-bool", bool(rhost))
|
||||
@ -298,6 +302,7 @@ class Root(rend.Page):
|
||||
time.localtime(announced)))
|
||||
ctx.fillSlots("version", version)
|
||||
ctx.fillSlots("service_name", service_name)
|
||||
ctx.fillSlots("available_space", available_space)
|
||||
|
||||
return ctx.tag
|
||||
|
||||
|
@ -173,6 +173,7 @@
|
||||
<td><h3>Since</h3></td>
|
||||
<td><h3>Announced</h3></td>
|
||||
<td><h3>Version</h3></td>
|
||||
<td><h3>Available</h3></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr n:pattern="item" n:render="service_row">
|
||||
@ -186,6 +187,7 @@
|
||||
<td class="service-since timestamp"><n:slot name="since"/></td>
|
||||
<td class="service-announced timestamp"><n:slot name="announced"/></td>
|
||||
<td class="service-version"><n:slot name="version"/></td>
|
||||
<td class="service-available-space"><n:slot name="available_space"/></td>
|
||||
</tr>
|
||||
<tr n:pattern="empty"><td>You are not presently connected to any peers</td></tr>
|
||||
</table>
|
||||
|
Loading…
Reference in New Issue
Block a user