[Pkg-libvirt-commits] [libguestfs] 28/59: v2v: Remove further uses of polymorphic variants.
Hilko Bengen
bengen at moszumanska.debian.org
Sun May 3 21:26:35 UTC 2015
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch experimental
in repository libguestfs.
commit 946d49cbbcfb47b5bb344ee24957e1c8e39f78e3
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Sat Apr 25 21:40:49 2015 +0100
v2v: Remove further uses of polymorphic variants.
See commit 3a080c3fbffa5846f71528c6fd978be7853b33b8.
---
v2v/OVF.ml | 38 +++++++++++++++++++-------------------
v2v/OVF.mli | 4 ++--
v2v/cmdline.ml | 10 +++++-----
v2v/output_rhev.ml | 4 ++--
v2v/output_rhev.mli | 2 +-
v2v/output_vdsm.ml | 4 ++--
v2v/output_vdsm.mli | 2 +-
v2v/types.ml | 4 ++++
v2v/types.mli | 6 ++++++
v2v/v2v.ml | 8 ++++----
10 files changed, 46 insertions(+), 36 deletions(-)
diff --git a/v2v/OVF.ml b/v2v/OVF.ml
index a1ce73b..43ef16b 100644
--- a/v2v/OVF.ml
+++ b/v2v/OVF.ml
@@ -47,53 +47,53 @@ let get_vmtype = function
| { i_type = "linux"; i_distro = "rhel"; i_major_version = major;
i_product_name = product }
when major >= 5 && string_find product "Server" >= 0 ->
- `Server
+ Server
| { i_type = "linux"; i_distro = "rhel"; i_major_version = major }
when major >= 5 ->
- `Desktop
+ Desktop
| { i_type = "linux"; i_distro = "rhel"; i_major_version = major;
i_product_name = product }
when major >= 3 && string_find product "ES" >= 0 ->
- `Server
+ Server
| { i_type = "linux"; i_distro = "rhel"; i_major_version = major;
i_product_name = product }
when major >= 3 && string_find product "AS" >= 0 ->
- `Server
+ Server
| { i_type = "linux"; i_distro = "rhel"; i_major_version = major }
when major >= 3 ->
- `Desktop
+ Desktop
- | { i_type = "linux"; i_distro = "fedora" } -> `Desktop
+ | { i_type = "linux"; i_distro = "fedora" } -> Desktop
| { i_type = "windows"; i_major_version = 5; i_minor_version = 1 } ->
- `Desktop (* Windows XP *)
+ Desktop (* Windows XP *)
| { i_type = "windows"; i_major_version = 5; i_minor_version = 2;
i_product_name = product } when string_find product "XP" >= 0 ->
- `Desktop (* Windows XP *)
+ Desktop (* Windows XP *)
| { i_type = "windows"; i_major_version = 5; i_minor_version = 2 } ->
- `Server (* Windows 2003 *)
+ Server (* Windows 2003 *)
| { i_type = "windows"; i_major_version = 6; i_minor_version = 0;
i_product_name = product } when string_find product "Server" >= 0 ->
- `Server (* Windows 2008 *)
+ Server (* Windows 2008 *)
| { i_type = "windows"; i_major_version = 6; i_minor_version = 0 } ->
- `Desktop (* Vista *)
+ Desktop (* Vista *)
| { i_type = "windows"; i_major_version = 6; i_minor_version = 1;
i_product_name = product } when string_find product "Server" >= 0 ->
- `Server (* Windows 2008R2 *)
+ Server (* Windows 2008R2 *)
| { i_type = "windows"; i_major_version = 6; i_minor_version = 1 } ->
- `Server (* Windows 7 *)
+ Server (* Windows 7 *)
- | _ -> `Server
+ | _ -> Server
(* Determine the ovf:OperatingSystemSection_Type from libguestfs
* inspection. See ovirt-engine sources, file:
@@ -173,8 +173,8 @@ let create_meta_files verbose output_alloc sd_uuid image_uuids targets =
(* Note: Upper case in the .meta, mixed case in the OVF. *)
let output_alloc_for_rhev =
match output_alloc with
- | `Sparse -> "SPARSE"
- | `Preallocated -> "PREALLOCATED" in
+ | Sparse -> "SPARSE"
+ | Preallocated -> "PREALLOCATED" in
List.map (
fun ({ target_overlay = ov } as t, image_uuid) ->
@@ -222,7 +222,7 @@ let rec create_ovf verbose source targets guestcaps inspect
match vmtype with
| Some vmtype -> vmtype
| None -> get_vmtype inspect in
- let vmtype = match vmtype with `Desktop -> "0" | `Server -> "1" in
+ let vmtype = match vmtype with Desktop -> "0" | Server -> "1" in
let ostype = get_ostype inspect in
let ovf : doc =
@@ -373,8 +373,8 @@ and add_disks targets guestcaps output_alloc sd_uuid image_uuids vol_uuids ovf =
(* Note: Upper case in the .meta, mixed case in the OVF. *)
let output_alloc_for_rhev =
match output_alloc with
- | `Sparse -> "Sparse"
- | `Preallocated -> "Preallocated" in
+ | Sparse -> "Sparse"
+ | Preallocated -> "Preallocated" in
(* Add disk to <References/> node. *)
let disk =
diff --git a/v2v/OVF.mli b/v2v/OVF.mli
index 2b2f18f..d894991 100644
--- a/v2v/OVF.mli
+++ b/v2v/OVF.mli
@@ -18,7 +18,7 @@
(** Functions for dealing with OVF files. *)
-val create_meta_files : bool -> [`Sparse|`Preallocated] -> string -> string list -> Types.target list -> string list
+val create_meta_files : bool -> Types.output_allocation -> string -> string list -> Types.target list -> string list
(** Create the .meta file associated with each target.
Note this does not write them, since output_rhev has to do a
@@ -26,5 +26,5 @@ val create_meta_files : bool -> [`Sparse|`Preallocated] -> string -> string list
file is returned (one per target), and they must be written to
[target_file ^ ".meta"]. *)
-val create_ovf : bool -> Types.source -> Types.target list -> Types.guestcaps -> Types.inspect -> [`Sparse|`Preallocated] -> [`Server|`Desktop] option -> string -> string list -> string list -> string -> DOM.doc
+val create_ovf : bool -> Types.source -> Types.target list -> Types.guestcaps -> Types.inspect -> Types.output_allocation -> Types.vmtype option -> string -> string list -> string list -> string -> DOM.doc
(** Create the OVF file. *)
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
index 58ecd62..6300b03 100644
--- a/v2v/cmdline.ml
+++ b/v2v/cmdline.ml
@@ -108,10 +108,10 @@ let parse_cmdline () =
error (f_"unknown -o option: %s") s
in
- let output_alloc = ref `Sparse in
+ let output_alloc = ref Sparse in
let set_output_alloc = function
- | "sparse" -> output_alloc := `Sparse
- | "preallocated" -> output_alloc := `Preallocated
+ | "sparse" -> output_alloc := Sparse
+ | "preallocated" -> output_alloc := Preallocated
| s ->
error (f_"unknown -oa option: %s") s
in
@@ -242,8 +242,8 @@ read the man page virt-v2v(1).
let trace = !trace in
let vmtype =
match !vmtype with
- | "server" -> Some `Server
- | "desktop" -> Some `Desktop
+ | "server" -> Some Server
+ | "desktop" -> Some Desktop
| "" -> None
| _ ->
error (f_"unknown --vmtype option, must be \"server\" or \"desktop\"") in
diff --git a/v2v/output_rhev.ml b/v2v/output_rhev.ml
index 0e0eb30..06a2f1b 100644
--- a/v2v/output_rhev.ml
+++ b/v2v/output_rhev.ml
@@ -119,8 +119,8 @@ object
sprintf "-o rhev -os %s%s" os
(match vmtype with
| None -> ""
- | Some `Server -> " --vmtype server"
- | Some `Desktop -> " --vmtype desktop")
+ | Some Server -> " --vmtype server"
+ | Some Desktop -> " --vmtype desktop")
(* RHEV doesn't support serial consoles. This causes the conversion
* step to remove it.
diff --git a/v2v/output_rhev.mli b/v2v/output_rhev.mli
index 48b8a4e..cb4b80e 100644
--- a/v2v/output_rhev.mli
+++ b/v2v/output_rhev.mli
@@ -21,7 +21,7 @@
val mount_and_check_storage_domain : bool -> string -> string -> (string * string)
(** This helper function is also used by the VDSM target. *)
-val output_rhev : bool -> string -> [`Server|`Desktop] option -> [`Sparse|`Preallocated] -> Types.output
+val output_rhev : bool -> string -> Types.vmtype option -> Types.output_allocation -> Types.output
(** [output_rhev verbose os vmtype output_alloc] creates and
returns a new {!Types.output} object specialized for writing
output to RHEV-M or oVirt Export Storage Domain. *)
diff --git a/v2v/output_vdsm.ml b/v2v/output_vdsm.ml
index a59ff7c..3869696 100644
--- a/v2v/output_vdsm.ml
+++ b/v2v/output_vdsm.ml
@@ -47,8 +47,8 @@ object
vdsm_params.ovf_output
(match vmtype with
| None -> ""
- | Some `Server -> " --vmtype server"
- | Some `Desktop -> " --vmtype desktop")
+ | Some Server -> " --vmtype server"
+ | Some Desktop -> " --vmtype desktop")
(* RHEV doesn't support serial consoles. This causes the conversion
* step to remove it.
diff --git a/v2v/output_vdsm.mli b/v2v/output_vdsm.mli
index 5e1cb54..161a108 100644
--- a/v2v/output_vdsm.mli
+++ b/v2v/output_vdsm.mli
@@ -26,7 +26,7 @@ type vdsm_params = {
}
(** Miscellaneous extra command line parameters used by VDSM. *)
-val output_vdsm : bool -> string -> vdsm_params -> [`Server|`Desktop] option -> [`Sparse|`Preallocated] -> Types.output
+val output_vdsm : bool -> string -> vdsm_params -> Types.vmtype option -> Types.output_allocation -> Types.output
(** [output_vdsm verbose os rhev_params output_alloc] creates and
returns a new {!Types.output} object specialized for writing
output to Data Domains directly under VDSM control. *)
diff --git a/v2v/types.ml b/v2v/types.ml
index fb8deaa..f896fc7 100644
--- a/v2v/types.ml
+++ b/v2v/types.ml
@@ -297,3 +297,7 @@ class virtual output verbose = object
method virtual create_metadata : source -> target list -> guestcaps -> inspect -> unit
method keep_serial_console = true
end
+
+type output_allocation = Sparse | Preallocated
+
+type vmtype = Desktop | Server
diff --git a/v2v/types.mli b/v2v/types.mli
index 5c5d7de..78959ed 100644
--- a/v2v/types.mli
+++ b/v2v/types.mli
@@ -206,3 +206,9 @@ class virtual output : bool -> object
(** Whether this output supports serial consoles (RHEV does not). *)
end
(** Encapsulates all [-o], etc output arguments as an object. *)
+
+type output_allocation = Sparse | Preallocated
+(** Type of [-oa] (output allocation) option. *)
+
+type vmtype = Desktop | Server
+(** Type of [--vmtype] option. *)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 1fc02bb..b4e6fb2 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -345,10 +345,10 @@ let rec main () =
(* What output preallocation mode should we use? *)
let preallocation =
match t.target_format, output_alloc with
- | "raw", `Sparse -> Some "sparse"
- | "raw", `Preallocated -> Some "full"
- | "qcow2", `Sparse -> Some "off" (* ? *)
- | "qcow2", `Preallocated -> Some "metadata"
+ | "raw", Sparse -> Some "sparse"
+ | "raw", Preallocated -> Some "full"
+ | "qcow2", Sparse -> Some "off" (* ? *)
+ | "qcow2", Preallocated -> Some "metadata"
| _ -> None (* ignore -oa flag for other formats *) in
let compat =
match t.target_format with "qcow2" -> Some "1.1" | _ -> None in
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list