def _get_file_data(ifname_prefix, interface):
    """
    Return data for (sub-)interfaces and routes
    """

    label = interface['label']

    ip4s = interface['ip4s']
    ip6s = interface['ip6s']

    gateway4 = interface['gateway4']
    gateway6 = interface['gateway6']

    dns = interface['dns']

    ifaces = []

    ifname_suffix_num = 0

    for ip4, ip6 in map(None, ip4s, ip6s):
        if ifname_suffix_num:
            ifname = "%s:%d" % (ifname_prefix, ifname_suffix_num)
        else:
            ifname = ifname_prefix

        iface_data = "# Automatically generated, do not edit\n\n"
        if label:
            iface_data += "# Label %s\n" % label
        iface_data += "DEVICE=%s\n" % ifname
        iface_data += "BOOTPROTO=static\n"
        iface_data += "HWADDR=%s\n" % interface['mac']

        if ip4:
            iface_data += "IPADDR=%(address)s\n" % ip4
            iface_data += "NETMASK=%(netmask)s\n" % ip4
            if gateway4:
                iface_data += "DEFROUTE=yes\n"
                iface_data += gateway4 % "GATEWAY=%s\n"
                gateway4 = None

        if ip6:
            iface_data += "IPV6INIT=yes\n"
            iface_data += "IPV6_AUTOCONF=no\n"
            iface_data += "IPV6ADDR=%(address)s/%(prefixlen)s\n" % ip6

            if gateway6:
                iface_data += "IPV6_DEFAULTGW=%s%%%s\n" % (gateway6, ifname)
                gateway6 = None

        if dns:
            for j, nameserver in enumerate(dns):
                iface_data += "DNS%d=%s\n" % (j + 1, nameserver)
            dns = None

        iface_data += "ONBOOT=yes\n"
        iface_data += "NM_CONTROLLED=no\n"
        ifname_suffix_num += 1

        ifaces.append((ifname, iface_data))

    route_data = ''
    for i, route in enumerate(interface['routes']):
        if route['network'] == '0.0.0.0' and \
                route['netmask'] == '0.0.0.0' and \
                'gateway4' in interface and \
                route['gateway'] == interface['gateway4']:
            continue
        route_data += "ADDRESS%d=%s\n" % (i, route['network'])
        route_data += "NETMASK%d=%s\n" % (i, route['netmask'])
        route_data += "GATEWAY%d=%s\n" % (i, route['gateway'])

    return (ifaces, route_data)
dataset/ETHPy150Open rackerlabs/openstack-guest-agents-unix/commands/redhat/network.py/_get_file_data/swapped operands of `%`