コード例 #1
0
ファイル: status.py プロジェクト: oVirt/ovirt-node-ng
 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"))
コード例 #2
0
ファイル: status.py プロジェクト: paulwilliams/ovirt-node-ng
 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"))
コード例 #3
0
ファイル: status.py プロジェクト: paulwilliams/ovirt-node-ng
    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"))
コード例 #4
0
    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
コード例 #5
0
ファイル: update.py プロジェクト: prownd/ovirt-node-ng
    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)
コード例 #6
0
ファイル: motd.py プロジェクト: prownd/ovirt-node-ng
    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))