Example #1
0
def distribute(master, slave):
    if rconf.args.use_gconf_volinfo:
        mvol = VolinfoFromGconf(master.volume, master=True)
    else:
        mvol = Volinfo(master.volume, master.host, master=True)
    logging.debug('master bricks: ' + repr(mvol.bricks))
    prelude = []
    slave_host = None
    slave_vol = None

    prelude = [gconf.get("ssh-command")] + \
        gconf.get("ssh-options").split() + \
        ["-p", str(gconf.get("ssh-port"))] + \
        [slave.remote_addr]

    logging.debug('slave SSH gateway: ' + slave.remote_addr)

    if rconf.args.use_gconf_volinfo:
        svol = VolinfoFromGconf(slave.volume, master=False)
    else:
        svol = Volinfo(slave.volume, "localhost", prelude, master=False)

    sbricks = svol.bricks
    suuid = svol.uuid
    slave_host = slave.remote_addr.split('@')[-1]
    slave_vol = slave.volume

    # save this xattr for the session delete command
    old_stime_xattr_prefix = gconf.get("stime-xattr-prefix", None)
    new_stime_xattr_prefix = "trusted.glusterfs." + mvol.uuid + "." + \
                             svol.uuid
    if not old_stime_xattr_prefix or \
       old_stime_xattr_prefix != new_stime_xattr_prefix:
        gconf.setconfig("stime-xattr-prefix", new_stime_xattr_prefix)

    logging.debug('slave bricks: ' + repr(sbricks))

    slavenodes = set((b['host'], b["uuid"]) for b in sbricks)
    rap = SSH.parse_ssh_address(slave)
    slaves = [(rap['user'] + '@' + h[0], h[1]) for h in slavenodes]

    workerspex = []
    for idx, brick in enumerate(mvol.bricks):
        if rconf.args.local_node_id == brick['uuid']:
            is_hot = mvol.is_hot(":".join([brick['host'], brick['dir']]))
            workerspex.append((brick,
                               slaves[idx % len(slaves)],
                               get_subvol_num(idx, mvol, is_hot),
                               is_hot))
    logging.debug('worker specs: ' + repr(workerspex))
    return workerspex, suuid, slave_vol, slave_host, master, slavenodes
Example #2
0
def distribute(master, slave):
    if rconf.args.use_gconf_volinfo:
        mvol = VolinfoFromGconf(master.volume, master=True)
    else:
        mvol = Volinfo(master.volume, master.host)
    logging.debug('master bricks: ' + repr(mvol.bricks))
    prelude = []
    slave_host = None
    slave_vol = None

    prelude = [gconf.get("ssh-command")] + \
        gconf.get("ssh-options").split() + \
        ["-p", str(gconf.get("ssh-port"))] + \
        [slave.remote_addr]

    logging.debug('slave SSH gateway: ' + slave.remote_addr)

    if rconf.args.use_gconf_volinfo:
        svol = VolinfoFromGconf(slave.volume, master=False)
    else:
        svol = Volinfo(slave.volume, "localhost", prelude)

    sbricks = svol.bricks
    suuid = svol.uuid
    slave_host = slave.remote_addr.split('@')[-1]
    slave_vol = slave.volume

    # save this xattr for the session delete command
    old_stime_xattr_prefix = gconf.get("stime-xattr-prefix", None)
    new_stime_xattr_prefix = "trusted.glusterfs." + mvol.uuid + "." + \
                             svol.uuid
    if not old_stime_xattr_prefix or \
       old_stime_xattr_prefix != new_stime_xattr_prefix:
        gconf.setconfig("stime-xattr-prefix", new_stime_xattr_prefix)

    logging.debug('slave bricks: ' + repr(sbricks))

    slavenodes = set((b['host'], b["uuid"]) for b in sbricks)
    rap = SSH.parse_ssh_address(slave)
    slaves = [(rap['user'] + '@' + h[0], h[1]) for h in slavenodes]

    workerspex = []
    for idx, brick in enumerate(mvol.bricks):
        if rconf.args.local_node_id == brick['uuid']:
            is_hot = mvol.is_hot(":".join([brick['host'], brick['dir']]))
            workerspex.append((brick,
                               slaves[idx % len(slaves)],
                               get_subvol_num(idx, mvol, is_hot),
                               is_hot))
    logging.debug('worker specs: ' + repr(workerspex))
    return workerspex, suuid, slave_vol, slave_host, master, slavenodes
Example #3
0
def subcmd_config_set(args):
    import sys

    try:
        gconf.setconfig(config_name_format(args.name), args.value)
    except gconf.GconfNotConfigurable:
        cnf_val = gconf.get(config_name_format(args.name), None)
        if cnf_val is None:
            sys.stderr.write("Invalid config name \"%s\"\n" % args.name)
            sys.exit(ERROR_CONFIG_INVALID)

        # Not configurable
        sys.stderr.write("Not configurable \"%s\"\n" % args.name)
        sys.exit(ERROR_CONFIG_NOT_CONFIGURABLE)
    except gconf.GconfInvalidValue:
        sys.stderr.write("Invalid config value \"%s=%s\"\n" %
                         (args.name, args.value))
        sys.exit(ERROR_CONFIG_INVALID_VALUE)
Example #4
0
def subcmd_config_set(args):
    import sys

    try:
        gconf.setconfig(config_name_format(args.name), args.value)
    except gconf.GconfNotConfigurable:
        cnf_val = gconf.get(config_name_format(args.name), None)
        if cnf_val is None:
            sys.stderr.write("Invalid config name \"%s\"\n" % args.name)
            sys.exit(ERROR_CONFIG_INVALID)

        # Not configurable
        sys.stderr.write("Not configurable \"%s\"\n" % args.name)
        sys.exit(ERROR_CONFIG_NOT_CONFIGURABLE)
    except gconf.GconfInvalidValue:
        sys.stderr.write("Invalid config value \"%s=%s\"\n" % (args.name,
                                                               args.value))
        sys.exit(ERROR_CONFIG_INVALID_VALUE)
Example #5
0
def get_subvol_num(brick_idx, vol, hot):
    tier = vol.is_tier()
    disperse_count = vol.disperse_count(tier, hot)
    replica_count = vol.replica_count(tier, hot)
    distribute_count = vol.distribution_count(tier, hot)
    gconf.setconfig("master-distribution-count", distribute_count)

    if (tier and not hot):
        brick_idx = brick_idx - vol.get_hot_bricks_count(tier)

    subvol_size = disperse_count if disperse_count > 0 else replica_count
    cnt = int((brick_idx + 1) / subvol_size)
    rem = (brick_idx + 1) % subvol_size
    if rem > 0:
        cnt = cnt + 1

    if (tier and hot):
        return "hot_" + str(cnt)
    elif (tier and not hot):
        return "cold_" + str(cnt)
    else:
        return str(cnt)