]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
added 'debugshell' module a convenient dumping ground for tools for manhole environment
authorRob Kinninmont <robk@allmydata.com>
Fri, 1 Dec 2006 02:53:08 +0000 (19:53 -0700)
committerRob Kinninmont <robk@allmydata.com>
Fri, 1 Dec 2006 02:53:08 +0000 (19:53 -0700)
allmydata/manhole.py
debugshell.py [new file with mode: 0644]

index dfc7af3f8c7b5b40f6b25db6b7a4a130602ff6ec..02daaf5bc84fdd426d0d1fb4703d8cbf6e98ccc6 100644 (file)
@@ -133,9 +133,14 @@ class _BaseManhole(service.MultiService):
 
         def makeNamespace():
             # close over 'self' so we can get access to .parent later
-            namespace = {
-                'app': self.parent,
-                }
+            import types
+            import debugshell
+            debugshell.app = self.parent # make client/queen accesible via 'app'
+            namespace = {}
+            for sym in dir(debugshell):
+                if sym.startswith('__') and sym.endswith('__'):
+                    continue
+                namespace[sym] = getattr(debugshell, sym)
             return namespace
 
         def makeProtocol():
diff --git a/debugshell.py b/debugshell.py
new file mode 100644 (file)
index 0000000..130c909
--- /dev/null
@@ -0,0 +1,17 @@
+import os
+
+def get_random_bucket_on(nodeid, size=200):
+    d = app.get_remote_service(nodeid, 'storageserver')
+    def get_bucket(rss):
+        return rss.callRemote('allocate_bucket',
+                              verifierid=os.urandom(20),
+                              bucket_num=26,
+                              size=size,
+                              leaser=app.tub.tubID,
+                              )
+    d.addCallback(get_bucket)
+    return d
+
+def write_to_bucket(bucket, bytes=100):
+    return bucket.callRemote('write', data=os.urandom(bytes))
+