Blame SOURCES/0045-v2v-vddk-Print-passthrough-options.patch

151578
From e94aedc6fc64f255ab1fa2fcd31f78e86c28c5de Mon Sep 17 00:00:00 2001
151578
From: "Richard W.M. Jones" <rjones@redhat.com>
151578
Date: Mon, 16 Oct 2017 14:32:28 +0100
151578
Subject: [PATCH] v2v: vddk: Print passthrough options.
151578
151578
Changes the output to look like:
151578
151578
[   0.0] Opening the source -i libvirt -ic vpx://... guestname --vddk ... --vddk-thumbprint ...
151578
151578
(cherry picked from commit ce2aa47d1d79223c1a7a49b3f41e09078f22f554)
151578
---
151578
 v2v/input_libvirt_vddk.ml | 42 ++++++++++++++++++++++++++++++++----------
151578
 1 file changed, 32 insertions(+), 10 deletions(-)
151578
151578
diff --git a/v2v/input_libvirt_vddk.ml b/v2v/input_libvirt_vddk.ml
151578
index 89d2552f6..b322a9c49 100644
151578
--- a/v2v/input_libvirt_vddk.ml
151578
+++ b/v2v/input_libvirt_vddk.ml
151578
@@ -101,8 +101,34 @@ See also \"INPUT FROM VDDK\" in the virt-v2v(1) manual.") library_path
151578
       error (f_"You must pass the ‘--vddk-thumbprint’ option with the SSL thumbprint of the VMware server.  To find the thumbprint, see the nbdkit-vddk-plugin(1) manual.  See also \"INPUT FROM VDDK\" in the virt-v2v(1) manual.")
151578
   in
151578
 
151578
+  (* List of passthrough parameters. *)
151578
+  let vddk_passthrus =
151578
+    [ "config",      (fun { vddk_config }      -> vddk_config);
151578
+      "cookie",      (fun { vddk_cookie }      -> vddk_cookie);
151578
+      "nfchostport", (fun { vddk_nfchostport } -> vddk_nfchostport);
151578
+      "port",        (fun { vddk_port }        -> vddk_port);
151578
+      "snapshot",    (fun { vddk_snapshot }    -> vddk_snapshot);
151578
+      "thumbprint",  (fun { vddk_thumbprint }  -> vddk_thumbprint);
151578
+      "transports",  (fun { vddk_transports }  -> vddk_transports);
151578
+      "vimapiver",   (fun { vddk_vimapiver }   -> vddk_vimapiver) ] in
151578
+
151578
 object
151578
-  inherit input_libvirt password libvirt_uri guest
151578
+  inherit input_libvirt password libvirt_uri guest as super
151578
+
151578
+  method as_options =
151578
+    let pt_options =
151578
+      String.concat "" (
151578
+        List.map (
151578
+          fun (name, get_field) ->
151578
+            match get_field vddk_options with
151578
+            | None -> ""
151578
+            | Some field -> sprintf " --vddk-%s %s" name field
151578
+        ) vddk_passthrus
151578
+      ) in
151578
+    sprintf "%s --vddk %s%s"
151578
+            super#as_options (* superclass prints "-i libvirt etc" *)
151578
+            vddk_options.vddk_libdir
151578
+            pt_options
151578
 
151578
   method source () =
151578
     error_unless_vddk_libdir ();
151578
@@ -209,15 +235,11 @@ object
151578
       add_arg (sprintf "libdir=%s" libdir);
151578
 
151578
       (* The passthrough parameters. *)
151578
-      let pt name = may (fun field -> add_arg (sprintf "%s=%s" name field)) in
151578
-      pt "config" vddk_options.vddk_config;
151578
-      pt "cookie" vddk_options.vddk_cookie;
151578
-      pt "nfchostport" vddk_options.vddk_nfchostport;
151578
-      pt "port" vddk_options.vddk_port;
151578
-      pt "snapshot" vddk_options.vddk_snapshot;
151578
-      pt "thumbprint" vddk_options.vddk_thumbprint;
151578
-      pt "transports" vddk_options.vddk_transports;
151578
-      pt "vimapiver" vddk_options.vddk_vimapiver;
151578
+      List.iter (
151578
+        fun (name, get_field) ->
151578
+          may (fun field -> add_arg (sprintf "%s=%s" name field))
151578
+              (get_field vddk_options)
151578
+      ) vddk_passthrus;
151578
 
151578
       get_args () in
151578
 
151578
-- 
151578
2.14.3
151578