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

This commit is contained in:
Blake Harnden 2022-03-04 09:19:56 -08:00
parent 2eef7076f4
commit 0536747d9a
2 changed files with 13 additions and 42 deletions

View file

@ -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

View file

@ -304,12 +304,9 @@ 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:
if not result and exceptions:
message = "\n".join(exceptions)
self.app.show_exception_data(
"Start Exception", "Session failed to start", message