daemon: added initial podman node support
This commit is contained in:
parent
c76bc2ee8a
commit
a80796ac72
15 changed files with 310 additions and 35 deletions
|
@ -12,15 +12,7 @@ from core.emulator.data import (
|
|||
from core.errors import CoreError
|
||||
|
||||
T = TypeVar(
|
||||
"T",
|
||||
bound=Union[
|
||||
EventData,
|
||||
ExceptionData,
|
||||
NodeData,
|
||||
LinkData,
|
||||
FileData,
|
||||
ConfigData,
|
||||
],
|
||||
"T", bound=Union[EventData, ExceptionData, NodeData, LinkData, FileData, ConfigData]
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ class NodeTypes(Enum):
|
|||
DOCKER = 15
|
||||
LXC = 16
|
||||
WIRELESS = 17
|
||||
PODMAN = 18
|
||||
|
||||
|
||||
class LinkTypes(Enum):
|
||||
|
|
|
@ -43,7 +43,7 @@ class HookManager:
|
|||
state_hooks = self.script_hooks.setdefault(state, {})
|
||||
if file_name in state_hooks:
|
||||
raise CoreError(
|
||||
f"adding duplicate state({state.name}) hook script({file_name})",
|
||||
f"adding duplicate state({state.name}) hook script({file_name})"
|
||||
)
|
||||
state_hooks[file_name] = data
|
||||
|
||||
|
@ -59,7 +59,7 @@ class HookManager:
|
|||
if file_name not in state_hooks:
|
||||
raise CoreError(
|
||||
f"deleting state({state.name}) hook script({file_name}) "
|
||||
"that does not exist",
|
||||
"that does not exist"
|
||||
)
|
||||
del state_hooks[file_name]
|
||||
|
||||
|
@ -77,7 +77,7 @@ class HookManager:
|
|||
if hook in hooks:
|
||||
name = getattr(callable, "__name__", repr(hook))
|
||||
raise CoreError(
|
||||
f"adding duplicate state({state.name}) hook callback({name})",
|
||||
f"adding duplicate state({state.name}) hook callback({name})"
|
||||
)
|
||||
hooks.append(hook)
|
||||
|
||||
|
@ -96,7 +96,7 @@ class HookManager:
|
|||
name = getattr(callable, "__name__", repr(hook))
|
||||
raise CoreError(
|
||||
f"deleting state({state.name}) hook callback({name}) "
|
||||
"that does not exist",
|
||||
"that does not exist"
|
||||
)
|
||||
hooks.remove(hook)
|
||||
|
||||
|
@ -132,7 +132,7 @@ class HookManager:
|
|||
except (OSError, subprocess.CalledProcessError) as e:
|
||||
raise CoreError(
|
||||
f"failure running state({state.name}) "
|
||||
f"hook script({file_name}): {e}",
|
||||
f"hook script({file_name}): {e}"
|
||||
)
|
||||
for hook in self.callback_hooks.get(state, []):
|
||||
try:
|
||||
|
@ -141,5 +141,5 @@ class HookManager:
|
|||
name = getattr(callable, "__name__", repr(hook))
|
||||
raise CoreError(
|
||||
f"failure running state({state.name}) "
|
||||
f"hook callback({name}): {e}",
|
||||
f"hook callback({name}): {e}"
|
||||
)
|
||||
|
|
|
@ -57,6 +57,7 @@ from core.nodes.network import (
|
|||
WlanNode,
|
||||
)
|
||||
from core.nodes.physical import PhysicalNode, Rj45Node
|
||||
from core.nodes.podman import PodmanNode
|
||||
from core.nodes.wireless import WirelessNode
|
||||
from core.plugins.sdt import Sdt
|
||||
from core.services.coreservices import CoreServices
|
||||
|
@ -81,9 +82,9 @@ NODES: dict[NodeTypes, type[NodeBase]] = {
|
|||
NodeTypes.DOCKER: DockerNode,
|
||||
NodeTypes.LXC: LxcNode,
|
||||
NodeTypes.WIRELESS: WirelessNode,
|
||||
NodeTypes.PODMAN: PodmanNode,
|
||||
}
|
||||
NODES_TYPE: dict[type[NodeBase], NodeTypes] = {NODES[x]: x for x in NODES}
|
||||
CONTAINER_NODES: set[type[NodeBase]] = {DockerNode, LxcNode}
|
||||
CTRL_NET_ID: int = 9001
|
||||
LINK_COLORS: list[str] = ["green", "blue", "orange", "purple", "turquoise"]
|
||||
NT: TypeVar = TypeVar("NT", bound=NodeBase)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue