-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement a link state monitor task #71
Conversation
c8d6c2f
to
df35715
Compare
Codecov Report
@@ Coverage Diff @@
## master #71 +/- ##
==========================================
+ Coverage 94.06% 94.88% +0.82%
==========================================
Files 22 24 +2
Lines 1144 1250 +106
==========================================
+ Hits 1076 1186 +110
+ Misses 68 64 -4
... and 3 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
c1f58ee
to
9f5c354
Compare
3934a0c
to
d4c81c8
Compare
We shouldn't need to create the dictionary elsewhere, so its best to default to starting with an empty dict that we can start using immediately.
d4c81c8
to
153afdc
Compare
We do not actually ever need the numerical values from the MIB in our state handling code, as the values are translated to strings for us by the MIB layer. It is therefore better to use a StrEnum, which makes translation from MIB string values easier, and makes the saved state even more human-readable. Also, at least one of the states that Zino 1 operates with, "adminDown" isn't actually a state value from the MIB. It is used to flag the case where an interface operational state is down not because of an error or missing link, but because the administrator has disabled the port on purpose. Because of this, the InterfaceOperState enum was also renamed to InterfaceState (since it doesn't necessarily represent just operstate values).
This makes it easier to annotate other methods that will return or use a data structure that came from the sparsewalk method.
This is an initial re-implementation of the link state monitor parts of Zino 1. Some bits and pieces are still missing, and some TODO points a strewn throughout.
According to Håvard Eidnes, we may need to keep the alias value for non-watched interfaces, especially for PM functionality that comes later. That an interface is not watched only means we shouldn't generate events for it.
These are used by the original Zino for this type of event.
This also factors out state updating and event generation to separate methods.
153afdc
to
3341f0d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could increse coverage further by adding some more tests as codecov points out.
Would be nice with a couple small tests specifically for BaseInterfaceRow.is_sane
As noted in code review, it's a good idea to log some details whenever we skip updating an interface due to receiving faulty or incomplete SNMP data.
This changes the code flow based on comments from @stveit: Processing a single interface where the collected data is incomplete will raise an exception, while when processing multiple interfaces, single interfaces with issues are just logged and otherwise ignored to not interrupt the flow.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
This implements the basics of a link state monitor task, along with some of the necessary changes to the surrounding codebase.
As a side-effect, this also introduces basic test coverage for the zino.tasks module, which had none.
Closes #75