]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
add RIClient.get_versions, in the hopes of enabling backwards-compatibility code...
authorBrian Warner <warner@allmydata.com>
Thu, 26 Apr 2007 19:01:25 +0000 (12:01 -0700)
committerBrian Warner <warner@allmydata.com>
Thu, 26 Apr 2007 19:01:25 +0000 (12:01 -0700)
src/allmydata/client.py
src/allmydata/interfaces.py
src/allmydata/test/test_client.py

index 6e0f9b603d55c1a525d8a7f0be96dfeaee951895..b22d033e09098680fa331e620de33b4e3f942779 100644 (file)
@@ -7,6 +7,7 @@ from allmydata import node
 
 from twisted.internet import defer
 
+import allmydata
 from allmydata.Crypto.Util.number import bytes_to_long
 from allmydata.storageserver import StorageServer
 from allmydata.upload import Uploader
@@ -26,6 +27,9 @@ class Client(node.Node, Referenceable):
     INTRODUCER_FURL_FILE = "introducer.furl"
     GLOBAL_VDRIVE_FURL_FILE = "vdrive.furl"
 
+    # we're pretty narrow-minded right now
+    OLDEST_SUPPORTED_VERSION = allmydata.__version__
+
     def __init__(self, basedir="."):
         node.Node.__init__(self, basedir)
         self.my_pburl = None
@@ -87,6 +91,9 @@ class Client(node.Node, Referenceable):
             self.connected_to_vdrive = False
         vdrive_root.notifyOnDisconnect(_disconnected)
 
+    def remote_get_versions(self):
+        return str(allmydata.__version__), str(self.OLDEST_SUPPORTED_VERSION)
+
     def remote_get_service(self, name):
         # TODO: 'vdrive' should not be public in the medium term
         return self.getServiceNamed(name)
index abb4ab5cd6105790b29314a9f4535e8f0087e311..855e85c9c49fe46699f9f5a917404210b68a7e3b 100644 (file)
@@ -25,6 +25,19 @@ class RIIntroducer(RemoteInterface):
         return None
 
 class RIClient(RemoteInterface):
+    def get_versions():
+        """Return a tuple of (my_version, oldest_supported) strings.
+
+        Each string can be parsed by an allmydata.util.version.Version
+        instance, and then compared. The first goal is to make sure that
+        nodes are not confused by speaking to an incompatible peer. The
+        second goal is to enable the development of backwards-compatibility
+        code.
+
+        This method is likely to change in incompatible ways until we get the
+        whole compatibility scheme nailed down.
+        """
+        return TupleOf(str, str)
     def get_service(name=str):
         return Referenceable
     def get_nodeid():
index b9bbba2400db8d0fb22f02c45b576ccd4517329f..3366dea6321fc9f9464dc7b0ac3a790419c1cc59 100644 (file)
@@ -2,7 +2,9 @@
 import os
 from twisted.trial import unittest
 
+import allmydata
 from allmydata import client, introducer
+from allmydata.util import version
 
 class MyIntroducerClient(introducer.IntroducerClient):
     def __init__(self):
@@ -39,3 +41,12 @@ class Basic(unittest.TestCase):
             c2.introducer_client.connections[k] = None
         self.failUnlessEqual(permute(c2, "one"), ['3','1','0','4','2'])
 
+    def test_versions(self):
+        basedir = "test_client.Basic.test_versions"
+        os.mkdir(basedir)
+        open(os.path.join(basedir, "introducer.furl"), "w").write("")
+        open(os.path.join(basedir, "vdrive.furl"), "w").write("")
+        c = client.Client(basedir)
+        mine, oldest = c.remote_get_versions()
+        self.failUnlessEqual(version.Version(mine), allmydata.__version__)
+