From: Brian Warner Date: Sun, 10 Jun 2007 04:03:57 +0000 (-0700) Subject: webish: show vdrive and introducer connectedness separately X-Git-Tag: allmydata-tahoe-0.3.0~2 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri//%22%22?a=commitdiff_plain;h=363ed1264a420caac1862b1d9fcb700fd38b67a6;p=tahoe-lafs%2Ftahoe-lafs.git webish: show vdrive and introducer connectedness separately Also don't offer a link to the vdrive webpages if we don't have a vdrive.furl --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index f25ed962..09acfefc 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -36,7 +36,7 @@ class Client(node.Node, Referenceable): node.Node.__init__(self, basedir) self.my_furl = None self.introducer_client = None - self.connected_to_vdrive = False + self._connected_to_vdrive = False self.add_service(StorageServer(os.path.join(basedir, self.STOREDIR))) self.add_service(Uploader()) self.add_service(Downloader()) @@ -113,12 +113,12 @@ class Client(node.Node, Referenceable): def _got_vdrive(self, vdrive_root): # vdrive_root implements RIMutableDirectoryNode self.log("connected to vdrive") - self.connected_to_vdrive = True + self._connected_to_vdrive = True self.getServiceNamed("vdrive").set_root(vdrive_root) if "webish" in self.namedServices: self.getServiceNamed("webish").set_root_dirnode(vdrive_root) def _disconnected(): - self.connected_to_vdrive = False + self._connected_to_vdrive = False vdrive_root.notifyOnDisconnect(_disconnected) def remote_get_versions(self): @@ -137,6 +137,8 @@ class Client(node.Node, Referenceable): def get_all_peerids(self): + if not self.introducer_client: + return [] return self.introducer_client.connections.iterkeys() def get_permuted_peers(self, key): @@ -150,3 +152,11 @@ class Client(node.Node, Referenceable): results.append((permuted, peerid, connection)) results.sort() return results + + def connected_to_vdrive(self): + return self._connected_to_vdrive + + def connected_to_introducer(self): + if self.introducer_client: + return self.introducer_client.connected_to_introducer() + return False diff --git a/src/allmydata/introducer.py b/src/allmydata/introducer.py index 96dd875b..ccda1e71 100644 --- a/src/allmydata/introducer.py +++ b/src/allmydata/introducer.py @@ -39,6 +39,7 @@ class IntroducerClient(service.Service, Referenceable): self.connections = {} # k: nodeid, v: ref self.reconnectors = {} # k: FURL, v: reconnector + self._connected = False self.connection_observers = observer.ObserverList() @@ -94,12 +95,19 @@ class IntroducerClient(service.Service, Referenceable): def _got_introducer(self, introducer): self.log(" introducing ourselves: %s, %s" % (self, self.my_furl)) + self._connected = True d = introducer.callRemote("hello", node=self, furl=self.my_furl) + introducer.notifyOnDisconnect(self._disconnected) + + def _disconnected(self): + self._connected = False def notify_on_new_connection(self, cb): """Register a callback that will be fired (with nodeid, rref) when a new connection is established.""" self.connection_observers.subscribe(cb) + def connected_to_introducer(self): + return self._connected diff --git a/src/allmydata/web/welcome.xhtml b/src/allmydata/web/welcome.xhtml index c9e3116b..b4c3b94f 100644 --- a/src/allmydata/web/welcome.xhtml +++ b/src/allmydata/web/welcome.xhtml @@ -10,13 +10,14 @@

Welcome To AllMyData! (tahoe2)

-

To view the global shared filestore, Click Here!

+

Grid Status

My nodeid:
Introducer:
Connected to introducer?:
+
Connected to vdrive?:
Known+Connected Peers:
diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index 794a6b76..daf6cdf0 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -33,7 +33,11 @@ class Welcome(rend.Page): def data_introducer_furl(self, ctx, data): return IClient(ctx).introducer_furl def data_connected_to_introducer(self, ctx, data): - if IClient(ctx).connected_to_vdrive: + if IClient(ctx).connected_to_introducer(): + return "yes" + return "no" + def data_connected_to_vdrive(self, ctx, data): + if IClient(ctx).connected_to_vdrive(): return "yes" return "no" def data_num_peers(self, ctx, data): @@ -54,6 +58,13 @@ class Welcome(rend.Page): ctx.fillSlots("peerid", nodeid_a) return ctx.tag + def render_vdrive(self, ctx, data): + if IClient(ctx).connected_to_vdrive(): + return T.p["To view the global shared filestore, ", + T.a(href="../vdrive")["Click Here!"], + ] + return T.p["vdrive.furl not specified, no vdrive available."] + # this is a form where users can download files by URI def bind_download(self, ctx):