[jenkins-ci PATCH v5 4/5] mappings: extend mapping to allow per-arch entries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For example to prevent Xen being installed on any s390x

  xen:
    default-s390x:
    deb: libxen-dev
    Fedora: xen-devel

Or the inverse to only install Xen on x86_64 on Debian, but allow
it on all archs on Fedora

  xen:
    deb-x86_64: libxen-dev
    Fedora: xen-devel

Note that the architecture specific matches are considered after
all the non-architcture matches.

The mappings are updated to blacklist libnuma on arm6/7 for Debian
since it is not built for those archs. xen is whitelisted to only
be used on x86_64, arm7 and aarch64 for Debian, since the majority
of other architectures don't support it.

The dockerfile generator is updated to apply arch filtering based
on the host arch.

The ansible playbook is not actually implementing support for
non-x86_64 architectures in this commit. It is just hardcoding
x86_64, which is enough to ensure the changes in the mappings.yml
file are a no-op initially.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 guests/lcitool                             | 15 +++++++-
 guests/playbooks/update/tasks/packages.yml | 32 +++++++++++++++++
 guests/vars/mappings.yml                   | 42 +++++++++++++++++++---
 3 files changed, 84 insertions(+), 5 deletions(-)

diff --git a/guests/lcitool b/guests/lcitool
index 88bc945..263ab0d 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -20,6 +20,7 @@ import argparse
 import fnmatch
 import json
 import os
+import platform
 import random
 import string
 import subprocess
@@ -302,6 +303,8 @@ class Application:
         self._inventory = Inventory()
         self._projects = Projects()
 
+        self._native_arch = self._libvirt_host_arch()
+
         self._parser = argparse.ArgumentParser(
             conflict_handler="resolve",
             description="libvirt CI guest management tool",
@@ -424,6 +427,15 @@ class Application:
             raise Error(
                 "Failed to run {} on '{}': {}".format(playbook, hosts, ex))
 
+    def _libvirt_host_arch(self):
+        # Same canonicalization as libvirt virArchFromHost
+        arch = platform.machine()
+        if arch in ["i386", "i486", "i586"]:
+            arch = "i686"
+        if arch == "amd64":
+            arch = "x86_64"
+        return arch
+
     def _action_hosts(self, args):
         for host in self._inventory.expand_pattern("all"):
             print(host)
@@ -540,7 +552,8 @@ class Application:
                 )
 
         pkgs = {}
-        keys = ["default", package_format, os_name, os_full]
+        base_keys = ["default", package_format, os_name, os_full]
+        keys = base_keys + [k + "-" + self._native_arch for k in base_keys]
         # We need to add the base project manually here: the standard
         # machinery hides it because it's an implementation detail
         for project in projects + ["base"]:
diff --git a/guests/playbooks/update/tasks/packages.yml b/guests/playbooks/update/tasks/packages.yml
index 7fdfc45..b3b8a27 100644
--- a/guests/playbooks/update/tasks/packages.yml
+++ b/guests/playbooks/update/tasks/packages.yml
@@ -52,6 +52,38 @@
   when:
     - mappings[item][os_name + os_version] is defined
 
+- name: '{{ project }}: Look up mappings (default with arch)'
+  set_fact:
+    temp: '{{ temp|combine({ item: mappings[item]["default" + "-" + "x86_64"] }) }}'
+  with_items:
+    '{{ packages }}'
+  when:
+    - mappings[item]["default" + "-" + "x86_64"] is defined
+
+- name: '{{ project }}: Look up mappings (package format with arch)'
+  set_fact:
+    temp: '{{ temp|combine({ item: mappings[item][package_format + "-" + "x86_64"] }) }}'
+  with_items:
+    '{{ packages }}'
+  when:
+    - mappings[item][package_format + "-" + "x86_64"] is defined
+
+- name: '{{ project }}: Look up mappings (OS name with arch)'
+  set_fact:
+    temp: '{{ temp|combine({ item: mappings[item][os_name + "-" + "x86_64"] }) }}'
+  with_items:
+    '{{ packages }}'
+  when:
+    - mappings[item][os_name + "-" + "x86_64"] is defined
+
+- name: '{{ project }}: Look up mappings (OS version with arch)'
+  set_fact:
+    temp: '{{ temp|combine({ item: mappings[item][os_name + os_version + "-" + "x86_64"] }) }}'
+  with_items:
+    '{{ packages }}'
+  when:
+    - mappings[item][os_name + os_version + "-" + "x86_64"] is defined
+
 - set_fact:
     flattened: []
 
diff --git a/guests/vars/mappings.yml b/guests/vars/mappings.yml
index 8ff2f34..ea46ce4 100644
--- a/guests/vars/mappings.yml
+++ b/guests/vars/mappings.yml
@@ -7,9 +7,25 @@
 # priority:
 #
 #   - default
-#   - package format (deb, pkg, rpm)
-#   - OS name (CentOS, Debian, Fedora, FreeBSD, Ubuntu)
-#   - OS version (CentOS7, Debian9, FedoraRawhide, Ubuntu18 and so on)
+#   - package format
+#   - OS name
+#   - OS version
+#   - default with arch
+#   - package format with arch
+#   - OS name with arch
+#   - OS version with arch
+#
+# Valid package formats are
+#   - deb, pkg, rpm
+#
+# Valid OS names are:
+#   - CentOS, Debian, Fedora, FreeBSD, Ubuntu
+#
+# Valid OS versions are:
+#   - CentOS7, Debian9, FedoraRawhide, Ubuntu18 and so on
+#
+# The 'with arch' levels take a suffix "-$ARCH" where  $ARCH
+# is a libvirt arch name.
 #
 # So something like
 #
@@ -27,6 +43,20 @@
 #
 # will result in the 'ccache' package being installed everywhere except
 # for CentOS, where nothing will be installed.
+#
+# For example to prevent Xen being installed on any s390x
+#
+#  xen:
+#    default-s390x:
+#    deb: libxen-dev
+#    Fedora: xen-devel
+#
+# Or the inverse to only install Xen on x86_64
+#
+#  xen:
+#    deb-x86_64: libxen-dev
+#    Fedora-x86_64: xen-devel
+#
 
 mappings:
 
@@ -278,6 +308,8 @@ mappings:
 
   libnuma:
     deb: libnuma-dev
+    deb-armv6l:
+    deb-armv7l:
     rpm: numactl-devel
 
   libparted:
@@ -821,7 +853,9 @@ mappings:
     Debian8:
 
   xen:
-    deb: libxen-dev
+    deb-x86_64: libxen-dev
+    deb-armv7l: libxen-dev
+    deb-aarch64: libxen-dev
     Fedora: xen-devel
 
   xfsprogs:
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux