|
|
a30de4 |
From bdeb7926bea75bb62a5165eb94ee4084d678f7fe Mon Sep 17 00:00:00 2001
|
|
|
a30de4 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
a30de4 |
Date: Fri, 13 Oct 2017 17:14:07 +0100
|
|
|
a30de4 |
Subject: [PATCH] v2v: vCenter: Handle disks with snapshots (RHBZ#1172425).
|
|
|
a30de4 |
|
|
|
a30de4 |
This implements a missing feature from old virt-v2v, namely being able
|
|
|
a30de4 |
to cope with a guest with snapshots. Note this only converts the top
|
|
|
a30de4 |
(latest) snapshot. As in old virt-v2v it does NOT convert the whole
|
|
|
a30de4 |
chain of snapshots.
|
|
|
a30de4 |
|
|
|
a30de4 |
(cherry picked from commit c380920034612290eef4476ab4e731c492c68869)
|
|
|
a30de4 |
---
|
|
|
a30de4 |
v2v/vCenter.ml | 28 ++++++++++++++++++++++++----
|
|
|
a30de4 |
1 file changed, 24 insertions(+), 4 deletions(-)
|
|
|
a30de4 |
|
|
|
a30de4 |
diff --git a/v2v/vCenter.ml b/v2v/vCenter.ml
|
|
|
a30de4 |
index f53affb48..a1aaf7b7e 100644
|
|
|
a30de4 |
--- a/v2v/vCenter.ml
|
|
|
a30de4 |
+++ b/v2v/vCenter.ml
|
|
|
a30de4 |
@@ -46,6 +46,7 @@ type remote_resource = {
|
|
|
a30de4 |
}
|
|
|
a30de4 |
|
|
|
a30de4 |
let source_re = Str.regexp "^\\[\\(.*\\)\\] \\(.*\\)\\.vmdk$"
|
|
|
a30de4 |
+let snapshot_re = Str.regexp "^\\(.*\\)-[0-9][0-9][0-9][0-9][0-9][0-9]\\(\\.vmdk\\)$"
|
|
|
a30de4 |
|
|
|
a30de4 |
let rec map_source ?readahead ?password dcPath uri scheme server path =
|
|
|
a30de4 |
(* If no_verify=1 was passed in the libvirt URI, then we have to
|
|
|
a30de4 |
@@ -58,7 +59,28 @@ let rec map_source ?readahead ?password dcPath uri scheme server path =
|
|
|
a30de4 |
(* XXX only works if the query string is not URI-quoted *)
|
|
|
a30de4 |
String.find query "no_verify=1" = -1 in
|
|
|
a30de4 |
|
|
|
a30de4 |
- let https_url = get_https_url dcPath uri server path in
|
|
|
a30de4 |
+ let https_url =
|
|
|
a30de4 |
+ let https_url = get_https_url dcPath uri server path in
|
|
|
a30de4 |
+ (* Check the URL exists. *)
|
|
|
a30de4 |
+ let status, _, _ =
|
|
|
a30de4 |
+ fetch_headers_from_url password scheme uri sslverify https_url in
|
|
|
a30de4 |
+ (* If a disk is actually a snapshot image it will have '-00000n'
|
|
|
a30de4 |
+ * appended to its name, e.g.:
|
|
|
a30de4 |
+ * [yellow:storage1] RHEL4-X/RHEL4-X-000003.vmdk
|
|
|
a30de4 |
+ * The flat storage is still called RHEL4-X-flat, however. If we got
|
|
|
a30de4 |
+ * a 404 and the vmdk name looks like it might be a snapshot, try
|
|
|
a30de4 |
+ * again without the snapshot suffix.
|
|
|
a30de4 |
+ *)
|
|
|
a30de4 |
+ if status = "404" && Str.string_match snapshot_re path 0 then (
|
|
|
a30de4 |
+ let path = Str.matched_group 1 path ^ Str.matched_group 2 path in
|
|
|
a30de4 |
+ get_https_url dcPath uri server path
|
|
|
a30de4 |
+ )
|
|
|
a30de4 |
+ else
|
|
|
a30de4 |
+ (* Note that other non-200 status errors will be handled
|
|
|
a30de4 |
+ * in get_session_cookie below, so we don't have to worry
|
|
|
a30de4 |
+ * about them here.
|
|
|
a30de4 |
+ *)
|
|
|
a30de4 |
+ https_url in
|
|
|
a30de4 |
|
|
|
a30de4 |
let session_cookie =
|
|
|
a30de4 |
get_session_cookie password scheme uri sslverify https_url in
|
|
|
a30de4 |
@@ -115,9 +137,7 @@ and get_https_url dcPath uri server path =
|
|
|
a30de4 |
| n when n >= 1 -> ":" ^ string_of_int n
|
|
|
a30de4 |
| _ -> "" in
|
|
|
a30de4 |
|
|
|
a30de4 |
- (* XXX Old virt-v2v could also handle snapshots, ie:
|
|
|
a30de4 |
- * "[datastore1] Fedora 20/Fedora 20-NNNNNN.vmdk"
|
|
|
a30de4 |
- * XXX Need to handle templates. The file is called "-delta.vmdk" in
|
|
|
a30de4 |
+ (* XXX Need to handle templates. The file is called "-delta.vmdk" in
|
|
|
a30de4 |
* place of "-flat.vmdk".
|
|
|
a30de4 |
*)
|
|
|
a30de4 |
sprintf "https://%s%s/folder/%s-flat.vmdk?dcPath=%s&dsName=%s"
|
|
|
a30de4 |
--
|
|
|
a30de4 |
2.14.3
|
|
|
a30de4 |
|