etingof / pysmi

SNMP MIB parser
http://snmplabs.com/pysmi/
BSD 2-Clause "Simplified" License
132 stars 51 forks source link

Add MIB objects instances code generation #44

Closed etingof closed 5 years ago

etingof commented 5 years ago

Refactor pysnmp code generation templates to generate Managed Objects Instances alone and with management instrumentation hooks.

The intention here is to automate pysnmp-based SNMP agents implementation by generating the boilerplate extension points where user calls to the actual data sources could be hooked up.

Implementation-wise, Jinja2 templates being used for pysnmp code generation have been overhauled to align better with this two-purpose design i.e. being able to generate just MIB definitions (for MIB browsing purposes) and MIB instrumentation. The latter can be generated in two variants:

In both cases above MIB instrumentation hooks are being generated to interface with the actual user data source.

As it stands now, generated ManagedObjectInstances are not actually instantiated and exported from the MIB module - the user is expected to provide proper OID and/or value prior to uncommenting the generated snippets.

codecov-io commented 5 years ago

Codecov Report

Merging #44 into master will decrease coverage by 0.38%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #44      +/-   ##
==========================================
- Coverage   74.45%   74.07%   -0.39%     
==========================================
  Files          31       31              
  Lines        2368     2368              
==========================================
- Hits         1763     1754       -9     
- Misses        605      614       +9
Impacted Files Coverage Δ
pysmi/codegen/pysnmp.py 93.1% <100%> (ø) :arrow_up:
pysmi/error.py 80.55% <0%> (-11.12%) :arrow_down:
pysmi/reader/zipreader.py 78.37% <0%> (-3.61%) :arrow_down:
pysmi/parser/smi.py 81.03% <0%> (-0.18%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 13174c7...1fd0799. Read the comment docs.