Since we no longer need to return the extra data needed by
virt-v2v-copy-to-local, we can greatly simplify the interface to this
module.
---
v2v/input_libvirt_vcenter_https.ml | 6 ++--
v2v/vCenter.ml | 16 ++-------
v2v/vCenter.mli | 53 ++++++------------------------
3 files changed, 16 insertions(+), 59 deletions(-)
diff --git a/v2v/input_libvirt_vcenter_https.ml b/v2v/input_libvirt_vcenter_https.ml
index 2265f76ec..0886067b0 100644
--- a/v2v/input_libvirt_vcenter_https.ml
+++ b/v2v/input_libvirt_vcenter_https.ml
@@ -88,9 +88,9 @@ object (self)
| { p_source = P_source_dev _ } -> assert false
| { p_source_disk = disk; p_source = P_dont_rewrite } -> disk
| { p_source_disk = disk; p_source = P_source_file path } ->
- let { VCenter.qemu_uri } =
- VCenter.map_source ?bandwidth ?password_file:input_password
- dcPath parsed_uri server path in
+ let qemu_uri =
+ VCenter.qemu_uri_of_path ?bandwidth ?password_file:input_password
+ dcPath parsed_uri server path in
(* The libvirt ESX driver doesn't normally specify a format, but
* the format of the -flat file is *always* raw, so force it here.
diff --git a/v2v/vCenter.ml b/v2v/vCenter.ml
index 33120e881..b41422c1f 100644
--- a/v2v/vCenter.ml
+++ b/v2v/vCenter.ml
@@ -25,17 +25,10 @@ open Common_gettext.Gettext
open Xml
open Utils
-type remote_resource = {
- https_url : string;
- qemu_uri : string;
- session_cookie : string option;
- sslverify : bool;
-}
-
let source_re = PCRE.compile "^\\[(.*)\\] (.*)\\.vmdk$"
let snapshot_re = PCRE.compile "^(.*)-\\d{6}(\\.vmdk)$"
-let rec map_source ?bandwidth ?password_file dcPath uri server path =
+let rec qemu_uri_of_path ?bandwidth ?password_file dcPath uri server path =
(* If no_verify=1 was passed in the libvirt URI, then we have to
* turn off certificate verification here too.
*)
@@ -82,11 +75,8 @@ let rec map_source ?bandwidth ?password_file dcPath uri server path =
?user:uri.uri_user https_url in
let qemu_uri = Nbdkit_sources.run nbdkit in
- (* Return the struct. *)
- { https_url = https_url;
- qemu_uri = qemu_uri;
- session_cookie = session_cookie;
- sslverify = sslverify }
+ (* Return the QEMU URI. *)
+ qemu_uri
and get_https_url dcPath uri server path =
if not (PCRE.matches source_re path) then
diff --git a/v2v/vCenter.mli b/v2v/vCenter.mli
index d400d39b4..848def9dc 100644
--- a/v2v/vCenter.mli
+++ b/v2v/vCenter.mli
@@ -18,52 +18,19 @@
(** Functions for dealing with VMware vCenter. *)
-type remote_resource = {
- https_url : string;
- (** The full URL of the remote disk as an https link on the vCenter
- server. It will have the general form
- [
https://vcenter/folder/.../guest-flat.vmdk?dcPath=...&...] *)
-
- qemu_uri : string;
- (** The remote disk as a QEMU URI. This opaque blob (usually a
- [json:] URL) can be passed to [qemu] or [qemu-img] as a backing
- file. *)
-
- session_cookie : string option;
- (** When creating the URLs above, the module contacts the vCenter
- server, logs in, and gets the session cookie, which can later
- be passed back to the server instead of having to log in each
- time (this is also more efficient since it avoids vCenter
- running out of authentication sessions).
-
- This can be [None] if the session cookie could not be read (but
- authentication was successful). You can proceed without the
- session cookie in this case, but there is an unavoidable
- danger of running out of authentication sessions. If the
- session cookie could not be read, this function prints a
- warning.
-
- If authentication {i failed} then the {!map_source} function
- would exit with an error, so [None] does not indicate auth
- failure. *)
-
- sslverify : bool;
- (** This is true except when the libvirt URI had [?no_verify=1] in
- the parameters. *)
-}
-(** The "remote resource" is the structure returned by the {!map_source}
- function. *)
-
-val map_source : ?bandwidth:Types.bandwidth -> ?password_file:string ->
- string -> Xml.uri -> string -> string -> remote_resource
-(** [map_source ?password_file dcPath uri server path]
- maps the [<source path=...>] string to a {!remote_resource}
- structure containing both an [https://] URL and a qemu URI,
- both pointing the guest disk.
+val qemu_uri_of_path : ?bandwidth:Types.bandwidth -> ?password_file:string ->
+ string -> Xml.uri -> string -> string -> string
+(** [qemu_uri_of_path ?bandwidth ?password_file dcPath uri server path]
+ maps the [<source path=...>] string to a qemu URI pointing
+ to the guest disk.
The input [path] comes from libvirt and will be something like:
["[datastore1] Fedora 20/Fedora 20.vmdk"]
(including those literal spaces in the string).
This checks that the disk exists and that authentication is
- correct, otherwise it will fail. *)
+ correct, otherwise it will fail.
+
+ The returned QEMU URI is an opaque blob (usually a [json:] URL)
+ which can be passed to [qemu] or [qemu-img] as a backing
+ file. *)
--
2.27.0