summaryrefslogtreecommitdiff
path: root/tests/common/iface.py
blob: dbd052ab359086f240e7f1917308421d2f63e57e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from common import netns

# up interface. if netns is None, then up in global rt. if ok returns 0
def up(iface, netns_name):
    command = ["ip", "link", "set", iface, "up"]
    exit, out, err = netns.exec(netns_name, command)
    print(
        "iface.up: iface=%s netns=%s exit=%d out=%s err=%s"
        % (iface, netns_name, exit, out, err)
    )

    return exit


# delete interface. if netns is None, then up in global rt. if ok returns 0
def delete(iface, netns_name):
    exit, out, err = netns.exec(netns_name, ["ip", "link", "delete", iface])
    print(
        "iface.delete: iface=%s netns=%s exit=%d out=%s err=%s"
        % (iface, netns_name, exit, out, err)
    )

    return exit