File: test_link_create.py

package info (click to toggle)
pyroute2 0.8.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,704 kB
  • sloc: python: 50,245; makefile: 280; javascript: 183; ansic: 81; sh: 44; awk: 17
file content (27 lines) | stat: -rw-r--r-- 906 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pytest
from pr2test.marks import require_root

from pyroute2.netlink.rtnl.ifinfmsg import ifinfmsg

pytestmark = [require_root()]


@pytest.mark.parametrize('smode', ('IPVLAN_MODE_L2', 'IPVLAN_MODE_L3'))
def test_create_ipvlan(context, smode):
    master = context.new_ifname
    ipvlan = context.new_ifname
    # create the master link
    index = context.ndb.interfaces.create(
        ifname=master, kind='dummy'
    ).commit()['index']
    # check modes
    # maybe move modes dict somewhere else?
    cmode = ifinfmsg.ifinfo.data_map['ipvlan'].modes[smode]
    assert ifinfmsg.ifinfo.data_map['ipvlan'].modes[cmode] == smode
    # create ipvlan
    context.ipr.link(
        'add', ifname=ipvlan, kind='ipvlan', link=index, mode=cmode
    )
    interface = context.ndb.interfaces.wait(ifname=ipvlan, timeout=5)
    assert interface['link'] == index
    assert interface['ipvlan_mode'] == cmode