def _update_info(self, status): services = ["vdsmd"] statuses = {} for service in services: srv_status = ServiceStatus(service) srv_machine = StatusParser(srv_status).parse() vals = {"human": srv_status, "machine": srv_machine, "status": srv_machine[service]["status"]} statuses[service] = vals if self.machine_readable: output = dict() output.update(StatusParser(status.results).parse()) for k, v in statuses.items(): service_status = v["machine"] if v["status"] != "ok": output["status"] = "bad" output.update(service_status) self.output = json.dumps(output) else: output = status.details().splitlines() overall_status = output.pop(0) for k, v in statuses.items(): if v["status"] != "ok": fields = overall_status.split() overall_status = "%s %s" % (fields[0], bcolors.fail("BAD")) output.append(v["human"]) output = "%s\n%s" % (overall_status, "\n".join(output)) self.output = output
def __new__(self, service): tmpl = "{0} ... {1}" try: subprocess.check_call(["systemctl", "status", "%s.service" % service], stdout=DEVNULL, stderr=DEVNULL) return tmpl.format(service, bcolors.ok("OK")) except Exception: return tmpl.format(service, bcolors.fail("BAD"))
def __new__(self, service): tmpl = '{0} ... {1}' try: subprocess.check_call(["systemctl", "status", "%s.service" % service], stdout=DEVNULL, stderr=DEVNULL) return tmpl.format(service, bcolors.ok("OK")) except Exception: return tmpl.format(service, bcolors.fail("BAD"))
def write(self): if self.machine: print json.dumps(self.results) else: # Neither JSON nor YAML gives a very nice output here, so use # our own formatter, since pprint includes sigils status = bcolors.ok("Success") if self.results["success"] else \ bcolors.fail("Failure") print "Status: %s" % status if self.results["success"]: print " Please reboot to use the initialized system" else: print " Reason:" for line in self.results["reason"].splitlines(): print " %s" % line
def write(self): if self.machine: print(json.dumps(self.results)) else: # Neither JSON nor YAML gives a very nice output here, so use # our own formatter, since pprint includes sigils status = bcolors.ok("Success") if self.results["success"] else \ bcolors.fail("Failure") print("Status: %s" % status) if self.results["success"]: print(" New layer: %s" % self.results["next_layer"]) else: print(" Reason:") for line in self.results["reason"].splitlines(): print(" %s" % line)
def __new__(self, service): tmpl = '{0} ... {1}' try: subprocess.check_call(["systemctl", "status", "%s.service" % service], stdout=DEVNULL, stderr=DEVNULL) return tmpl.format(service, bcolors.ok("OK")) except Exception: log = subprocess.check_output(["journalctl", "-u", "vdsmd.service"]) has_run = False for line in log.splitlines(): if "Started" in line: has_run = True if has_run: return tmpl.format(service, bcolors.fail("BAD")) else: return tmpl.format(service, bcolors.ok("OK"))
def write(self): if self.machine_readable: output = dict() output["node_status"] = self.status["status"] output["additional_info"] = "Please check the status manually " \ "using `nodectl check`" print(json.dumps(output)) else: txts = [""] if not self.status["status"] == "ok": txts += [" node status: " + bcolors.fail("DEGRADED")] txts += [ " Please check the status manually using" " `nodectl check`" ] else: txts += [" node status: " + bcolors.ok("OK")] txts += [" See `nodectl check` for more information"] txts += [""] print("\n".join(txts))