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