|
|
|
|
@ -57,13 +57,14 @@ class Network:
|
|
|
|
|
self.namespaces = {} |
|
|
|
|
self.children = [] |
|
|
|
|
self.serial = 0 |
|
|
|
|
self.log = (self.directory / "network.jsonl").open("w", buffering=1) |
|
|
|
|
self.log = (self.directory / "network.jsonl").open("a", buffering=1) |
|
|
|
|
|
|
|
|
|
def command(self, name, arguments, *, input=None, check=True): |
|
|
|
|
prefix = self.prefix(name) |
|
|
|
|
started = time.monotonic() |
|
|
|
|
result = subprocess.run(prefix + list(arguments), input=input, text=True, capture_output=True, timeout=20) |
|
|
|
|
self.log.write(json.dumps({"time": started, "namespace": name, "argv": list(arguments), |
|
|
|
|
inode = self.namespaces[name][1] if name else self.controller |
|
|
|
|
self.log.write(json.dumps({"time": started, "namespace": name, "inode": inode, "argv": list(arguments), |
|
|
|
|
"rc": result.returncode, "stdout": result.stdout, "stderr": result.stderr}) + "\n") |
|
|
|
|
if check and result.returncode: |
|
|
|
|
raise RuntimeError(f"{name}: {' '.join(arguments)}: {result.stderr.strip() or result.stdout.strip()}") |
|
|
|
|
|