def get_gateways(interfaces):
    gateway4s = []
    gateway6s = []

    for interface in interfaces.itervalues():
        gateway = interface.get('gateway4')
        if gateway:
            gateway4s.append(gateway)

        gateway = interface.get('gateway6')
        if gateway:
            gateway6s.append(gateway)

    if len(gateway4s) > 1:
        raise RuntimeError("Multiple IPv4 default routes specified")
    if len(gateway6s) > 1:
        raise RuntimeError("Multiple IPv6 default routes specified")

    gateway4 = gateway4s and gateway4s[0] or None
    gateway6 = gateway6s and gateway6s[0] or None

    return gateway4, gateway6
dataset/ETHPy150Open rackerlabs/openstack-guest-agents-unix/commands/network.py/get_gateways/original