Skip to content

Commit

Permalink
Clarify what down-state means in docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
stveit committed Aug 29, 2024
1 parent eb08b92 commit 29a6315
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/zino/statemodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ def dump_event_to_file(self, dir_name: str):
statefile.write(self.model_dump_json(exclude_none=True, indent=2))

def is_down(self) -> bool:
"""Returns true if the event is in a down state"""
"""Returns true if the event is in a down state.
What is considered a "down state" depends on the type of event,
but generally it means something like a device or a port is down.
"""
return False


Expand All @@ -358,6 +361,10 @@ def subindex(self) -> SubIndex:
return self.ifindex

def is_down(self) -> bool:
"""Returns true if the event is in a down state.
A PortStateEvent is considered "down" if the port it is related to is
either down or in a flapping state.
"""
return self.portstate in [InterfaceState.DOWN, InterfaceState.FLAPPING]


Expand Down Expand Up @@ -399,6 +406,10 @@ class ReachabilityEvent(Event):
reachability: Optional[ReachabilityState] = None

def is_down(self) -> bool:
"""Returns true if the event is in a down state.
A ReachabilityEvent is considered "down" if the device it is related to
is not reachable.
"""
return self.reachability == ReachabilityState.NORESPONSE


Expand Down

0 comments on commit 29a6315

Please sign in to comment.