mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-19 03:06:33 +00:00
checker: re-enable checker web results (although they just say 'Healthy' right now)
This commit is contained in:
parent
7394607141
commit
3e9322bcb6
@ -646,8 +646,17 @@ POST $URL?t=check
|
||||
|
||||
This triggers the FileChecker to determine the current "health" of the
|
||||
given file or directory, by counting how many shares are available. The
|
||||
results will be displayed on the directory page containing this file.
|
||||
page that is returned will display the results. This can be used as a "show
|
||||
me detailed information about this file" page.
|
||||
|
||||
If a when_done=url argument is provided, the return value will be a redirect
|
||||
to that URL instead of the checker results.
|
||||
|
||||
If a return_to=url argument is provided, the returned page will include a
|
||||
link to the given URL entitled "Return to the parent directory".
|
||||
|
||||
If a verify=true argument is provided, the node will perform a more
|
||||
intensive check, downloading and verifying every single bit of every share.
|
||||
|
||||
GET $DIRURL?t=manifest
|
||||
|
||||
|
@ -28,19 +28,20 @@ class Results:
|
||||
def is_healthy(self):
|
||||
return self.healthy
|
||||
|
||||
def html_summary(self):
|
||||
if self.healthy:
|
||||
return "<span>healthy</span>"
|
||||
return "<span>NOT HEALTHY</span>"
|
||||
def get_storage_index_string(self):
|
||||
return self.storage_index_s
|
||||
|
||||
def html(self):
|
||||
s = "<div>\n"
|
||||
s += "<h1>Checker Results for Immutable SI=%s</h1>\n" % self.storage_index_s
|
||||
def get_mutability_string(self):
|
||||
if self.storage_index:
|
||||
return "immutable"
|
||||
return "literal"
|
||||
|
||||
def to_string(self):
|
||||
s = ""
|
||||
if self.healthy:
|
||||
s += "<h2>Healthy!</h2>\n"
|
||||
s += "Healthy!\n"
|
||||
else:
|
||||
s += "<h2>Not Healthy!</h2>\n"
|
||||
s += "</div>\n"
|
||||
s += "Not Healthy!\n"
|
||||
return s
|
||||
|
||||
|
||||
|
@ -1484,16 +1484,15 @@ class ICheckerResults(Interface):
|
||||
"""Return a bool, True if the file is fully healthy, False if it is
|
||||
damaged in any way."""
|
||||
|
||||
def html_summary():
|
||||
"""Return a short string, with a single <span> element, that
|
||||
describes summarized results of the check. This will be displayed on
|
||||
the web-interface directory page, in a narrow column, showing stored
|
||||
results for all files at the same time."""
|
||||
def get_storage_index_string():
|
||||
"""Return a string with the abbreviated storage index."""
|
||||
def get_mutability_string():
|
||||
"""Return a string with 'mutable' or 'immutable'."""
|
||||
|
||||
def html():
|
||||
"""Return a string, with a single <div> element that describes the
|
||||
detailed results of the check/verify operation. This string will be
|
||||
displayed on a page all by itself."""
|
||||
def to_string():
|
||||
"""Return a string that describes the detailed results of the
|
||||
check/verify operation. This string will be displayed on a page all
|
||||
by itself."""
|
||||
|
||||
# The old checker results (for only immutable files) were described
|
||||
# with this:
|
||||
|
@ -158,18 +158,17 @@ class Results:
|
||||
def is_healthy(self):
|
||||
return self.healthy
|
||||
|
||||
def html_summary(self):
|
||||
if self.healthy:
|
||||
return "<span>healthy</span>"
|
||||
return "<span>NOT HEALTHY</span>"
|
||||
def get_storage_index_string(self):
|
||||
return self.storage_index_s
|
||||
|
||||
def html(self):
|
||||
s = "<div>\n"
|
||||
s += "<h1>Checker Results for Mutable SI=%s</h1>\n" % self.storage_index_s
|
||||
def get_mutability_string(self):
|
||||
return "mutable"
|
||||
|
||||
def to_string(self):
|
||||
s = ""
|
||||
if self.healthy:
|
||||
s += "<h2>Healthy!</h2>\n"
|
||||
s += "Healthy!\n"
|
||||
else:
|
||||
s += "<h2>Not Healthy!</h2>\n"
|
||||
s += "</div>\n"
|
||||
s += "Not Healthy!\n"
|
||||
return s
|
||||
|
||||
|
@ -27,8 +27,11 @@ class FakeCHKFileNode:
|
||||
return self.my_uri
|
||||
def get_verifier(self):
|
||||
return IURI(self.my_uri).get_verifier()
|
||||
def check(self):
|
||||
return defer.succeed(None)
|
||||
def check(self, verify=False, repair=False):
|
||||
r = checker.Results(None)
|
||||
r.healthy = True
|
||||
r.problems = []
|
||||
return defer.succeed(r)
|
||||
def is_mutable(self):
|
||||
return False
|
||||
def is_readonly(self):
|
||||
|
@ -1397,12 +1397,53 @@ class Web(WebMixin, unittest.TestCase):
|
||||
return d
|
||||
|
||||
def test_POST_FILEURL_check(self):
|
||||
d = self.POST(self.public_url + "/foo/bar.txt", t="check")
|
||||
bar_url = self.public_url + "/foo/bar.txt"
|
||||
d = self.POST(bar_url, t="check")
|
||||
def _check(res):
|
||||
# this currently just returns "None". You'd only really use it
|
||||
# with a when_done= redirect.
|
||||
self.failUnlessEqual(res, "None")
|
||||
self.failUnless("Healthy!" in res)
|
||||
d.addCallback(_check)
|
||||
redir_url = "http://allmydata.org/TARGET"
|
||||
def _check2(statuscode, target):
|
||||
self.failUnlessEqual(statuscode, str(http.FOUND))
|
||||
self.failUnlessEqual(target, redir_url)
|
||||
d.addCallback(lambda res:
|
||||
self.shouldRedirect2("test_POST_FILEURL_check",
|
||||
_check2,
|
||||
self.POST, bar_url,
|
||||
t="check",
|
||||
when_done=redir_url))
|
||||
d.addCallback(lambda res:
|
||||
self.POST(bar_url, t="check", return_to=redir_url))
|
||||
def _check3(res):
|
||||
self.failUnless("Healthy!" in res)
|
||||
self.failUnless("Return to parent directory" in res)
|
||||
self.failUnless(redir_url in res)
|
||||
d.addCallback(_check3)
|
||||
return d
|
||||
|
||||
def test_POST_DIRURL_check(self):
|
||||
foo_url = self.public_url + "/foo/"
|
||||
d = self.POST(foo_url, t="check")
|
||||
def _check(res):
|
||||
self.failUnless("Healthy!" in res)
|
||||
d.addCallback(_check)
|
||||
redir_url = "http://allmydata.org/TARGET"
|
||||
def _check2(statuscode, target):
|
||||
self.failUnlessEqual(statuscode, str(http.FOUND))
|
||||
self.failUnlessEqual(target, redir_url)
|
||||
d.addCallback(lambda res:
|
||||
self.shouldRedirect2("test_POST_DIRURL_check",
|
||||
_check2,
|
||||
self.POST, foo_url,
|
||||
t="check",
|
||||
when_done=redir_url))
|
||||
d.addCallback(lambda res:
|
||||
self.POST(foo_url, t="check", return_to=redir_url))
|
||||
def _check3(res):
|
||||
self.failUnless("Healthy!" in res)
|
||||
self.failUnless("Return to parent directory" in res)
|
||||
self.failUnless(redir_url in res)
|
||||
d.addCallback(_check3)
|
||||
return d
|
||||
|
||||
def test_POST_FILEURL_bad_t(self):
|
||||
|
18
src/allmydata/web/checker-results.xhtml
Normal file
18
src/allmydata/web/checker-results.xhtml
Normal file
@ -0,0 +1,18 @@
|
||||
<html xmlns:n="http://nevow.com/ns/nevow/0.1">
|
||||
<head>
|
||||
<title>AllMyData - Tahoe - Check Results</title>
|
||||
<!-- <link href="http://www.allmydata.com/common/css/styles.css"
|
||||
rel="stylesheet" type="text/css"/> -->
|
||||
<link href="/webform_css" rel="stylesheet" type="text/css"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>File Check Results for SI=<span n:render="storage_index" /> (<span n:render="mutability" />)</h1>
|
||||
|
||||
<pre n:render="results" />
|
||||
|
||||
<div n:render="return" />
|
||||
|
||||
</body>
|
||||
</html>
|
25
src/allmydata/web/checker_results.py
Normal file
25
src/allmydata/web/checker_results.py
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
from nevow import rend, inevow, tags as T
|
||||
from allmydata.web.common import getxmlfile, get_arg
|
||||
|
||||
class CheckerResults(rend.Page):
|
||||
docFactory = getxmlfile("checker-results.xhtml")
|
||||
|
||||
def __init__(self, results):
|
||||
self.r = results
|
||||
|
||||
def render_storage_index(self, ctx, data):
|
||||
return self.r.get_storage_index_string()
|
||||
|
||||
def render_mutability(self, ctx, data):
|
||||
return self.r.get_mutability_string()
|
||||
|
||||
def render_results(self, ctx, data):
|
||||
return ctx.tag[self.r.to_string()]
|
||||
|
||||
def render_return(self, ctx, data):
|
||||
req = inevow.IRequest(ctx)
|
||||
return_to = get_arg(req, "return_to", None)
|
||||
if return_to:
|
||||
return T.div[T.a(href=return_to)["Return to parent directory"]]
|
||||
return ""
|
@ -11,7 +11,7 @@ from nevow.inevow import IRequest
|
||||
|
||||
from foolscap.eventual import fireEventually
|
||||
|
||||
from allmydata.util import log, base32
|
||||
from allmydata.util import base32
|
||||
from allmydata.uri import from_string_verifier, from_string_dirnode, \
|
||||
CHKFileVerifierURI
|
||||
from allmydata.interfaces import IDirectoryNode, IFileNode, IMutableFileNode, \
|
||||
@ -21,6 +21,7 @@ from allmydata.web.common import text_plain, WebError, IClient, \
|
||||
getxmlfile, RenderMixin
|
||||
from allmydata.web.filenode import ReplaceMeMixin, \
|
||||
FileNodeHandler, PlaceHolderNodeHandler
|
||||
from allmydata.web.checker_results import CheckerResults
|
||||
|
||||
class BlockingFileError(Exception):
|
||||
# TODO: catch and transform
|
||||
@ -330,12 +331,7 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
|
||||
def _POST_check(self, req):
|
||||
# check this directory
|
||||
d = self.node.check()
|
||||
def _done(res):
|
||||
log.msg("checked %s, results %s" % (self.node, res),
|
||||
facility="tahoe.webish", level=log.NOISY)
|
||||
return str(res)
|
||||
d.addCallback(_done)
|
||||
# TODO: results
|
||||
d.addCallback(lambda res: CheckerResults(res))
|
||||
return d
|
||||
|
||||
def _POST_set_children(self, req):
|
||||
@ -458,7 +454,7 @@ class DirectoryAsHTML(rend.Page):
|
||||
check_done_url = "../uri/%s/" % urllib.quote(self.node.get_uri())
|
||||
check = T.form(action=check_url, method="post")[
|
||||
T.input(type='hidden', name='t', value='check'),
|
||||
T.input(type='hidden', name='when_done', value=check_done_url),
|
||||
T.input(type='hidden', name='return_to', value=check_done_url),
|
||||
T.input(type='submit', value='check', name="check"),
|
||||
]
|
||||
ctx.fillSlots("overwrite",
|
||||
|
@ -15,6 +15,7 @@ from allmydata.util import log
|
||||
|
||||
from allmydata.web.common import text_plain, WebError, IClient, RenderMixin, \
|
||||
boolean_of_arg, get_arg, should_create_intermediate_directories
|
||||
from allmydata.web.checker_results import CheckerResults
|
||||
|
||||
class ReplaceMeMixin:
|
||||
|
||||
@ -244,12 +245,7 @@ class FileNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
|
||||
|
||||
def _POST_check(self, req):
|
||||
d = self.node.check()
|
||||
def _done(res):
|
||||
log.msg("checked %s, results %s" % (self.node, res),
|
||||
facility="tahoe.webish", level=log.NOISY)
|
||||
return str(res)
|
||||
d.addCallback(_done)
|
||||
# TODO: results
|
||||
d.addCallback(lambda res: CheckerResults(res))
|
||||
return d
|
||||
|
||||
def render_DELETE(self, ctx):
|
||||
|
Loading…
Reference in New Issue
Block a user