37 lines
677 B
Python
37 lines
677 B
Python
from backend.events.bus import EventBus
|
|
|
|
|
|
def run_action(action, node, bus: EventBus):
|
|
|
|
bus.emit(
|
|
"task_update",
|
|
node=node["name"],
|
|
action=action["name"],
|
|
state="running"
|
|
)
|
|
|
|
try:
|
|
# placeholder execution logic
|
|
result = action["cmd"]()
|
|
|
|
bus.emit(
|
|
"task_update",
|
|
node=node["name"],
|
|
action=action["name"],
|
|
state="done"
|
|
)
|
|
|
|
return 0
|
|
|
|
except Exception as e:
|
|
|
|
bus.emit(
|
|
"failure",
|
|
node=node["name"],
|
|
action=action["name"],
|
|
state="failed",
|
|
reason=str(e)
|
|
)
|
|
|
|
return 1
|