コード例 #1
0
def add_node(name):
    '''
    Add node to corosync.conf
    '''
    coronodes = None
    nodes = None
    coronodes = utils.list_corosync_nodes()
    try:
        nodes = utils.list_cluster_nodes()
    except Exception:
        nodes = []
    ipaddr = get_ip(name)
    if name in coronodes or (ipaddr and ipaddr in coronodes):
        err_buf.warning("%s already in corosync.conf" % (name))
        return
    if name in nodes:
        err_buf.warning("%s already in configuration" % (name))
        return

    f = open(conf()).read()
    p = Parser(f)

    node_addr = name
    node_id = next_nodeid(p)

    p.add(
        'nodelist',
        make_section(
            'nodelist.node',
            make_value('nodelist.node.ring0_addr', node_addr) +
            make_value('nodelist.node.nodeid', str(node_id))))

    num_nodes = p.count('nodelist.node')
    if num_nodes > 2:
        p.remove('quorum.two_node')

    f = open(conf(), 'w')
    f.write(p.to_string())
    f.close()

    # update running config (if any)
    if nodes:
        utils.ext_cmd([
            "corosync-cmapctl", "-s",
            "nodelist.node.%s.nodeid" % (num_nodes - 1), "u32",
            str(node_id)
        ],
                      shell=False)
        utils.ext_cmd([
            "corosync-cmapctl", "-s",
            "nodelist.node.%s.ring0_addr" % (num_nodes - 1), "str", node_addr
        ],
                      shell=False)
コード例 #2
0
ファイル: corosync.py プロジェクト: lge/crmsh
def add_node(name):
    '''
    Add node to corosync.conf
    '''
    coronodes = None
    nodes = None
    coronodes = utils.list_corosync_nodes()
    try:
        nodes = utils.list_cluster_nodes()
    except Exception:
        nodes = []
    ipaddr = get_ip(name)
    if name in coronodes or (ipaddr and ipaddr in coronodes):
        err_buf.warning("%s already in corosync.conf" % (name))
        return
    if name in nodes:
        err_buf.warning("%s already in configuration" % (name))
        return

    f = open(conf()).read()
    p = Parser(f)

    node_addr = name
    node_id = next_nodeid(p)

    p.add('nodelist',
          make_section('nodelist.node',
                       make_value('nodelist.node.ring0_addr', node_addr) +
                       make_value('nodelist.node.nodeid', str(node_id))))

    num_nodes = p.count('nodelist.node')
    if num_nodes > 2:
        p.remove('quorum.two_node')

    f = open(conf(), 'w')
    f.write(p.to_string())
    f.close()

    # update running config (if any)
    if nodes:
        utils.ext_cmd(["corosync-cmapctl",
                       "-s", "nodelist.node.%s.nodeid" % (num_nodes - 1),
                       "u32", str(node_id)], shell=False)
        utils.ext_cmd(["corosync-cmapctl",
                       "-s", "nodelist.node.%s.ring0_addr" % (num_nodes - 1),
                       "str", node_addr], shell=False)
コード例 #3
0
ファイル: ui_cluster.py プロジェクト: lge/crmsh
 def requires(self):
     stack = utils.cluster_stack()
     if len(stack) > 0 and stack != 'corosync':
         err_buf.warning("Unsupported cluster stack %s detected." % (stack))
         return False
     return True
コード例 #4
0
 def requires(self):
     stack = utils.cluster_stack()
     if len(stack) > 0 and stack != 'corosync':
         err_buf.warning("Unsupported cluster stack %s detected." % (stack))
         return False
     return corosync.check_tools()