Esempio n. 1
0
def _get_iface_info(iface, addresses, routes):
    ipv4gateway = get_gateway(routes, iface, family=4)
    ipv4addr, ipv4netmask, ipv4addrs, ipv6addrs = getIpInfo(
        iface, addresses, ipv4gateway)
    is_dhcpv4 = dhclient.is_active(iface, family=4)
    is_dhcpv6 = dhclient.is_active(iface, family=6)

    return {'mtu': get_mtu(iface), 'addr': ipv4addr, 'ipv4addrs': ipv4addrs,
            'gateway': ipv4gateway, 'netmask': ipv4netmask,
            'ipv4defaultroute': is_default_route(ipv4gateway),
            'dhcpv4': is_dhcpv4, 'ipv6addrs': ipv6addrs,
            'ipv6gateway': get_gateway(routes, iface, family=6),
            'ipv6autoconf': is_ipv6_local_auto(iface), 'dhcpv6': is_dhcpv6}
Esempio n. 2
0
File: info.py Progetto: nirs/vdsm
def _get_iface_info(iface, addresses, routes):
    ipv4gateway = get_gateway(routes, iface, family=4)
    ipv4addr, ipv4netmask, ipv4addrs, ipv6addrs = getIpInfo(
        iface, addresses, ipv4gateway)
    is_dhcpv4 = dhclient.is_active(iface, family=4)
    is_dhcpv6 = dhclient.is_active(iface, family=6)
    mtu = iflink(iface).mtu()
    return {'mtu': mtu, 'addr': ipv4addr, 'ipv4addrs': ipv4addrs,
            'gateway': ipv4gateway, 'netmask': ipv4netmask,
            'ipv4defaultroute': is_default_route(ipv4gateway, routes),
            'dhcpv4': is_dhcpv4, 'ipv6addrs': ipv6addrs,
            'ipv6gateway': get_gateway(routes, iface, family=6),
            'ipv6autoconf': is_ipv6_local_auto(iface), 'dhcpv6': is_dhcpv6}
Esempio n. 3
0
File: cache.py Progetto: rexhsu/vdsm
def _getNetInfo(iface, bridged, routes, ipaddrs, net_attrs):
    """Returns a dictionary of properties about the network's interface status.
    Raises a KeyError if the iface does not exist."""
    data = {}
    try:
        if bridged:
            data.update({
                'ports': bridges.ports(iface),
                'stp': bridges.stp_state(iface)
            })
        else:
            # ovirt-engine-3.1 expects to see the "interface" attribute iff the
            # network is bridgeless. Please remove the attribute and this
            # comment when the version is no longer supported.
            data['interface'] = iface

        gateway = get_gateway(routes, iface)
        ipv4addr, ipv4netmask, ipv4addrs, ipv6addrs = getIpInfo(
            iface, ipaddrs, gateway)

        is_dhcpv4 = dhclient.is_active(iface, family=4)
        is_dhcpv6 = dhclient.is_active(iface, family=6)

        data.update({
            'iface': iface,
            'bridged': bridged,
            'addr': ipv4addr,
            'netmask': ipv4netmask,
            'dhcpv4': is_dhcpv4,
            'dhcpv6': is_dhcpv6,
            'ipv4addrs': ipv4addrs,
            'ipv6addrs': ipv6addrs,
            'ipv6autoconf': is_ipv6_local_auto(iface),
            'gateway': gateway,
            'ipv6gateway': get_gateway(routes, iface, family=6),
            'mtu': getMtu(iface)
        })
    except (IOError, OSError) as e:
        if e.errno == errno.ENOENT:
            logging.info('Obtaining info for net %s.', iface, exc_info=True)
            raise KeyError('Network %s was not found' % iface)
        else:
            raise
    return data
Esempio n. 4
0
def _devinfo(link, routes, ipaddrs):
    gateway = get_gateway(routes, link.name)
    ipv4addr, ipv4netmask, ipv4addrs, ipv6addrs = getIpInfo(
        link.name, ipaddrs, gateway)

    is_dhcpv4 = dhclient.is_active(link.name, family=4)
    is_dhcpv6 = dhclient.is_active(link.name, family=6)

    return {'addr': ipv4addr,
            'ipv4addrs': ipv4addrs,
            'ipv6addrs': ipv6addrs,
            'ipv6autoconf': is_ipv6_local_auto(link.name),
            'gateway': gateway,
            'ipv6gateway': get_gateway(routes, link.name, family=6),
            'dhcpv4': is_dhcpv4,
            'dhcpv6': is_dhcpv6,
            'mtu': link.mtu,
            'netmask': ipv4netmask,
            'ipv4defaultroute': is_default_route(gateway)}
Esempio n. 5
0
def _get_net_info(interface, routes):
    mtu = mtus.getMtu(interface)
    ipaddrs = addresses.getIpAddrs()
    addr, netmask, ipv4addrs, ipv6addrs = addresses.getIpInfo(interface,
                                                              ipaddrs)
    dhcpv4 = dhclient.is_active(interface, family=4)
    dhcpv6 = dhclient.is_active(interface, family=6)
    gateway = netinfo_routes.get_gateway(routes, interface)
    ipv6gateway = netinfo_routes.get_gateway(routes, interface, family=6)

    return {
        'mtu': str(mtu),
        'addr': addr,
        'gateway': gateway,
        'netmask': netmask,
        'dhcpv4': dhcpv4,
        'ipv4addrs': ipv4addrs,
        'ipv6addrs': ipv6addrs,
        'ipv6autoconf': addresses.is_ipv6_local_auto(interface),
        'ipv6gateway': ipv6gateway,
        'dhcpv6': dhcpv6,
        'ipv4defaultroute': netinfo_routes.is_default_route(gateway)}
Esempio n. 6
0
def _get_net_info(interface, routes):
    mtu = mtus.getMtu(interface)
    ipaddrs = addresses.getIpAddrs()
    addr, netmask, ipv4addrs, ipv6addrs = addresses.getIpInfo(
        interface, ipaddrs)
    dhcpv4 = dhclient.is_active(interface, family=4)
    dhcpv6 = dhclient.is_active(interface, family=6)
    gateway = netinfo_routes.get_gateway(routes, interface)
    ipv6gateway = netinfo_routes.get_gateway(routes, interface, family=6)

    return {
        'mtu': str(mtu),
        'addr': addr,
        'gateway': gateway,
        'netmask': netmask,
        'dhcpv4': dhcpv4,
        'ipv4addrs': ipv4addrs,
        'ipv6addrs': ipv6addrs,
        'ipv6autoconf': addresses.is_ipv6_local_auto(interface),
        'ipv6gateway': ipv6gateway,
        'dhcpv6': dhcpv6
    }
Esempio n. 7
0
    def testDhclientLeases(self, family, dateFormat):
        with veth_pair() as (server, client):
            addrAdd(server, IP_ADDRESS, IP_CIDR)
            addrAdd(server, IPv6_ADDRESS, IPv6_CIDR, 6)
            linkSet(server, ['up'])

            with dnsmasq_run(server, DHCP_RANGE_FROM, DHCP_RANGE_TO,
                             DHCPv6_RANGE_FROM, DHCPv6_RANGE_TO, IP_GATEWAY):

                with namedTemporaryDir(dir='/var/lib/dhclient') as dir:
                    dhclient_runner = dhcp.DhclientRunner(
                        client, family, dir, dateFormat)
                    try:
                        with running(dhclient_runner):
                            is_dhcpv4 = dhclient.is_active(client, family=4)
                            is_dhcpv6 = dhclient.is_active(client, family=6)
                    except dhcp.ProcessCannotBeKilled:
                        raise SkipTest('dhclient could not be killed')

        if family == 4:
            self.assertTrue(is_dhcpv4)
        else:
            self.assertTrue(is_dhcpv6)
Esempio n. 8
0
 def assertDhclient(self, iface, family):
     return dhclient.is_active(iface, family)
Esempio n. 9
0
 def assertDhclient(self, iface, family):
     return dhclient.is_active(iface, family)