Change in vdsm[ovirt-3.5.6]: hotunplug: support python 2.6

danken at redhat.com danken at redhat.com
Mon Nov 23 14:35:44 UTC 2015


Hello Amit Aviram, Francesco Romani,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/49007

to review the following change.

Change subject: hotunplug: support python 2.6
......................................................................

hotunplug: support python 2.6

In commit d0d05b02ee, we introduced a libvirt quering method to find
out if a drive was attached to a VM.

However- The XPath expression used in this method is supported only in
ElementTree1.3: http://effbot.org/zone/element-xpath.htm, which was only
introduced in Python 2.7:
https://docs.python.org/2/library/xml.etree.elementtree.html

As VDSM needs to support Python2.6 on RHEL6, this patch changes the
method to work with ElementTreee x.y available in Python 2.6.

Change-Id: Ia89620ff3aab14dc09373c44c8567b74e2103a60
Bug-Url: https://bugzilla.redhat.com/1283287
Label: ovirt-3.5-only
Signed-off-by: Amit Aviram <aaviram at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/48916
Reviewed-by: Nir Soffer <nsoffer at redhat.com>
Reviewed-by: Francesco Romani <fromani at redhat.com>
Continuous-Integration: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/07/49007/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 72287fd..ba4940c 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4151,8 +4151,8 @@
     def _isDriveAttached(self, drive):
         root = ET.fromstring(self._dom.XMLDesc(0))
         source_key = 'dev' if drive.blockDev else 'file'
-        return bool(root.findall("./devices/disk/source[@%s='%s']" %
-                                 (source_key, drive.path)))
+        sources = root.findall("./devices/disk/source")
+        return bool([s for s in sources if s.get(source_key) == drive.path])
 
     def _readPauseCode(self, timeout):
         # libvirt does not not export yet the I/O error reason code.


-- 
To view, visit https://gerrit.ovirt.org/49007
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia89620ff3aab14dc09373c44c8567b74e2103a60
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5.6
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Amit Aviram <aaviram at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list