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
af98d725
Unverified
Commit
af98d725
authored
Sep 26, 2024
by
Jakob Görgen
Browse files
fixed ip link set + fixed ip addr add
parent
1b2e3992
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
24 deletions
+42
-24
experiments/simbricks/orchestration/instantiation/base.py
experiments/simbricks/orchestration/instantiation/base.py
+6
-14
experiments/simbricks/orchestration/simulation/base.py
experiments/simbricks/orchestration/simulation/base.py
+1
-6
experiments/simbricks/orchestration/system/base.py
experiments/simbricks/orchestration/system/base.py
+18
-0
experiments/simbricks/orchestration/system/host/base.py
experiments/simbricks/orchestration/system/host/base.py
+17
-4
No files found.
experiments/simbricks/orchestration/instantiation/base.py
View file @
af98d725
...
@@ -71,9 +71,7 @@ class InstantiationEnvironment(util_base.IdObj):
...
@@ -71,9 +71,7 @@ class InstantiationEnvironment(util_base.IdObj):
super
().
__init__
()
super
().
__init__
()
self
.
_repodir
:
str
=
pathlib
.
Path
(
repo_path
).
resolve
()
self
.
_repodir
:
str
=
pathlib
.
Path
(
repo_path
).
resolve
()
self
.
_workdir
:
str
=
(
self
.
_workdir
:
str
=
(
workdir
workdir
if
workdir
else
pathlib
.
Path
(
f
"
{
self
.
_repodir
}
/wrkdir"
).
resolve
()
if
workdir
else
pathlib
.
Path
(
f
"
{
self
.
_repodir
}
/wrkdir"
).
resolve
()
)
)
self
.
_output_base
:
str
=
(
self
.
_output_base
:
str
=
(
output_base
output_base
...
@@ -152,18 +150,11 @@ class Instantiation(util_base.IdObj):
...
@@ -152,18 +150,11 @@ class Instantiation(util_base.IdObj):
def
qemu_path
(
self
)
->
str
:
def
qemu_path
(
self
)
->
str
:
return
self
.
_env
.
_qemu_path
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
(
def
_get_opposing_interface
(
self
,
interface
:
sys_base
.
Interface
self
,
interface
:
sys_base
.
Interface
)
->
sys_base
.
Interface
:
)
->
sys_base
.
Interface
:
channel
=
self
.
_get_chan_by_interface
(
interface
=
interface
)
opposing_inf
=
interface
.
get_opposing_
interface
(
)
return
channel
.
a
if
channel
.
a
is
not
interface
else
channel
.
b
return
opposing_inf
def
_opposing_interface_within_same_sim
(
def
_opposing_interface_within_same_sim
(
self
,
interface
:
sys_base
.
Interface
self
,
interface
:
sys_base
.
Interface
...
@@ -171,6 +162,7 @@ class Instantiation(util_base.IdObj):
...
@@ -171,6 +162,7 @@ class Instantiation(util_base.IdObj):
opposing_interface
=
self
.
_get_opposing_interface
(
interface
=
interface
)
opposing_interface
=
self
.
_get_opposing_interface
(
interface
=
interface
)
component
=
interface
.
component
component
=
interface
.
component
opposing_component
=
opposing_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
(
return
self
.
find_sim_by_spec
(
spec
=
component
)
==
self
.
find_sim_by_spec
(
spec
=
opposing_component
spec
=
opposing_component
)
)
...
@@ -196,7 +188,7 @@ class Instantiation(util_base.IdObj):
...
@@ -196,7 +188,7 @@ class Instantiation(util_base.IdObj):
return
socket
return
socket
def
_interface_to_sock_path
(
self
,
interface
:
sys_base
.
Interface
)
->
str
:
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_ident
=
f
"
{
channel
.
a
.
_id
}
.
{
channel
.
_id
}
.
{
channel
.
b
.
_id
}
"
queue_type
=
None
queue_type
=
None
...
...
experiments/simbricks/orchestration/simulation/base.py
View file @
af98d725
...
@@ -193,16 +193,11 @@ class Simulator(utils_base.IdObj):
...
@@ -193,16 +193,11 @@ class Simulator(utils_base.IdObj):
)
)
return
interface
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
(
def
_get_socket
(
self
,
inst
:
inst_base
.
Instantiation
,
interface
:
sys_conf
.
Interface
self
,
inst
:
inst_base
.
Instantiation
,
interface
:
sys_conf
.
Interface
)
->
inst_base
.
Socket
|
None
:
)
->
inst_base
.
Socket
|
None
:
# get the channel associated with this interface
# 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
# check if interfaces channel is simulator internal, i.e. doesnt need an instanciation
if
not
self
.
_chan_needs_instance
(
chan
):
if
not
self
.
_chan_needs_instance
(
chan
):
return
None
return
None
...
...
experiments/simbricks/orchestration/system/base.py
View file @
af98d725
...
@@ -89,6 +89,15 @@ class Interface(util_base.IdObj):
...
@@ -89,6 +89,15 @@ class Interface(util_base.IdObj):
peer_if
=
self
.
channel
.
a
peer_if
=
self
.
channel
.
a
return
peer_if
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"
)
T
=
tp
.
TypeVar
(
"T"
)
@
staticmethod
@
staticmethod
...
@@ -113,3 +122,12 @@ class Channel(util_base.IdObj):
...
@@ -113,3 +122,12 @@ class Channel(util_base.IdObj):
# it's not referenced anywhere, so that's fine I guess.
# it's not referenced anywhere, so that's fine I guess.
self
.
a
.
disconnect
()
self
.
a
.
disconnect
()
self
.
b
.
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
experiments/simbricks/orchestration/system/host/base.py
View file @
af98d725
...
@@ -29,6 +29,7 @@ from os import path
...
@@ -29,6 +29,7 @@ from os import path
import
simbricks.orchestration.instantiation.base
as
instantiation
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
import
pcie
as
pcie
from
simbricks.orchestration.system.host
import
app
from
simbricks.orchestration.system.host
import
app
from
simbricks.orchestration.utils
import
base
as
utils_base
from
simbricks.orchestration.utils
import
base
as
utils_base
...
@@ -104,7 +105,9 @@ class BaseLinuxHost(FullSystemHost):
...
@@ -104,7 +105,9 @@ class BaseLinuxHost(FullSystemHost):
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
.
__name__
)
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
]:
"""
"""
...
@@ -121,11 +124,15 @@ class BaseLinuxHost(FullSystemHost):
...
@@ -121,11 +124,15 @@ 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
.
__name__
)
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
.
__name__
)
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
():
...
@@ -184,7 +191,13 @@ class LinuxHost(BaseLinuxHost):
...
@@ -184,7 +191,13 @@ class LinuxHost(BaseLinuxHost):
cmds
.
append
(
f
"modprobe
{
d
}
"
)
cmds
.
append
(
f
"modprobe
{
d
}
"
)
index
=
0
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
):
if
not
utils_base
.
check_type
(
inf
.
component
,
eth
.
EthSimpleNIC
):
continue
continue
# Get ifname parameter if set, otherwise default to ethX
# Get ifname parameter if set, otherwise default to ethX
...
...
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