v2v: -o rhv-upload: change precheck script to return a JSON

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.
This commit is contained in:
Pino Toscano
2019-09-12 14:17:36 +02:00
parent 6499fdc199
commit cc6e2a7f9e
2 changed files with 12 additions and 2 deletions

View File

@@ -230,8 +230,14 @@ 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 ()

View File

@@ -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)