示例#1
0
def get_config_and_install(deployfile='../confs/vm_list.yaml', autoyast='../confs/my_ha_inst.xml'):
    dp = GET_VM_CONF(deployfile)

    vm_list = dp.get_vms_conf()
    resource = dp.get_single_section_conf("resources")
    devices = dp.get_single_section_conf("devices")

    installVMs(vm_list, resource, devices)
示例#2
0
def getCtsConf(stonith_type="external/libvirt", interface1='br1', configuration="../cts_conf", yamlfile='../confs/vm_list.yaml'):
    dp = GET_VM_CONF(yamlfile)
    stonith_type="external/libvirt"
    content=""
    
    vm_list = dp.get_vms_conf()
    node_list=""
    for vm in vm_list.keys():
        if node_list == '':
            node_list = vm
        else:
            node_list += ',' + vm
    f = open(configuration, 'w')
    content += "NODE_LIST=%s\n" % node_list
    content += "STONITH_TYPE=%s\n" % stonith_type
    f.write(content)
    f.close()
def get_cluster_conf(sleep_time="0", configuration="../cluster_conf",
                     yaml="../confs/vm_list.yaml", recursive=False, stonith="sbd"):

    if sleep_time != "0":
        time.sleep(int(sleep_time))

    dp = GET_VM_CONF(yaml)

    vm_list = dp.get_vms_conf()
    devices = dp.get_single_section_conf("devices")
    if devices is not None and devices.has_key("nic"):
        interface = devices["nic"]
    else:
        interface = "br0"
    contents = write_conf_file(vm_list, dp, interface, recursive, stonith)
    #Write env file to "../cluster_conf"
    f=open(configuration, 'w')
    f.write(contents)
    f.close()

    print contents
示例#4
0
def get_cluster_conf(sleep_time="0", configuration="../cluster_conf",
                     yaml="../confs/vm_list.yaml", recursive=False):
    vm_list={}

    if sleep_time != "0":
        time.sleep(int(sleep_time))

    dp = GET_VM_CONF(yaml)

    vm_list = dp.get_vms_conf()
    devices = dp.get_single_section_conf("devices")

    if devices is not None and devices.has_key("nic"):
        interface = devices["nic"]
    else:
        interface = "br0"
    ipaddr = get_ipaddr_by_interface(interface)
    netaddr = get_netaddr(interface)
    netmask = get_net_mask(interface).split(".")
    if len(netmask) != 4:
        netmask_int = 24
    else:
        netmask_int = 0
        for i in netmask:
            netmask_int += bin(int(i))[2:].count("1")
    ip_range = "%s/%d" % (netaddr, netmask_int)

    num_vms = len(vm_list.keys())
    contents = "NODES=%d\n" % num_vms

    print "DEBUG: Checking ip range: %s" % ip_range
    vm_names = vm_list.keys()
    vm_info_list = get_ip_list_by_mac(vm_names, ip_range)

    recur_times = 0
    already_restart = False
    while recursive:
        if isAllIpAssigned(vm_info_list):
            print "All nodes have been assigned IP address."
            break

        if recur_times == 20:
            if already_restart:
                print "Failed to get IP address!"
                sys.exit(3)
            else:
                restartNoIpNodes(vm_info_list)
                recur_times = 0
                already_restart = True

        time.sleep(10)
        recur_times += 1
        print "Checking again..."
        vm_info_list = get_ip_list_by_mac(vm_names, ip_range)

    i = 1
    for vm in vm_info_list.keys():
        contents += "HOSTNAME_NODE%d=%s\n" % (i, vm)
        contents += "IP_NODE%d=%s\n" % (i, vm_info_list[vm][0])
        i += 1

    iscsi = dp.get_single_section_conf("iscsi")

    target_ip = iscsi["target_ip"]
    target_lun = iscsi["target_lun"]
    if target_ip is None:
        target_ip = "147.2.207.237"
    if target_lun is None:
        target_lun = "iqn.2015-08.suse.bej.bliu:441a202b-6aa3-479f-b56f-374e2f38ba20"
    contents += "TARGET_IP=%s\n" % target_ip
    contents += "TARGET_LUN=%s\n" % target_lun
    contents += "NETADDR=%s\n" % netaddr
    contents += "IPADDR=%s\n" % ipaddr
    #Write env file to "../cluster_conf"
    f=open(configuration, 'w')
    f.write(contents)
    f.close()

    print contents
    return