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