Change in vdsm[master]: v2v: _read_ovf_from_tar_ova use tarfile package

shavivi at redhat.com shavivi at redhat.com
Tue Dec 8 14:06:50 UTC 2015


Shahar Havivi has uploaded a new change for review.

Change subject: v2v: _read_ovf_from_tar_ova use tarfile package
......................................................................

v2v: _read_ovf_from_tar_ova use tarfile package

using build-in package instead of execCmd.

Change-Id: I5e027470f0ab283b3260fc02aafc01fe3debc95f
Signed-off-by: Shahar Havivi <shaharh at redhat.com>
---
M vdsm/v2v.py
1 file changed, 7 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/06/50106/1

diff --git a/vdsm/v2v.py b/vdsm/v2v.py
index 23f1c7f..e93ddee 100644
--- a/vdsm/v2v.py
+++ b/vdsm/v2v.py
@@ -917,13 +917,13 @@
 
 
 def _read_ovf_from_tar_ova(ova_path):
-    # FIXME: change to tarfile package when support --to-stdout
-    cmd = ['/usr/bin/tar', 'xf', ova_path, '*.ovf', '--to-stdout']
-    rc, output, error = execCmd(cmd)
-    if rc:
-        raise V2VError(error)
-
-    return ''.join(output)
+    tar = tarfile.TarFile(ova_path)
+    for member in tar.getmembers():
+        if member.name.endswith('.ovf'):
+            ovf = tar.extractfile(member)
+            with closing(ovf):
+                return ovf.read()
+    raise ClientError('OVA does not contains file with .ovf suffix')
 
 
 def _add_general_ovf_info(vm, node, ns):


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5e027470f0ab283b3260fc02aafc01fe3debc95f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Shahar Havivi <shavivi at redhat.com>


More information about the vdsm-patches mailing list