summaryrefslogtreecommitdiffstats
path: root/test/vpp_qemu_utils.py
blob: 50fc1c865a6a53e675a12f6332c3a351e91b9ca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python

# Utility functions for QEMU tests ##

import subprocess


def create_namespace(ns):
    try:
        subprocess.run(["ip", "netns", "add", ns])
    except subprocess.CalledProcessError as e:
        raise Exception("Error creating namespace:", e.output)


def list_namespace(ns):
    """List the IP address of a namespace"""
    try:
        subprocess.run(["ip", "netns", "exec", ns, "ip", "addr"])
    except subprocess.CalledProcessError as e:
        raise Exception("Error listing namespace IP:", e.output)