From: David-Sarah Hopwood Date: Sat, 29 Dec 2012 04:17:00 +0000 (+0000) Subject: If a helper is not configured, make the banner on the welcome page say that, and... X-Git-Tag: allmydata-tahoe-1.10a1~26 X-Git-Url: https://git.rkrishnan.org/specifications/reliability?a=commitdiff_plain;h=a5895b9d59212ab1a000b6e1d099cad4fe630c4d;p=tahoe-lafs%2Ftahoe-lafs.git If a helper is not configured, make the banner on the welcome page say that, and have a white background. fixes #1735 Author: kick Signed-off-by: David-Sarah Hopwood --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 1e4479bb..e1899971 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -306,6 +306,9 @@ class Client(node.Node, pollmixin.PollMixin): def init_client(self): helper_furl = self.get_config("client", "helper.furl", None) + if helper_furl in ("None", ""): + helper_furl = None + DEP = self.DEFAULT_ENCODING_PARAMETERS DEP["k"] = int(self.get_config("client", "shares.needed", DEP["k"])) DEP["n"] = int(self.get_config("client", "shares.total", DEP["n"])) diff --git a/src/allmydata/test/test_client.py b/src/allmydata/test/test_client.py index 53734648..04458e68 100644 --- a/src/allmydata/test/test_client.py +++ b/src/allmydata/test/test_client.py @@ -172,6 +172,24 @@ class Basic(testutil.ReallyEqualMixin, unittest.TestCase): self.failUnless("node.uptime" in stats) self.failUnless(isinstance(stats["node.uptime"], float)) + def test_helper_furl(self): + basedir = "test_client.Basic.test_helper_furl" + os.mkdir(basedir) + + def _check(config, expected_furl): + fileutil.write(os.path.join(basedir, "tahoe.cfg"), + BASECONFIG + config) + c = client.Client(basedir) + uploader = c.getServiceNamed("uploader") + furl, connected = uploader.get_helper_info() + self.failUnlessEqual(furl, expected_furl) + + _check("", None) + _check("helper.furl =\n", None) + _check("helper.furl = \n", None) + _check("helper.furl = None", None) + _check("helper.furl = pb://blah\n", "pb://blah") + @mock.patch('allmydata.util.log.msg') @mock.patch('allmydata.frontends.drop_upload.DropUploader') def test_create_drop_uploader(self, mock_drop_uploader, mock_log_msg): diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index 2c6c0ceb..576c3da3 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -80,6 +80,9 @@ class FakeNodeMaker(NodeMaker): class FakeUploader(service.Service): name = "uploader" + helper_furl = None + helper_connected = False + def upload(self, uploadable): d = uploadable.get_size() d.addCallback(lambda size: uploadable.read(size)) @@ -100,8 +103,10 @@ class FakeUploader(service.Service): return ur d.addCallback(_got_data) return d + def get_helper_info(self): - return (None, False) + return (self.helper_furl, self.helper_connected) + def build_one_ds(): ds = DownloadStatus("storage_index", 1234) @@ -609,6 +614,36 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi d.addCallback(_check) return d + def test_helper_status(self): + d = defer.succeed(None) + + # set helper furl to None + def _set_helper_not_configured2(ign): + self.s.uploader.helper_furl = None + return self.GET("/") + d.addCallback(_set_helper_not_configured2) + d.addCallback(lambda res: + self.failUnlessIn('Connected to helper?: not configured', res)) + + # enable helper, not connected + def _set_helper_not_connected(ign): + self.s.uploader.helper_furl = "pb://someHelper" + self.s.uploader.helper_connected = False + return self.GET("/") + d.addCallback(_set_helper_not_connected) + d.addCallback(lambda res: + self.failUnlessIn('Connected to helper?: no', res)) + + # enable helper, connected + def _set_helper_connected(ign): + self.s.uploader.helper_furl = "pb://someHelper" + self.s.uploader.helper_connected = True + return self.GET("/") + d.addCallback(_set_helper_connected) + d.addCallback(lambda res: + self.failUnlessIn('Connected to helper?: yes', res)) + return d + def test_storage(self): d = self.GET("/storage") def _check(res): diff --git a/src/allmydata/web/root.py b/src/allmydata/web/root.py index 2cd315d9..6f467cc8 100644 --- a/src/allmydata/web/root.py +++ b/src/allmydata/web/root.py @@ -200,6 +200,7 @@ class Root(rend.Page): def data_introducer_furl(self, ctx, data): return self.client.introducer_furl + def data_connected_to_introducer(self, ctx, data): if self.client.connected_to_introducer(): return "yes" @@ -212,12 +213,19 @@ class Root(rend.Page): return None furl, connected = uploader.get_helper_info() return furl + + def data_connected_to_helper_description(self, ctx, data): + return self.data_connected_to_helper(ctx, data).replace('-', ' ') + def data_connected_to_helper(self, ctx, data): try: uploader = self.client.getServiceNamed("uploader") except KeyError: return "no" # we don't even have an Uploader furl, connected = uploader.get_helper_info() + + if furl is None: + return "not-configured" if connected: return "yes" return "no" diff --git a/src/allmydata/web/static/tahoe.css b/src/allmydata/web/static/tahoe.css index 297bbe44..4a94d49c 100644 --- a/src/allmydata/web/static/tahoe.css +++ b/src/allmydata/web/static/tahoe.css @@ -6,7 +6,7 @@ pre.overflow { padding: .25em; overflow: auto; } - + /* ----------------------------------------------------------------------- */ /* colors borrowed from the Allmydata logo */ @@ -34,7 +34,6 @@ th { .table-headings-top th { text-align: center; - } .table-headings-left th { text-align: right; @@ -52,6 +51,10 @@ legend { border: 1px solid #F00; background-color: #FBB; } +.connected-not-configured { + border: 1px solid #AAA; + background-color: #FFF; +} .encoded, .nodeid { font-family: monospace; diff --git a/src/allmydata/web/welcome.xhtml b/src/allmydata/web/welcome.xhtml index b493ee79..f88c02ca 100644 --- a/src/allmydata/web/welcome.xhtml +++ b/src/allmydata/web/welcome.xhtml @@ -47,7 +47,7 @@
connected-
Helper:
-
Connected to helper?:
+
Connected to helper?:

Connected to