← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~andersson123/autopkgtest-cloud:add_eol_scripts into autopkgtest-cloud:master

 

Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:add_eol_scripts into autopkgtest-cloud:master.

Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)

For more details, see:
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/447927
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:add_eol_scripts into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/remove-eol-release-images-and-containers b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/remove-eol-release-images-and-containers
new file mode 100644
index 0000000..251e31b
--- /dev/null
+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/remove-eol-release-images-and-containers
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+release=$1
+rc_path=$2
+
+echo "hey! Have you removed ${release} from the service bundle and run a mojo run? (y/n)"
+
+read yes_or_no
+if [ "${yes_or_no}" = "n" ]; then
+    exit 1
+fi
+
+echo "Hey! Have you double checked this script for the correct command line arguments? (y/n)"
+read yes_or_no
+if [ "${yes_or_no}" = "n" ]; then
+    exit 1
+fi
+
+echo "Hey! Are you sure you want to delete the openstack images for ${release}? (y/n)"
+read yes_or_no
+if [ "${yes_or_no}" = "n" ]; then
+    exit 1
+fi
+
+echo "Deleting openstack images for ${release}..."
+for file in "${rc_path}"*; do
+        (
+                source $file
+                echo "deleting ${release} images from ${file}"
+                images=($(openstack image list | grep "adt/ubuntu-$release" | cut -d"|" -f2 | xargs))
+                for str in "${images[@]}"; do openstack image delete $str; done
+        )
+done
+
+echo "Hey! Are you sure you want to delete the swift containers (you will be prompted per container still) for ${release}? (y/n)"
+read yes_or_no
+if [ "${yes_or_no}" = "n" ]; then
+    exit 1
+fi
+
+delete_me=($(swift list | grep $release))
+for str in "${delete_me[@]}"; do
+    echo "Would you like to delete ${str}? (y/n)"
+    read choice
+    if [[ "${choice}" == "y" ]]; then
+        swift delete $str
+        echo "${str} deleted!"
+    else
+        echo "doing nothing"
+    fi
+done