コード例 #1
0
ファイル: netinfo_test.py プロジェクト: mykaul/vdsm
    def test_get_gateway(self):
        TEST_IFACE = 'test_iface'
        # different tables but the gateway is the same so it should be reported
        DUPLICATED_GATEWAY = {TEST_IFACE: [
            {
                'destination': 'none',
                'family': 'inet',
                'gateway': '12.34.56.1',
                'oif': TEST_IFACE,
                'oif_index': 8,
                'scope': 'global',
                'source': None,
                'table': 203569230,  # lucky us, we got the address 12.34.56.78
            }, {
                'destination': 'none',
                'family': 'inet',
                'gateway': '12.34.56.1',
                'oif': TEST_IFACE,
                'oif_index': 8,
                'scope': 'global',
                'source': None,
                'table': 254,
            }]}
        SINGLE_GATEWAY = {TEST_IFACE: [DUPLICATED_GATEWAY[TEST_IFACE][0]]}

        gateway = routes.get_gateway(SINGLE_GATEWAY, TEST_IFACE)
        self.assertEqual(gateway, '12.34.56.1')
        gateway = routes.get_gateway(DUPLICATED_GATEWAY, TEST_IFACE)
        self.assertEqual(gateway, '12.34.56.1')
コード例 #2
0
ファイル: netinfoTests.py プロジェクト: fancyKai/vdsm
    def test_get_gateway(self):
        TEST_IFACE = 'test_iface'
        # different tables but the gateway is the same so it should be reported
        DUPLICATED_GATEWAY = {
            TEST_IFACE: [
                {
                    'destination': 'none',
                    'family': 'inet',
                    'gateway': '12.34.56.1',
                    'oif': TEST_IFACE,
                    'oif_index': 8,
                    'scope': 'global',
                    'source': None,
                    'table':
                    203569230,  # lucky us, we got the address 12.34.56.78
                },
                {
                    'destination': 'none',
                    'family': 'inet',
                    'gateway': '12.34.56.1',
                    'oif': TEST_IFACE,
                    'oif_index': 8,
                    'scope': 'global',
                    'source': None,
                    'table': 254,
                }
            ]
        }
        SINGLE_GATEWAY = {TEST_IFACE: [DUPLICATED_GATEWAY[TEST_IFACE][0]]}

        gateway = routes.get_gateway(SINGLE_GATEWAY, TEST_IFACE)
        self.assertEqual(gateway, '12.34.56.1')
        gateway = routes.get_gateway(DUPLICATED_GATEWAY, TEST_IFACE)
        self.assertEqual(gateway, '12.34.56.1')
コード例 #3
0
ファイル: ovs_after_get_caps.py プロジェクト: fancyKai/vdsm
def _get_net_info(attrs, interface, dhcpv4ifaces, dhcpv6ifaces, routes):
    mtu = mtus.getMtu(interface)
    addr, netmask, ipv4addrs, ipv6addrs = addresses.getIpInfo(interface)
    dhcpv4 = dhcp.dhcp_used(interface, dhcpv4ifaces, attrs)
    dhcpv6 = dhcp.dhcp_used(interface, dhcpv6ifaces, attrs, 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,
        'ipv6gateway': ipv6gateway,
        'dhcpv6': dhcpv6,
        'cfg': {'BOOTPROTO': 'dhcp' if dhcpv4 else 'none'}}
コード例 #4
0
ファイル: ovs_after_get_caps.py プロジェクト: kanalun/vdsm
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,
        'cfg': {'BOOTPROTO': 'dhcp' if dhcpv4 else 'none'}}
コード例 #5
0
def _get_net_info(attrs, interface, dhcpv4ifaces, dhcpv6ifaces, routes):
    mtu = mtus.getMtu(interface)
    addr, netmask, ipv4addrs, ipv6addrs = addresses.getIpInfo(interface)
    dhcpv4 = dhcp.dhcp_used(interface, dhcpv4ifaces, attrs)
    dhcpv6 = dhcp.dhcp_used(interface, dhcpv6ifaces, attrs, 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,
        'ipv6gateway': ipv6gateway,
        'dhcpv6': dhcpv6,
        'cfg': {
            'BOOTPROTO': 'dhcp' if dhcpv4 else 'none'
        }
    }