Example #1
0
def info(name=None):
    cmd = VOLUME_CMD + ["info"] + ([name] if name else [])
    data = utils.execute_and_output(cmd, _parseinfo)
    if name and not data:
        raise GlusterCliFailure("Volume %s does not exist" % name)

    return data
def quorumtype(name, quorum_type):
    if name and quorum_type:
        cmd = VOLUME_CMD + [
            "set", name, "cluster.server-quorum-type", quorum_type
        ]
        return utils.checkstatuszero(cmd)
    raise GlusterCliFailure("name or quorum type should not be empty")
def quorumratio(quorum_type, quorum_ratio):
    if quorum_type and quorum_ratio:
        cmd = VOLUME_CMD + [
            "set", "all", "cluster." + quorum_type + "-quorum-ratio",
            quorum_ratio
        ]
        return utils.checkstatuszero(cmd)
    raise GlusterCliFailure("quorum type or quorum ratio should not be empty")
Example #4
0
def execute_and_output(cmd, func):
    rc, out, err = execute(cmd + ['--xml'])
    if rc == 0:
        return func(out)

    raise GlusterCliFailure(err)
Example #5
0
def checkstatuszero(cmd):
    rc, _, err = execute(cmd)
    if rc == 0:
        return True

    raise GlusterCliFailure(err)