blob: 50fc1c865a6a53e675a12f6332c3a351e91b9ca3 [file] [log] [blame]
Naveen Joy7ea7ab52021-05-11 10:31:18 -07001#!/usr/bin/env python
2
3# Utility functions for QEMU tests ##
4
5import subprocess
6
7
8def create_namespace(ns):
9 try:
10 subprocess.run(["ip", "netns", "add", ns])
11 except subprocess.CalledProcessError as e:
12 raise Exception("Error creating namespace:", e.output)
13
14
15def list_namespace(ns):
16 """List the IP address of a namespace"""
17 try:
18 subprocess.run(["ip", "netns", "exec", ns, "ip", "addr"])
19 except subprocess.CalledProcessError as e:
20 raise Exception("Error listing namespace IP:", e.output)