xref: /linux/tools/testing/selftests/drivers/net/lib/py/remote_netns.py (revision 621cde16e49b3ecf7d59a8106a20aaebfb4a59a9)
1# SPDX-License-Identifier: GPL-2.0
2
3import os
4import subprocess
5
6from lib.py import cmd
7
8
9class Remote:
10    def __init__(self, name, dir_path):
11        self.name = name
12        self.dir_path = dir_path
13
14    def cmd(self, comm):
15        return subprocess.Popen(["ip", "netns", "exec", self.name, "bash", "-c", comm],
16                                 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
17
18    def deploy(self, what):
19        if os.path.isabs(what):
20            return what
21        return os.path.abspath(self.dir_path + "/" + what)
22