← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1407915] [NEW] libvirt: Leverage xpath instead of searching manully

 

Public bug reported:

libvirt use xml format to create/describe  domain, add/delete devices.  There are some codes  hadle xml search by manul
like:

ret = doc.findall('./devices/disk')
    for node in ret:
        for child in node.getchildren():
            if child.tag == 'target':
                if child.get('dev') == device:
                    return etree.tostring(node)
that  can be handled by xpath like:

node = doc.find("./devices/disk/target[@dev='%s'].." % device)
if node is not None:
    return etree.tostring(node)

More complicated code convert  xml to  config instance. then search manully, like: 
from https://github.com/openstack/nova/blob/master/nova/virt/libvirt/driver.py#L2924
to https://github.com/openstack/nova/blob/master/nova/virt/libvirt/driver.py#L2932

This bug will track related issue.

** Affects: nova
     Importance: Undecided
     Assignee: ChangBo Guo(gcb) (glongwave)
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1407915

Title:
  libvirt: Leverage xpath  instead of  searching manully

Status in OpenStack Compute (Nova):
  New

Bug description:
  libvirt use xml format to create/describe  domain, add/delete devices.  There are some codes  hadle xml search by manul
  like:

  ret = doc.findall('./devices/disk')
      for node in ret:
          for child in node.getchildren():
              if child.tag == 'target':
                  if child.get('dev') == device:
                      return etree.tostring(node)
  that  can be handled by xpath like:

  node = doc.find("./devices/disk/target[@dev='%s'].." % device)
  if node is not None:
      return etree.tostring(node)

  More complicated code convert  xml to  config instance. then search manully, like: 
  from https://github.com/openstack/nova/blob/master/nova/virt/libvirt/driver.py#L2924
  to https://github.com/openstack/nova/blob/master/nova/virt/libvirt/driver.py#L2932

  This bug will track related issue.

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1407915/+subscriptions


Follow ups

References