Ala Hino has uploaded a new change for review. Change subject: qemuimg: Introduce InvalidOutput exception ......................................................................
qemuimg: Introduce InvalidOutput exception Raised when the command output is not valid. Change-Id: If3f801f05f130c2417e4946877e31030260269a1 Signed-off-by: Ala Hino <ah...@redhat.com> --- M lib/vdsm/qemuimg.py 1 file changed, 20 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/08/65208/1 diff --git a/lib/vdsm/qemuimg.py b/lib/vdsm/qemuimg.py index 28cddee..8f6dc35 100644 --- a/lib/vdsm/qemuimg.py +++ b/lib/vdsm/qemuimg.py @@ -65,6 +65,21 @@ self.cmd, self.ecode, self.stdout, self.stderr, self.message) +class InvalidOutput(QImgError): + """ + Raised when the command output is not valid. + """ + + def __init__(self, cmd, stdout, message): + self.cmd = cmd + self.stdout = stdout + self.message = message + + def __str__(self): + return "cmd=%s, stdout=%s, message=%s" % ( + self.cmd, self.stdout, self.message) + + def info(image, format=None): cmd = [_qemuimg.cmd, "info", "--output", "json"] @@ -79,7 +94,7 @@ try: qemu_info = _parse_qemuimg_json(out) except ValueError: - raise QImgError(cmd, rc, out, err, "Failed to process qemu-img output") + raise InvalidOutput(cmd, out, "Failed to process qemu-img output") try: info = { @@ -87,7 +102,7 @@ 'virtualsize': qemu_info['virtual-size'], } except KeyError as key: - raise QImgError(cmd, rc, out, err, "Missing field: %r" % key) + raise InvalidOutput(cmd, out, "Missing field: %r" % key) if 'cluster-size' in qemu_info: info['clustersize'] = qemu_info['cluster-size'] @@ -97,7 +112,7 @@ try: info['compat'] = qemu_info['format-specific']['data']['compat'] except KeyError: - raise QImgError(cmd, rc, out, err, "'compat' expected but not found") + raise InvalidOutput(cmd, out, "'compat' expected but not found") return info @@ -148,11 +163,11 @@ try: qemu_check = _parse_qemuimg_json(out) except ValueError: - raise QImgError(cmd, rc, out, err, "Failed to process qemu-img output") + raise InvalidOutput(cmd, out, "Failed to process qemu-img output") try: return {"offset": qemu_check["image-end-offset"]} except KeyError: - raise QImgError(cmd, rc, out, err, "unable to parse qemu-img check output") + raise InvalidOutput(cmd, out, "unable to parse qemu-img check output") def convert(srcImage, dstImage, srcFormat=None, dstFormat=None, -- To view, visit https://gerrit.ovirt.org/65208 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If3f801f05f130c2417e4946877e31030260269a1 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Ala Hino <ah...@redhat.com> _______________________________________________ vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org