Пример #1
0
 def test_local_auto_with_static_address_without_ra_server(self, nic0):
     ipwrapper.addrAdd(nic0, '2001::88', IPV6_PREFIX_LENGTH, family=6)
     ip_addrs = addresses.getIpAddrs()[nic0]
     assert addresses.is_ipv6_local_auto(nic0)
     assert 2 == len(ip_addrs), ip_addrs
     assert addresses.is_ipv6(ip_addrs[0])
     assert not addresses.is_dynamic(ip_addrs[0])
Пример #2
0
    def test_local_auto_with_dynamic_address_from_ra(self):
        IPV6_NETADDRESS = '2001:1:1:1'
        IPV6_NETPREFIX_LEN = '64'
        with veth_pair() as (server, client):
            with dnsmasq_run(server, ipv6_slaac_prefix=IPV6_NETADDRESS + '::'):
                with wait_for_ipv6(client):
                    ipwrapper.linkSet(client, ['up'])
                    ipwrapper.linkSet(server, ['up'])
                    ipwrapper.addrAdd(server,
                                      IPV6_NETADDRESS + '::1',
                                      IPV6_NETPREFIX_LEN,
                                      family=6)

                # Expecting link and global addresses on client iface
                # The addresses are given randomly, so we sort them
                ip_addrs = sorted(addresses.getIpAddrs()[client],
                                  key=lambda ip: ip['address'])
                self.assertEqual(2, len(ip_addrs))

                self.assertTrue(addresses.is_dynamic(ip_addrs[0]))
                self.assertEqual('global', ip_addrs[0]['scope'])
                self.assertEqual(IPV6_NETADDRESS,
                                 ip_addrs[0]['address'][:len(IPV6_NETADDRESS)])

                self.assertEqual('link', ip_addrs[1]['scope'])
Пример #3
0
def create_netinfo(ovs_info):
    addresses = getIpAddrs()
    routes = get_routes()

    _netinfo = {'networks': {}}

    for bridge, bridge_attrs in six.iteritems(ovs_info.bridges):
        ports = bridge_attrs['ports']

        southbound = ovs_info.southbound_port(ports)

        # northbound ports represents networks
        stp = bridge_attrs['stp']
        for northbound_port in ovs_info.northbound_ports(ports):
            _netinfo['networks'][northbound_port] = _get_network_info(
                northbound_port,
                bridge,
                southbound,
                ports,
                stp,
                addresses,
                routes,
            )

    return _netinfo
Пример #4
0
 def test_local_auto_with_static_address_without_ra_server(self):
     with dummy_device() as dev:
         ipwrapper.addrAdd(dev, '2001::88', '64', family=6)
         ip_addrs = addresses.getIpAddrs()[dev]
         self.assertTrue(addresses.is_ipv6_local_auto(dev))
         self.assertEqual(2, len(ip_addrs))
         self.assertTrue(addresses.is_ipv6(ip_addrs[0]))
         self.assertTrue(not addresses.is_dynamic(ip_addrs[0]))
Пример #5
0
 def test_local_auto_with_static_address_without_ra_server(self):
     with dummy_device() as dev:
         ipwrapper.addrAdd(dev, '2001::88', '64', family=6)
         ip_addrs = addresses.getIpAddrs()[dev]
         self.assertTrue(addresses.is_ipv6_local_auto(dev))
         self.assertEqual(2, len(ip_addrs), ip_addrs)
         self.assertTrue(addresses.is_ipv6(ip_addrs[0]))
         self.assertTrue(not addresses.is_dynamic(ip_addrs[0]))
Пример #6
0
 def test_local_auto_with_static_address_without_ra_server(self):
     with dummy_device() as dev:
         ipwrapper.addrAdd(dev, '2001::88', '64', family=6)
         ip_addrs = addresses.getIpAddrs()[dev]
         assert addresses.is_ipv6_local_auto(dev)
         assert 2 == len(ip_addrs), ip_addrs
         assert addresses.is_ipv6(ip_addrs[0])
         assert not addresses.is_dynamic(ip_addrs[0])
Пример #7
0
 def test_local_auto_with_static_address_without_ra_server(self, nic0):
     Interface.from_existing_dev_name(nic0).add_ip('2001::88',
                                                   IPV6_PREFIX_LENGTH,
                                                   IpFamily.IPv6)
     ip_addrs = addresses.getIpAddrs()[nic0]
     assert addresses.is_ipv6_local_auto(nic0)
     assert 2 == len(ip_addrs), ip_addrs
     assert addresses.is_ipv6(ip_addrs[0])
     assert not addresses.is_dynamic(ip_addrs[0])
Пример #8
0
    def test_local_auto_with_dynamic_address_from_ra(self, dynamic_ipv6_iface):
        # Expecting link and global addresses on client iface
        # The addresses are given randomly, so we sort them
        ip_addrs = sorted(
            addresses.getIpAddrs()[dynamic_ipv6_iface],
            key=lambda ip: ip['address'],
        )
        assert len(ip_addrs) == 2

        assert addresses.is_dynamic(ip_addrs[0])
        assert ip_addrs[0]['scope'] == 'global'
        assert ip_addrs[0]['address'].startswith(IPV6_ADDR_BASE)

        assert ip_addrs[1]['scope'] == 'link'
Пример #9
0
Файл: info.py Проект: nirs/vdsm
def create_netinfo(ovs_info):
    addresses = getIpAddrs()
    routes = get_routes()

    _netinfo = {'networks': {}}

    for bridge, bridge_attrs in six.iteritems(ovs_info.bridges):
        ports = bridge_attrs['ports']

        southbound = ovs_info.southbound_port(ports)

        # northbound ports represents networks
        stp = bridge_attrs['stp']
        for northbound_port in ovs_info.northbound_ports(ports):
            _netinfo['networks'][northbound_port] = _get_network_info(
                northbound_port, bridge, southbound, ports, stp, addresses,
                routes)

    return _netinfo
Пример #10
0
def _get_net_info(interface, routes):
    mtu = mtus.getMtu(interface)
    ipaddrs = addresses.getIpAddrs()
    addr, netmask, ipv4addrs, ipv6addrs = addresses.getIpInfo(interface,
                                                              ipaddrs)
    dhcpv4, dhcpv6 = dhcp.dhcp_status(interface, ipaddrs)
    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}
Пример #11
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)}
Пример #12
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
    }
Пример #13
0
    def test_local_auto_with_dynamic_address_from_ra(self):
        IPV6_NETADDRESS = '2001:1:1:1'
        IPV6_NETPREFIX_LEN = '64'
        with veth_pair() as (server, client):
            ipwrapper.addrAdd(server, IPV6_NETADDRESS + '::1',
                              IPV6_NETPREFIX_LEN, family=6)
            ipwrapper.linkSet(server, ['up'])
            with dnsmasq_run(server, ipv6_slaac_prefix=IPV6_NETADDRESS + '::'):
                with wait_for_ipv6(client):
                    ipwrapper.linkSet(client, ['up'])

                # Expecting link and global addresses on client iface
                # The addresses are given randomly, so we sort them
                ip_addrs = sorted(addresses.getIpAddrs()[client],
                                  key=lambda ip: ip['address'])
                self.assertEqual(2, len(ip_addrs), ip_addrs)

                self.assertTrue(addresses.is_dynamic(ip_addrs[0]))
                self.assertEqual('global', ip_addrs[0]['scope'])
                self.assertEqual(IPV6_NETADDRESS,
                                 ip_addrs[0]['address'][:len(IPV6_NETADDRESS)])

                self.assertEqual('link', ip_addrs[1]['scope'])