Skip to content

Commit

Permalink
Improve clear_flapping (#50)
Browse files Browse the repository at this point in the history
* Fix typo in clear_flapping
* Let clear_flapping accept an event id
  • Loading branch information
hmpf authored Mar 15, 2024
1 parent 3622dc4 commit 3ac8081
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/zinolib/controllers/zino1.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
from typing import Dict, Iterable, List, TypedDict, Optional, Set
import logging

from .base import EventManager
from .base import EventManager, EventOrId
from ..compat import StrEnum
from ..event_types import EventType, Event, HistoryEntry, LogEntry, AdmState
from ..event_types import PortStateEvent
Expand Down Expand Up @@ -463,14 +463,15 @@ def disconnect(self):
self._verify_session()
self.session = self._session_adapter.close_session(self.session)

def clear_flapping(self, event: PortStateEvent):
def clear_flapping(self, event_or_id: EventOrId):
"""Clear flapping state of a PortStateEvent
Usage:
c = ritz_session.case(123)
c.clear_flapping()
"""
if event.type == Event.Type.PortState:
event = self._get_event(event_or_id)
if event.type == Event.Type.PORTSTATE:
return self.session.request.clear_flapping(event.router, event.if_index)
return None

Expand Down

0 comments on commit 3ac8081

Please sign in to comment.