From 6f78f2da7aeb37a3c805bcfed01a94be2e7c078a Mon Sep 17 00:00:00 2001
From: Alex Iribarren <Alex.Iribarren@cern.ch>
Date: Thu, 25 Feb 2021 17:51:57 +0100
Subject: [PATCH 1/4] Add debugging

---
 ci/common.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ci/common.yml b/ci/common.yml
index 9f3f251..a639c69 100644
--- a/ci/common.yml
+++ b/ci/common.yml
@@ -17,6 +17,7 @@
 
 .get_latest_image: &get_latest_image
   - |
+    set -x
     if [[ -z "${IMAGE}" ]]; then
       if [[ "${OS: -1}" -eq "s" ]]; then
         SEARCH="--property os_distro="CS" --property os_distro_major=\"${OS:0:-1}\""
@@ -25,6 +26,7 @@
       fi
       IMAGE=$(openstack image list $SEARCH --property os_edition="Base" --public --sort created_at -c ID -f value | tail -n1)
     fi
+    set +x
 
 .test_unmanaged_physical:
   extends: .openstack
-- 
GitLab


From 0c2a7688d1cbd1182e3fb336d528967229eb109c Mon Sep 17 00:00:00 2001
From: Alex Iribarren <Alex.Iribarren@cern.ch>
Date: Thu, 25 Feb 2021 18:08:39 +0100
Subject: [PATCH 2/4] Try to fix image search

---
 ci/common.yml | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/ci/common.yml b/ci/common.yml
index a639c69..4c0283f 100644
--- a/ci/common.yml
+++ b/ci/common.yml
@@ -19,12 +19,18 @@
   - |
     set -x
     if [[ -z "${IMAGE}" ]]; then
-      if [[ "${OS: -1}" -eq "s" ]]; then
-        SEARCH="--property os_distro="CS" --property os_distro_major=\"${OS:0:-1}\""
+      if [[ "${OS: -1}" == "s" ]]; then
+        OS_DISTRO="CS"
+        OS_MAJOR="${OS:0:-1}"
       else
-        SEARCH="--property os_distro_major=\"${OS}\""
+        OS_MAJOR="${OS}"
+        if [[ "${OS}" -eq 7 ]]; then
+          OS_DISTRO="CC"
+        else
+          OS_DISTRO="C"
+        fi
       fi
-      IMAGE=$(openstack image list $SEARCH --property os_edition="Base" --public --sort created_at -c ID -f value | tail -n1)
+      IMAGE=$(openstack image list --property os_distro="${OS_DISTRO}" --property os_distro_major="${OS_MAJOR}" --property os_edition="Base" --public --sort created_at -c ID -f value | tail -n1)
     fi
     set +x
 
-- 
GitLab


From a0a7408f54f4e027585a2dff04cd0cf9892ce9fd Mon Sep 17 00:00:00 2001
From: Alex Iribarren <Alex.Iribarren@cern.ch>
Date: Thu, 25 Feb 2021 18:13:21 +0100
Subject: [PATCH 3/4] Show nice error

---
 ci/common.yml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ci/common.yml b/ci/common.yml
index 4c0283f..dc5eb9c 100644
--- a/ci/common.yml
+++ b/ci/common.yml
@@ -31,6 +31,11 @@
         fi
       fi
       IMAGE=$(openstack image list --property os_distro="${OS_DISTRO}" --property os_distro_major="${OS_MAJOR}" --property os_edition="Base" --public --sort created_at -c ID -f value | tail -n1)
+      if [[ -z "${IMAGE}" ]]; then
+        echo "No image found matching:"
+        echo openstack image list --property os_distro="${OS_DISTRO}" --property os_distro_major="${OS_MAJOR}" --property os_edition="Base" --public --sort created_at
+        exit 1
+      fi
     fi
     set +x
 
-- 
GitLab


From 2fce841c80d27aa456f21b1ee5bc46d1f1d73ccf Mon Sep 17 00:00:00 2001
From: Alex Iribarren <Alex.Iribarren@cern.ch>
Date: Thu, 25 Feb 2021 18:14:18 +0100
Subject: [PATCH 4/4] Remove debugging

---
 ci/common.yml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/ci/common.yml b/ci/common.yml
index dc5eb9c..d662d34 100644
--- a/ci/common.yml
+++ b/ci/common.yml
@@ -17,7 +17,6 @@
 
 .get_latest_image: &get_latest_image
   - |
-    set -x
     if [[ -z "${IMAGE}" ]]; then
       if [[ "${OS: -1}" == "s" ]]; then
         OS_DISTRO="CS"
@@ -37,7 +36,6 @@
         exit 1
       fi
     fi
-    set +x
 
 .test_unmanaged_physical:
   extends: .openstack
-- 
GitLab