Aravinda VK has uploaded a new change for review.
Change subject: gluster: Handling Attribute error in Python 2.6
......................................................................
gluster: Handling Attribute error in Python 2.6
xml.etree.cElementTree in Python 2.6 doesn't have the attribute
ParseError(Introduced in Python 2.7). VDSM gluster/cli.py tries
to capture etree.ParseError when gluster cli returns incompatible
xml output.
Change-Id: I63c33b34ce11473636365ea094e267c5424c7255
Signed-off-by: Aravinda VK <avishwan(a)redhat.com>
(cherry picked from commit 5759c876e414b433b1a42e50e1817d5841ec2ef2)
---
M vdsm/gluster/cli.py
1 file changed, 12 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/29/12829/1
diff --git a/vdsm/gluster/cli.py b/vdsm/gluster/cli.py
index 7136281..d4f65ab 100644
--- a/vdsm/gluster/cli.py
+++ b/vdsm/gluster/cli.py
@@ -31,6 +31,12 @@
)
+if hasattr(etree, 'ParseError'):
+ _etreeExceptions = (etree.ParseError, AttributeError, ValueError)
+else:
+ _etreeExceptions = (SyntaxError, AttributeError, ValueError)
+
+
def _getGlusterVolCmd():
return [_glusterCommandPath.cmd, "--mode=script", "volume"]
@@ -85,7 +91,7 @@
tree = etree.fromstring('\n'.join(out))
rv = int(tree.find('opRet').text)
msg = tree.find('opErrstr').text
- except (etree.ParseError, AttributeError, ValueError):
+ except _etreeExceptions:
raise ge.GlusterXmlErrorException(err=out)
if rv == 0:
return tree
@@ -303,7 +309,7 @@
return _parseVolumeStatusMem(xmltree)
else:
return _parseVolumeStatus(xmltree)
- except (etree.ParseError, AttributeError, ValueError):
+ except _etreeExceptions:
raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
@@ -427,7 +433,7 @@
raise ge.GlusterVolumesListFailedException(rc=e.rc, err=e.err)
try:
return _parseVolumeInfo(xmltree)
- except (etree.ParseError, AttributeError, ValueError):
+ except _etreeExceptions:
raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
@@ -448,7 +454,7 @@
raise ge.GlusterVolumeCreateFailedException(rc=e.rc, err=e.err)
try:
return {'uuid': xmltree.find('volCreate/volume/id').text}
- except (etree.ParseError, AttributeError, ValueError):
+ except _etreeExceptions:
raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
@@ -787,7 +793,7 @@
return _parsePeerStatus(xmltree,
_getLocalIpAddress() or _getGlusterHostName(),
_getGlusterUuid(), HostStatus.CONNECTED)
- except (etree.ParseError, AttributeError, ValueError):
+ except _etreeExceptions:
raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
@@ -878,5 +884,5 @@
raise ge.GlusterVolumeProfileInfoFailedException(rc=e.rc, err=e.err)
try:
return _parseVolumeProfileInfo(xmltree, nfs)
- except (etree.ParseError, AttributeError, ValueError):
+ except _etreeExceptions:
raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
--
To view, visit
http://gerrit.ovirt.org/12829
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I63c33b34ce11473636365ea094e267c5424c7255
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.2
Gerrit-Owner: Aravinda VK <avishwan(a)redhat.com>