Blame SOURCES/0005-v2v-OVF-Code-formatting.patch

df3bb2
From 00ed208050cdb2178ac58878cb126504ebc7b311 Mon Sep 17 00:00:00 2001
df3bb2
From: "Richard W.M. Jones" <rjones@redhat.com>
df3bb2
Date: Thu, 22 Feb 2018 14:22:12 +0000
df3bb2
Subject: [PATCH] v2v: OVF: Code formatting.
df3bb2
df3bb2
Updates commit a52ed4b4454396eb13d2cdf5762292bff3104f66
df3bb2
("v2v: ovf: Create OVF more aligned with the standard") with some
df3bb2
small code refactoring and formatting.
df3bb2
df3bb2
(cherry picked from commit 9e83f3a2ccef4e91b0b3275b712df8b16e233cff)
df3bb2
---
df3bb2
 v2v/create_ovf.ml | 73 ++++++++++++++++++++++++++---------------------
df3bb2
 1 file changed, 41 insertions(+), 32 deletions(-)
df3bb2
df3bb2
diff --git a/v2v/create_ovf.ml b/v2v/create_ovf.ml
df3bb2
index d0735afce..0e07afea8 100644
df3bb2
--- a/v2v/create_ovf.ml
df3bb2
+++ b/v2v/create_ovf.ml
df3bb2
@@ -530,20 +530,16 @@ let rec create_ovf source targets guestcaps inspect
df3bb2
  * For example normal disk section is in node <DiskSection> whereas in case of
df3bb2
  * RHV export storage domain it is <Section xsi:type="ovf:DiskSection_Type">.
df3bb2
  *)
df3bb2
-and get_flavoured_section ovf ovf_flavour ovirt_path rhv_path rhv_path_attr =
df3bb2
-  let nodes =
df3bb2
-    match ovf_flavour with
df3bb2
-    | OVirt ->
df3bb2
-      let nodes = path_to_nodes ovf ovirt_path in
df3bb2
-      (match nodes with
df3bb2
+and get_flavoured_section ovf ovirt_path rhv_path rhv_path_attr = function
df3bb2
+  | OVirt ->
df3bb2
+     let nodes = path_to_nodes ovf ovirt_path in
df3bb2
+     (match nodes with
df3bb2
       | [node] -> node
df3bb2
       | [] | _::_::_ -> assert false)
df3bb2
-    | RHVExportStorageDomain ->
df3bb2
-      let nodes = path_to_nodes ovf rhv_path in
df3bb2
-      try find_node_by_attr nodes rhv_path_attr
df3bb2
-      with Not_found -> assert false
df3bb2
-  in
df3bb2
-  nodes
df3bb2
+  | RHVExportStorageDomain ->
df3bb2
+     let nodes = path_to_nodes ovf rhv_path in
df3bb2
+     try find_node_by_attr nodes rhv_path_attr
df3bb2
+     with Not_found -> assert false
df3bb2
 
df3bb2
 (* This modifies the OVF DOM, adding a section for each disk. *)
df3bb2
 and add_disks targets guestcaps output_alloc sd_uuid image_uuids vol_uuids
df3bb2
@@ -553,14 +549,19 @@ and add_disks targets guestcaps output_alloc sd_uuid image_uuids vol_uuids
df3bb2
     match nodes with
df3bb2
     | [] | _::_::_ -> assert false
df3bb2
     | [node] -> node in
df3bb2
-  let disk_section = get_flavoured_section ovf ovf_flavour
df3bb2
-    ["ovf:Envelope"; "DiskSection"]
df3bb2
-    ["ovf:Envelope"; "Section"]
df3bb2
-    ("xsi:type", "ovf:DiskSection_Type") in
df3bb2
-  let virtualhardware_section = get_flavoured_section ovf ovf_flavour
df3bb2
-    ["ovf:Envelope"; "VirtualSystem"; "VirtualHardwareSection"]
df3bb2
-    ["ovf:Envelope"; "Content"; "Section"]
df3bb2
-    ("xsi:type", "ovf:VirtualHardwareSection_Type") in
df3bb2
+  let disk_section =
df3bb2
+    get_flavoured_section ovf
df3bb2
+                          ["ovf:Envelope"; "DiskSection"]
df3bb2
+                          ["ovf:Envelope"; "Section"]
df3bb2
+                          ("xsi:type", "ovf:DiskSection_Type")
df3bb2
+                          ovf_flavour in
df3bb2
+  let virtualhardware_section =
df3bb2
+    get_flavoured_section ovf
df3bb2
+                          ["ovf:Envelope"; "VirtualSystem";
df3bb2
+                               "VirtualHardwareSection"]
df3bb2
+                          ["ovf:Envelope"; "Content"; "Section"]
df3bb2
+                          ("xsi:type", "ovf:VirtualHardwareSection_Type")
df3bb2
+                          ovf_flavour in
df3bb2
 
df3bb2
   (* Iterate over the disks, adding them to the OVF document. *)
df3bb2
   List.iteri (
df3bb2
@@ -693,14 +694,19 @@ and add_disks targets guestcaps output_alloc sd_uuid image_uuids vol_uuids
df3bb2
 
df3bb2
 (* This modifies the OVF DOM, adding a section for each NIC. *)
df3bb2
 and add_networks nics guestcaps ovf_flavour ovf =
df3bb2
-  let network_section = get_flavoured_section ovf ovf_flavour
df3bb2
-    ["ovf:Envelope"; "NetworkSection"]
df3bb2
-    ["ovf:Envelope"; "Section"]
df3bb2
-    ("xsi:type", "ovf:NetworkSection_Type") in
df3bb2
-  let virtualhardware_section = get_flavoured_section ovf ovf_flavour
df3bb2
-    ["ovf:Envelope"; "VirtualSystem"; "VirtualHardwareSection"]
df3bb2
-    ["ovf:Envelope"; "Content"; "Section"]
df3bb2
-    ("xsi:type", "ovf:VirtualHardwareSection_Type") in
df3bb2
+  let network_section =
df3bb2
+    get_flavoured_section ovf
df3bb2
+                          ["ovf:Envelope"; "NetworkSection"]
df3bb2
+                          ["ovf:Envelope"; "Section"]
df3bb2
+                          ("xsi:type", "ovf:NetworkSection_Type")
df3bb2
+                          ovf_flavour in
df3bb2
+  let virtualhardware_section =
df3bb2
+    get_flavoured_section ovf
df3bb2
+                          ["ovf:Envelope"; "VirtualSystem";
df3bb2
+                               "VirtualHardwareSection"]
df3bb2
+                          ["ovf:Envelope"; "Content"; "Section"]
df3bb2
+                          ("xsi:type", "ovf:VirtualHardwareSection_Type")
df3bb2
+                          ovf_flavour in
df3bb2
 
df3bb2
   (* Iterate over the NICs, adding them to the OVF document. *)
df3bb2
   List.iteri (
df3bb2
@@ -761,10 +767,13 @@ and add_sound_card sound ovf_flavour ovf =
df3bb2
 
df3bb2
   match device with
df3bb2
   | Some device ->
df3bb2
-     let virtualhardware_section = get_flavoured_section ovf ovf_flavour
df3bb2
-       ["ovf:Envelope"; "VirtualSystem"; "VirtualHardwareSection"]
df3bb2
-       ["ovf:Envelope"; "Content"; "Section"]
df3bb2
-       ("xsi:type", "ovf:VirtualHardwareSection_Type") in
df3bb2
+     let virtualhardware_section =
df3bb2
+       get_flavoured_section ovf
df3bb2
+                             ["ovf:Envelope"; "VirtualSystem";
df3bb2
+                                  "VirtualHardwareSection"]
df3bb2
+                             ["ovf:Envelope"; "Content"; "Section"]
df3bb2
+                             ("xsi:type", "ovf:VirtualHardwareSection_Type")
df3bb2
+                             ovf_flavour in
df3bb2
 
df3bb2
      let item =
df3bb2
        e "Item" [] [
df3bb2
-- 
df3bb2
2.21.0
df3bb2