Re: [Libguestfs] [PATCH] v2v: OVF: write ovirt:id attribute for the OS in OVirt flavour

2018-04-05 Thread Arik Hadas
On Thu, Apr 5, 2018 at 10:27 AM, Richard W.M. Jones 
wrote:

> On Wed, Apr 04, 2018 at 06:22:12PM +0200, Pino Toscano wrote:
> > When writing the OVF in OVirt flavour, add a ovirt:id attribute to the
> > OperatingSystemSection tag: this attribute represents the numeric value
> > of the ostype ID, which is ignored by oVirt when parsing OVFs in API
> > mode.
> > ---
> >  v2v/create_ovf.ml | 202 ++
> +++-
> >  1 file changed, 201 insertions(+), 1 deletion(-)
> >
> > diff --git a/v2v/create_ovf.ml b/v2v/create_ovf.ml
> > index 64edd2b86..34cd925e7 100644
> > --- a/v2v/create_ovf.ml
> > +++ b/v2v/create_ovf.ml
> > @@ -216,6 +216,203 @@ and get_ostype = function
> >typ distro major minor arch product;
> >  "Unassigned"
> >
> > +(* Determine the ovirt:id attribute from libguestfs inspection.
> > + * See ovirt-engine sources, file:
> > + *   packaging/conf/osinfo-defaults.properties
> > + * and also:
> > + *   https://bugzilla.redhat.com/show_bug.cgi?id=1219857#c9
> > + *)
> > +and get_ovirt_osid = function
> > +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version =
> 3;
> > +  i_arch = "i386" } ->
> > +9
> > +
> > +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version =
> 3;
> > +  i_arch = "x86_64" } ->
> > +15
> > +
> > +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version =
> 4;
> > +  i_arch = "i386" } ->
> > +8
> > +
> > +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version =
> 4;
> > +  i_arch = "x86_64" } ->
> > +14
> > +
> > +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version =
> 5;
> > +  i_arch = "i386" } ->
> > +7
> > +
> > +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version =
> 5;
> > +  i_arch = "x86_64" } ->
> > +13
> > +
> > +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version =
> 6;
> > +  i_arch = "i386" } ->
> > +18
> > +
> > +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version =
> 6;
> > +  i_arch = "x86_64" } ->
> > +19
> > +
> > +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version =
> 6;
> > +  i_minor_version = min; i_arch = ("ppc64"|"ppc64le") } when min >=
> 9 ->
> > +1007
> > +
> > +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version =
> 6;
> > +  i_arch = ("ppc64"|"ppc64le") } ->
> > +1003
> > +
> > +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version =
> 7;
> > +  i_arch = "x86_64" } ->
> > +24
> > +
> > +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version =
> 7;
> > +  i_arch = ("ppc64"|"ppc64le") } ->
> > +1006
> > +
> > +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version =
> 7;
> > +  i_arch = "s390x" } ->
> > +2003
> > +
> > +  | { i_type = "linux"; i_distro = "sles"; i_major_version = 11;
> > +  i_arch = "x86_64" } ->
> > +1193
> > +
> > +  | { i_type = "linux"; i_distro = "sles"; i_major_version = 11;
> > +  i_arch = "ppc64" | "ppc64le" } ->
> > +1004
> > +
> > +  | { i_type = "linux"; i_distro = "sles"; i_major_version = 12;
> > +  i_arch = "s390x" } ->
> > +2004
> > +
> > +   (* Only Debian 7 is available, so use it for any 7+ version. *)
> > +  | { i_type = "linux"; i_distro = "debian"; i_major_version = v }
> > +  when v >= 7 ->
> > +1300
> > +
> > +   (* Only Ubuntu 12.04 to 14.04 are available, so use them starting
> > +* from 12.04, and 14.04 for anything after it.
> > +*)
> > +  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v;
> > +  i_arch = ("ppc64"|"ppc64le") } when v >= 14 ->
> > +1005
> > +
> > +  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v;
> > +  i_arch = "s390x" } when v >= 16 ->
> > +2005
> > +
> > +  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v }
> > +  when v >= 14 ->
> > +1256
> > +
> > +  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 12;
> > +  i_minor_version = 4 } ->
> > +1252
> > +
> > +  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 12;
> > +  i_minor_version = 10 } ->
> > +1253
> > +
> > +  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 13;
> > +  i_minor_version = 4 } ->
> > +1254
> > +
> > +  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 13;
> > +  i_minor_version = 10 } ->
> > +1255
> > +
> > +  | { i_type = "linux"; i_arch = ("ppc64"|"ppc64le") } ->
> > +1002
> > +
> > +  | { i_type = "linux"; i_arch = "s390x" } ->
> > +2002
> > +
> > +  | { i_type = "linux" } ->
> > +5
> > +
> > +  | { i_type = "windows"; i_major_version = 5; i_minor_version = 1 } ->
> > +1 (* no architecture differentiation of XP on RHV *)
> > +
> > +  | { i_type = "windows"; i_major_version = 5; i_minor_version = 2;
> > +  i_product_name = product } 

Re: [Libguestfs] [PATCH] v2v: OVF: write ovirt:id attribute for the OS in OVirt flavour

2018-04-05 Thread Richard W.M. Jones
On Wed, Apr 04, 2018 at 06:22:12PM +0200, Pino Toscano wrote:
> When writing the OVF in OVirt flavour, add a ovirt:id attribute to the
> OperatingSystemSection tag: this attribute represents the numeric value
> of the ostype ID, which is ignored by oVirt when parsing OVFs in API
> mode.
> ---
>  v2v/create_ovf.ml | 202 
> +-
>  1 file changed, 201 insertions(+), 1 deletion(-)
> 
> diff --git a/v2v/create_ovf.ml b/v2v/create_ovf.ml
> index 64edd2b86..34cd925e7 100644
> --- a/v2v/create_ovf.ml
> +++ b/v2v/create_ovf.ml
> @@ -216,6 +216,203 @@ and get_ostype = function
>typ distro major minor arch product;
>  "Unassigned"
>  
> +(* Determine the ovirt:id attribute from libguestfs inspection.
> + * See ovirt-engine sources, file:
> + *   packaging/conf/osinfo-defaults.properties
> + * and also:
> + *   https://bugzilla.redhat.com/show_bug.cgi?id=1219857#c9
> + *)
> +and get_ovirt_osid = function
> +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 3;
> +  i_arch = "i386" } ->
> +9
> +
> +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 3;
> +  i_arch = "x86_64" } ->
> +15
> +
> +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 4;
> +  i_arch = "i386" } ->
> +8
> +
> +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 4;
> +  i_arch = "x86_64" } ->
> +14
> +
> +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 5;
> +  i_arch = "i386" } ->
> +7
> +
> +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 5;
> +  i_arch = "x86_64" } ->
> +13
> +
> +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6;
> +  i_arch = "i386" } ->
> +18
> +
> +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6;
> +  i_arch = "x86_64" } ->
> +19
> +
> +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6;
> +  i_minor_version = min; i_arch = ("ppc64"|"ppc64le") } when min >= 9 ->
> +1007
> +
> +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6;
> +  i_arch = ("ppc64"|"ppc64le") } ->
> +1003
> +
> +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 7;
> +  i_arch = "x86_64" } ->
> +24
> +
> +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 7;
> +  i_arch = ("ppc64"|"ppc64le") } ->
> +1006
> +
> +  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 7;
> +  i_arch = "s390x" } ->
> +2003
> +
> +  | { i_type = "linux"; i_distro = "sles"; i_major_version = 11;
> +  i_arch = "x86_64" } ->
> +1193
> +
> +  | { i_type = "linux"; i_distro = "sles"; i_major_version = 11;
> +  i_arch = "ppc64" | "ppc64le" } ->
> +1004
> +
> +  | { i_type = "linux"; i_distro = "sles"; i_major_version = 12;
> +  i_arch = "s390x" } ->
> +2004
> +
> +   (* Only Debian 7 is available, so use it for any 7+ version. *)
> +  | { i_type = "linux"; i_distro = "debian"; i_major_version = v }
> +  when v >= 7 ->
> +1300
> +
> +   (* Only Ubuntu 12.04 to 14.04 are available, so use them starting
> +* from 12.04, and 14.04 for anything after it.
> +*)
> +  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v;
> +  i_arch = ("ppc64"|"ppc64le") } when v >= 14 ->
> +1005
> +
> +  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v;
> +  i_arch = "s390x" } when v >= 16 ->
> +2005
> +
> +  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v }
> +  when v >= 14 ->
> +1256
> +
> +  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 12;
> +  i_minor_version = 4 } ->
> +1252
> +
> +  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 12;
> +  i_minor_version = 10 } ->
> +1253
> +
> +  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 13;
> +  i_minor_version = 4 } ->
> +1254
> +
> +  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 13;
> +  i_minor_version = 10 } ->
> +1255
> +
> +  | { i_type = "linux"; i_arch = ("ppc64"|"ppc64le") } ->
> +1002
> +
> +  | { i_type = "linux"; i_arch = "s390x" } ->
> +2002
> +
> +  | { i_type = "linux" } ->
> +5
> +
> +  | { i_type = "windows"; i_major_version = 5; i_minor_version = 1 } ->
> +1 (* no architecture differentiation of XP on RHV *)
> +
> +  | { i_type = "windows"; i_major_version = 5; i_minor_version = 2;
> +  i_product_name = product } when String.find product "XP" >= 0 ->
> +1 (* no architecture differentiation of XP on RHV *)
> +
> +  | { i_type = "windows"; i_major_version = 5; i_minor_version = 2;
> +  i_arch = "i386" } ->
> +3
> +
> +  | { i_type = "windows"; i_major_version = 5; i_minor_version = 2;
> +  i_arch = "x86_64" } ->
> +10
> +
> +  | { i_type = "windows"; i_major_version = 6; 

[Libguestfs] [PATCH] v2v: OVF: write ovirt:id attribute for the OS in OVirt flavour

2018-04-04 Thread Pino Toscano
When writing the OVF in OVirt flavour, add a ovirt:id attribute to the
OperatingSystemSection tag: this attribute represents the numeric value
of the ostype ID, which is ignored by oVirt when parsing OVFs in API
mode.
---
 v2v/create_ovf.ml | 202 +-
 1 file changed, 201 insertions(+), 1 deletion(-)

diff --git a/v2v/create_ovf.ml b/v2v/create_ovf.ml
index 64edd2b86..34cd925e7 100644
--- a/v2v/create_ovf.ml
+++ b/v2v/create_ovf.ml
@@ -216,6 +216,203 @@ and get_ostype = function
   typ distro major minor arch product;
 "Unassigned"
 
+(* Determine the ovirt:id attribute from libguestfs inspection.
+ * See ovirt-engine sources, file:
+ *   packaging/conf/osinfo-defaults.properties
+ * and also:
+ *   https://bugzilla.redhat.com/show_bug.cgi?id=1219857#c9
+ *)
+and get_ovirt_osid = function
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 3;
+  i_arch = "i386" } ->
+9
+
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 3;
+  i_arch = "x86_64" } ->
+15
+
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 4;
+  i_arch = "i386" } ->
+8
+
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 4;
+  i_arch = "x86_64" } ->
+14
+
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 5;
+  i_arch = "i386" } ->
+7
+
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 5;
+  i_arch = "x86_64" } ->
+13
+
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6;
+  i_arch = "i386" } ->
+18
+
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6;
+  i_arch = "x86_64" } ->
+19
+
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6;
+  i_minor_version = min; i_arch = ("ppc64"|"ppc64le") } when min >= 9 ->
+1007
+
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 6;
+  i_arch = ("ppc64"|"ppc64le") } ->
+1003
+
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 7;
+  i_arch = "x86_64" } ->
+24
+
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 7;
+  i_arch = ("ppc64"|"ppc64le") } ->
+1006
+
+  | { i_type = "linux"; i_distro = ("rhel"|"centos"); i_major_version = 7;
+  i_arch = "s390x" } ->
+2003
+
+  | { i_type = "linux"; i_distro = "sles"; i_major_version = 11;
+  i_arch = "x86_64" } ->
+1193
+
+  | { i_type = "linux"; i_distro = "sles"; i_major_version = 11;
+  i_arch = "ppc64" | "ppc64le" } ->
+1004
+
+  | { i_type = "linux"; i_distro = "sles"; i_major_version = 12;
+  i_arch = "s390x" } ->
+2004
+
+   (* Only Debian 7 is available, so use it for any 7+ version. *)
+  | { i_type = "linux"; i_distro = "debian"; i_major_version = v }
+  when v >= 7 ->
+1300
+
+   (* Only Ubuntu 12.04 to 14.04 are available, so use them starting
+* from 12.04, and 14.04 for anything after it.
+*)
+  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v;
+  i_arch = ("ppc64"|"ppc64le") } when v >= 14 ->
+1005
+
+  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v;
+  i_arch = "s390x" } when v >= 16 ->
+2005
+
+  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = v }
+  when v >= 14 ->
+1256
+
+  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 12;
+  i_minor_version = 4 } ->
+1252
+
+  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 12;
+  i_minor_version = 10 } ->
+1253
+
+  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 13;
+  i_minor_version = 4 } ->
+1254
+
+  | { i_type = "linux"; i_distro = "ubuntu"; i_major_version = 13;
+  i_minor_version = 10 } ->
+1255
+
+  | { i_type = "linux"; i_arch = ("ppc64"|"ppc64le") } ->
+1002
+
+  | { i_type = "linux"; i_arch = "s390x" } ->
+2002
+
+  | { i_type = "linux" } ->
+5
+
+  | { i_type = "windows"; i_major_version = 5; i_minor_version = 1 } ->
+1 (* no architecture differentiation of XP on RHV *)
+
+  | { i_type = "windows"; i_major_version = 5; i_minor_version = 2;
+  i_product_name = product } when String.find product "XP" >= 0 ->
+1 (* no architecture differentiation of XP on RHV *)
+
+  | { i_type = "windows"; i_major_version = 5; i_minor_version = 2;
+  i_arch = "i386" } ->
+3
+
+  | { i_type = "windows"; i_major_version = 5; i_minor_version = 2;
+  i_arch = "x86_64" } ->
+10
+
+  | { i_type = "windows"; i_major_version = 6; i_minor_version = 0;
+  i_arch = "i386" } ->
+4
+
+  | { i_type = "windows"; i_major_version = 6; i_minor_version = 0;
+  i_arch = "x86_64" } ->
+16
+
+  | { i_type = "windows"; i_major_version = 6; i_minor_version = 1;
+  i_arch = "i386" } ->
+11
+
+  | { i_type = "windows"; i_major_version = 6; i_minor_version = 1;
+  i_arch =