|
|
10436e |
From 9d7503382f33a7721378ec586ea718c63a0ec3b6 Mon Sep 17 00:00:00 2001
|
|
|
10436e |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
10436e |
Date: Thu, 19 Sep 2019 12:19:09 +0200
|
|
|
10436e |
Subject: [PATCH] v2v: -o rhv-upload: add -oo rhv-disk-uuid option
|
|
|
10436e |
|
|
|
10436e |
This way it is possible to override the UUIDs of the uploaded disks,
|
|
|
10436e |
instead of letting RHV generate them.
|
|
|
10436e |
|
|
|
10436e |
This can be useful to force certain UUIDs, and to specify the disks in
|
|
|
10436e |
--no-copy mode (which now can be used).
|
|
|
10436e |
|
|
|
10436e |
(cherry picked from commit 537ba8357e44ca3aa8878a2ac98e9476a570d3f4)
|
|
|
10436e |
---
|
|
|
10436e |
v2v/output_rhv_upload.ml | 43 ++++++++++++++++++++++++++++++++-----
|
|
|
10436e |
v2v/rhv-upload-plugin.py | 2 ++
|
|
|
10436e |
v2v/virt-v2v-output-rhv.pod | 24 +++++++++++++++++++++
|
|
|
10436e |
3 files changed, 64 insertions(+), 5 deletions(-)
|
|
|
10436e |
|
|
|
10436e |
diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml
|
|
|
10436e |
index 382ad0d93..206657a2b 100644
|
|
|
10436e |
--- a/v2v/output_rhv_upload.ml
|
|
|
10436e |
+++ b/v2v/output_rhv_upload.ml
|
|
|
10436e |
@@ -32,6 +32,7 @@ type rhv_options = {
|
|
|
10436e |
rhv_cluster : string option;
|
|
|
10436e |
rhv_direct : bool;
|
|
|
10436e |
rhv_verifypeer : bool;
|
|
|
10436e |
+ rhv_disk_uuids : string list option;
|
|
|
10436e |
}
|
|
|
10436e |
|
|
|
10436e |
let print_output_options () =
|
|
|
10436e |
@@ -41,6 +42,11 @@ let print_output_options () =
|
|
|
10436e |
-oo rhv-cluster=CLUSTERNAME Set RHV cluster name.
|
|
|
10436e |
-oo rhv-direct[=true|false] Use direct transfer mode (default: false).
|
|
|
10436e |
-oo rhv-verifypeer[=true|false] Verify server identity (default: false).
|
|
|
10436e |
+
|
|
|
10436e |
+You can override the UUIDs of the disks, instead of using autogenerated UUIDs
|
|
|
10436e |
+after their uploads (if you do, you must supply one for each disk):
|
|
|
10436e |
+
|
|
|
10436e |
+ -oo rhv-disk-uuid=UUID Disk UUID
|
|
|
10436e |
")
|
|
|
10436e |
|
|
|
10436e |
let parse_output_options options =
|
|
|
10436e |
@@ -48,6 +54,7 @@ let parse_output_options options =
|
|
|
10436e |
let rhv_cluster = ref None in
|
|
|
10436e |
let rhv_direct = ref false in
|
|
|
10436e |
let rhv_verifypeer = ref false in
|
|
|
10436e |
+ let rhv_disk_uuids = ref None in
|
|
|
10436e |
|
|
|
10436e |
List.iter (
|
|
|
10436e |
function
|
|
|
10436e |
@@ -63,6 +70,8 @@ let parse_output_options options =
|
|
|
10436e |
| "rhv-direct", v -> rhv_direct := bool_of_string v
|
|
|
10436e |
| "rhv-verifypeer", "" -> rhv_verifypeer := true
|
|
|
10436e |
| "rhv-verifypeer", v -> rhv_verifypeer := bool_of_string v
|
|
|
10436e |
+ | "rhv-disk-uuid", v ->
|
|
|
10436e |
+ rhv_disk_uuids := Some (v :: (Option.default [] !rhv_disk_uuids))
|
|
|
10436e |
| k, _ ->
|
|
|
10436e |
error (f_"-o rhv-upload: unknown output option ‘-oo %s’") k
|
|
|
10436e |
) options;
|
|
|
10436e |
@@ -75,8 +84,9 @@ let parse_output_options options =
|
|
|
10436e |
let rhv_cluster = !rhv_cluster in
|
|
|
10436e |
let rhv_direct = !rhv_direct in
|
|
|
10436e |
let rhv_verifypeer = !rhv_verifypeer in
|
|
|
10436e |
+ let rhv_disk_uuids = Option.map List.rev !rhv_disk_uuids in
|
|
|
10436e |
|
|
|
10436e |
- { rhv_cafile; rhv_cluster; rhv_direct; rhv_verifypeer }
|
|
|
10436e |
+ { rhv_cafile; rhv_cluster; rhv_direct; rhv_verifypeer; rhv_disk_uuids }
|
|
|
10436e |
|
|
|
10436e |
let nbdkit_python_plugin = Config.virt_v2v_nbdkit_python_plugin
|
|
|
10436e |
let pidfile_timeout = 30
|
|
|
10436e |
@@ -270,6 +280,16 @@ object
|
|
|
10436e |
method install_rhev_apt = true
|
|
|
10436e |
|
|
|
10436e |
method prepare_targets source overlays _ _ _ _ =
|
|
|
10436e |
+ let uuids =
|
|
|
10436e |
+ match rhv_options.rhv_disk_uuids with
|
|
|
10436e |
+ | None ->
|
|
|
10436e |
+ List.map (fun _ -> None) overlays
|
|
|
10436e |
+ | Some uuids ->
|
|
|
10436e |
+ if List.length uuids <> List.length overlays then
|
|
|
10436e |
+ error (f_"the number of ‘-oo rhv-disk-uuid’ parameters passed on the command line has to match the number of guest disk images (for this guest: %d)")
|
|
|
10436e |
+ (List.length overlays);
|
|
|
10436e |
+ List.map (fun uuid -> Some uuid) uuids in
|
|
|
10436e |
+
|
|
|
10436e |
let output_name = source.s_name in
|
|
|
10436e |
let json_params =
|
|
|
10436e |
("output_name", JSON.String output_name) :: json_params in
|
|
|
10436e |
@@ -284,7 +304,7 @@ object
|
|
|
10436e |
* target URI to point to the NBD socket.
|
|
|
10436e |
*)
|
|
|
10436e |
List.map (
|
|
|
10436e |
- fun (target_format, ov) ->
|
|
|
10436e |
+ fun ((target_format, ov), uuid) ->
|
|
|
10436e |
let id = ov.ov_source.s_disk_id in
|
|
|
10436e |
let disk_name = sprintf "%s-%03d" output_name id in
|
|
|
10436e |
let json_params =
|
|
|
10436e |
@@ -310,6 +330,12 @@ object
|
|
|
10436e |
let json_params =
|
|
|
10436e |
("diskid_file", JSON.String diskid_file) :: json_params in
|
|
|
10436e |
|
|
|
10436e |
+ let json_params =
|
|
|
10436e |
+ match uuid with
|
|
|
10436e |
+ | None -> json_params
|
|
|
10436e |
+ | Some uuid ->
|
|
|
10436e |
+ ("rhv_disk_uuid", JSON.String uuid) :: json_params in
|
|
|
10436e |
+
|
|
|
10436e |
(* Write the JSON parameters to a file. *)
|
|
|
10436e |
let json_param_file = tmpdir // sprintf "params%d.json" id in
|
|
|
10436e |
with_open_out
|
|
|
10436e |
@@ -379,7 +405,7 @@ If the messages above are not sufficient to diagnose the problem then add the
|
|
|
10436e |
"file.export", JSON.String "/";
|
|
|
10436e |
] in
|
|
|
10436e |
TargetURI ("json:" ^ JSON.string_of_doc json_params)
|
|
|
10436e |
- ) overlays
|
|
|
10436e |
+ ) (List.combine overlays uuids)
|
|
|
10436e |
|
|
|
10436e |
method disk_copied t i nr_disks =
|
|
|
10436e |
(* Get the UUID of the disk image. This file is written
|
|
|
10436e |
@@ -395,7 +421,14 @@ If the messages above are not sufficient to diagnose the problem then add the
|
|
|
10436e |
disks_uuids <- disks_uuids @ [diskid];
|
|
|
10436e |
|
|
|
10436e |
method create_metadata source targets _ guestcaps inspect target_firmware =
|
|
|
10436e |
- assert (List.length disks_uuids = List.length targets);
|
|
|
10436e |
+ let image_uuids =
|
|
|
10436e |
+ match rhv_options.rhv_disk_uuids, disks_uuids with
|
|
|
10436e |
+ | None, [] ->
|
|
|
10436e |
+ error (f_"there must be ‘-oo rhv-disk-uuid’ parameters passed on the command line to specify the UUIDs of guest disk images (for this guest: %d)")
|
|
|
10436e |
+ (List.length targets)
|
|
|
10436e |
+ | Some uuids, _ -> uuids
|
|
|
10436e |
+ | None, uuids -> uuids in
|
|
|
10436e |
+ assert (List.length image_uuids = List.length targets);
|
|
|
10436e |
|
|
|
10436e |
(* The storage domain UUID. *)
|
|
|
10436e |
let sd_uuid =
|
|
|
10436e |
@@ -411,7 +444,7 @@ If the messages above are not sufficient to diagnose the problem then add the
|
|
|
10436e |
let ovf =
|
|
|
10436e |
Create_ovf.create_ovf source targets guestcaps inspect
|
|
|
10436e |
target_firmware output_alloc
|
|
|
10436e |
- sd_uuid disks_uuids vol_uuids vm_uuid
|
|
|
10436e |
+ sd_uuid image_uuids vol_uuids vm_uuid
|
|
|
10436e |
OVirt in
|
|
|
10436e |
let ovf = DOM.doc_to_string ovf in
|
|
|
10436e |
|
|
|
10436e |
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
|
|
|
10436e |
index 4d61a089b..6ec74a5d4 100644
|
|
|
10436e |
--- a/v2v/rhv-upload-plugin.py
|
|
|
10436e |
+++ b/v2v/rhv-upload-plugin.py
|
|
|
10436e |
@@ -135,6 +135,8 @@ def open(readonly):
|
|
|
10436e |
disk_format = types.DiskFormat.COW
|
|
|
10436e |
disk = disks_service.add(
|
|
|
10436e |
disk = types.Disk(
|
|
|
10436e |
+ # The ID is optional.
|
|
|
10436e |
+ id = params.get('rhv_disk_uuid'),
|
|
|
10436e |
name = params['disk_name'],
|
|
|
10436e |
description = "Uploaded by virt-v2v",
|
|
|
10436e |
format = disk_format,
|
|
|
10436e |
diff --git a/v2v/virt-v2v-output-rhv.pod b/v2v/virt-v2v-output-rhv.pod
|
|
|
10436e |
index 651f61dae..e840ca78d 100644
|
|
|
10436e |
--- a/v2v/virt-v2v-output-rhv.pod
|
|
|
10436e |
+++ b/v2v/virt-v2v-output-rhv.pod
|
|
|
10436e |
@@ -9,6 +9,7 @@ virt-v2v-output-rhv - Using virt-v2v to convert guests to oVirt or RHV
|
|
|
10436e |
[-oo rhv-cafile=FILE]
|
|
|
10436e |
[-oo rhv-cluster=CLUSTER]
|
|
|
10436e |
[-oo rhv-direct]
|
|
|
10436e |
+ [-oo rhv-disk-uuid=UUID ...]
|
|
|
10436e |
[-oo rhv-verifypeer]
|
|
|
10436e |
|
|
|
10436e |
virt-v2v [-i* options] -o rhv -os [esd:/path|/path]
|
|
|
10436e |
@@ -104,6 +105,29 @@ F</etc/pki/ovirt-engine/ca.pem> on the oVirt engine.
|
|
|
10436e |
|
|
|
10436e |
Set the RHV Cluster Name. If not given it uses C<Default>.
|
|
|
10436e |
|
|
|
10436e |
+=item I<-oo rhv-disk-uuid=>C<UUID>
|
|
|
10436e |
+
|
|
|
10436e |
+This option can used to manually specify UUIDs for the disks when
|
|
|
10436e |
+creating the virtual machine. If not specified, the oVirt engine will
|
|
|
10436e |
+generate random UUIDs for the disks. Please note that:
|
|
|
10436e |
+
|
|
|
10436e |
+=over 4
|
|
|
10436e |
+
|
|
|
10436e |
+=item *
|
|
|
10436e |
+
|
|
|
10436e |
+you B<must> pass as many I<-oo rhv-disk-uuid=UUID> options as the
|
|
|
10436e |
+amount of disks in the guest
|
|
|
10436e |
+
|
|
|
10436e |
+=item *
|
|
|
10436e |
+
|
|
|
10436e |
+the specified UUIDs are used as they are, without checking whether
|
|
|
10436e |
+they are already used by other disks
|
|
|
10436e |
+
|
|
|
10436e |
+=back
|
|
|
10436e |
+
|
|
|
10436e |
+This option is considered advanced, and to be used mostly in
|
|
|
10436e |
+combination with I<--no-copy>.
|
|
|
10436e |
+
|
|
|
10436e |
=item I<-oo rhv-direct>
|
|
|
10436e |
|
|
|
10436e |
If this option is given then virt-v2v will attempt to directly upload
|
|
|
10436e |
--
|
|
|
10436e |
2.26.2
|
|
|
10436e |
|