class CheckerResults:
implements(ICheckerResults)
- def __init__(self, storage_index):
+ def __init__(self, uri, storage_index):
+ assert isinstance(uri, str)
+ self.uri = uri
self.storage_index = storage_index
self.problems = []
self.data = {"count-corrupt-shares": 0,
return self.storage_index
def get_storage_index_string(self):
return base32.b2a(self.storage_index)
+ def get_uri(self):
+ return self.uri
def is_healthy(self):
return self.healthy
"""Return a list of (needed, total, found, sharemap), where sharemap maps
share number to a list of (binary) nodeids of the shareholders."""
- def __init__(self, client, storage_index, needed_shares, total_shares):
+ def __init__(self, client, uri, storage_index, needed_shares, total_shares):
self.peer_getter = client.get_permuted_peers
self.needed_shares = needed_shares
self.total_shares = total_shares
self.found_shares = set()
+ self.uri = uri
self.storage_index = storage_index
self.sharemap = {}
self.responded = set()
pass
def _done(self, res):
- r = CheckerResults(self.storage_index)
+ r = CheckerResults(self.uri, self.storage_index)
report = []
healthy = bool(len(self.found_shares) >= self.total_shares)
r.set_healthy(healthy)
# remaining shareholders, and it cannot verify the plaintext.
check_plaintext_hash = False
- def __init__(self, client, storage_index, k, N, size, ueb_hash):
+ def __init__(self, client, uri, storage_index, k, N, size, ueb_hash):
self._client = client
+ self._uri = uri
self._storage_index = storage_index
self._uri_extension_hash = ueb_hash
self._total_shares = N
self._si_s = storage.si_b2a(self._storage_index)
self.init_logging()
- self._check_results = r = CheckerResults(self._storage_index)
+ self._check_results = r = CheckerResults(self._uri, self._storage_index)
r.set_data({"count-shares-needed": k,
"count-shares-expected": N,
})
ueb_hash = self.u.uri_extension_hash
if verify:
v = self.verifier_class(self._client,
- storage_index, k, N, size, ueb_hash)
+ self.get_uri(), storage_index,
+ k, N, size, ueb_hash)
else:
- v = self.checker_class(self._client, storage_index, k, N)
+ v = self.checker_class(self._client,
+ self.get_uri(), storage_index,
+ k, N)
return v.start()
def check_and_repair(self, monitor, verify=False):
"""Return a string with the (binary) storage index."""
def get_storage_index_string():
"""Return a string with the (printable) abbreviated storage index."""
+ def get_uri():
+ """Return the (string) URI of the object that was checked."""
def is_healthy():
"""Return a boolean, True if the file/dir is fully healthy, False if
self._monitor = monitor
self.bad_shares = [] # list of (nodeid,shnum,failure)
self._storage_index = self._node.get_storage_index()
- self.results = CheckerResults(self._storage_index)
+ self.results = CheckerResults(node.get_uri(), self._storage_index)
self.need_repair = False
self.responded = set() # set of (binary) nodeids
d = self._node.repair(self.results)
def _repair_finished(repair_results):
self.cr_results.repair_successful = True
- r = CheckerResults(self._storage_index)
+ r = CheckerResults(self._node.get_uri(), self._storage_index)
self.cr_results.post_repair_results = r
self._fill_checker_results(repair_results.servermap, r)
self.cr_results.repair_results = repair_results # TODO?
return self.storage_index
def check(self, monitor, verify=False):
- r = CheckerResults(self.storage_index)
+ r = CheckerResults(self.my_uri, self.storage_index)
is_bad = self.bad_shares.get(self.storage_index, None)
data = {}
data["count-shares-needed"] = 3
return self.storage_index
def check(self, monitor, verify=False):
- r = CheckerResults(self.storage_index)
+ r = CheckerResults(self.my_uri.to_string(), self.storage_index)
is_bad = self.bad_shares.get(self.storage_index, None)
data = {}
data["count-shares-needed"] = 3
return self.verifieruri
def check(self, monitor, verify=False):
- r = CheckerResults(None)
+ r = CheckerResults("", None)
r.set_healthy(True)
return defer.succeed(r)
<span n:render="rebalance" />
</div>
+<div n:render="repair" />
+
<div n:render="results" />
<div n:render="return" />
return ctx.tag["Healthy!"]
return ctx.tag["Not Healthy!: ", self._html(self.r.get_summary())]
+ def render_repair(self, ctx, data):
+ if self.r.is_healthy():
+ return ""
+ repair = T.form(action=".", method="post",
+ enctype="multipart/form-data")[
+ T.fieldset[
+ T.input(type="hidden", name="t", value="check"),
+ T.input(type="hidden", name="repair", value="true"),
+ T.input(type="submit", value="Repair"),
+ ]]
+ return ctx.tag[repair]
+
def render_rebalance(self, ctx, data):
if self.r.needs_rebalancing():
return ctx.tag["(needs rebalancing)"]