[Libvir] libvirt 0.1.8 Help

Hi, I have the following code working on libvirt 0.1.9: ######################################## conn = libvirt.openReadOnly(None) if conn == None: print 'Failed to open connection to the hypervisor' #sys.exit(1) try: domains = conn.listDomainsID() num = conn.numOfDomains() except: print 'Failed to find the list of domains' for i in range(num): try: dom0 = conn.lookupByID(domains[i]) domInfo = dom0.info() except: print "Unexpected error:", sys.exc_info() ############################################## For legacy reason, I have to get it working on libvirt 0.1.8 but I am constantly getting the following error: Unexpected error: (<class libvirt.libvirtError at 0xb7f49f2c>, < libvirt.libvirtError instance at 0xb7f4f2cc>, <traceback object at 0xb7f44c5c>) Any help would be much appreciated! Cheers Omer -- ---------------------------------------------------------- CERN – European Organization for Nuclear Research, IT Department, CH-1211 Geneva 23, Switzerland Phone: +41 (0) 22 767 2224 Fax: +41 (0) 22 766 8683 E-mail : Omer.Khalid@cern.ch Homepage: http://cern.ch/Omer.Khalid

On Wed, Jun 27, 2007 at 03:39:30PM +0200, Omer Khalid wrote:
Hi,
I have the following code working on libvirt 0.1.9:
######################################## conn = libvirt.openReadOnly(None) if conn == None: print 'Failed to open connection to the hypervisor' #sys.exit(1)
try: domains = conn.listDomainsID() num = conn.numOfDomains() except: print 'Failed to find the list of domains'
for i in range(num): try: dom0 = conn.lookupByID(domains[i]) domInfo = dom0.info() except: print "Unexpected error:", sys.exc_info()
##############################################
For legacy reason, I have to get it working on libvirt 0.1.8 but I am constantly getting the following error:
Unexpected error: (<class libvirt.libvirtError at 0xb7f49f2c>, < libvirt.libvirtError instance at 0xb7f4f2cc>, <traceback object at 0xb7f44c5c>)
Try adding an exception handler that prints out useful information rather than raw python object references for a start... Its impossible to debug this unless you get the text associated with the exception. Regards, Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

I tried with the traceback. Here is the output: [('<stdin>', 3, '?', None), ('/usr/lib/python2.3/site-packages/libvirt.py', 268, 'lookupByID', "if ret is None:raise libvirtError('virDomainLookupByID() failed')")] [('<stdin>', 3, '?', None), ('/usr/lib/python2.3/site-packages/libvirt.py', 268, 'lookupByID', "if ret is None:raise libvirtError('virDomainLookupByID() failed')")] Thanks Omer On 6/27/07, Daniel P. Berrange <berrange@redhat.com> wrote:
On Wed, Jun 27, 2007 at 03:39:30PM +0200, Omer Khalid wrote:
Hi,
I have the following code working on libvirt 0.1.9:
######################################## conn = libvirt.openReadOnly(None) if conn == None: print 'Failed to open connection to the hypervisor' #sys.exit(1)
try: domains = conn.listDomainsID() num = conn.numOfDomains() except: print 'Failed to find the list of domains'
for i in range(num): try: dom0 = conn.lookupByID(domains[i]) domInfo = dom0.info() except: print "Unexpected error:", sys.exc_info()
##############################################
For legacy reason, I have to get it working on libvirt 0.1.8 but I am constantly getting the following error:
Unexpected error: (<class libvirt.libvirtError at 0xb7f49f2c>, < libvirt.libvirtError instance at 0xb7f4f2cc>, <traceback object at 0xb7f44c5c>)
Try adding an exception handler that prints out useful information rather than raw python object references for a start... Its impossible to debug this unless you get the text associated with the exception.
Regards, Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
-- ---------------------------------------------------------- CERN – European Organization for Nuclear Research, IT Department, CH-1211 Geneva 23, Switzerland Phone: +41 (0) 22 767 2224 Fax: +41 (0) 22 766 8683 E-mail : Omer.Khalid@cern.ch Homepage: http://cern.ch/Omer.Khalid

Omer Khalid wrote:
I tried with the traceback. Here is the output:
[('<stdin>', 3, '?', None), ('/usr/lib/python2.3/site-packages/libvirt.py', 268, 'lookupByID', "if ret is None:raise libvirtError('virDomainLookupByID() failed')")] [('<stdin>', 3, '?', None), ('/usr/lib/python2.3/site-packages/libvirt.py', 268, 'lookupByID', "if ret is None:raise libvirtError('virDomainLookupByID() failed')")]
So we changed the Python bindings to raise an exception instead of just return None as an indication of error. Omer, please see also: https://www.redhat.com/archives/libvir-list/2007-June/msg00383.html Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

Hi Richard, Thanks for your prompt reply. I looked up the link. It refers to changing "Language bindings could be modified to detect this function"... What does that mean? Because catching the exception is concerned, that is I am already doing! Cheers Omer On 6/27/07, Richard W.M. Jones <rjones@redhat.com> wrote:
Omer Khalid wrote:
I tried with the traceback. Here is the output:
[('<stdin>', 3, '?', None), ('/usr/lib/python2.3/site-packages/libvirt.py', 268, 'lookupByID', "if ret is None:raise libvirtError('virDomainLookupByID() failed')")] [('<stdin>', 3, '?', None), ('/usr/lib/python2.3/site-packages/libvirt.py', 268, 'lookupByID', "if ret is None:raise libvirtError('virDomainLookupByID() failed')")]
So we changed the Python bindings to raise an exception instead of just return None as an indication of error.
Omer, please see also:
https://www.redhat.com/archives/libvir-list/2007-June/msg00383.html
Rich.
-- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903
-- ---------------------------------------------------------- CERN – European Organization for Nuclear Research, IT Department, CH-1211 Geneva 23, Switzerland Phone: +41 (0) 22 767 2224 Fax: +41 (0) 22 766 8683 E-mail : Omer.Khalid@cern.ch Homepage: http://cern.ch/Omer.Khalid
participants (3)
-
Daniel P. Berrange
-
Omer Khalid
-
Richard W.M. Jones