Migrate cleanup old images script from ODL
[releng/global-jjb.git] / shell / openstack-cleanup-old-images.sh
diff --git a/shell/openstack-cleanup-old-images.sh b/shell/openstack-cleanup-old-images.sh
new file mode 100644 (file)
index 0000000..cbb2ef8
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash -l
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2017, 2018 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+# Removes openstack images older than X days in the cloud
+echo "---> Cleanup old images"
+
+os_cloud="${OS_CLOUD:-vex}"
+os_image_cleanup_age="${OS_IMAGE_CLEANUP_AGE:-30}"
+
+set -eux -o pipefail
+
+lftools openstack --os-cloud "${os_cloud}" image cleanup --days="${os_image_cleanup_age}"