[Libguestfs] [PATCH] v2v: -o rhv-upload: check for ovirtsdk4 (RHBZ#1601943)

Pino Toscano ptoscano at redhat.com
Tue Jul 17 15:14:44 UTC 2018


Check earlier whether the ovirtsdk4 Python can be imported correctly,
to avoid errors later on during the migration.
---
 v2v/output_rhv_upload.ml | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml
index 0152b8d5a..63fa2411a 100644
--- a/v2v/output_rhv_upload.ml
+++ b/v2v/output_rhv_upload.ml
@@ -126,6 +126,13 @@ class output_rhv_upload output_alloc output_conn
             python3
   in
 
+  (* Check that the 'ovirtsdk4' Python module is available. *)
+  let error_unless_ovirtsdk4_module_available () =
+    let res = run_command [ python3; "-c"; "import ovirtsdk4" ] in
+    if res <> 0 then
+      error (f_"the Python module ‘ovirtsdk4’ could not be loaded, is it installed?  See previous messages for problems.")
+  in
+
   (* Check that nbdkit is available and new enough. *)
   let error_unless_nbdkit_working () =
     if 0 <> Sys.command "nbdkit --version >/dev/null" then
@@ -231,6 +238,7 @@ object
 
   method precheck () =
     error_unless_python_binary_on_path ();
+    error_unless_ovirtsdk4_module_available ();
     error_unless_nbdkit_working ();
     error_unless_nbdkit_python3_working ();
     error_unless_output_alloc_sparse ();
-- 
2.17.1




More information about the Libguestfs mailing list