From: Leif Ryge Date: Thu, 20 Nov 2014 22:46:20 +0000 (+0000) Subject: add "Available" column to welcome page (#648) X-Git-Tag: allmydata-tahoe-1.10.1a1~103 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/css/flags/?a=commitdiff_plain;h=335c2ed06ab97443e1809819bb77b9946bec405c;p=tahoe-lafs%2Ftahoe-lafs.git 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 --- diff --git a/src/allmydata/storage/server.py b/src/allmydata/storage/server.py index 9c0397c0..1de4b22f 100644 --- a/src/allmydata/storage/server.py +++ b/src/allmydata/storage/server.py @@ -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, diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py index 92ecf6e6..f8b19d66 100644 --- a/src/allmydata/storage_client.py +++ b/src/allmydata/storage_client.py @@ -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 diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index 52c53b5b..14684c38 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -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): diff --git a/src/allmydata/web/root.py b/src/allmydata/web/root.py index 9495d3df..5f1d2367 100644 --- a/src/allmydata/web/root.py +++ b/src/allmydata/web/root.py @@ -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 diff --git a/src/allmydata/web/welcome.xhtml b/src/allmydata/web/welcome.xhtml index bcfa3d04..72a2be16 100644 --- a/src/allmydata/web/welcome.xhtml +++ b/src/allmydata/web/welcome.xhtml @@ -173,6 +173,7 @@

Since

Announced

Version

+

Available

@@ -186,6 +187,7 @@ + You are not presently connected to any peers