From 0536747d9a11997a456664a283a7b368d2a1736f Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Fri, 4 Mar 2022 09:19:56 -0800 Subject: [PATCH] daemon/gui: adjustments to how a session instantiates, allowing the new python gui to move to a failed start state, this allows inpecting the failed nodes to see what went wrong --- daemon/core/emulator/session.py | 38 ++++++--------------------------- daemon/core/gui/toolbar.py | 17 ++++++--------- 2 files changed, 13 insertions(+), 42 deletions(-) diff --git a/daemon/core/emulator/session.py b/daemon/core/emulator/session.py index 60d52f82..219555d5 100644 --- a/daemon/core/emulator/session.py +++ b/daemon/core/emulator/session.py @@ -1177,34 +1177,30 @@ class Session: :return: list of service boot errors during startup """ + if self.state == EventTypes.RUNTIME_STATE: + logger.warning("ignoring instantiate, already in runtime state") + return [] # write current nodes out to session directory file self.write_nodes() - # create control net interfaces and network tunnels # which need to exist for emane to sync on location events # in distributed scenarios self.add_remove_control_net(0, remove=False) - # initialize distributed tunnels self.distributed.start() - # instantiate will be invoked again upon emane configure if self.emane.startup() == EmaneState.NOT_READY: return [] - # boot node services and then start mobility exceptions = self.boot_nodes() if not exceptions: self.mobility.startup() - # notify listeners that instantiation is complete event = EventData(event_type=EventTypes.INSTANTIATION_COMPLETE) self.broadcast_event(event) - - # assume either all nodes have booted already, or there are some - # nodes on slave servers that will be booted and those servers will - # send a node status response message - self.check_runtime() + # startup event loop + self.event_loop.run() + self.set_state(EventTypes.RUNTIME_STATE, send_event=True) return exceptions def get_node_count(self) -> int: @@ -1226,28 +1222,6 @@ class Session: count += 1 return count - def check_runtime(self) -> None: - """ - Check if we have entered the runtime state, that all nodes have been - started and the emulation is running. Start the event loop once we - have entered runtime (time=0). - - :return: nothing - """ - # this is called from instantiate() after receiving an event message - # for the instantiation state - logger.debug( - "session(%s) checking if not in runtime state, current state: %s", - self.id, - self.state.name, - ) - if self.state == EventTypes.RUNTIME_STATE: - logger.info("valid runtime state found, returning") - return - # start event loop and set to runtime - self.event_loop.run() - self.set_state(EventTypes.RUNTIME_STATE, send_event=True) - def data_collect(self) -> None: """ Tear down a running session. Stop the event loop and any running diff --git a/daemon/core/gui/toolbar.py b/daemon/core/gui/toolbar.py index faf8ab36..7392071d 100644 --- a/daemon/core/gui/toolbar.py +++ b/daemon/core/gui/toolbar.py @@ -304,16 +304,13 @@ class Toolbar(ttk.Frame): task.start() def start_callback(self, result: bool, exceptions: List[str]) -> None: - if result: - self.set_runtime() - self.app.core.show_mobility_players() - else: - enable_buttons(self.design_frame, enabled=True) - if exceptions: - message = "\n".join(exceptions) - self.app.show_exception_data( - "Start Exception", "Session failed to start", message - ) + self.set_runtime() + self.app.core.show_mobility_players() + if not result and exceptions: + message = "\n".join(exceptions) + self.app.show_exception_data( + "Start Exception", "Session failed to start", message + ) def set_runtime(self) -> None: enable_buttons(self.runtime_frame, enabled=True)