import re


def _get_ip_addr_num(file_path):
    """Get the next IPADDR index num to use for adding an ip addr to an
    ifcfg file.
    """
    num = ''
    with open(file_path, 'r') as f:
        data = f.read()
    data = data.splitlines()
    for line in data:
        found = re.search(r'IPADDR(\d?)=', line)
        if found:
            if found.group(1) == '':
                num = 0
            else:
                num = str(int(found.group(1)) + 1)
    return num