mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0036-v2v-o-rhv-upload-check-for-ovirtsdk4-RHBZ-1601943.patch

d0ea73
From bb6b81861e72535f57bdc8e9a3457807f21ad28c Mon Sep 17 00:00:00 2001
d0ea73
From: Pino Toscano <ptoscano@redhat.com>
d0ea73
Date: Tue, 17 Jul 2018 17:12:38 +0200
d0ea73
Subject: [PATCH] v2v: -o rhv-upload: check for ovirtsdk4 (RHBZ#1601943)
d0ea73
d0ea73
Check earlier whether the ovirtsdk4 Python can be imported correctly,
d0ea73
to avoid errors later on during the migration.
d0ea73
---
d0ea73
 v2v/output_rhv_upload.ml | 8 ++++++++
d0ea73
 1 file changed, 8 insertions(+)
d0ea73
d0ea73
diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml
d0ea73
index 0152b8d5a..63fa2411a 100644
d0ea73
--- a/v2v/output_rhv_upload.ml
d0ea73
+++ b/v2v/output_rhv_upload.ml
d0ea73
@@ -126,6 +126,13 @@ class output_rhv_upload output_alloc output_conn
d0ea73
             python3
d0ea73
   in
d0ea73
 
d0ea73
+  (* Check that the 'ovirtsdk4' Python module is available. *)
d0ea73
+  let error_unless_ovirtsdk4_module_available () =
d0ea73
+    let res = run_command [ python3; "-c"; "import ovirtsdk4" ] in
d0ea73
+    if res <> 0 then
d0ea73
+      error (f_"the Python module ‘ovirtsdk4’ could not be loaded, is it installed?  See previous messages for problems.")
d0ea73
+  in
d0ea73
+
d0ea73
   (* Check that nbdkit is available and new enough. *)
d0ea73
   let error_unless_nbdkit_working () =
d0ea73
     if 0 <> Sys.command "nbdkit --version >/dev/null" then
d0ea73
@@ -231,6 +238,7 @@ object
d0ea73
 
d0ea73
   method precheck () =
d0ea73
     error_unless_python_binary_on_path ();
d0ea73
+    error_unless_ovirtsdk4_module_available ();
d0ea73
     error_unless_nbdkit_working ();
d0ea73
     error_unless_nbdkit_python3_working ();
d0ea73
     error_unless_output_alloc_sparse ();
d0ea73
-- 
d0ea73
2.20.1
d0ea73