|
|
da373f |
From bb04eba9683c4143f9b5880238f006af3b13c05c Mon Sep 17 00:00:00 2001
|
|
|
3efd08 |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
3efd08 |
Date: Thu, 12 Sep 2019 14:17:36 +0200
|
|
|
3efd08 |
Subject: [PATCH] v2v: -o rhv-upload: change precheck script to return a JSON
|
|
|
3efd08 |
|
|
|
3efd08 |
This way it is possible to communicate data from the precheck script
|
|
|
3efd08 |
back to virt-v2v.
|
|
|
3efd08 |
|
|
|
3efd08 |
For now there are no results, so the resulting JSON is discarded.
|
|
|
3efd08 |
|
|
|
3efd08 |
(cherry picked from commit cc6e2a7f9ea53258c2edb758e3ec9beb7baa1fc6)
|
|
|
3efd08 |
---
|
|
|
3efd08 |
v2v/output_rhv_upload.ml | 8 +++++++-
|
|
|
3efd08 |
v2v/rhv-upload-precheck.py | 6 +++++-
|
|
|
3efd08 |
2 files changed, 12 insertions(+), 2 deletions(-)
|
|
|
3efd08 |
|
|
|
3efd08 |
diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml
|
|
|
3efd08 |
index adcbdf25f..fd6f2e3e6 100644
|
|
|
3efd08 |
--- a/v2v/output_rhv_upload.ml
|
|
|
3efd08 |
+++ b/v2v/output_rhv_upload.ml
|
|
|
3efd08 |
@@ -234,8 +234,14 @@ object
|
|
|
3efd08 |
error_unless_nbdkit_python_plugin_working ();
|
|
|
3efd08 |
error_unless_output_alloc_sparse ();
|
|
|
3efd08 |
(* Python code prechecks. *)
|
|
|
3efd08 |
- if Python_script.run_command precheck_script json_params [] <> 0 then
|
|
|
3efd08 |
+ let precheck_fn = tmpdir // "v2vprecheck.json" in
|
|
|
3efd08 |
+ let fd = Unix.openfile precheck_fn [O_WRONLY; O_CREAT] 0o600 in
|
|
|
3efd08 |
+ if Python_script.run_command ~stdout_fd:fd
|
|
|
3efd08 |
+ precheck_script json_params [] <> 0 then
|
|
|
3efd08 |
error (f_"failed server prechecks, see earlier errors");
|
|
|
3efd08 |
+ let json = JSON_parser.json_parser_tree_parse_file precheck_fn in
|
|
|
3efd08 |
+ debug "precheck output parsed as: %s"
|
|
|
3efd08 |
+ (JSON.string_of_doc ~fmt:JSON.Indented ["", json]);
|
|
|
3efd08 |
if have_selinux then
|
|
|
3efd08 |
error_unless_nbdkit_compiled_with_selinux ()
|
|
|
3efd08 |
|
|
|
3efd08 |
diff --git a/v2v/rhv-upload-precheck.py b/v2v/rhv-upload-precheck.py
|
|
|
3efd08 |
index d6a58f0fc..de8a66c05 100644
|
|
|
3efd08 |
--- a/v2v/rhv-upload-precheck.py
|
|
|
3efd08 |
+++ b/v2v/rhv-upload-precheck.py
|
|
|
3efd08 |
@@ -70,4 +70,8 @@ if len(clusters) == 0:
|
|
|
3efd08 |
raise RuntimeError("The cluster ā%sā does not exist" %
|
|
|
3efd08 |
(params['rhv_cluster']))
|
|
|
3efd08 |
|
|
|
3efd08 |
-# Otherwise everything is OK, exit with no error.
|
|
|
3efd08 |
+# Otherwise everything is OK, print a JSON with the results.
|
|
|
3efd08 |
+results = {
|
|
|
3efd08 |
+}
|
|
|
3efd08 |
+
|
|
|
3efd08 |
+json.dump(results, sys.stdout)
|
|
|
3efd08 |
--
|
|
|
da373f |
2.18.4
|
|
|
3efd08 |
|