From 9a8923c32301cab40151097508ae7fb2eca2e3b4 Mon Sep 17 00:00:00 2001
From: Jim Fehlig <jfehlig@suse.com>
Date: Fri, 15 Nov 2019 15:59:45 -0700
Subject: [PATCH] Add support for openSUSE Leap 15.1

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
---
 guests/configs/autoinst.xml                   | 75 +++++++++++++++++++
 .../libvirt-opensuse-15.1/docker.yml          |  2 +
 .../libvirt-opensuse-15.1/install.yml         |  2 +
 .../host_vars/libvirt-opensuse-15.1/main.yml  | 22 ++++++
 guests/inventory                              |  1 +
 guests/lcitool                                |  2 +
 guests/vars/mappings.yml                      | 38 +++++++++-
 7 files changed, 140 insertions(+), 2 deletions(-)

diff --git a/guests/configs/autoinst.xml b/guests/configs/autoinst.xml
new file mode 100644
index 0000000..d3bdb5c
--- /dev/null
+++ b/guests/configs/autoinst.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<!DOCTYPE profile>
+<profile
+  xmlns="http://www.suse.com/1.0/yast2ns"
+  xmlns:config="http://www.suse.com/1.0/configns">
+  <general>
+    <mode>
+      <confirm config:type="boolean">false</confirm>
+    </mode>
+  </general>
+  <partitioning config:type="list">
+    <drive>
+      <device>/dev/vda</device>
+      <use>all</use>
+      <partitions config:type="list">
+        <partition>
+          <filesystem config:type="symbol">swap</filesystem>
+          <size>500M</size>
+          <mount>swap</mount>
+        </partition>
+        <partition>
+          <filesystem config:type="symbol">ext4</filesystem>
+          <mount>/</mount>
+          <size>max</size>
+        </partition>
+      </partitions>
+    </drive>
+  </partitioning>
+  <timezone>
+    <hwclock>UTC</hwclock>
+    <timezone>UTC</timezone>
+  </timezone>
+  <add-on>
+    <add_on_products config:type="list">
+      <listentry>
+        <media_url>http://download.opensuse.org/distribution/leap/15.1/repo/oss/</media_url>
+        <name>repo-oss</name>
+      </listentry>
+      <listentry>
+        <media_url>http://download.opensuse.org/update/leap/15.1/oss</media_url>
+        <name>repo-update</name>
+      </listentry>
+      <listentry>
+        <media_url>http://download.opensuse.org/distribution/leap/15.1/repo/non-oss/</media_url>
+        <name>repo-non-oss</name>
+      </listentry>
+      <listentry>
+        <media_url>http://download.opensuse.org/update/leap/15.1/non-oss/</media_url>
+        <name>repo-update-non-oss</name>
+      </listentry>
+    </add_on_products>
+  </add-on>
+  <software>
+    <install_recommended config:type="boolean">false</install_recommended>
+      <patterns config:type="list">
+      <pattern>base</pattern>
+      <pattern>minimal_base</pattern>
+      <pattern>yast2_basis</pattern>
+    </patterns>
+  </software>
+  <networking>
+    <keep_install_network config:type="boolean">true</keep_install_network>
+  </networking>
+  <users config:type="list">
+    <user>
+      <username>root</username>
+      <user_password>root</user_password>
+      <encrypted config:type="boolean">false</encrypted>
+      <uid>0</uid>
+      <gid>0</gid>
+      <home>/root</home>
+      <shell>/bin/bash</shell>
+    </user>
+  </users>
+</profile>
diff --git a/guests/host_vars/libvirt-opensuse-15.1/docker.yml b/guests/host_vars/libvirt-opensuse-15.1/docker.yml
new file mode 100644
index 0000000..1fcbc38
--- /dev/null
+++ b/guests/host_vars/libvirt-opensuse-15.1/docker.yml
@@ -0,0 +1,2 @@
+---
+docker_base: openSUSE:15.1
diff --git a/guests/host_vars/libvirt-opensuse-15.1/install.yml b/guests/host_vars/libvirt-opensuse-15.1/install.yml
new file mode 100644
index 0000000..d0fdbe5
--- /dev/null
+++ b/guests/host_vars/libvirt-opensuse-15.1/install.yml
@@ -0,0 +1,2 @@
+---
+install_url: http://download.opensuse.org/distribution/leap/15.1/repo/oss/
diff --git a/guests/host_vars/libvirt-opensuse-15.1/main.yml b/guests/host_vars/libvirt-opensuse-15.1/main.yml
new file mode 100644
index 0000000..cdd4509
--- /dev/null
+++ b/guests/host_vars/libvirt-opensuse-15.1/main.yml
@@ -0,0 +1,22 @@
+---
+projects:
+  - libosinfo
+  - libvirt
+  - libvirt-cim
+  - libvirt-dbus
+  - libvirt-glib
+  - libvirt-perl
+  - libvirt-python
+  - libvirt-sandbox
+  - libvirt-tck
+  - osinfo-db
+  - osinfo-db-tools
+  - virt-manager
+  - virt-viewer
+
+package_format: 'rpm'
+package_manager: 'zypper'
+os_name: 'openSUSE'
+os_version: '15.1'
+
+ansible_python_interpreter: /usr/bin/python3
diff --git a/guests/inventory b/guests/inventory
index 3b15513..c86f8cc 100644
--- a/guests/inventory
+++ b/guests/inventory
@@ -8,5 +8,6 @@ libvirt-fedora-rawhide
 libvirt-freebsd-11
 libvirt-freebsd-12
 libvirt-freebsd-current
+libvirt-opensuse-15.1
 libvirt-ubuntu-16
 libvirt-ubuntu-18
diff --git a/guests/lcitool b/guests/lcitool
index a630971..39e6853 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -531,6 +531,8 @@ class Application:
                 install_config = "preseed.cfg"
             elif facts["os_name"] in ["CentOS", "Fedora"]:
                 install_config = "kickstart.cfg"
+            elif facts["os_name"] == "openSUSE":
+                install_config = "autoinst.xml"
             else:
                 raise Exception(
                     "Host {} doesn't support installation".format(host)
diff --git a/guests/vars/mappings.yml b/guests/vars/mappings.yml
index bd9b161..ca8eb84 100644
--- a/guests/vars/mappings.yml
+++ b/guests/vars/mappings.yml
@@ -19,10 +19,10 @@
 #   - deb, pkg, rpm
 #
 # Valid OS names are:
-#   - CentOS, Debian, Fedora, FreeBSD, Ubuntu
+#   - CentOS, Debian, Fedora, FreeBSD, openSUSE, Ubuntu
 #
 # Valid OS versions are:
-#   - CentOS7, Debian9, FedoraRawhide, Ubuntu18 and so on
+#   - CentOS7, Debian9, FedoraRawhide, openSUSE15.1, Ubuntu18 and so on
 #
 # The arch specific rules use a prefix "$ARCH-" where  $ARCH
 # is a libvirt arch name.
@@ -70,6 +70,7 @@ mappings:
 
   apparmor:
     deb: libapparmor-dev
+    openSUSE: libapparmor-devel
     cross-policy-deb: foreign
 
   augeas:
@@ -117,6 +118,7 @@ mappings:
   cppi:
     Fedora: cppi
     FreeBSD: cppi
+    openSUSE: cppi
 
   cyrus-sasl:
     deb: libsasl2-dev
@@ -127,6 +129,7 @@ mappings:
   dbus-daemon:
     default: dbus
     Fedora: dbus-daemon
+    openSUSE: dbus-1
 
   device-mapper:
     deb: libdevmapper-dev
@@ -196,6 +199,7 @@ mappings:
     deb: libglusterfs-dev
     rpm: glusterfs-api-devel
     Debian9: glusterfs-common
+    openSUSE: glusterfs-devel
     Ubuntu16: glusterfs-common
     Ubuntu18: glusterfs-common
     cross-policy-deb: foreign
@@ -204,6 +208,7 @@ mappings:
     deb: libgnutls28-dev
     pkg: gnutls
     rpm: gnutls-devel
+    openSUSE: libgnutls-devel
     cross-policy-deb: foreign
 
   go:
@@ -228,6 +233,7 @@ mappings:
 
   gtk-update-icon-cache:
     default: gtk-update-icon-cache
+    openSUSE: gtk3-tools
     Ubuntu16: libgtk2.0-bin
 
   gtk-vnc2:
@@ -248,14 +254,17 @@ mappings:
   ip:
     deb: iproute2
     rpm: iproute
+    openSUSE: iproute2
 
   iscsiadm:
     deb: open-iscsi
     rpm: iscsi-initiator-utils
+    openSUSE: open-iscsi
 
   isoinfo:
     default: genisoimage
     FreeBSD: cdrkit
+    openSUSE: mkisofs
 
   java:
     deb: openjdk-11-jre-headless
@@ -289,6 +298,7 @@ mappings:
   libaudit:
     deb: libaudit-dev
     rpm: audit-libs-devel
+    openSUSE: audit-devel
     cross-policy-deb: foreign
 
   libblkid:
@@ -320,6 +330,7 @@ mappings:
     deb: libdbus-1-dev
     pkg: dbus
     rpm: dbus-devel
+    openSUSE: dbus-1-devel
     cross-policy-deb: foreign
 
   libgovirt:
@@ -347,6 +358,7 @@ mappings:
     rpm: numactl-devel
     armv6l-deb:
     armv7l-deb:
+    openSUSE: libnuma-devel
     cross-policy-deb: foreign
 
   libparted:
@@ -370,6 +382,7 @@ mappings:
     deb: librbd-dev
     Fedora: librbd-devel
     CentOS7: librbd1-devel
+    openSUSE: librbd-devel
     cross-policy-deb: foreign
 
   libselinux:
@@ -436,6 +449,7 @@ mappings:
     deb: locales
     Fedora: glibc-langpack-en
     FreeBSD:
+    openSUSE: glibc-locale
 
   lsof:
     default: lsof
@@ -458,6 +472,7 @@ mappings:
   ninja:
    default: ninja-build
    FreeBSD: ninja
+   openSUSE: ninja
 
   mingw32-curl:
     Fedora: mingw32-curl
@@ -639,6 +654,7 @@ mappings:
   netcf:
     deb: libnetcf-dev
     rpm: netcf-devel
+    openSUSE:
     cross-policy-deb: skip
 
   net-tools:
@@ -678,6 +694,7 @@ mappings:
     deb: perl
     pkg: perl5
     rpm: perl-Archive-Tar
+    openSUSE: perl-Archive-Tar-Wrapper
 
   perl-CPAN-Changes:
     deb: libcpan-changes-perl
@@ -709,6 +726,7 @@ mappings:
     deb: libio-compress-perl
     pkg: p5-IO-Compress
     rpm: perl-IO-Compress-Bzip2
+    openSUSE: perl-Compress-Bzip2
 
   perl-IO-String:
     deb: libio-string-perl
@@ -747,6 +765,7 @@ mappings:
     deb: libtest-lwp-useragent-perl
     pkg: p5-Test-LWP-UserAgent
     Fedora: perl-Test-LWP-UserAgent
+    openSUSE: perl-Test-LWP-UserAgent
 
   perl-Test-Pod:
     deb: libtest-pod-perl
@@ -809,20 +828,24 @@ mappings:
     deb: python-dev
     pkg: python2
     rpm: python2-devel
+    openSUSE: python-devel
     cross-policy-deb: foreign
 
   python2-lxml:
     default: python-lxml
     Fedora: python2-lxml
     FreeBSD: py27-lxml
+    openSUSE: python2-lxml
 
   python2-nose:
     default: python-nose
     Fedora: python2-nose
     FreeBSD: py27-nose
+    openSUSE: python2-nose
 
   python2-setuptools:
     CentOS7: python2-setuptools
+    openSUSE: python2-setuptools
 
   python3:
     default: python3
@@ -831,6 +854,7 @@ mappings:
     default: python3-dbus
     FreeBSD: py36-dbus
     CentOS7: python36-dbus
+    openSUSE: python3-dbus-python
 
   python3-devel:
     deb: python3-dev
@@ -838,17 +862,20 @@ mappings:
     Fedora: python3-devel
     CentOS7: python36-devel
     cross-policy-deb: foreign
+    openSUSE: python3-devel
 
   python3-gi:
     deb: python3-gi
     pkg: py36-gobject3
     rpm: python3-gobject
     CentOS7: python36-gobject
+    openSUSE: python3-gobject
 
   python3-libxml2:
     default: python3-libxml2
     FreeBSD: py36-libxml2
     CentOS7:
+    openSUSE: python3-libxml2-python
     Ubuntu16:
 
   python3-lxml:
@@ -864,6 +891,7 @@ mappings:
   python3-pip:
     CentOS7: python3-pip
     Debian9: python3-pip
+    openSUSE: python3-pip
     Ubuntu16: python3-pip
     Ubuntu18: python3-pip
 
@@ -929,6 +957,7 @@ mappings:
     deb: libspice-client-gtk-3.0-dev
     pkg: spice-gtk
     rpm: spice-gtk3-devel
+    openSUSE: spice-gtk-devel
     cross-policy-deb: foreign
 
   strace:
@@ -942,6 +971,7 @@ mappings:
     deb: iproute2
     rpm: iproute-tc
     CentOS7: iproute
+    openSUSE: iproute2
 
   unzip:
     default: unzip
@@ -964,10 +994,12 @@ mappings:
   wireshark:
     deb: wireshark-dev
     Fedora: wireshark-devel
+    openSUSE: wireshark-devel
     cross-policy-deb: skip
 
   xen:
     Fedora: xen-devel
+    openSUSE: xen-devel
     x86_64-deb: libxen-dev
     armv7l-deb: libxen-dev
     aarch64-deb: libxen-dev
@@ -994,6 +1026,7 @@ mappings:
   xz-static:
     deb: liblzma-dev
     Fedora: xz-static
+    openSUSE: xz-static-devel
     cross-policy-deb: foreign
 
   yajl:
@@ -1015,6 +1048,7 @@ mappings:
   zlib-static:
     deb: zlib1g-dev
     rpm: zlib-static
+    openSUSE: zlib-devel-static
     cross-policy-deb: foreign
 
 
-- 
2.23.0

