Bug 1393018

Summary: Conflicting docs for python domain lookup
Product: [Community] Virtualization Tools Reporter: Landon <lgbland>
Component: libvirt-appdev-guideAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED WONTFIX QA Contact:
Severity: low Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: berrange, lgbland, libvirt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-16 17:35:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Landon 2016-11-08 17:18:14 UTC
Description of problem:

It looks like there is some conflicting docs in pythons domain lookup documentation: 

http://libvirt.org/docs/libvirt-appdev-guide-python/en-US/html/libvirt_application_development_guide_using_python-Guest_Domains.html

vs

https://libvirt.org/python.html



Specifically, this part:

dom = conn.lookupByName(domainName)
if dom == None:
    print('Failed to get the domain object', file=sys.stderr)

vs

try:
    dom0 = conn.lookupByName("Domain-0")
except:
    print 'Failed to find the main domain'


On the version of python-libvirt that I'm using (1.2.2 on ubuntu 14.04) when conn.lookupByName cannot find the domain name, it raises a libvirt.libvirtError, with err.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN. This is also the case for lookupById() and lookupByUuid(). Assuming this wasn't behavior that was recently changed, the appdev docs should be updated to reflect this.

Comment 1 Daniel Berrangé 2020-04-16 17:35:17 UTC
Closing old bug since the appdev guide is no longer maintained.