mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Let's use dict for details data, much better for semantic when defining strings etc...
This commit is contained in:
parent
8e83f8aa29
commit
f0c0f63bb4
9 changed files with 30 additions and 22 deletions
|
@ -27,7 +27,7 @@ class BaseSystemDiagnoser(Diagnoser):
|
|||
if os.path.exists("/proc/device-tree/model"):
|
||||
model = read_file('/proc/device-tree/model').strip()
|
||||
hardware["data"]["board"] = model
|
||||
hardware["details"] = [("diagnosis_basesystem_hardware_board", (model,))]
|
||||
hardware["details"] = [("diagnosis_basesystem_hardware_board", {"model": model})]
|
||||
|
||||
yield hardware
|
||||
|
||||
|
@ -51,8 +51,12 @@ class BaseSystemDiagnoser(Diagnoser):
|
|||
# Here, ynh_core_version is for example "3.5.4.12", so [:3] is "3.5" and we check it's the same for all packages
|
||||
ynh_core_version = ynh_packages["yunohost"]["version"]
|
||||
consistent_versions = all(infos["version"][:3] == ynh_core_version[:3] for infos in ynh_packages.values())
|
||||
ynh_version_details = [("diagnosis_basesystem_ynh_single_version", (package, infos["version"], infos["repo"]))
|
||||
for package, infos in ynh_packages.items()]
|
||||
ynh_version_details = [("diagnosis_basesystem_ynh_single_version",
|
||||
{"package":package,
|
||||
"version": infos["version"],
|
||||
"repo": infos["repo"]}
|
||||
)
|
||||
for package, infos in ynh_packages.items()]
|
||||
|
||||
if consistent_versions:
|
||||
yield dict(meta={"test": "ynh_versions"},
|
||||
|
|
|
@ -58,7 +58,7 @@ class IPDiagnoser(Diagnoser):
|
|||
yield dict(meta={"test": "dnsresolv"},
|
||||
status="WARNING",
|
||||
summary=("diagnosis_ip_weird_resolvconf", {}),
|
||||
details=[("diagnosis_ip_weird_resolvconf_details", ())])
|
||||
details=[("diagnosis_ip_weird_resolvconf_details", {})])
|
||||
else:
|
||||
yield dict(meta={"test": "dnsresolv"},
|
||||
status="SUCCESS",
|
||||
|
|
|
@ -52,15 +52,17 @@ class DNSRecordsDiagnoser(Diagnoser):
|
|||
discrepancies = []
|
||||
|
||||
for r in records:
|
||||
current_value = self.get_current_record(domain, r["name"], r["type"]) or "None"
|
||||
expected_value = r["value"] if r["value"] != "@" else domain + "."
|
||||
r["current"] = self.get_current_record(domain, r["name"], r["type"]) or "None"
|
||||
if r["value"] == "@":
|
||||
r["value"] = domain + "."
|
||||
|
||||
if current_value == "None":
|
||||
discrepancies.append(("diagnosis_dns_missing_record", (r["type"], r["name"], expected_value)))
|
||||
elif current_value != expected_value:
|
||||
discrepancies.append(("diagnosis_dns_discrepancy", (r["type"], r["name"], expected_value, current_value)))
|
||||
if r["current"] == "None":
|
||||
discrepancies.append(("diagnosis_dns_missing_record", r))
|
||||
elif r["current"] != r["value"]:
|
||||
discrepancies.append(("diagnosis_dns_discrepancy", r))
|
||||
|
||||
if discrepancies:
|
||||
discrepancies = [("diagnosis_dns_point_to_doc", {})] + discrepancies
|
||||
status = "ERROR" if (category == "basic" or (is_main_domain and category != "extra")) else "WARNING"
|
||||
summary = ("diagnosis_dns_bad_conf", {"domain": domain, "category": category})
|
||||
else:
|
||||
|
|
|
@ -49,12 +49,13 @@ class PortsDiagnoser(Diagnoser):
|
|||
yield dict(meta={"port": str(port)},
|
||||
status="ERROR",
|
||||
summary=("diagnosis_ports_unreachable", {"port": port}),
|
||||
details=[("diagnosis_ports_needed_by", (service, category)), ("diagnosis_ports_forwarding_tip", ())])
|
||||
details=[("diagnosis_ports_needed_by", {"service": service, "category": category}),
|
||||
("diagnosis_ports_forwarding_tip", {})])
|
||||
else:
|
||||
yield dict(meta={"port": str(port)},
|
||||
status="SUCCESS",
|
||||
summary=("diagnosis_ports_ok", {"port": port}),
|
||||
details=[("diagnosis_ports_needed_by", (service, category))])
|
||||
details=[("diagnosis_ports_needed_by", {"service": service, "category": category})])
|
||||
|
||||
|
||||
def main(args, env, loggers):
|
||||
|
|
|
@ -51,7 +51,7 @@ class WebDiagnoser(Diagnoser):
|
|||
yield dict(meta={"domain": domain},
|
||||
status="ERROR",
|
||||
summary=("diagnosis_http_unreachable", {"domain": domain}),
|
||||
details=[(detail,())])
|
||||
details=[(detail,{})])
|
||||
|
||||
# In there or idk where else ...
|
||||
# try to diagnose hairpinning situation by crafting a request for the
|
||||
|
|
|
@ -22,12 +22,12 @@ class ServicesDiagnoser(Diagnoser):
|
|||
if result["status"] != "running":
|
||||
item["status"] = "ERROR"
|
||||
item["summary"] = ("diagnosis_services_bad_status", {"service": service, "status": result["status"]})
|
||||
item["details"] = [("diagnosis_services_bad_status_tip", (service,))]
|
||||
item["details"] = [("diagnosis_services_bad_status_tip", {"service":service})]
|
||||
|
||||
elif result["configuration"] == "broken":
|
||||
item["status"] = "WARNING"
|
||||
item["summary"] = ("diagnosis_services_conf_broken", {"service": service})
|
||||
item["details"] = [(d, tuple()) for d in result["configuration-details"]]
|
||||
item["details"] = [(d, {}) for d in result["configuration-details"]]
|
||||
|
||||
else:
|
||||
item["status"] = "SUCCESS"
|
||||
|
|
|
@ -22,7 +22,7 @@ class SecurityDiagnoser(Diagnoser):
|
|||
yield dict(meta={"test": "meltdown"},
|
||||
status="ERROR",
|
||||
summary=("diagnosis_security_vulnerable_to_meltdown", {}),
|
||||
details=[("diagnosis_security_vulnerable_to_meltdown_details", ())]
|
||||
details=[("diagnosis_security_vulnerable_to_meltdown_details", {})]
|
||||
)
|
||||
else:
|
||||
yield dict(meta={},
|
||||
|
|
|
@ -140,7 +140,7 @@
|
|||
"diagnosis_basesystem_hardware_board": "Server board model is {model}",
|
||||
"diagnosis_basesystem_host": "Server is running Debian {debian_version}",
|
||||
"diagnosis_basesystem_kernel": "Server is running Linux kernel {kernel_version}",
|
||||
"diagnosis_basesystem_ynh_single_version": "{0} version: {1} ({2})",
|
||||
"diagnosis_basesystem_ynh_single_version": "{package} version: {version} ({repo})",
|
||||
"diagnosis_basesystem_ynh_main_version": "Server is running YunoHost {main_version} ({repo})",
|
||||
"diagnosis_basesystem_ynh_inconsistent_versions": "You are running inconsistent versions of the YunoHost packages... most probably because of a failed or partial upgrade.",
|
||||
"diagnosis_display_tip_web": "You can go to the Diagnosis section (in the home screen) to see the issues found.",
|
||||
|
@ -167,12 +167,13 @@
|
|||
"diagnosis_ip_weird_resolvconf_details": "Instead, this file should be a symlink to /etc/resolvconf/run/resolv.conf itself pointing to 127.0.0.1 (dnsmasq). The actual resolvers should be configured in /etc/resolv.dnsmasq.conf.",
|
||||
"diagnosis_dns_good_conf": "Good DNS configuration for domain {domain} (category {category})",
|
||||
"diagnosis_dns_bad_conf": "Bad or missing DNS configuration for domain {domain} (category {category})",
|
||||
"diagnosis_dns_missing_record": "According to the recommended DNS configuration, you should add a DNS record with type {0}, name {1} and value {2}. You can check https://yunohost.org/dns_config for more info.",
|
||||
"diagnosis_dns_discrepancy": "The DNS record with type {0} and name {1} does not match the recommended configuration. Current value: {2}. Excepted value: {3}. You can check https://yunohost.org/dns_config for more info.",
|
||||
"diagnosis_dns_missing_record": "According to the recommended DNS configuration, you should add a DNS record with type: {type}, name: {name}, and value: {value}",
|
||||
"diagnosis_dns_discrepancy": "The DNS record with type {type} and name {name} does not match the recommended configuration. Current value: {current}. Excepted value: {value}",
|
||||
"diagnosis_dns_point_to_doc": "Please check the documentation at https://yunohost.org/dns_config if you need help about configuring DNS records",
|
||||
"diagnosis_services_running": "Service {service} is running!",
|
||||
"diagnosis_services_conf_broken": "Configuration is broken for service {service}!",
|
||||
"diagnosis_services_bad_status": "Service {service} is {status} :(",
|
||||
"diagnosis_services_bad_status_tip": "You can try to restart the service, and if it doesn't work, have a look at the service logs using 'yunohost service log {0}' or through the 'Services' section of the webadmin.",
|
||||
"diagnosis_services_bad_status_tip": "You can try to restart the service, and if it doesn't work, have a look at the service logs using 'yunohost service log {service}' or through the 'Services' section of the webadmin.",
|
||||
"diagnosis_diskusage_verylow": "Storage {mountpoint} (on device {device}) has only {free_abs_GB} GB ({free_percent}%) space remaining. You should really consider cleaning up some space.",
|
||||
"diagnosis_diskusage_low": "Storage {mountpoint} (on device {device}) has only {free_abs_GB} GB ({free_percent}%) space remaining. Be careful.",
|
||||
"diagnosis_diskusage_ok": "Storage {mountpoint} (on device {device}) still has {free_abs_GB} GB ({free_percent}%) space left!",
|
||||
|
@ -205,7 +206,7 @@
|
|||
"diagnosis_ports_could_not_diagnose": "Could not diagnose if ports are reachable from outside. Error: {error}",
|
||||
"diagnosis_ports_unreachable": "Port {port} is not reachable from outside.",
|
||||
"diagnosis_ports_ok": "Port {port} is reachable from outside.",
|
||||
"diagnosis_ports_needed_by": "Exposing this port is needed for {1} features (service {0})",
|
||||
"diagnosis_ports_needed_by": "Exposing this port is needed for {category} features (service {service})",
|
||||
"diagnosis_ports_forwarding_tip": "To fix this issue, you most probably need to configure port forwarding on your internet router as described in https://yunohost.org/isp_box_config",
|
||||
"diagnosis_http_could_not_diagnose": "Could not diagnose if domain is reachable from outside. Error: {error}",
|
||||
"diagnosis_http_ok": "Domain {domain} is reachable through HTTP from outside the local network.",
|
||||
|
|
|
@ -458,7 +458,7 @@ class Diagnoser():
|
|||
item["summary"] = m18n.n(summary_key, **summary_args)
|
||||
|
||||
if "details" in item:
|
||||
item["details"] = [m18n.n(key, *values) for key, values in item["details"]]
|
||||
item["details"] = [m18n.n(key, **values) for key, values in item["details"]]
|
||||
|
||||
|
||||
def _list_diagnosis_categories():
|
||||
|
|
Loading…
Add table
Reference in a new issue