This way it is possible to communicate data from the precheck script
back to virt-v2v.
For now there are no results, so the resulting JSON is discarded.
---
v2v/output_rhv_upload.ml | 7 ++++++-
v2v/rhv-upload-precheck.py | 6 +++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml
index 91552536a..e74a897b9 100644
--- a/v2v/output_rhv_upload.ml
+++ b/v2v/output_rhv_upload.ml
@@ -230,8 +230,13 @@ object
error_unless_nbdkit_python_plugin_working ();
error_unless_output_alloc_sparse ();
(* Python code prechecks. *)
- if Python_script.run_command precheck_script json_params [] <> 0 then
+ let precheck_fn = tmpdir // "v2vprecheck.json" in
+ let fd = Unix.openfile precheck_fn [O_WRONLY; O_CREAT] 0o600 in
+ if Python_script.run_command ~stdout_fd:fd precheck_script json_params [] <> 0
then
error (f_"failed server prechecks, see earlier errors");
+ let json = JSON_parser.json_parser_tree_parse_file precheck_fn in
+ debug "precheck output parsed as: %s"
+ (JSON.string_of_doc ~fmt:JSON.Indented ["", json]);
if have_selinux then
error_unless_nbdkit_compiled_with_selinux ()
diff --git a/v2v/rhv-upload-precheck.py b/v2v/rhv-upload-precheck.py
index 6253c26ac..a317d997c 100644
--- a/v2v/rhv-upload-precheck.py
+++ b/v2v/rhv-upload-precheck.py
@@ -70,4 +70,8 @@ if len(clusters) == 0:
raise RuntimeError("The cluster ā%sā does not exist" %
(params['rhv_cluster']))
-# Otherwise everything is OK, exit with no error.
+# Otherwise everything is OK, print a JSON with the results.
+results = {
+}
+
+json.dump(results, sys.stdout)
--
2.21.0