diff options
author | Mike Durnosvistov <mdurnosvistov@mirantis.com> | 2015-01-06 19:44:16 +0200 |
---|---|---|
committer | Mike Durnosvistov <mdurnosvistov@mirantis.com> | 2015-02-04 14:45:20 +0200 |
commit | 309cc55173056ecbb6d1b31029a6714546439183 (patch) | |
tree | 9679c217af8d0a92e27090e7050c34dccc281c6f | |
parent | 4582c25b385930b10bd73294a2eeadfaae2f8e82 (diff) | |
download | nova-309cc55173056ecbb6d1b31029a6714546439183.tar.gz |
libvirt: Use XPath instead of loop in _get_all_block_devices
etree supports XPath to find specific node, so we don't need
find the node with comparing its tag and attribute. This commit
uses Xpath in method _get_all_block_devices.
Partial-Bug: #1407915
Change-Id: I554392873ae61f0007a8d13d906852fb2582eb47
-rw-r--r-- | nova/virt/libvirt/driver.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index be6af83c26..2b2b7715c3 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -4301,13 +4301,9 @@ class LibvirtDriver(driver.ComputeDriver): continue except Exception: continue - ret = doc.findall('./devices/disk') - for node in ret: - if node.get('type') != 'block': - continue - for child in node.getchildren(): - if child.tag == 'source': - devices.append(child.get('dev')) + sources = doc.findall("./devices/disk[@type='block']/source") + for source in sources: + devices.append(source.get('dev')) return devices def _get_interfaces(self, xml): |