Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
1b2e3992
Unverified
Commit
1b2e3992
authored
Sep 26, 2024
by
Jakob Görgen
Browse files
fixed Applications mapper functionality
parent
6a887cf5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
30 deletions
+36
-30
experiments/simbricks/orchestration/system/host/app.py
experiments/simbricks/orchestration/system/host/app.py
+1
-1
experiments/simbricks/orchestration/system/host/base.py
experiments/simbricks/orchestration/system/host/base.py
+35
-29
No files found.
experiments/simbricks/orchestration/system/host/app.py
View file @
1b2e3992
...
@@ -47,7 +47,7 @@ class BaseLinuxApplication(abc.ABC):
...
@@ -47,7 +47,7 @@ class BaseLinuxApplication(abc.ABC):
@
abc
.
abstractmethod
@
abc
.
abstractmethod
def
run_cmds
(
self
,
inst
:
inst_base
.
Instantiation
)
->
list
[
str
]:
def
run_cmds
(
self
,
inst
:
inst_base
.
Instantiation
)
->
list
[
str
]:
"""Commands to run on node."""
"""Commands to run on node."""
r
eturn
[]
r
aise
Exception
(
"must be overwritten"
)
def
cleanup_cmds
(
self
,
inst
:
inst_base
.
Instantiation
)
->
list
[
str
]:
def
cleanup_cmds
(
self
,
inst
:
inst_base
.
Instantiation
)
->
list
[
str
]:
"""Commands to run to cleanup node."""
"""Commands to run to cleanup node."""
...
...
experiments/simbricks/orchestration/system/host/base.py
View file @
1b2e3992
...
@@ -30,6 +30,7 @@ import simbricks.orchestration.instantiation.base as instantiation
...
@@ -30,6 +30,7 @@ import simbricks.orchestration.instantiation.base as instantiation
from
simbricks.orchestration.system
import
base
as
base
from
simbricks.orchestration.system
import
base
as
base
from
simbricks.orchestration.system
import
eth
as
eth
from
simbricks.orchestration.system
import
eth
as
eth
from
simbricks.orchestration.system.host
import
app
from
simbricks.orchestration.system.host
import
app
from
simbricks.orchestration.utils
import
base
as
utils_base
if
tp
.
TYPE_CHECKING
:
if
tp
.
TYPE_CHECKING
:
from
simbricks.orchestration.system.host
import
disk_images
from
simbricks.orchestration.system.host
import
disk_images
...
@@ -80,9 +81,7 @@ class BaseLinuxHost(FullSystemHost):
...
@@ -80,9 +81,7 @@ class BaseLinuxHost(FullSystemHost):
def
_concat_app_cmds
(
def
_concat_app_cmds
(
self
,
self
,
inst
:
instantiation
.
Instantiation
,
inst
:
instantiation
.
Instantiation
,
mapper
:
tp
.
Callable
[
mapper_name
:
str
,
[
app
.
BaseLinuxApplication
,
instantiation
.
Instantiation
],
list
[
str
]
],
)
->
list
[
str
]:
)
->
list
[
str
]:
"""
"""
Generate command list from applications by applying `mapper` to each
Generate command list from applications by applying `mapper` to each
...
@@ -90,17 +89,22 @@ class BaseLinuxHost(FullSystemHost):
...
@@ -90,17 +89,22 @@ class BaseLinuxHost(FullSystemHost):
"""
"""
cmds
=
[]
cmds
=
[]
for
app
in
self
.
applications
:
for
app
in
self
.
applications
:
cmds
+=
mapper
(
app
,
inst
)
mapper
=
getattr
(
app
,
mapper_name
,
None
)
if
mapper
is
None
:
raise
Exception
(
f
"coulkd not determine mapper function with name
{
mapper_name
}
"
)
cmds
+=
mapper
(
inst
)
return
cmds
return
cmds
def
run_cmds
(
self
,
inst
:
instantiation
.
Instantiation
)
->
list
[
str
]:
def
run_cmds
(
self
,
inst
:
instantiation
.
Instantiation
)
->
list
[
str
]:
"""Commands to run on node."""
"""Commands to run on node."""
return
self
.
_concat_app_cmds
(
inst
,
app
.
BaseLinuxApplication
.
run_cmds
)
return
self
.
_concat_app_cmds
(
inst
,
app
.
BaseLinuxApplication
.
run_cmds
.
__name__
)
def
cleanup_cmds
(
self
,
inst
:
instantiation
.
Instantiation
)
->
list
[
str
]:
def
cleanup_cmds
(
self
,
inst
:
instantiation
.
Instantiation
)
->
list
[
str
]:
"""Commands to run to cleanup node."""
"""Commands to run to cleanup node."""
return
self
.
_concat_app_cmds
(
inst
,
app
.
BaseLinuxApplication
.
cleanup_cmds
)
return
self
.
_concat_app_cmds
(
inst
,
app
.
BaseLinuxApplication
.
cleanup_cmds
.
__name__
)
def
config_files
(
self
,
inst
:
instantiation
.
Instantiation
)
->
dict
[
str
,
tp
.
IO
]:
def
config_files
(
self
,
inst
:
instantiation
.
Instantiation
)
->
dict
[
str
,
tp
.
IO
]:
"""
"""
...
@@ -117,11 +121,11 @@ class BaseLinuxHost(FullSystemHost):
...
@@ -117,11 +121,11 @@ class BaseLinuxHost(FullSystemHost):
def
prepare_pre_cp
(
self
,
inst
:
instantiation
.
Instantiation
)
->
list
[
str
]:
def
prepare_pre_cp
(
self
,
inst
:
instantiation
.
Instantiation
)
->
list
[
str
]:
"""Commands to run to prepare node before checkpointing."""
"""Commands to run to prepare node before checkpointing."""
return
self
.
_concat_app_cmds
(
inst
,
app
.
BaseLinuxApplication
.
prepare_pre_cp
)
return
self
.
_concat_app_cmds
(
inst
,
app
.
BaseLinuxApplication
.
prepare_pre_cp
.
__name__
)
def
prepare_post_cp
(
self
,
inst
:
instantiation
.
Instantiation
)
->
list
[
str
]:
def
prepare_post_cp
(
self
,
inst
:
instantiation
.
Instantiation
)
->
list
[
str
]:
"""Commands to run to prepare node after checkpoint restore."""
"""Commands to run to prepare node after checkpoint restore."""
return
self
.
_concat_app_cmds
(
inst
,
app
.
BaseLinuxApplication
.
prepare_post_cp
)
return
self
.
_concat_app_cmds
(
inst
,
app
.
BaseLinuxApplication
.
prepare_post_cp
.
__name__
)
def
config_str
(
self
,
inst
:
instantiation
.
Instantiation
)
->
str
:
def
config_str
(
self
,
inst
:
instantiation
.
Instantiation
)
->
str
:
if
inst
.
create_cp
():
if
inst
.
create_cp
():
...
@@ -139,7 +143,8 @@ class BaseLinuxHost(FullSystemHost):
...
@@ -139,7 +143,8 @@ class BaseLinuxHost(FullSystemHost):
+
self
.
run_cmds
(
inst
)
+
self
.
run_cmds
(
inst
)
+
self
.
cleanup_cmds
(
inst
)
+
self
.
cleanup_cmds
(
inst
)
)
)
return
"
\n
"
.
join
(
es
)
cmd
=
"
\n
"
.
join
(
es
)
return
cmd
def
strfile
(
self
,
s
:
str
)
->
io
.
BytesIO
:
def
strfile
(
self
,
s
:
str
)
->
io
.
BytesIO
:
"""
"""
...
@@ -170,35 +175,36 @@ class LinuxHost(BaseLinuxHost):
...
@@ -170,35 +175,36 @@ class LinuxHost(BaseLinuxHost):
+
'/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"'
,
+
'/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"'
,
]
+
super
().
prepare_pre_cp
(
inst
)
]
+
super
().
prepare_pre_cp
(
inst
)
def
prepare_post_cp
(
self
,
inst
)
->
tp
.
L
ist
[
str
]:
def
prepare_post_cp
(
self
,
inst
)
->
l
ist
[
str
]:
l
=
[]
cmds
=
super
().
prepare_post_cp
(
inst
)
for
d
in
self
.
drivers
:
for
d
in
self
.
drivers
:
if
d
[
0
]
==
"/"
:
if
d
[
0
]
==
"/"
:
l
.
append
(
f
"insmod
{
d
}
"
)
cmds
.
append
(
f
"insmod
{
d
}
"
)
else
:
l
.
append
(
f
"modprobe
{
d
}
"
)
eth_i
=
0
for
i
in
self
.
interfaces
():
# Get ifname parameter if set, otherwise default to ethX
if
isinstance
(
i
,
eth
.
EthSimpleNIC
):
ifn
=
f
"eth
{
eth_i
}
"
eth_i
+=
1
else
:
else
:
cmds
.
append
(
f
"modprobe
{
d
}
"
)
index
=
0
for
inf
in
base
.
Interface
.
filter_by_type
(
self
.
interfaces
(),
eth
.
EthInterface
):
if
not
utils_base
.
check_type
(
inf
.
component
,
eth
.
EthSimpleNIC
):
continue
continue
# Get ifname parameter if set, otherwise default to ethX
ifn
=
f
"eth
{
index
}
"
index
+=
1
com
:
eth
.
EthSimpleNIC
=
inf
.
component
# Force MAC if requested
# Force MAC if requested
TODO: FIXME
if
"force_mac_addr"
in
i
.
parameters
:
#
if "force_mac_addr" in i.parameters:
mac
=
i
.
parameters
[
"force_mac_addr"
]
#
mac = i.parameters["force_mac_addr"]
l
.
append
(
f
"ip link set dev
{
ifn
}
address "
f
"
{
mac
}
"
)
#
l.append(f"ip link set dev {ifn} address " f"{mac}")
# Bring interface up
# Bring interface up
l
.
append
(
f
"ip link set dev
{
ifn
}
up"
)
cmds
.
append
(
f
"ip link set dev
{
ifn
}
up"
)
# Add IP addresses if included
# Add IP addresses if included
if
"ipv4_addrs"
in
i
.
parameters
:
assert
com
.
_ip
is
not
None
for
a
in
i
.
parameters
[
"ipv4_addrs"
]:
cmds
.
append
(
f
"ip addr add
{
com
.
_ip
}
dev
{
ifn
}
"
)
l
.
append
(
f
"ip addr add
{
a
}
dev
{
ifn
}
"
)
return
super
().
prepare_post_cp
(
inst
)
+
l
return
cmds
class
I40ELinuxHost
(
LinuxHost
):
class
I40ELinuxHost
(
LinuxHost
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment