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 :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 # write current nodes out to session directory file
self.write_nodes() self.write_nodes()
# create control net interfaces and network tunnels # create control net interfaces and network tunnels
# which need to exist for emane to sync on location events # which need to exist for emane to sync on location events
# in distributed scenarios # in distributed scenarios
self.add_remove_control_net(0, remove=False) self.add_remove_control_net(0, remove=False)
# initialize distributed tunnels # initialize distributed tunnels
self.distributed.start() self.distributed.start()
# instantiate will be invoked again upon emane configure # instantiate will be invoked again upon emane configure
if self.emane.startup() == EmaneState.NOT_READY: if self.emane.startup() == EmaneState.NOT_READY:
return [] return []
# boot node services and then start mobility # boot node services and then start mobility
exceptions = self.boot_nodes() exceptions = self.boot_nodes()
if not exceptions: if not exceptions:
self.mobility.startup() self.mobility.startup()
# notify listeners that instantiation is complete # notify listeners that instantiation is complete
event = EventData(event_type=EventTypes.INSTANTIATION_COMPLETE) event = EventData(event_type=EventTypes.INSTANTIATION_COMPLETE)
self.broadcast_event(event) self.broadcast_event(event)
# startup event loop
# assume either all nodes have booted already, or there are some self.event_loop.run()
# nodes on slave servers that will be booted and those servers will self.set_state(EventTypes.RUNTIME_STATE, send_event=True)
# send a node status response message
self.check_runtime()
return exceptions return exceptions
def get_node_count(self) -> int: def get_node_count(self) -> int:
@ -1226,28 +1222,6 @@ class Session:
count += 1 count += 1
return count 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: def data_collect(self) -> None:
""" """
Tear down a running session. Stop the event loop and any running Tear down a running session. Stop the event loop and any running

View file

@ -304,16 +304,13 @@ class Toolbar(ttk.Frame):
task.start() task.start()
def start_callback(self, result: bool, exceptions: List[str]) -> None: def start_callback(self, result: bool, exceptions: List[str]) -> None:
if result: self.set_runtime()
self.set_runtime() self.app.core.show_mobility_players()
self.app.core.show_mobility_players() if not result and exceptions:
else: message = "\n".join(exceptions)
enable_buttons(self.design_frame, enabled=True) self.app.show_exception_data(
if exceptions: "Start Exception", "Session failed to start", message
message = "\n".join(exceptions) )
self.app.show_exception_data(
"Start Exception", "Session failed to start", message
)
def set_runtime(self) -> None: def set_runtime(self) -> None:
enable_buttons(self.runtime_frame, enabled=True) enable_buttons(self.runtime_frame, enabled=True)