Discussion:
current status of python bindings in the trunk
Noah Gift
2007-05-08 12:21:46 UTC
Permalink
I had problems importing the netsnmp python moduel once I had compiled
version 5.4. Is the version in the trunk a better place to checkout
the python bindings?

Noah
Noah Gift
2007-05-08 12:25:16 UTC
Permalink
Sorry for the double post, but this is the traceback I get on the
version in the trunk as well:

In [1]: import netsnmp
---------------------------------------------------------------------------
<type 'exceptions.ImportError'> Traceback (most recent call last)

/src/net-snmp-svn-main/python/<ipython console> in <module>()

/src/net-snmp-svn-main/python/netsnmp/__init__.py in <module>()
----> 1 from client import *

/src/net-snmp-svn-main/python/netsnmp/client.py in <module>()
2 import string
3 import re
4 import types
5
6 # control verbosity of error output

<type 'exceptions.ImportError'>: No module named client_intf
Post by Noah Gift
I had problems importing the netsnmp python moduel once I had compiled
version 5.4. Is the version in the trunk a better place to checkout
the python bindings?
Noah
Dave Shield
2007-05-09 13:10:40 UTC
Permalink
Post by Noah Gift
I had problems importing the netsnmp python moduel once I had compiled
version 5.4. Is the version in the trunk a better place to checkout
the python bindings?
I don't think there's any significant difference between the two
Comparing the two, the only extra change on the SVN trunk is
the removal of a couple of C++ comments. I suspect the
actual code is identical.

Note that this functionality is very new, and should probably be
regarded as alpha-status. Any fixes gratefully received.

Dave

PS: I don't think there's enough traffic to justify a separate mailing list,
so here is as good as anywhere for questions about the python bindings.
But bear in mind that very few people are using these bindings as yet,
so you're probably now one of the leading experts!
Noah Gift
2007-05-09 13:27:27 UTC
Permalink
Well the good news is that, with the help of a colleague, I was able
to get the bindings to work properly. When I compiled from source on
ubuntu 7.04 and then installed the python egg it could not find
libnetsnmp.so.15 when I did an import from ipython.

My colleague used ldconfig to link the path to libnetsnmp.so.15 in:
/usr/local/lib/libnetsnmp.so.15

then I was working. I also tried to get this to compile on OS X and
OS X server and had some big issues, but that isn't really the top of
my list right now as I usually work from an ubuntu shell as I have
come to not count on OS X having things up to date that I would expect
work on a linux box.

Now, I am in the process of writing some test python code to query a
Cisco router. Since I will be working on this project for quite a
while and need to be an expert on python and SNMP, I will volunteer to
help as much as possible. If we have a wiki for the python bindings,
I can put what I learned up so far.

As for the separate mailing list, it might encourage more python
programmers to get involved as there is quite a bit of traffic on this
list that is not related to my problem :) Of course, that is being
selfish, but well...I am a little selfish sometimes.

Noah
Post by Dave Shield
Post by Noah Gift
I had problems importing the netsnmp python moduel once I had compiled
version 5.4. Is the version in the trunk a better place to checkout
the python bindings?
I don't think there's any significant difference between the two
Comparing the two, the only extra change on the SVN trunk is
the removal of a couple of C++ comments. I suspect the
actual code is identical.
Note that this functionality is very new, and should probably be
regarded as alpha-status. Any fixes gratefully received.
Dave
PS: I don't think there's enough traffic to justify a separate mailing list,
so here is as good as anywhere for questions about the python bindings.
But bear in mind that very few people are using these bindings as yet,
so you're probably now one of the leading experts!
Dave Shield
2007-05-09 13:48:05 UTC
Permalink
Post by Noah Gift
If we have a wiki for the python bindings,
I can put what I learned up so far.
Your wish is my command, Oh Master.
See
http://www.net-snmp.org/wiki/index.php?title=Python_Bindings
Post by Noah Gift
As for the separate mailing list, it might encourage more python
programmers to get involved as there is quite a bit of traffic on this
list that is not related to my problem :) Of course, that is being
selfish, but well...I am a little selfish sometimes.
I'm not convinced, personally - but we've got a project admin meeting
coming up. I'll raise the suggestion there, and see what the others
think. (Or people can always comment here, of course).

Dave
Noah Gift
2007-05-09 14:13:05 UTC
Permalink
Thanks. I started a page and put a usage example. Someone else is
editing right now, but I will probably add more later.
Post by Dave Shield
Post by Noah Gift
If we have a wiki for the python bindings,
I can put what I learned up so far.
Your wish is my command, Oh Master.
See
http://www.net-snmp.org/wiki/index.php?title=Python_Bindings
Post by Noah Gift
As for the separate mailing list, it might encourage more python
programmers to get involved as there is quite a bit of traffic on this
list that is not related to my problem :) Of course, that is being
selfish, but well...I am a little selfish sometimes.
I'm not convinced, personally - but we've got a project admin meeting
coming up. I'll raise the suggestion there, and see what the others
think. (Or people can always comment here, of course).
With the stuff happening in the python world, I see this as a potent
combination:
web app framework + sqlalchemy + net-snmp = fun

I am sure I am not the only python person who thinks this..
Post by Dave Shield
Dave
G. S. Marzot
2007-05-09 17:21:25 UTC
Permalink
just for the record...thous was a general net-snmp install related problem
rather than anything related to the python bindings...right?

thanks, G
Post by Noah Gift
Well the good news is that, with the help of a colleague, I was able
to get the bindings to work properly. When I compiled from source on
ubuntu 7.04 and then installed the python egg it could not find
libnetsnmp.so.15 when I did an import from ipython.
/usr/local/lib/libnetsnmp.so.15
then I was working. I also tried to get this to compile on OS X and
OS X server and had some big issues, but that isn't really the top of
my list right now as I usually work from an ubuntu shell as I have
come to not count on OS X having things up to date that I would expect
work on a linux box.
Now, I am in the process of writing some test python code to query a
Cisco router. Since I will be working on this project for quite a
while and need to be an expert on python and SNMP, I will volunteer to
help as much as possible. If we have a wiki for the python bindings,
I can put what I learned up so far.
As for the separate mailing list, it might encourage more python
programmers to get involved as there is quite a bit of traffic on this
list that is not related to my problem :) Of course, that is being
selfish, but well...I am a little selfish sometimes.
Noah
Post by Dave Shield
Post by Noah Gift
I had problems importing the netsnmp python moduel once I had compiled
version 5.4. Is the version in the trunk a better place to checkout
the python bindings?
I don't think there's any significant difference between the two
Comparing the two, the only extra change on the SVN trunk is
the removal of a couple of C++ comments. I suspect the
actual code is identical.
Note that this functionality is very new, and should probably be
regarded as alpha-status. Any fixes gratefully received.
Dave
PS: I don't think there's enough traffic to justify a separate mailing list,
so here is as good as anywhere for questions about the python bindings.
But bear in mind that very few people are using these bindings as yet,
so you're probably now one of the leading experts!
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-coders mailing list
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
Noah Gift
2007-05-09 18:23:51 UTC
Permalink
Not really, as I was able to compile with lots of warnings, but when I went
to install the egg the snmp module was linked a non-existance shared object
(not in path). So this was a python problem, although, I didn't really test
the regular snmp stuff to much..I would think someone would have pointed
that out by now though....
Post by G. S. Marzot
just for the record...thous was a general net-snmp install related problem
rather than anything related to the python bindings...right?
thanks, G
Post by Noah Gift
Well the good news is that, with the help of a colleague, I was able
to get the bindings to work properly. When I compiled from source on
ubuntu 7.04 and then installed the python egg it could not find
libnetsnmp.so.15 when I did an import from ipython.
/usr/local/lib/libnetsnmp.so.15
then I was working. I also tried to get this to compile on OS X and
OS X server and had some big issues, but that isn't really the top of
my list right now as I usually work from an ubuntu shell as I have
come to not count on OS X having things up to date that I would expect
work on a linux box.
Now, I am in the process of writing some test python code to query a
Cisco router. Since I will be working on this project for quite a
while and need to be an expert on python and SNMP, I will volunteer to
help as much as possible. If we have a wiki for the python bindings,
I can put what I learned up so far.
As for the separate mailing list, it might encourage more python
programmers to get involved as there is quite a bit of traffic on this
list that is not related to my problem :) Of course, that is being
selfish, but well...I am a little selfish sometimes.
Noah
Post by Dave Shield
Post by Noah Gift
I had problems importing the netsnmp python moduel once I had compiled
version 5.4. Is the version in the trunk a better place to checkout
the python bindings?
I don't think there's any significant difference between the two
Comparing the two, the only extra change on the SVN trunk is
the removal of a couple of C++ comments. I suspect the
actual code is identical.
Note that this functionality is very new, and should probably be
regarded as alpha-status. Any fixes gratefully received.
Dave
PS: I don't think there's enough traffic to justify a separate mailing
list,
Post by Noah Gift
Post by Dave Shield
so here is as good as anywhere for questions about the python bindings.
But bear in mind that very few people are using these bindings as yet,
so you're probably now one of the leading experts!
-------------------------------------------------------------------------
Post by Noah Gift
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-coders mailing list
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
G. S. Marzot
2007-05-09 18:48:45 UTC
Permalink
Post by Noah Gift
Not really, as I was able to compile with lots of warnings, but when I went
to install the egg the snmp module was linked a non-existance shared object
(not in path). So this was a python problem, although, I didn't really test
the regular snmp stuff to much..I would think someone would have pointed
that out by now though....
hmmm...if you had done a full install of the net-snmp package I think ldconfig
should have been run for you. No package that relies on the net-snmp shared lib
would work in that case. I keep thinking this is not something specific to the
python build...am I still missing something

running the test suite might have shown a prob before install...

anyway what are your thoughts on what should be done differently?

-G
Noah Gift
2007-05-09 19:05:18 UTC
Permalink
Post by Noah Gift
Post by Noah Gift
Not really, as I was able to compile with lots of warnings, but when I
went
Post by Noah Gift
to install the egg the snmp module was linked a non-existance shared
object
Post by Noah Gift
(not in path). So this was a python problem, although, I didn't really test
the regular snmp stuff to much..I would think someone would have pointed
that out by now though....
hmmm...if you had done a full install of the net-snmp package I think ldconfig
should have been run for you. No package that relies on the net-snmp shared lib
would work in that case. I keep thinking this is not something specific to the
python build...am I still missing something
running the test suite might have shown a prob before install...
That is a good point, I don't remember running the test. I need to compile
it again on a few more VM's so I will report back with Cent OS and Ubuntu
notes.


anyway what are your thoughts on what should be done differently?


It would be super, super, super cool if we could install the python bindings
via "easy_install" from the python cheeseshop without even worrying about
the underlying net-snmp package. You would get a ton of python people using
net-SNMP if eggs were available. At PyCon this year, I went to the egg talk
and it sounds like eggs are very close to being part of the the standard
library.





-G
Noah Gift
2007-05-09 19:32:59 UTC
Permalink
Post by Noah Gift
Post by G. S. Marzot
running the test suite might have shown a prob before install...
That is a good point, I don't remember running the test. I need to
compile it again on a few more VM's so I will report back with Cent OS and
Ubuntu notes.
On a fresh Ubuntu 7.04 install and using a tarball from svn last night I get
this traceback when I run the test:

***@nlap-ubu-vm:/src/net-snmp-svn-main/python/netsnmp/tests# python test.py
Traceback (most recent call last):
File "test.py", line 6, in <module>
import netsnmp
File "/src/net-snmp-svn-main/python/netsnmp/tests/__init__.py", line 1, in
<module>

File "build/bdist.linux-i686/egg/netsnmp/client.py", line 1, in <module>
File "build/bdist.linux-i686/egg/netsnmp/client_intf.py", line 7, in
<module>
File "build/bdist.linux-i686/egg/netsnmp/client_intf.py", line 6, in
__bootstrap__
ImportError: libnetsnmp.so.15: cannot open shared object file: No such file
or directory


Which means I need to run ldconfig.
Thomas Anders
2007-05-09 20:41:56 UTC
Permalink
Post by Noah Gift
It would be super, super, super cool if we could install the python bindings
via "easy_install" from the python cheeseshop without even worrying about
the underlying net-snmp package. You would get a ton of python people using
net-SNMP if eggs were available. At PyCon this year, I went to the egg talk
and it sounds like eggs are very close to being part of the the standard
library.
It'd also be beneficial if the Python bindings could easily make it into
the popular Linux distros. I've just submitted the following patch (from
Debian) which would at least make life easier for packagers:

[ 1716114 ] Let Python build in source tree
http://sourceforge.net/tracker/index.php?func=detail&aid=1716114&group_id=12694&atid=312694

Would anyone be willing to review it?


+Thomas
Dave Shield
2007-05-10 08:39:01 UTC
Permalink
Post by Thomas Anders
I've just submitted the following patch (from
Would anyone be willing to review it?
I'm no Python expert (to put it mildly!), but this patch seems:
a) plausible, and
b) safe


The Python bindings are still very much alpha code as yet,
so I don't think you need worry about applying changes and
fixes. You wouldn't have write access if we didn't trust your
judgement, Thomas!

If you think this is a good patch, then go ahead and apply it.

Dave
G. S. Marzot
2007-05-10 17:34:20 UTC
Permalink
looks good in a quick eyeball review...thanks Thomas.

-G
Post by Thomas Anders
Post by Noah Gift
It would be super, super, super cool if we could install the python bindings
via "easy_install" from the python cheeseshop without even worrying about
the underlying net-snmp package. You would get a ton of python people using
net-SNMP if eggs were available. At PyCon this year, I went to the egg talk
and it sounds like eggs are very close to being part of the the standard
library.
It'd also be beneficial if the Python bindings could easily make it into
the popular Linux distros. I've just submitted the following patch (from
[ 1716114 ] Let Python build in source tree
http://sourceforge.net/tracker/index.php?func=detail&aid=1716114&group_id=12694&atid=312694
Would anyone be willing to review it?
+Thomas
Thomas Anders
2007-05-10 22:00:01 UTC
Permalink
Post by G. S. Marzot
looks good in a quick eyeball review...thanks Thomas.
Applied to 5.4.x and trunk (r16352).


+Thomas
Wes Hardaker
2007-05-17 04:06:45 UTC
Permalink
GSM> hmmm...if you had done a full install of the net-snmp package I
GSM> think ldconfig should have been run for you.

For the record, if you do a make install from the net-snmp directory,
the build system does *NOT* run ldconfig. It prints a very big
warning (libtool does, actually) but it doesn't run it. If you
install from rpms, or likely from other package management tools, most
of those should run ldconfig for you (assuming they were written right).
--
Wes Hardaker
Sparta, Inc.
Noah Gift
2007-05-17 11:49:50 UTC
Permalink
Post by Wes Hardaker
GSM> hmmm...if you had done a full install of the net-snmp package I
GSM> think ldconfig should have been run for you.
For the record, if you do a make install from the net-snmp directory,
the build system does *NOT* run ldconfig. It prints a very big
warning (libtool does, actually) but it doesn't run it. If you
install from rpms, or likely from other package management tools, most
of those should run ldconfig for you (assuming they were written right).
That is good to know. I just exported LD_LIBRARY_PATH=/usr/local/lib
and then put it in /etc/profile which works for me.

On this subject, do you think it would be possible to decouple the
net-SNMP core and the python bindings at all? The reason I ask is
that the preferred python module installation method is to use
something called "easy_install" which is somewhat similar to CPAN with
Perl.

http://peak.telecommunity.com/DevCenter/EasyInstall

At that point new eggs can be placed here: http://cheeseshop.python.org/pypi

On the testing and code I have written so far with the Python
bindings, it just works. The tracebacks are a little vague, but if
you use snmpget and multiple values are returned then you will get a
strange, vague error.

The other weird error issue that I already posted is when I try to get
a Mac Address by using something like:

var = netsnmp.Varbind('ipNetToMediaPhysAddress')

I get back what appears to be an Octal String and not a Hex String and
the : is substituted with /

I can fix this by using a regular expression and conversion, but it
also means I have to convert it to a list as a tuple is immutable,
etc. Was there a reason for this? As I prefer the default net-SNMP
value which is a Hex String and what most people are used to when they
refer to a Mac Address.
Wes Hardaker
2007-05-21 22:03:44 UTC
Permalink
NG> On this subject, do you think it would be possible to decouple the
NG> net-SNMP core and the python bindings at all? The reason I ask is
NG> that the preferred python module installation method is to use
NG> something called "easy_install" which is somewhat similar to CPAN
NG> with Perl.

The python module is, as you know, bound to the Net-SNMP internal
library... So you need it on the system to be able to compile and
install the python module (this binding is what gives such a speed
improvement; early tests resulted in about a 10x increase over the
other SNMP python modules).

But, the module itself does not need to be in the source directory of
net-snmp to build and install (unless I'm wrong, of course).

If you have a patch you think would help the module either in how it
works or how it is built, please do submit it to our patch database!!!

http://www.net-snmp.org/patches/

NG> The other weird error issue that I already posted is when I try to get
NG> a Mac Address by using something like:

NG> var = netsnmp.Varbind('ipNetToMediaPhysAddress')

NG> I get back what appears to be an Octal String and not a Hex String and
NG> the : is substituted with /

hmm... that does seem odd. Giovanni is probably the best person to
answer this question, but I suspect he's busy till at least next week.
--
Wes Hardaker
Sparta, Inc.
Noah Gift
2007-05-22 14:30:06 UTC
Permalink
Post by Wes Hardaker
NG> On this subject, do you think it would be possible to decouple the
NG> net-SNMP core and the python bindings at all? The reason I ask is
NG> that the preferred python module installation method is to use
NG> something called "easy_install" which is somewhat similar to CPAN
NG> with Perl.
The python module is, as you know, bound to the Net-SNMP internal
library... So you need it on the system to be able to compile and
install the python module (this binding is what gives such a speed
improvement; early tests resulted in about a 10x increase over the
other SNMP python modules).
But, the module itself does not need to be in the source directory of
net-snmp to build and install (unless I'm wrong, of course).
I am not sure of the actual implementation details myself, I could
research it if you need help. The ideal not technical implementation
would be an egg could install itself automatically against a source
tree. Even better would be if the egg could work independently of the
source code being there.
Post by Wes Hardaker
If you have a patch you think would help the module either in how it
works or how it is built, please do submit it to our patch database!!!
http://www.net-snmp.org/patches/
NG> The other weird error issue that I already posted is when I try to get
NG> var = netsnmp.Varbind('ipNetToMediaPhysAddress')
NG> I get back what appears to be an Octal String and not a Hex String and
NG> the : is substituted with /
hmm... that does seem odd. Giovanni is probably the best person to
answer this question, but I suspect he's busy till at least next week.
thanks!
Post by Wes Hardaker
--
Wes Hardaker
Sparta, Inc.
Wes Hardaker
2007-05-22 16:27:31 UTC
Permalink
NG> I am not sure of the actual implementation details myself, I could
NG> research it if you need help. The ideal not technical implementation
NG> would be an egg could install itself automatically against a source
NG> tree. Even better would be if the egg could work independently of the
NG> source code being there.

I, on the other hand, am not familiar with python eggs!
--
Wes Hardaker
Sparta, Inc.
Noah Gift
2007-05-22 18:37:53 UTC
Permalink
They are pretty nice. it is like apt-get for python modules in one
sense. We might try to get some help from the eggs mailing list. I
could do a little research and find out some more and get back to you.
Post by Wes Hardaker
NG> I am not sure of the actual implementation details myself, I could
NG> research it if you need help. The ideal not technical implementation
NG> would be an egg could install itself automatically against a source
NG> tree. Even better would be if the egg could work independently of the
NG> source code being there.
I, on the other hand, am not familiar with python eggs!
--
Wes Hardaker
Sparta, Inc.
G. S. Marzot
2007-05-31 14:32:17 UTC
Permalink
Post by Noah Gift
The ideal not technical implementation
would be an egg could install itself automatically against a source
tree. Even better would be if the egg could work independently of the
source code being there.
that was the designed intent...we will work to make this true...interested to
learn more about the easy install tools to use...I thought the setup.py way was
"normal".
Post by Noah Gift
Post by Wes Hardaker
NG> The other weird error issue that I already posted is when I try to get
NG> var = netsnmp.Varbind('ipNetToMediaPhysAddress')
NG> I get back what appears to be an Octal String and not a Hex String and
NG> the : is substituted with /
is this still a problem...can you post some output so I can see what's looking
wrong.

thanks, G
Noah Gift
2007-05-31 18:13:04 UTC
Permalink
One other coding design question:

I think Session is a pretty cool idea, but what about making it a
Super Class and having a Version 2 and Version 3 Class inhert from
Session? If these two classes overloaded the default methods and had
default keyword arguments it would be easier to subclass in Object
Oriented Code I am writing:

Right now I have the Session class looks like this:

class Session(object):
def __init__(self, **args):

It is a little non-intuitive to inhert from. If it had something like
it would be a little nicer to inhert from:

class SessionV2(Session):
def __init__(self, Version= 2, DestHost='127.0.0.1',
Community='public', **args)

Of course that makes it so someone could override Version=2, but I
think having the keywords in the __init__ method is easier.
Noah Gift
2007-12-13 01:54:43 UTC
Permalink
Just an FYI, I wrote an article for IBM Developerworks on IPython and
Net-SNMP.
http://www.ibm.com/developerworks/aix/library/au-netsnmpnipython/
Loading...