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

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