def create(name, bricks, replica=0, stripe=0, transport='tcp', force=False, start_volume=False): cmd = VOLUME_CMD + ["create", name] if stripe: cmd += ["stripe", str(stripe)] if replica: cmd += ["replica", str(replica)] cmd += ["transport", transport] cmd += bricks if force: cmd += ["force"] # If volume needs to be started, then run create command without # decorator else return create command and statuszerotrue # decorator will take care of running cmd if start_volume: utils.checkstatuszero(cmd) return start(name, force=True) else: return utils.checkstatuszero(cmd)
def clone(cloneName, snapName, description="", force=False, start=False): cmd = SNAPSHOT_CMD + ["clone", cloneName, snapName] if description != "": cmd += ["description", str(description)] if force: cmd += ["force"] utils.checkstatuszero(cmd) if start: return volume.start(cloneName)
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")
def removebrickCommit(name, brickpath, replica=0): cmd = VOLUME_CMD + ["remove-brick", name] if replica: cmd += ["replica", replica] cmd += [brickpath, "commit"] return utils.checkstatuszero(cmd)
def addbrick(name, brickpath, replica=0, stripe=0, force=False): cmd = VOLUME_CMD + ["add-brick", name] if stripe: cmd += ["stripe", stripe] if replica: cmd += ["replica", replica] cmd += [brickpath] if force: cmd += ["force"] return utils.checkstatuszero(cmd)
def create(volName, snapName, description="", force=False, activate_snapshot=False): cmd = SNAPSHOT_CMD + ["create", snapName, volName] if description != "": cmd += ["description", str(description)] if force: cmd += ["force"] # If volume needs to be started, then run create command without # decorator else return create command and statuszerotrue # decorator will take care of running cmd data = utils.execute_and_output(cmd, _parseCreateOutput) if activate_snapshot: if not data: raise GlusterCliFailure("Snapshot not created %s does not exist" % snapName) # utils.checkstatuszero(cmd) else: activate(data) else: utils.checkstatuszero(cmd) return data
def create(name, bricks, replica=0, stripe=0, transport='tcp', force=False, start_volume=False): cmd = VOLUME_CMD + ["create", name] if stripe > 0: cmd += ["stripe", str(stripe)] if replica > 0: cmd += ["replica", str(replica)] cmd += ["transport", transport] cmd += bricks if force: cmd += ["force"] # If volume needs to be started, then run create command without # decorator else return create command and statuszerotrue # decorator will take care of running cmd if start_volume: utils.checkstatuszero(cmd) return start(name, force=True) else: return utils.checkstatuszero(cmd)
def delete(name, stop_volume=False): if stop_volume: stop(name, force=True) cmd = VOLUME_CMD + ["delete", name] return utils.checkstatuszero(cmd)
def attach(hostname): return utils.checkstatuszero(PEER_CMD + ["probe", hostname])
def detach(hostname, force=False): cmd = PEER_CMD + ["detach", hostname] if force: cmd += ["force"] return utils.checkstatuszero(cmd)
def restore(name): cmd = SNAPSHOT_CMD + ["restore", name] return utils.checkstatuszero(cmd)
def deactivate(name, force=False): cmd = SNAPSHOT_CMD + ["deactivate", name] if force: cmd += ["force"] return utils.checkstatuszero(cmd)
def stop(name, force=False): cmd = VOLUME_CMD + ["stop", name] if force: cmd += ["force"] return utils.checkstatuszero(cmd)
def delete(name, deactivate_snapshot=False): if deactivate_snapshot: deactivate(name, force=True) cmd = SNAPSHOT_CMD + ["delete", name] return utils.checkstatuszero(cmd)