
Greetings all,
Thanks for your work on libsmi. I'm working on a python application to connect snmp traps to a TCP stream oriented management application and I've found libsmi to be exactly what I need to decode trap PDU's to tokens and arguments that the management application can parse.
To do so, I've implemented a hand coded Python wrapper around (so far) smi_config (except SetErrorHandler), most of smi_module (no Revision functions) and some of smi_node (no Element or Refinement functions). The advantage to hand-coding over SWIG is that the smi data structures are properly reflected in real python objects. With SWIG, a nodes smiValue reference becomes a string representation of a C pointer, providing no real value to the python programmer. By properly producing the return objects, the python Node object contains a "real" Value object that properly represents the equivalent C structure.
First question: Is there a test suite anywhere that I can use to help generate a python test suite to verify that I'm not mucking up the results of the underlying smi calls?
Second question: Is anyone else interested in a full Python wrapper? I'm no SMI expert (beyond SNMP MIB's using it), and I can't really pursue much more functionality since I'm basically clueless about Elements, Refinements, Types, and Macros. If there _is_ a test suite, I could implement based on that, if not I could use advice and suggestions on where to learn more so I can extend as time permits. If nobody else cares, I'll just keep it as is until I need more from it.
TIA

Hi!
Mark> Greetings all, Mark> Thanks for your work on libsmi. I'm working on a python application to Mark> connect snmp traps to a TCP stream oriented management application and Mark> I've found libsmi to be exactly what I need to decode trap PDU's to Mark> tokens and arguments that the management application can parse.
Mark> To do so, I've implemented a hand coded Python wrapper around (so far) Mark> smi_config (except SetErrorHandler), most of smi_module (no Revision Mark> functions) and some of smi_node (no Element or Refinement functions). Mark> The advantage to hand-coding over SWIG is that the smi data structures Mark> are properly reflected in real python objects. With SWIG, a nodes Mark> smiValue reference becomes a string representation of a C pointer, Mark> providing no real value to the python programmer. By properly Mark> producing the return objects, the python Node object contains a "real" Mark> Value object that properly represents the equivalent C structure.
Mark> First question: Is there a test suite anywhere that I can use to help Mark> generate a python test suite to verify that I'm not mucking up the Mark> results of the underlying smi calls?
Mark> Second question: Is anyone else interested in a full Python wrapper? Mark> I'm no SMI expert (beyond SNMP MIB's using it), and I can't really Mark> pursue much more functionality since I'm basically clueless about Mark> Elements, Refinements, Types, and Macros. If there _is_ a test suite, Mark> I could implement based on that, if not I could use advice and Mark> suggestions on where to learn more so I can extend as time permits. If Mark> nobody else cares, I'll just keep it as is until I need more from it.
Thanks for offering your contribution!
I have no clue, how such a Python <-> C comparing test suite could look like. But if the API functions (all of them are declared in smi.h) are mapped in your Python wrapper, then it should be fine, I guess. The only attempt that I could imagine would be to suck the data into a Python program, then reinitialize the libsmi and feed the data back into libsmi's internal data structures (this would require addition wrapping code just for this test purpose), and then run some output drivers and compare the results. But I'm not sure, if this is worth the effort.
+--> libsmi ----------------------------------------------> dump | ^ MIBs --+ compare| | v +--> libsmi --> python-wrapper --> test-stub --> libsmi --> dump
The test suite that comes with libsmi primarily ensures that the errors detected by the SMIv1/v2 parser and the output of the various dump drivers do not change over time while development continues.
I'm no Python programmer. The Python driver that exists in the libsmi Software has been contributed by Pat Knight (see the ChangeLog and THANKS files). Maybe, he has further comments.
-frank
participants (2)
-
Frank Strauss
-
Mark W. Alexander