Unverified Commit af98d725 authored by Jakob Görgen's avatar Jakob Görgen
Browse files

fixed ip link set + fixed ip addr add

parent 1b2e3992
......@@ -71,9 +71,7 @@ class InstantiationEnvironment(util_base.IdObj):
super().__init__()
self._repodir: str = pathlib.Path(repo_path).resolve()
self._workdir: str = (
workdir
if workdir
else pathlib.Path(f"{self._repodir}/wrkdir").resolve()
workdir if workdir else pathlib.Path(f"{self._repodir}/wrkdir").resolve()
)
self._output_base: str = (
output_base
......@@ -152,18 +150,11 @@ class Instantiation(util_base.IdObj):
def qemu_path(self) -> str:
return self._env._qemu_path
def _get_chan_by_interface(self, interface: sys_base.Interface) -> sys_base.Channel:
if not interface.is_connected():
raise Exception(
"cannot determine channel by interface, interface isn't connecteds"
)
return interface.channel
def _get_opposing_interface(
self, interface: sys_base.Interface
) -> sys_base.Interface:
channel = self._get_chan_by_interface(interface=interface)
return channel.a if channel.a is not interface else channel.b
opposing_inf = interface.get_opposing_interface()
return opposing_inf
def _opposing_interface_within_same_sim(
self, interface: sys_base.Interface
......@@ -171,6 +162,7 @@ class Instantiation(util_base.IdObj):
opposing_interface = self._get_opposing_interface(interface=interface)
component = interface.component
opposing_component = opposing_interface.component
assert interface is not opposing_interface
return self.find_sim_by_spec(spec=component) == self.find_sim_by_spec(
spec=opposing_component
)
......@@ -196,7 +188,7 @@ class Instantiation(util_base.IdObj):
return socket
def _interface_to_sock_path(self, interface: sys_base.Interface) -> str:
channel = self._get_chan_by_interface(interface=interface)
channel = interface.get_chan_raise()
queue_ident = f"{channel.a._id}.{channel._id}.{channel.b._id}"
queue_type = None
......
......@@ -193,16 +193,11 @@ class Simulator(utils_base.IdObj):
)
return interface
def _get_sys_chan(self, interface: sys_conf.Interface) -> sys_conf.Channel:
if not interface.is_connected():
raise Exception("interface does not need a channel as it is not connected")
return interface.channel
def _get_socket(
self, inst: inst_base.Instantiation, interface: sys_conf.Interface
) -> inst_base.Socket | None:
# get the channel associated with this interface
chan = self._get_sys_chan(interface=interface)
chan = interface.get_chan_raise()
# check if interfaces channel is simulator internal, i.e. doesnt need an instanciation
if not self._chan_needs_instance(chan):
return None
......
......@@ -89,6 +89,15 @@ class Interface(util_base.IdObj):
peer_if = self.channel.a
return peer_if
def get_chan_raise(self) -> Channel:
if not self.is_connected():
raise Exception(f"interface(id={self._id}) is not connected to channel")
return self.channel
def get_opposing_interface(self) -> Interface:
chan = self.get_chan_raise()
return chan.get_opposing_interface(interface=self)
T = tp.TypeVar("T")
@staticmethod
......@@ -113,3 +122,12 @@ class Channel(util_base.IdObj):
# it's not referenced anywhere, so that's fine I guess.
self.a.disconnect()
self.b.disconnect()
def get_opposing_interface(self, interface: Interface) -> Interface:
if interface is not self.a and interface is not self.b:
raise Exception(
"cannot determine opposing interface, interface is not connected to channel"
)
opposing = self.a if interface is self.b else self.b
assert opposing != interface
return opposing
......@@ -29,6 +29,7 @@ from os import path
import simbricks.orchestration.instantiation.base as instantiation
from simbricks.orchestration.system import base as base
from simbricks.orchestration.system import eth as eth
from simbricks.orchestration.system import pcie as pcie
from simbricks.orchestration.system.host import app
from simbricks.orchestration.utils import base as utils_base
......@@ -104,7 +105,9 @@ class BaseLinuxHost(FullSystemHost):
def cleanup_cmds(self, inst: instantiation.Instantiation) -> list[str]:
"""Commands to run to cleanup node."""
return self._concat_app_cmds(inst, app.BaseLinuxApplication.cleanup_cmds.__name__)
return self._concat_app_cmds(
inst, app.BaseLinuxApplication.cleanup_cmds.__name__
)
def config_files(self, inst: instantiation.Instantiation) -> dict[str, tp.IO]:
"""
......@@ -121,11 +124,15 @@ class BaseLinuxHost(FullSystemHost):
def prepare_pre_cp(self, inst: instantiation.Instantiation) -> list[str]:
"""Commands to run to prepare node before checkpointing."""
return self._concat_app_cmds(inst, app.BaseLinuxApplication.prepare_pre_cp.__name__)
return self._concat_app_cmds(
inst, app.BaseLinuxApplication.prepare_pre_cp.__name__
)
def prepare_post_cp(self, inst: instantiation.Instantiation) -> list[str]:
"""Commands to run to prepare node after checkpoint restore."""
return self._concat_app_cmds(inst, app.BaseLinuxApplication.prepare_post_cp.__name__)
return self._concat_app_cmds(
inst, app.BaseLinuxApplication.prepare_post_cp.__name__
)
def config_str(self, inst: instantiation.Instantiation) -> str:
if inst.create_cp():
......@@ -184,7 +191,13 @@ class LinuxHost(BaseLinuxHost):
cmds.append(f"modprobe {d}")
index = 0
for inf in base.Interface.filter_by_type(self.interfaces(), eth.EthInterface):
for host_inf in base.Interface.filter_by_type(
self.interfaces(), pcie.PCIeHostInterface
):
if not host_inf.is_connected():
continue
inf = host_inf.get_opposing_interface()
if not utils_base.check_type(inf.component, eth.EthSimpleNIC):
continue
# Get ifname parameter if set, otherwise default to ethX
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment