From 8c0154e5b6a5b3ca697c7e7cd283de23f6823f54 Mon Sep 17 00:00:00 2001 From: aliel Date: Fri, 26 May 2023 16:54:56 +0200 Subject: [PATCH] Fix ip command path #313 --- vm_supervisor/network/interfaces.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vm_supervisor/network/interfaces.py b/vm_supervisor/network/interfaces.py index 271e44f08..a121c6356 100644 --- a/vm_supervisor/network/interfaces.py +++ b/vm_supervisor/network/interfaces.py @@ -4,6 +4,7 @@ from subprocess import run from .ipaddresses import IPv4NetworkWithInterfaces +import shutil logger = logging.getLogger(__name__) @@ -27,10 +28,11 @@ def host_ip(self) -> IPv4Interface: async def create(self): logger.debug("Create network interface") - run(["/usr/bin/ip", "tuntap", "add", self.device_name, "mode", "tap"]) + ip_command = shutil.which("ip") + run([ip_command, "tuntap", "add", self.device_name, "mode", "tap"]) run( [ - "/usr/bin/ip", + ip_command, "addr", "add", str(self.host_ip.with_prefixlen), @@ -38,7 +40,7 @@ async def create(self): self.device_name, ] ) - run(["/usr/bin/ip", "link", "set", self.device_name, "up"]) + run([ip_command, "link", "set", self.device_name, "up"]) logger.debug(f"Network interface created: {self.device_name}") async def delete(self) -> None: