mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

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

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