Blame SOURCES/0004-v2v-vdsm-add-vdsm-fixed-ovf-option.patch

df3bb2
From 14cfe80643a7df4ddf412aebdf39543344c1cf6e Mon Sep 17 00:00:00 2001
df3bb2
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= <tgolembi@redhat.com>
df3bb2
Date: Thu, 22 Feb 2018 11:41:08 +0100
df3bb2
Subject: [PATCH] v2v: vdsm: add --vdsm-fixed-ovf option
df3bb2
MIME-Version: 1.0
df3bb2
Content-Type: text/plain; charset=UTF-8
df3bb2
Content-Transfer-Encoding: 8bit
df3bb2
df3bb2
Add option for -o vdsm that enables output of the modified OVF. oVirt
df3bb2
engine should already be able to consume the OVF, but let's not take any
df3bb2
chances and enable it only by command line argument. It can be made
df3bb2
default later when it receives proper testing.
df3bb2
df3bb2
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
df3bb2
(cherry picked from commit 285014b290507865fd2020e44ea453af0262b624)
df3bb2
---
df3bb2
 v2v/cmdline.ml                 | 10 ++++++++++
df3bb2
 v2v/create_ovf.ml              |  7 +++++++
df3bb2
 v2v/create_ovf.mli             |  9 +++++++++
df3bb2
 v2v/output_vdsm.ml             |  9 +++++++--
df3bb2
 v2v/output_vdsm.mli            |  1 +
df3bb2
 v2v/test-v2v-o-vdsm-options.sh |  3 ++-
df3bb2
 v2v/virt-v2v.pod               | 20 ++++++++++++++++++++
df3bb2
 7 files changed, 56 insertions(+), 3 deletions(-)
df3bb2
df3bb2
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
df3bb2
index d88d0a579..75909ee77 100644
df3bb2
--- a/v2v/cmdline.ml
df3bb2
+++ b/v2v/cmdline.ml
df3bb2
@@ -79,6 +79,11 @@ let parse_cmdline () =
df3bb2
   let vdsm_compat = ref "0.10" in
df3bb2
   let set_vdsm_compat s = vdsm_compat := s in
df3bb2
 
df3bb2
+  let vdsm_ovf_flavour = ref Create_ovf.RHVExportStorageDomain in
df3bb2
+  let ovf_flavours_str = String.concat "|" Create_ovf.ovf_flavours in
df3bb2
+  let set_vdsm_ovf_flavour arg =
df3bb2
+    vdsm_ovf_flavour := Create_ovf.ovf_flavour_of_string arg in
df3bb2
+
df3bb2
   let set_string_option_once optname optref arg =
df3bb2
     match !optref with
df3bb2
     | Some _ ->
df3bb2
@@ -251,6 +256,8 @@ let parse_cmdline () =
df3bb2
                                     s_"Output VM UUID";
df3bb2
     [ L"vdsm-ovf-output" ], Getopt.String ("-", set_string_option_once "--vdsm-ovf-output" vdsm_ovf_output),
df3bb2
                                     s_"Output OVF file";
df3bb2
+    [ L"vdsm-ovf-flavour" ], Getopt.Symbol (ovf_flavours_str, Create_ovf.ovf_flavours, set_vdsm_ovf_flavour),
df3bb2
+                                    s_"Set the type of generated OVF (default rhvexp)";
df3bb2
     [ L"vmtype" ],   Getopt.String ("-", vmtype_warning),
df3bb2
                                     s_"Ignored for backwards compatibility";
df3bb2
   ] in
df3bb2
@@ -327,6 +334,7 @@ read the man page virt-v2v(1).
df3bb2
   let vdsm_vol_uuids = List.rev !vdsm_vol_uuids in
df3bb2
   let vdsm_vm_uuid = !vdsm_vm_uuid in
df3bb2
   let vdsm_ovf_output = Option.default "." !vdsm_ovf_output in
df3bb2
+  let vdsm_ovf_flavour = !vdsm_ovf_flavour in
df3bb2
 
df3bb2
   (* No arguments and machine-readable mode?  Print out some facts
df3bb2
    * about what this binary supports.
df3bb2
@@ -343,6 +351,7 @@ read the man page virt-v2v(1).
df3bb2
     List.iter (printf "input:%s\n") (Modules_list.input_modules ());
df3bb2
     List.iter (printf "output:%s\n") (Modules_list.output_modules ());
df3bb2
     List.iter (printf "convert:%s\n") (Modules_list.convert_modules ());
df3bb2
+    List.iter (printf "ovf:%s\n") Create_ovf.ovf_flavours;
df3bb2
     exit 0
df3bb2
   );
df3bb2
 
df3bb2
@@ -542,6 +551,7 @@ read the man page virt-v2v(1).
df3bb2
         vm_uuid = vdsm_vm_uuid;
df3bb2
         ovf_output = vdsm_ovf_output;
df3bb2
         compat = vdsm_compat;
df3bb2
+        ovf_flavour = vdsm_ovf_flavour;
df3bb2
       } in
df3bb2
       Output_vdsm.output_vdsm os vdsm_options output_alloc,
df3bb2
       output_format, output_alloc in
df3bb2
diff --git a/v2v/create_ovf.ml b/v2v/create_ovf.ml
df3bb2
index 0ec0a088c..d0735afce 100644
df3bb2
--- a/v2v/create_ovf.ml
df3bb2
+++ b/v2v/create_ovf.ml
df3bb2
@@ -33,6 +33,13 @@ type ovf_flavour =
df3bb2
   | OVirt
df3bb2
   | RHVExportStorageDomain
df3bb2
 
df3bb2
+let ovf_flavours = ["ovirt"; "rhvexp"]
df3bb2
+
df3bb2
+let ovf_flavour_of_string = function
df3bb2
+  | "ovirt" -> OVirt
df3bb2
+  | "rhvexp" -> RHVExportStorageDomain
df3bb2
+  | flav -> invalid_arg flav
df3bb2
+
df3bb2
 (* We set the creation time to be the same for all dates in
df3bb2
  * all metadata files.  All dates in OVF are UTC.
df3bb2
  *)
df3bb2
diff --git a/v2v/create_ovf.mli b/v2v/create_ovf.mli
df3bb2
index 8a8c7dd12..2d80660e3 100644
df3bb2
--- a/v2v/create_ovf.mli
df3bb2
+++ b/v2v/create_ovf.mli
df3bb2
@@ -20,6 +20,15 @@ type ovf_flavour =
df3bb2
   | OVirt
df3bb2
   | RHVExportStorageDomain
df3bb2
 
df3bb2
+(** The string representation of available OVF flavours. *)
df3bb2
+val ovf_flavours : string list
df3bb2
+
df3bb2
+(** Convert from a string to the corresponding OVF flavour.
df3bb2
+
df3bb2
+    Throw [Invalid_argument] if the string does not match any
df3bb2
+    valid flavour. *)
df3bb2
+val ovf_flavour_of_string : string -> ovf_flavour
df3bb2
+
df3bb2
 (** Create OVF and related files for RHV.
df3bb2
 
df3bb2
     The format for RHV export storage domain is described in:
df3bb2
diff --git a/v2v/output_vdsm.ml b/v2v/output_vdsm.ml
df3bb2
index ce286d327..b76a2e930 100644
df3bb2
--- a/v2v/output_vdsm.ml
df3bb2
+++ b/v2v/output_vdsm.ml
df3bb2
@@ -32,6 +32,7 @@ type vdsm_options = {
df3bb2
   vm_uuid : string;
df3bb2
   ovf_output : string;
df3bb2
   compat : string;
df3bb2
+  ovf_flavour : Create_ovf.ovf_flavour;
df3bb2
 }
df3bb2
 
df3bb2
 class output_vdsm os vdsm_options output_alloc =
df3bb2
@@ -39,7 +40,7 @@ object
df3bb2
   inherit output
df3bb2
 
df3bb2
   method as_options =
df3bb2
-    sprintf "-o vdsm -os %s%s%s --vdsm-vm-uuid %s --vdsm-ovf-output %s%s" os
df3bb2
+    sprintf "-o vdsm -os %s%s%s --vdsm-vm-uuid %s --vdsm-ovf-output %s%s%s" os
df3bb2
       (String.concat ""
df3bb2
          (List.map (sprintf " --vdsm-image-uuid %s") vdsm_options.image_uuids))
df3bb2
       (String.concat ""
df3bb2
@@ -49,6 +50,10 @@ object
df3bb2
       (match vdsm_options.compat with
df3bb2
        | "0.10" -> "" (* currently this is the default, so don't print it *)
df3bb2
        | s -> sprintf " --vdsm-compat=%s" s)
df3bb2
+      (match vdsm_options.ovf_flavour with
df3bb2
+       | Create_ovf.OVirt -> "--vdsm-ovf-flavour=ovf"
df3bb2
+       (* currently this is the default, so don't print it *)
df3bb2
+       | Create_ovf.RHVExportStorageDomain -> "")
df3bb2
 
df3bb2
   method supported_firmware = [ TargetBIOS ]
df3bb2
 
df3bb2
@@ -176,7 +181,7 @@ object
df3bb2
       vdsm_options.image_uuids
df3bb2
       vdsm_options.vol_uuids
df3bb2
       vdsm_options.vm_uuid
df3bb2
-      Create_ovf.RHVExportStorageDomain in
df3bb2
+      vdsm_options.ovf_flavour in
df3bb2
 
df3bb2
     (* Write it to the metadata file. *)
df3bb2
     let file = vdsm_options.ovf_output // vdsm_options.vm_uuid ^ ".ovf" in
df3bb2
diff --git a/v2v/output_vdsm.mli b/v2v/output_vdsm.mli
df3bb2
index 401a71ec4..6ed684638 100644
df3bb2
--- a/v2v/output_vdsm.mli
df3bb2
+++ b/v2v/output_vdsm.mli
df3bb2
@@ -24,6 +24,7 @@ type vdsm_options = {
df3bb2
   vm_uuid : string;                   (* --vdsm-vm-uuid *)
df3bb2
   ovf_output : string;                (* --vdsm-ovf-output *)
df3bb2
   compat : string;                    (* --vdsm-compat=0.10|1.1 *)
df3bb2
+  ovf_flavour : Create_ovf.ovf_flavour;
df3bb2
 }
df3bb2
 (** Miscellaneous extra command line parameters used by VDSM. *)
df3bb2
 
df3bb2
diff --git a/v2v/test-v2v-o-vdsm-options.sh b/v2v/test-v2v-o-vdsm-options.sh
df3bb2
index 753efc4e7..4ad5d4aad 100755
df3bb2
--- a/v2v/test-v2v-o-vdsm-options.sh
df3bb2
+++ b/v2v/test-v2v-o-vdsm-options.sh
df3bb2
@@ -55,7 +55,8 @@ $VG virt-v2v --debug-gc \
df3bb2
     --vdsm-vol-uuid VOL \
df3bb2
     --vdsm-vm-uuid VM \
df3bb2
     --vdsm-ovf-output $d/12345678-1234-1234-1234-123456789abc/master/vms/VM \
df3bb2
-    --vdsm-compat=1.1
df3bb2
+    --vdsm-compat=1.1 \
df3bb2
+    --vdsm-ovf-flavour=ovirt
df3bb2
 
df3bb2
 # Test the OVF metadata was created.
df3bb2
 test -f $d/12345678-1234-1234-1234-123456789abc/master/vms/VM/VM.ovf
df3bb2
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
df3bb2
index cced114f3..0ea5fa97f 100644
df3bb2
--- a/v2v/virt-v2v.pod
df3bb2
+++ b/v2v/virt-v2v.pod
df3bb2
@@ -759,6 +759,26 @@ hex digit can be C<0-9> or C<a-f>), conforming to S<OSF DCE 1.1>.
df3bb2
 
df3bb2
 These options can only be used with I<-o vdsm>.
df3bb2
 
df3bb2
+=item B<--vdsm-ovf-flavour> flavour
df3bb2
+
df3bb2
+This option controls the format of the OVF generated at the end of conversion.
df3bb2
+Currently there are two possible flavours:
df3bb2
+
df3bb2
+=over 4
df3bb2
+
df3bb2
+=item rhevexp
df3bb2
+
df3bb2
+The OVF format used in RHV export storage domain.
df3bb2
+
df3bb2
+=item ovirt
df3bb2
+
df3bb2
+The OVF format understood by oVirt REST API.
df3bb2
+
df3bb2
+=back
df3bb2
+
df3bb2
+For backward compatibility the default is I<rhevexp>, but this may change in
df3bb2
+the future.
df3bb2
+
df3bb2
 =item B<-v>
df3bb2
 
df3bb2
 =item B<--verbose>
df3bb2
-- 
df3bb2
2.21.0
df3bb2