daemon: removed session state file, information should be available through grpc if needed

This commit is contained in:
Blake Harnden 2022-09-09 14:22:30 -07:00
parent e56d93f0fe
commit d045fc0d51
2 changed files with 0 additions and 16 deletions

View file

@ -728,27 +728,12 @@ class Session:
self.state = state self.state = state
self.state_time = time.monotonic() self.state_time = time.monotonic()
logger.info("changing session(%s) to state %s", self.id, state.name) logger.info("changing session(%s) to state %s", self.id, state.name)
self.write_state(state)
self.run_hooks(state) self.run_hooks(state)
self.run_state_hooks(state) self.run_state_hooks(state)
if send_event: if send_event:
event_data = EventData(event_type=state, time=str(time.monotonic())) event_data = EventData(event_type=state, time=str(time.monotonic()))
self.broadcast_event(event_data) self.broadcast_event(event_data)
def write_state(self, state: EventTypes) -> None:
"""
Write the state to a state file in the session dir.
:param state: state to write to file
:return: nothing
"""
state_file = self.directory / "state"
try:
with state_file.open("w") as f:
f.write(f"{state.value} {state.name}\n")
except IOError:
logger.exception("error writing state file: %s", state.name)
def run_hooks(self, state: EventTypes) -> None: def run_hooks(self, state: EventTypes) -> None:
""" """
Run hook scripts upon changing states. If hooks is not specified, run all hooks Run hook scripts upon changing states. If hooks is not specified, run all hooks

View file

@ -59,7 +59,6 @@ def patcher(request):
LinuxNetClient, "get_mac", return_value="00:00:00:00:00:00" LinuxNetClient, "get_mac", return_value="00:00:00:00:00:00"
) )
patch_manager.patch_obj(CoreNode, "create_file") patch_manager.patch_obj(CoreNode, "create_file")
patch_manager.patch_obj(Session, "write_state")
yield patch_manager yield patch_manager
patch_manager.shutdown() patch_manager.shutdown()