|
|
e9bfca |
From b9b146315156b0debe6902cdcd93f0dbe49370f0 Mon Sep 17 00:00:00 2001
|
|
|
e9bfca |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
e9bfca |
Date: Wed, 4 Apr 2018 18:18:32 +0200
|
|
|
e9bfca |
Subject: [PATCH] v2v: OVF: write ovirt:id attribute for the OS in OVirt
|
|
|
e9bfca |
flavour
|
|
|
e9bfca |
|
|
|
e9bfca |
When writing the OVF in OVirt flavour, add a ovirt:id attribute to the
|
|
|
e9bfca |
OperatingSystemSection tag: this attribute represents the numeric value
|
|
|
e9bfca |
of the ostype ID, which is ignored by oVirt when parsing OVFs in API
|
|
|
e9bfca |
mode.
|
|
|
e9bfca |
|
|
|
e9bfca |
(cherry picked from commit 593a19cc86cfa8f24c66518c8ba21222550b066a)
|
|
|
e9bfca |
---
|
|
|
e9bfca |
v2v/create_ovf.ml | 202 +++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
e9bfca |
1 file changed, 201 insertions(+), 1 deletion(-)
|
|
|
e9bfca |
|
|
|
e9bfca |
diff --git a/v2v/create_ovf.ml b/v2v/create_ovf.ml
|
|
|
e9bfca |
index bf3741e0f..ccde960df 100644
|
|
|
e9bfca |
--- a/v2v/create_ovf.ml
|
|
|
e9bfca |
+++ b/v2v/create_ovf.ml
|
|
|
e9bfca |
@@ -242,6 +242,203 @@ and get_ostype = function
|
|
|
e9bfca |
typ distro major minor arch product;
|
|
|
e9bfca |
"Unassigned"
|
|
|
e9bfca |
|
|
|
e9bfca |
+(* Determine the ovirt:id attribute from libguestfs inspection.
|
|
|
e9bfca |
+ * See ovirt-engine sources, file:
|
|
|
e9bfca |
+ * packaging/conf/osinfo-defaults.properties
|
|
|
e9bfca |
+ * and also:
|
|
|
e9bfca |
+ * https://bugzilla.redhat.com/show_bug.cgi?id=1219857#c9
|
|
|
e9bfca |
+ *)
|
|
|
e9bfca |
+and get_ovirt_osid = function
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 3;
|
|
|
e9bfca |
+ i_arch = "i386" } ->
|
|
|
e9bfca |
+ 9
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 3;
|
|
|
e9bfca |
+ i_arch = "x86_64" } ->
|
|
|
e9bfca |
+ 15
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 4;
|
|
|
e9bfca |
+ i_arch = "i386" } ->
|
|
|
e9bfca |
+ 8
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 4;
|
|
|
e9bfca |
+ i_arch = "x86_64" } ->
|
|
|
e9bfca |
+ 14
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 5;
|
|
|
e9bfca |
+ i_arch = "i386" } ->
|
|
|
e9bfca |
+ 7
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 5;
|
|
|
e9bfca |
+ i_arch = "x86_64" } ->
|
|
|
e9bfca |
+ 13
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6;
|
|
|
e9bfca |
+ i_arch = "i386" } ->
|
|
|
e9bfca |
+ 18
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6;
|
|
|
e9bfca |
+ i_arch = "x86_64" } ->
|
|
|
e9bfca |
+ 19
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6;
|
|
|
e9bfca |
+ i_minor_version = min; i_arch = ("ppc64"|"ppc64le") } when min >= 9 ->
|
|
|
e9bfca |
+ 1007
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6;
|
|
|
e9bfca |
+ i_arch = ("ppc64"|"ppc64le") } ->
|
|
|
e9bfca |
+ 1003
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 7;
|
|
|
e9bfca |
+ i_arch = "x86_64" } ->
|
|
|
e9bfca |
+ 24
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 7;
|
|
|
e9bfca |
+ i_arch = ("ppc64"|"ppc64le") } ->
|
|
|
e9bfca |
+ 1006
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 7;
|
|
|
e9bfca |
+ i_arch = "s390x" } ->
|
|
|
e9bfca |
+ 2003
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = "sles"; i_major_version = maj;
|
|
|
e9bfca |
+ i_arch = "x86_64" } when maj >= 11 ->
|
|
|
e9bfca |
+ 1193
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = "sles"; i_major_version = maj;
|
|
|
e9bfca |
+ i_arch = ("ppc64"|"ppc64le") } when maj >= 11 ->
|
|
|
e9bfca |
+ 1004
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = "sles"; i_major_version = maj;
|
|
|
e9bfca |
+ i_arch = "s390x" } when maj >= 12 ->
|
|
|
e9bfca |
+ 2004
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ (* Only Debian 7 is available, so use it for any 7+ version. *)
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = "debian"; i_major_version = v }
|
|
|
e9bfca |
+ when v >= 7 ->
|
|
|
e9bfca |
+ 1300
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ (* Only Ubuntu 12.04 to 14.04 are available, so use them starting
|
|
|
e9bfca |
+ * from 12.04, and 14.04 for anything after it.
|
|
|
e9bfca |
+ *)
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v;
|
|
|
e9bfca |
+ i_arch = ("ppc64"|"ppc64le") } when v >= 14 ->
|
|
|
e9bfca |
+ 1005
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v;
|
|
|
e9bfca |
+ i_arch = "s390x" } when v >= 16 ->
|
|
|
e9bfca |
+ 2005
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v }
|
|
|
e9bfca |
+ when v >= 14 ->
|
|
|
e9bfca |
+ 1256
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 12;
|
|
|
e9bfca |
+ i_minor_version = 4 } ->
|
|
|
e9bfca |
+ 1252
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 12;
|
|
|
e9bfca |
+ i_minor_version = 10 } ->
|
|
|
e9bfca |
+ 1253
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 13;
|
|
|
e9bfca |
+ i_minor_version = 4 } ->
|
|
|
e9bfca |
+ 1254
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 13;
|
|
|
e9bfca |
+ i_minor_version = 10 } ->
|
|
|
e9bfca |
+ 1255
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_arch = ("ppc64"|"ppc64le") } ->
|
|
|
e9bfca |
+ 1002
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux"; i_arch = "s390x" } ->
|
|
|
e9bfca |
+ 2002
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "linux" } ->
|
|
|
e9bfca |
+ 5
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 5; i_minor_version = 1 } ->
|
|
|
e9bfca |
+ 1 (* no architecture differentiation of XP on RHV *)
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 5; i_minor_version = 2;
|
|
|
e9bfca |
+ i_product_name = product } when String.find product "XP" >= 0 ->
|
|
|
e9bfca |
+ 1 (* no architecture differentiation of XP on RHV *)
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 5; i_minor_version = 2;
|
|
|
e9bfca |
+ i_arch = "i386" } ->
|
|
|
e9bfca |
+ 3
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 5; i_minor_version = 2;
|
|
|
e9bfca |
+ i_arch = "x86_64" } ->
|
|
|
e9bfca |
+ 10
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 6; i_minor_version = 0;
|
|
|
e9bfca |
+ i_arch = "i386" } ->
|
|
|
e9bfca |
+ 4
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 6; i_minor_version = 0;
|
|
|
e9bfca |
+ i_arch = "x86_64" } ->
|
|
|
e9bfca |
+ 16
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 6; i_minor_version = 1;
|
|
|
e9bfca |
+ i_arch = "i386" } ->
|
|
|
e9bfca |
+ 11
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 6; i_minor_version = 1;
|
|
|
e9bfca |
+ i_arch = "x86_64"; i_product_variant = "Client" } ->
|
|
|
e9bfca |
+ 12
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 6; i_minor_version = 1;
|
|
|
e9bfca |
+ i_arch = "x86_64" } ->
|
|
|
e9bfca |
+ 17
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 6; i_minor_version = 2;
|
|
|
e9bfca |
+ i_arch = "i386" } ->
|
|
|
e9bfca |
+ 20
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 6; i_minor_version = 2;
|
|
|
e9bfca |
+ i_arch = "x86_64"; i_product_variant = "Client" } ->
|
|
|
e9bfca |
+ 21
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 6; i_minor_version = 2;
|
|
|
e9bfca |
+ i_arch = "x86_64" } ->
|
|
|
e9bfca |
+ 23
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ (* Treat Windows 8.1 client like Windows 8. See:
|
|
|
e9bfca |
+ * https://bugzilla.redhat.com/show_bug.cgi?id=1309580#c4
|
|
|
e9bfca |
+ *)
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 6; i_minor_version = 3;
|
|
|
e9bfca |
+ i_arch = "i386"; i_product_variant = "Client" } ->
|
|
|
e9bfca |
+ 20
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 6; i_minor_version = 3;
|
|
|
e9bfca |
+ i_arch = "x86_64"; i_product_variant = "Client" } ->
|
|
|
e9bfca |
+ 21
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 6; i_minor_version = 3;
|
|
|
e9bfca |
+ i_arch = "x86_64" } ->
|
|
|
e9bfca |
+ 23
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 10; i_minor_version = 0;
|
|
|
e9bfca |
+ i_arch = "i386" } ->
|
|
|
e9bfca |
+ 26
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 10; i_minor_version = 0;
|
|
|
e9bfca |
+ i_arch = "x86_64"; i_product_variant = "Client" } ->
|
|
|
e9bfca |
+ 27
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = "windows"; i_major_version = 10; i_minor_version = 0;
|
|
|
e9bfca |
+ i_arch = "x86_64" } ->
|
|
|
e9bfca |
+ 29
|
|
|
e9bfca |
+
|
|
|
e9bfca |
+ | { i_type = typ; i_distro = distro;
|
|
|
e9bfca |
+ i_major_version = major; i_minor_version = minor; i_arch = arch;
|
|
|
e9bfca |
+ i_product_name = product } ->
|
|
|
e9bfca |
+ warning (f_"unknown guest operating system: %s %s %d.%d %s (%s)")
|
|
|
e9bfca |
+ typ distro major minor arch product;
|
|
|
e9bfca |
+ 0
|
|
|
e9bfca |
+
|
|
|
e9bfca |
(* Set the <Origin/> element based on the source hypervisor.
|
|
|
e9bfca |
* https://bugzilla.redhat.com/show_bug.cgi?id=1342398#c6
|
|
|
e9bfca |
* https://gerrit.ovirt.org/#/c/59147/
|
|
|
e9bfca |
@@ -321,6 +518,7 @@ let rec create_ovf source targets guestcaps inspect
|
|
|
e9bfca |
"xmlns:vssd", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData";
|
|
|
e9bfca |
"xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance";
|
|
|
e9bfca |
"xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1/";
|
|
|
e9bfca |
+ "xmlns:ovirt", "http://www.ovirt.org/ovf";
|
|
|
e9bfca |
"ovf:version", "0.9"
|
|
|
e9bfca |
] [
|
|
|
e9bfca |
Comment generated_by;
|
|
|
e9bfca |
@@ -383,8 +581,10 @@ let rec create_ovf source targets guestcaps inspect
|
|
|
e9bfca |
] in
|
|
|
e9bfca |
(match ovf_flavour with
|
|
|
e9bfca |
| OVirt ->
|
|
|
e9bfca |
+ let ovirt_osid = get_ovirt_osid inspect in
|
|
|
e9bfca |
e "OperatingSystemSection" ["ovf:id", vm_uuid;
|
|
|
e9bfca |
- "ovf:required", "false"]
|
|
|
e9bfca |
+ "ovf:required", "false";
|
|
|
e9bfca |
+ "ovirt:id", string_of_int ovirt_osid]
|
|
|
e9bfca |
osinfo_subnodes
|
|
|
e9bfca |
| RHVExportStorageDomain ->
|
|
|
e9bfca |
e "Section" ["ovf:id", vm_uuid; "ovf:required", "false";
|
|
|
e9bfca |
--
|
|
|
3d5c2a |
2.17.2
|
|
|
e9bfca |
|