mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

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

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