Esempio n. 1
0
    def _etcd_get_member_healthy_count(cls, admin):
        cmd = u"etcdctl cluster-health | grep 'is healthy:' | wc -l"
        (out, err, stat) = _exec_remote(admin, cmd)
        if err.strip() != '':
            raise Exp(errno.EPERM, "%s:%s" % (host.strip(), err.strip()))

        return out.strip()
Esempio n. 2
0
    def _etcd_member_is_healthy(cls, admin, host):
        cmd = u"etcdctl cluster-health | grep 'name=%s ' | grep 'is healthy:' | wc -l" % (host)
        (out, err, stat) = _exec_remote(admin, cmd)
        if err.strip() != '':
            raise Exp(errno.EPERM, "%s:%s" % (host.strip(), err.strip()))

        if out.strip() == "1":
            return True
        else:
            return False
Esempio n. 3
0
 def etcd_is_health(cls):
     """
     :return:
         return 1: etcd cluster health
         return 0: etcd cluster unhealth
     """
     host = cls.get_admin()
     cmd = u"etcdctl cluster-health"
     #print host.strip()
     (out, err, stat) = _exec_remote(host.strip(), cmd)
     if err.strip() != '':
         raise Exp(errno.EPERM, "%s:%s" % (host.strip(), err.strip()))
     if "cluster is healthy" in out:
         return 1
     else:
         _dwarn("Etcd status is unhealth, please check etcd status")
         return 0
Esempio n. 4
0
 def _exec_node(self, h, cmd):
     (out, err, stat) = _exec_remote(h, cmd)
     if (out):
         _dmsg(h + ":\n" + out)
     if (err):
         _dwarn(h + ":\n" + err)