Example #1
0
def test_ip_data_Link():
    link_info = ip.IpLinkInfo(context_wrap(IP_S_LINK))
    link_info_all = ip.IpLinkInfo(context_wrap(IP_S_LINK_ALL))
    link_info_all_2 = ip.IpLinkInfo(context_wrap(IP_S_LINK_ALL_2))
    link_info_all_3 = ip.IpLinkInfo(context_wrap(IP_S_LINK_ALL_3))
    if_list_all_3 = link_info_all_3.active
    assert sorted(if_list_all_3) == sorted(['lo', 'eth0_1', 'eth0_2', 'vxlan_sys_4789', 'gre1'])
    eth0_1 = link_info_all_3["eth0_1"]
    assert eth0_1["mac"] == "00:90:fa:8d:36:1e"
    assert eth0_1["rx_packets"] == 15139642734
    assert eth0_1["rx_bytes"] == 16809815066893
    if_list_all_2 = link_info_all_2.active
    if_list_all = link_info_all.active
    if_list = link_info.active
    assert len(if_list) == 4
    assert keys_in(["lo", "enp0s3", "enp0s8", "enp0s9"], if_list)
    assert keys_in(['ppp0', 'lo', 'tun0', 'enp0s25', 'vnet0', 'virbr0'], if_list_all)
    assert keys_in(['lo', 'eno1', 'eno2', 'ovs-system', 'br-ex', 'vxlan_sys_4789'], if_list_all_2)

    assert sorted(link_info.active) == sorted(['lo', 'enp0s3', 'enp0s8', 'enp0s9'])

    lo = link_info["lo"]
    assert lo["mac"] == "00:00:00:00:00:00"
    assert lo["flags"] == ["LOOPBACK", "UP", "LOWER_UP"]
    assert lo["type"] == "loopback"
    assert lo["mtu"] == 65536
    assert lo["rx_packets"] == 98
    assert lo["tx_packets"] == 10
    assert lo["index"] == 2

    enp0s3 = link_info["enp0s3"]
    assert enp0s3["mac"] == "08:00:27:4a:c5:ef"
    assert enp0s3["flags"] == ["BROADCAST", "MULTICAST", "UP", "LOWER_UP"]
    assert enp0s3["type"] == "ether"
    assert enp0s3["mtu"] == 1500
    assert enp0s3["rx_packets"] == 2244
    assert enp0s3["tx_packets"] == 1407
    assert enp0s3["index"] == 1

    enp0s25 = link_info_all["enp0s25"]
    assert enp0s25["mac"] == "1c:75:08:a5:7e:25"
    assert enp0s25["flags"] == ["BROADCAST", "MULTICAST", "UP", "LOWER_UP"]
    assert enp0s25["type"] == "ether"
    assert enp0s25["mtu"] == 1500
    assert enp0s25["rx_packets"] == 1492476
    assert enp0s25["tx_packets"] == 969514
    assert enp0s25["index"] == 2

    vxlan_sys_4789 = link_info_all_2["vxlan_sys_4789"]
    assert sorted(vxlan_sys_4789["vxlan"]) == sorted(['vxlan', 'id', '0', 'srcport', '0', '0', 'dstport', '4789', 'nolearning', 'ageing', '300', 'noudpcsum', 'noudp6zerocsumtx', 'udp6zerocsumrx', 'external'])
    ovs = link_info_all_2["ovs-system"]
    assert sorted(ovs["openvswitch"]) == sorted(['openvswitch', 'addrgenmode', 'eui64', 'numtxqueues', '1', 'numrxqueues', '1', 'gso_max_size', '65536', 'gso_max_segs', '65535'])
Example #2
0
def test_ip_data_Link():
    link_info = ip.IpLinkInfo(context_wrap(IP_S_LINK))
    link_info_all = ip.IpLinkInfo(context_wrap(IP_S_LINK_ALL))
    if_list_all = link_info_all.active
    if_list = link_info.active
    assert len(if_list) == 4
    assert keys_in(["lo", "enp0s3", "enp0s8", "enp0s9"], if_list)
    assert keys_in(['ppp0', 'lo', 'tun0', 'enp0s25', 'vnet0', 'virbr0'],
                   if_list_all)

    assert sorted(link_info.active) == sorted(
        ['lo', 'enp0s3', 'enp0s8', 'enp0s9'])

    lo = link_info["lo"]
    assert lo["mac"] == "00:00:00:00:00:00"
    assert lo["flags"] == ["LOOPBACK", "UP", "LOWER_UP"]
    assert lo["type"] == "loopback"
    assert lo["mtu"] == 65536
    assert lo["rx_packets"] == 98
    assert lo["tx_packets"] == 10
    assert lo["index"] == 2

    enp0s3 = link_info["enp0s3"]
    assert enp0s3["mac"] == "08:00:27:4a:c5:ef"
    assert enp0s3["flags"] == ["BROADCAST", "MULTICAST", "UP", "LOWER_UP"]
    assert enp0s3["type"] == "ether"
    assert enp0s3["mtu"] == 1500
    assert enp0s3["rx_packets"] == 2244
    assert enp0s3["tx_packets"] == 1407
    assert enp0s3["index"] == 1

    enp0s25 = link_info_all["enp0s25"]
    assert enp0s25["mac"] == "1c:75:08:a5:7e:25"
    assert enp0s25["flags"] == ["BROADCAST", "MULTICAST", "UP", "LOWER_UP"]
    assert enp0s25["type"] == "ether"
    assert enp0s25["mtu"] == 1500
    assert enp0s25["rx_packets"] == 1492476
    assert enp0s25["tx_packets"] == 969514
    assert enp0s25["index"] == 2