Skip to content

Commit

Permalink
Fix ip command path #313
Browse files Browse the repository at this point in the history
  • Loading branch information
aliel authored and hoh committed May 26, 2023
1 parent 13af11a commit 8c0154e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions vm_supervisor/network/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from subprocess import run

from .ipaddresses import IPv4NetworkWithInterfaces
import shutil

logger = logging.getLogger(__name__)

Expand All @@ -27,18 +28,19 @@ 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),
"dev",
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:
Expand Down

0 comments on commit 8c0154e

Please sign in to comment.