]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
add "Available" column to welcome page (#648)
authorLeif Ryge <leif@synthesize.us>
Thu, 20 Nov 2014 22:46:20 +0000 (22:46 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Sun, 23 Nov 2014 06:03:00 +0000 (06:03 +0000)
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

src/allmydata/storage/server.py
src/allmydata/storage_client.py
src/allmydata/test/test_web.py
src/allmydata/web/root.py
src/allmydata/web/welcome.xhtml

index 9c0397c0bffeaba894e1891d3e1b41a9f67f5db0..1de4b22fe948fe8bcf5397c37a7ce772abbebffe 100644 (file)
@@ -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,
index 92ecf6e6b4328954fbd81bbd86b39a9e3a6e83e9..f8b19d6646546b987d4188745f80983ff37f557f 100644 (file)
@@ -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
index 52c53b5b3525be0cfbb506724dea0cfb0ecff63f..14684c3861e6813bc2060de6f72d5670da462dcd 100644 (file)
@@ -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):
index 9495d3dfc93fd2244f637004773b7e21536a147c..5f1d236719c473ec17192c85c5b8af236322cb38 100644 (file)
@@ -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
 
index bcfa3d04555ab9382add3af10a7acfb7e8f025d8..72a2be169e3b81023011b16a9c771eb0d51d95f5 100644 (file)
                 <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">
               <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>