"vscode:/vscode.git/clone" did not exist on "47cb75a3f7ae295ea6fb2f7ab856962aaabedac3"
Commit 03739370 authored by Jakob Görgen's avatar Jakob Görgen Committed by Jakob Görgen
Browse files

experiments/simbricks/orchestration/nodeconfig: config_files takes additional...

experiments/simbricks/orchestration/nodeconfig: config_files takes additional env parameter for better path resolution
parent 6a2d9ec2
...@@ -26,6 +26,8 @@ import io ...@@ -26,6 +26,8 @@ import io
import tarfile import tarfile
import typing as tp import typing as tp
from simbricks.orchestration.experiment.experiment_environment import ExpEnv
class AppConfig(): class AppConfig():
"""Defines the application to run on a node or host.""" """Defines the application to run on a node or host."""
...@@ -120,7 +122,7 @@ class NodeConfig(): ...@@ -120,7 +122,7 @@ class NodeConfig():
self.run_cmds() + self.cleanup_cmds() + exit_es self.run_cmds() + self.cleanup_cmds() + exit_es
return '\n'.join(es) return '\n'.join(es)
def make_tar(self, path: str) -> None: def make_tar(self, env: ExpEnv, path: str) -> None:
with tarfile.open(path, 'w:') as tar: with tarfile.open(path, 'w:') as tar:
# add main run script # add main run script
cfg_i = tarfile.TarInfo('guest/run.sh') cfg_i = tarfile.TarInfo('guest/run.sh')
...@@ -133,7 +135,7 @@ class NodeConfig(): ...@@ -133,7 +135,7 @@ class NodeConfig():
cfg_f.close() cfg_f.close()
# add additional config files # add additional config files
for (n, f) in self.config_files().items(): for (n, f) in self.config_files(env).items():
f_i = tarfile.TarInfo('guest/' + n) f_i = tarfile.TarInfo('guest/' + n)
f_i.mode = 0o777 f_i.mode = 0o777
f.seek(0, io.SEEK_END) f.seek(0, io.SEEK_END)
...@@ -164,7 +166,8 @@ class NodeConfig(): ...@@ -164,7 +166,8 @@ class NodeConfig():
"""Commands to run to cleanup node.""" """Commands to run to cleanup node."""
return [] return []
def config_files(self) -> tp.Dict[str, tp.IO]: # pylint: disable=unused-argument
def config_files(self, env: ExpEnv) -> tp.Dict[str, tp.IO]:
""" """
Additional files to put inside the node, which are mounted under Additional files to put inside the node, which are mounted under
`/tmp/guest/`. `/tmp/guest/`.
...@@ -224,9 +227,9 @@ class CorundumLinuxNode(LinuxNode): ...@@ -224,9 +227,9 @@ class CorundumLinuxNode(LinuxNode):
self.drivers.append('/tmp/guest/mqnic.ko') self.drivers.append('/tmp/guest/mqnic.ko')
# pylint: disable=consider-using-with # pylint: disable=consider-using-with
def config_files(self) -> tp.Dict[str, tp.IO]: def config_files(self, env: ExpEnv) -> tp.Dict[str, tp.IO]:
m = {'mqnic.ko': open('../images/mqnic/mqnic.ko', 'rb')} m = {'mqnic.ko': open(f'{env.repodir}/images/mqnic/mqnic.ko', 'rb')}
return {**m, **super().config_files()} return {**m, **super().config_files(env)}
class E1000LinuxNode(LinuxNode): class E1000LinuxNode(LinuxNode):
...@@ -268,7 +271,7 @@ class MtcpNode(NodeConfig): ...@@ -268,7 +271,7 @@ class MtcpNode(NodeConfig):
f'ip addr add {self.ip}/{self.prefix} dev dpdk0' f'ip addr add {self.ip}/{self.prefix} dev dpdk0'
] ]
def config_files(self) -> tp.Dict[str, tp.IO]: def config_files(self, env: ExpEnv) -> tp.Dict[str, tp.IO]:
m = { m = {
'mtcp.conf': 'mtcp.conf':
self.strfile( self.strfile(
...@@ -286,7 +289,7 @@ class MtcpNode(NodeConfig): ...@@ -286,7 +289,7 @@ class MtcpNode(NodeConfig):
) )
} }
return {**m, **super().config_files()} return {**m, **super().config_files(env)}
class TASNode(NodeConfig): class TASNode(NodeConfig):
......
...@@ -125,7 +125,7 @@ class ExperimentBaseRunner(ABC): ...@@ -125,7 +125,7 @@ class ExperimentBaseRunner(ABC):
path = self.env.cfgtar_path(host) path = self.env.cfgtar_path(host)
if self.verbose: if self.verbose:
print('preparing config tar:', path) print('preparing config tar:', path)
host.node_config.make_tar(path) host.node_config.make_tar(self.env, path)
executor = self.sim_executor(host) executor = self.sim_executor(host)
task = asyncio.create_task(executor.send_file(path, self.verbose)) task = asyncio.create_task(executor.send_file(path, self.verbose))
copies.append(task) copies.append(task)
......
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