def add(volname, bricks, stripe=None, replica=None, arbiter=None, force=False): """ Add Bricks :param volname: Volume Name :param bricks: List of Bricks :param stripe: Stripe Count :param replica: Replica Count :param arbiter: Arbiter Count :param force: True|False Force Add Bricks :returns: Output of add-brick command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["add-brick", volname] if stripe is not None: cmd += ["stripe", "{0}".format(stripe)] if replica is not None: cmd += ["replica", "{0}".format(replica)] if arbiter is not None: cmd += ["arbiter", "{0}".format(arbiter)] cmd += bricks if force: cmd += ["force"] return volume_execute(cmd)
def clear_locks(volname, path, kind, inode_range=None, entry_basename=None, posix_range=None): """ Clear locks held on path :param volname: Volume Name :param path: Locked Path :param kind: Lock Kind(blocked|granted|all) :param inode_range: Inode Range :param entry_basename: Entry Basename :param posix_range: Posix Range :returns: Output of Clear locks command, raises GlusterCmdException((rc, out, err)) on error """ if kind.lower() not in LOCK_KINDS: raise GlusterCmdException((-1, "", "Invalid Lock Kind")) cmd = ["clear-locks", volname, "kind", kind.lower()] if inode_range is not None: cmd += ["inode", inode_range] if entry_basename is not None: cmd += ["entry", entry_basename] if posix_range is not None: cmd += ["posix", posix_range] return volume_execute(cmd)
def fix_layout_start(volname): """ Fix Layout Rebalance Start :param volname: Volume Name :returns: Output of the command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["rebalance", volname, "fix-layout", "start"] return volume_execute(cmd)
def profile_stop(volname): """ Stop Profile :param volname: Volume Name :return: Output of Profile command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["profile", volname, "stop"] return volume_execute(cmd)
def inode_quota_enable(volname): """ Enable Inode Quota :param volname: Volume Name :returns: Output of inode-quota Enable command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["inode-quota", volname, "enable"] return volume_execute(cmd)
def delete(volname): """ Delete Gluster Volume :param volname: Volume Name :returns: Output of Delete command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["delete", volname] return volume_execute(cmd)
def stop(volname): """ Rebalance Stop :param volname: Volume Name :returns: Output of the command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["rebalance", volname, "stop"] return volume_execute(cmd)
def barrier_disable(volname): """ Disable Barrier :param volname: Volume Name :returns: Output of Barrier command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["barrier", volname, "disable"] return volume_execute(cmd)
def create(volname, volbricks, replica=0, stripe=0, arbiter=0, disperse=0, disperse_data=0, redundancy=0, transport="tcp", force=False): """ Create Gluster Volume :param volname: Volume Name :param volbricks: List of Brick paths(HOSTNAME:PATH) :param replica: Number of Replica bricks :param stripe: Number of Stripe bricks :param arbiter: Number of Arbiter bricks :param disperse: Number of disperse bricks :param disperse_data: Number of disperse data bricks :param redundancy: Number of Redundancy bricks :param transport: Transport mode(tcp|rdma|tcp,rdma) :param force: (True|False) Create Volume with Force option :returns: Output of Create command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["create", volname] if replica != 0: cmd += ["replica", "{0}".format(replica)] if stripe != 0: cmd += ["stripe", "{0}".format(stripe)] if arbiter != 0: cmd += ["arbiter", "{0}".format(arbiter)] if disperse != 0: cmd += ["disperse", "{0}".format(disperse)] if disperse_data != 0: cmd += ["disperse-data", "{0}".format(disperse_data)] if redundancy != 0: cmd += ["redundancy", "{0}".format(redundancy)] if transport != "tcp": cmd += ["transport", transport] cmd += volbricks if force: cmd += ["force"] return volume_execute(cmd)
def restart(volname, force=False): """ Restart Gluster Volume, Wrapper around two calls stop and start :param volname: Volume Name :param force: (True|False) Restart Volume with Force option :returns: Output of Start command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["stop", volname] if force: cmd += ["force"] volume_execute(cmd) cmd = ["start", volname] if force: cmd += ["force"] return volume_execute(cmd)
def log_rotate(volname, brick): """ Brick log rotate :param volname: Volume Name :param brick: Brick Path :returns: Output of Log rotate command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["log", volname, "rotate", brick] return volume_execute(cmd)
def start(volname, force=False): """ Rebalance Start :param volname: Volume Name :param force: True|False Force start the rebalance :returns: Output of the command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["rebalance", volname, "start"] if force: cmd += ["force"] return volume_execute(cmd)
def sync(hostname, volname=None): """ Sync the volume information from a peer :param hostname: Hostname to sync from :param volname: Volume Name :returns: Output of Sync command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["sync", hostname] if volname is not None: cmd += [volname] return volume_execute(cmd)
def optset(volname, opts): """ Set Volume Options :param volname: Volume Name :param opts: Dict with config key as dict key and config value as value :returns: Output of Volume Set command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["set", volname] for key, value in opts.items(): cmd += [key, value] return volume_execute(cmd)
def stop(volname, force=False): """ Stop Gluster Volume :param volname: Volume Name :param force: (True|False) Stop Volume with Force option :returns: Output of Stop command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["stop", volname] if force: cmd += ["force"] return volume_execute(cmd)
def replace_commit(volname, source_brick, new_brick): """ Replace Bricks :param volname: Volume Name :param source_brick: Source Brick :param new_brick: New Replacement Brick :returns: Output of replace-brick command, raises GlusterCmdException((rc, out, err)) on error """ cmd = [ "replace-brick", volname, source_brick, new_brick, "commit", "force" ] return volume_execute(cmd)
def remove_commit(volname, bricks, replica=None): """ Remove Bricks Commit :param volname: Volume Name :param bricks: List of Bricks :param replica: Replica Count :returns: Output of remove-brick commit command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["remove-brick", volname] if replica is not None: cmd += ["replica", "{0}".format(replica)] cmd += bricks cmd += ["commit"] return volume_execute(cmd)
def optreset(volname, opt=None, force=False): """ Reset Volume Options :param volname: Volume Name :param opt: Option name to reset, else reset all :param force: Force reset options :returns: Output of Volume Reset command, raises GlusterCmdException((rc, out, err)) on error """ cmd = ["reset", volname] if opt is not None: cmd += [opt] if force: cmd += ["force"] return volume_execute(cmd)