snimpy icon indicating copy to clipboard operation
snimpy copied to clipboard

Add isolated MIB loaders to support multiple sets of MIBs

Open iwanb opened this issue 8 years ago • 15 comments

I have added a MibLoader class in the mib module so you can load and use isolated sets of MIBs. It uses the dataset feature of libsmi (smiInit("tag:dataset")). I have added some simple tests for it, and all the existing tests are passing (on my machine at least). One issue is that AFAIK there is not way to release the memory of only that dataset, so if you want to start from scratch you need to reset libsmi completely. The goal is to support multiple agents with different versions of the same MIB.

Let me know if there are other things I need to do.

iwanb avatar Feb 05 '17 12:02 iwanb

Coverage Status

Coverage decreased (-0.2%) to 89.134% when pulling 86cb8d64099661114f69afc14408ef63f8891afe on iwanb:master into 123ca18b06426b360d4c92e28fa46fa05d81c311 on vincentbernat:master.

coveralls avatar Feb 05 '17 13:02 coveralls

Thanks! The diff is huge, but I suppose GitHub is just confused about whitespaces. I will look at it more later. As for the test errors, Python 2.6 needs {0}.format(...). I don't know where the error with PySNMP 4.2 comes from. I can have a look at it later, but feel free to add commits to this PR if you can fix that.

vincentbernat avatar Feb 05 '17 14:02 vincentbernat

OK, I will also have a look at the failures. The big diff in mib.py is moving the functions into a class. I also added method calls to the mibloader in test_mib.py instead of functions. And last I duplicated the snimpy mib with different names to allow tests on an different mib set, and the test agent loads both mibs.

iwanb avatar Feb 05 '17 14:02 iwanb

Coverage Status

Coverage decreased (-0.2%) to 89.134% when pulling 2ba44c515e087df4256fdd3198b72c76bf96a088 on iwanb:master into 123ca18b06426b360d4c92e28fa46fa05d81c311 on vincentbernat:master.

coveralls avatar Feb 05 '17 15:02 coveralls

Coverage Status

Coverage decreased (-0.2%) to 89.134% when pulling 2ba44c515e087df4256fdd3198b72c76bf96a088 on iwanb:master into 123ca18b06426b360d4c92e28fa46fa05d81c311 on vincentbernat:master.

coveralls avatar Feb 05 '17 15:02 coveralls

Coverage Status

Coverage decreased (-0.2%) to 89.134% when pulling 2ba44c515e087df4256fdd3198b72c76bf96a088 on iwanb:master into 123ca18b06426b360d4c92e28fa46fa05d81c311 on vincentbernat:master.

coveralls avatar Feb 05 '17 15:02 coveralls

Coverage Status

Coverage decreased (-0.2%) to 89.134% when pulling 2ba44c515e087df4256fdd3198b72c76bf96a088 on iwanb:master into 123ca18b06426b360d4c92e28fa46fa05d81c311 on vincentbernat:master.

coveralls avatar Feb 05 '17 15:02 coveralls

Coverage Status

Coverage decreased (-0.2%) to 89.134% when pulling 2ba44c515e087df4256fdd3198b72c76bf96a088 on iwanb:master into 123ca18b06426b360d4c92e28fa46fa05d81c311 on vincentbernat:master.

coveralls avatar Feb 05 '17 15:02 coveralls

Coverage Status

Coverage decreased (-0.2%) to 89.134% when pulling 2ba44c515e087df4256fdd3198b72c76bf96a088 on iwanb:master into 123ca18b06426b360d4c92e28fa46fa05d81c311 on vincentbernat:master.

coveralls avatar Feb 05 '17 15:02 coveralls

Coverage Status

Coverage decreased (-0.2%) to 89.134% when pulling 2ba44c515e087df4256fdd3198b72c76bf96a088 on iwanb:master into 123ca18b06426b360d4c92e28fa46fa05d81c311 on vincentbernat:master.

coveralls avatar Feb 05 '17 15:02 coveralls

Coverage Status

Coverage decreased (-0.2%) to 89.134% when pulling 8c2c1bbff1ed24750484a1767f209bcd716d1cd4 on iwanb:master into 123ca18b06426b360d4c92e28fa46fa05d81c311 on vincentbernat:master.

coveralls avatar Feb 05 '17 16:02 coveralls

Coverage Status

Coverage decreased (-0.2%) to 89.134% when pulling 135db30a69bad6f9f81d2c74406ea57a39e689d6 on iwanb:master into 123ca18b06426b360d4c92e28fa46fa05d81c311 on vincentbernat:master.

coveralls avatar Feb 07 '17 20:02 coveralls

Any idea about the error with PySNMP 4.2? I cannot reproduce it on my computer and I really don't see where it could come from.

iwanb avatar Feb 07 '17 21:02 iwanb

Dunno. But I'll look more into it later (at the same time I'll read your changes). I will be unavailable for a week soon, so it can take two weeks for me to do something.

vincentbernat avatar Feb 07 '17 21:02 vincentbernat

I didn't forget about the PR, but I am lacking time. Please, be patient.

vincentbernat avatar Mar 06 '17 16:03 vincentbernat