merge incomplete stuff with other patches
authorZooko O'Whielacronx <zooko@zooko.com>
Fri, 23 Mar 2007 23:20:26 +0000 (16:20 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Fri, 23 Mar 2007 23:20:26 +0000 (16:20 -0700)
src/allmydata/client.py
src/allmydata/interfaces.py

index d628026b65c22389b40145d4d2a2a91a1269729c..b063805e55a7d29a4cc86e08d78c70ad03cab2b4 100644 (file)
@@ -29,9 +29,7 @@ class Client(node.Node, Referenceable):
     def __init__(self, basedir="."):
         node.Node.__init__(self, basedir)
         self.queen = None # self.queen is either None or a RemoteReference
-        self.all_peers = set()
-        self.peer_pburls = {}
-        self.connections = {}
+        self.introducer_client = None
         self.add_service(StorageServer(os.path.join(basedir, self.STOREDIR)))
         self.add_service(Uploader())
         self.add_service(Downloader())
@@ -52,6 +50,9 @@ class Client(node.Node, Referenceable):
 
     def tub_ready(self):
         self.my_pburl = self.tub.registerReference(self)
+        if self.queen_pburl:
+            self.introducer_client = IntroducerClient(self.tub, self.queen_pburl, self.my_pburl)
+        self.register_control()
         self.maybe_connect_to_queen()
 
     def set_queen_pburl(self, queen_pburl):
@@ -71,6 +72,15 @@ class Client(node.Node, Referenceable):
         self.queen_connector = self.tub.connectTo(self.queen_pburl,
                                                   self._got_queen)
 
+    def register_control(self):
+        c = ControlServer()
+        c.setServiceParent(self)
+        control_url = self.tub.registerReference(c)
+        f = open("control.pburl", "w")
+        f.write(control_url + "\n")
+        f.close()
+        os.chmod("control.pburl", 0600)
+
     def stopService(self):
         if self.introducer_client:
             self.introducer_client.stop()
index f33888f5de5d30945958ba6adc0c02f98e74f445..67bf189e47a5f8fe2ecd68729f69d6c011d1ca2d 100644 (file)
@@ -1,6 +1,6 @@
 
 from zope.interface import Interface
-from foolscap.schema import StringConstraint, ListOf, TupleOf, Any
+from foolscap.schema import StringConstraint, ListOf, SetOf, TupleOf, Any
 from foolscap import RemoteInterface
 
 Nodeid = StringConstraint(20) # binary format 20-byte SHA1 hash