示例#1
0
def _get_mon_id_map(unused_mon_ids, minions):
    mon_id_map = dict(zip(unused_mon_ids, minions))
    monitors = {}
    for id, minion in mon_id_map.iteritems():
        monitors[id] = {
            "name": minions[minion].get("monitor_name", utils.get_short_hostname(minion)),
            "address": minions[minion]["public_ip"],
        }
    return mon_id_map, monitors
示例#2
0
def add_ceph_osd(cluster_name, minions):
    """
    :: minions = {MINION_ID: {'public_ip': IP_ADDRESS,
                              'cluster_ip': IP_ADDRESS,
                              'host_name': HOSTNAME,
                              'devices': {DEVICE: FSTYPE, ...}}, ...}

    """
    conf_file = _CEPH_CLUSTER_CONF_DIR + "/" + cluster_name + "/" + cluster_name + ".conf"
    config = ConfigParser.RawConfigParser()
    config.read(conf_file)

    public_network = IPNetwork(config.get("global", "public network"))
    if config.has_option("global", "cluster network"):
        cluster_network = IPNetwork(config.get("global", "cluster network"))
    else:
        cluster_network = None
    public_network, cluster_network = check_minion_networks(
        minions, public_network, cluster_network, check_cluster_network=True
    )

    pillar_data = {}
    for minion, v in minions.iteritems():
        pillar_data[minion] = {
            "cluster_name": cluster_name,
            "cluster_id": config.get("global", "fsid"),
            "devices": v["devices"],
        }
    pillar = {"usm": pillar_data}

    out = run_state(local, minions, "prepare_ceph_osd", expr_form="list", kwarg={"pillar": pillar})
    if out:
        return out

    out = local.cmd(minions, "cmd.run_all", ["ceph-disk activate-all"], expr_form="list")

    osd_map = {}
    failed_minions = {}
    for minion, v in out.iteritems():
        osds = []

        if v.get("retcode") != 0:
            failed_minions[minion] = v
            continue

        for line in v["stdout"].splitlines():
            if line.startswith("=== "):
                osds.append(line.split("=== ")[1].strip())
                break
        osd_map[minion] = osds

    config.set("global", "cluster network", cluster_network)
    for minion, osds in osd_map.iteritems():
        name = minions[minion].get("host_name", utils.get_short_hostname(minion))
        for osd in osds:
            config.add_section(osd)
            config.set(osd, "host", name)
            config.set(osd, "public addr", minions[minion]["public_ip"])
            config.set(osd, "cluster addr", minions[minion]["cluster_ip"])

    with open(conf_file, "wb") as f:
        config.write(f)

    sync_ceph_conf(cluster_name, minions)

    return failed_minions